Closed Thread Icon

Topic awaiting preservation: parseInt behaviour (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=23969" title="Pages that link to Topic awaiting preservation: parseInt behaviour (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: parseInt behaviour <span class="small">(Page 1 of 1)</span>\

 
GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 11-09-2004 20:14

hello,
can anyone explain to me why

parseInt("0380")

returns 3.

but

parseInt("380")

returns 380.



(i would need a function that does the second)

Iron Wallaby
Paranoid (IV) Inmate

From: USA
Insane since: May 2004

posted posted 11-09-2004 20:16

What you're looking for is parseInt("0380", 10);

You have to tell it to parse it into base 10 numerals.

"Any sufficiently advanced technology is indistinguishable from magic." -- Arthur C. Clarke
"Any sufficiently arcane magic is indistinguishable from technology." -- P. David Lebling

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 11-09-2004 20:24

GRUMBLE: Preceeding a numeral value by a 0 identify it as an octal numeral thus the value 3 since 8 is not a valid number for an octal variable.

However, the parsefloat() function does work in base 10.

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 11-09-2004 22:44

interesting.

thanks guys.

TwoD
Nervous Wreck (II) Inmate

From: Sweden
Insane since: Aug 2004

posted posted 11-10-2004 08:51

Didn't know that but now that I do, it explains some of the problems I've had lol

/TwoD

« BackwardsOnwards »

Show Forum Drop Down Menu