Re: FAQ Topic - Why does parseInt('09') give an error?



JRS: In article <_O-dnTujw4yz62XZnZ2dnUVZ_vadnZ2d@xxxxxxxxxxx>, dated
Fri, 1 Sep 2006 14:05:30 remote, seen in news:comp.lang.javascript,
Randy Webb <HikksNotAtHome@xxxxxxx> posted :

<FAQENTRY>

"If no Base is given, the parseInt function decides what base the number
is in by looking at the number. It assumes that any number beginning
with 0x is Hexadecimal, and may assume that any number beginning with 0
is Octal. To remove this ambiguity, always use the Radix parameter with
parseInt".
</FAQENTRY>


Naive. There are circumstances in which it is right for the user to
choose the base from 8, 10, 16. Don't be a Stalinist.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
.



Relevant Pages

  • Re: number of times a character occurs in a string
    ... Randy Webb posted: ... ISTM that return +res.length should do for those 2 lines. ... jscr maths, dates, sources. ... TP/BP/Delphi/jscr/&c, FAQ items, links. ...
    (comp.lang.javascript)
  • Re: Cross domain autofill and submit
    ... Randy Webb posted: ... It looks as if that should alert in IE 4. ... jscr maths, dates, sources. ... TP/BP/Delphi/jscr/&c, FAQ items, links. ...
    (comp.lang.javascript)
  • Re: Confused on Syntax
    ... What I would use is the parseInt function: ... Unary + will do what is wanted, and FWIW will do it quicker. ... jscr maths, dates, sources. ...
    (microsoft.public.scripting.jscript)

Loading