View Single Post
  #1 (permalink)  
Old December 4th, 2015, 09:46 AM
Moby Moby is offline
Authorized User
Points: 134, Level: 2
Points: 134, Level: 2 Points: 134, Level: 2 Points: 134, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2015
Location: the sea
Posts: 10
Thanks: 4
Thanked 5 Times in 4 Posts
Default Ch. 2, parseInt(): book claims can be used for converting to binary, etc.?

In the "Data Conversion" section of Chapter 2, the book claims that "you can use parseInt() to convert numbers to binary (Base 2), hex (Base 16), and other number systems." In reality, it does the opposite.

The method toString() is the method that is useful for converting a number to different number systems, not parseInt(). parseInt(10, 2) results in the number 2, as the book says, but that is not a conversion of ten into binary, but an interpretation of 10 as being binary already, in which case its base 10 value would be 2. The base 10 value of ten would be represented 1010 in binary.

Has anyone else noticed this error? Is there something I am missing here?
Reply With Quote