p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning JavaScript 5th Edition (http://p2p.wrox.com/forumdisplay.php?f=793)
-   -   Ch. 2, parseInt(): book claims can be used for converting to binary, etc.? (http://p2p.wrox.com/showthread.php?t=95276)

Moby December 4th, 2015 09:46 AM

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?

jmcpeak January 8th, 2016 02:40 PM

No, you're not missing anything. The book is both wrong and extremely poorly worded in that passage.

Moby January 9th, 2016 12:22 AM

Thanks for your reply. Can this be added to the errata for the book?


All times are GMT -4. The time now is 08:12 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.