The leading zero signifies that the number is an octal; like 0x is hex. Use
parseInt.

parseInt ("0023", 10);

/**
 * Timestamp, to see how long this thing takes to post: 1:58 PM EST
 */

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of quinrou .
Sent: Tuesday, January 24, 2006 1:01 PM
To: Flashcoders mailing list
Subject: [Flashcoders] number casting weirdness

Hi all,

I am having some really strange things with the Number casll

here are some tests I've been running and some unexpecting things happened.

var str:String = "0023";
trace(str); // output 0023 - this correct and expected


var numb:Number = Number(str)
trace(numb); // output 19 - this incorrect and unexpected - was expecting
either 0023 or 23

var numb2:Number = Number("23")
trace(numb2); // output 23 - this correct and expected

var numb3:Number = Number("00"+"23")
trace(numb3); // output 19 - this incorrect and unexpected - was expecting
either 0023 or 23

var numb4:Number = Number("11"+"23")
trace(numb4); // output 1123 - this correct and expected

is there a bug with the class number and the use of 0 ? how am I supposed to
get 0023 or 23 out of "0023" (string) without cleaning the string and
looking for the 0's.

thanks

Seb
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to