Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: parseInt()


Message #1 by "Swathi Akella" <swathi@m...> on Sat, 17 Mar 2001 12:08:00 +0530
For the first parameter of parseInt, values that begin with '0' are
considered octal (and values that begin with '0x' are considered
hexadecimal).  So parseInt("08") will have the same result as parseInt("8",
8).

I suggest you explicitly specify the radix if you might have values that
begin with 0.

a = parseInt("08", 10)    // Returns 8

Cheers,
Anil

Sevina Technologies
www.Sevina.com


----- Original Message -----
From: "Swathi Akella" <swathi@m...>
To: "javascript" <javascript@p...>
Sent: Saturday, March 17, 2001 7:39 PM
Subject: [javascript] parseInt()


> Hello,
> I found a little funny problme with javascript.
> I'm using parseInt to convert string data to int.
> So when we give
> a=parseInt("08") ;
> or
> a=parseInt("09") ;
>
> parseInt is returning 0.
> But  its ok if the values r less than 8 i.e 07,06....00.
>
> While parseFloat is returning correct results.
>
> Can u tell me whats the reason.
>
> Swathi


  Return to Index