Bug Javascript Function parseInt

Not so long ago I encountered a problem with the parseInt JavaScript function. In some cases the parseInt returns an incorrect value. For example, parseInt("08") results in 0 instead of 8 and parseInt("09") also results in 0 instead of 9.
Apparently the reason for this is because the zero in front is trying to tell the browser that this is an octal number, and "08" and "09" are not valid octal numbers.
With parseFloat I didn't have the problem. So to "fix" the problem, I used the following: parseInt(parseFloat("string value"))

Please note that this "bug" only happens when the value being checked is a string and the string starts with a leading zero.

Kevin Dosseray

Comments

Popular posts from this blog

New CRM 2011 VM on PartnerSource

BizTalk Error: The adapter failed to transmit message going to send port

CRM 2011 together with the Scribe Adapter for CRM 4.0