# newbie help... im stuck with this

• Newbie
• Posts: 7
• Loc: Philippines, Cebu

3+ Months Ago

okay...

so im making a small flash program that converts different number basese like from decimal to hex or to binary

and then i come up with this problem coz whenever i try to convert the input value on a textfield which is a string to a number with these values (example below), it outputs different values when converted to a number using the Number() or int() or even parseInt(). here's what i get:

trace(Number("011"); //outputs 9
trace(Number("11"); //outputs 11

what is wrong with this? please help anybody and also explain why...

thanks!

cheers,
darth
• Genius
• Posts: 13508
• Loc: Florida

3+ Months Ago

Code: [ Select ]
trace(parseFloat("00000011"));

If parseInt(string, radix) diddn't work then you diddn't specify the radix as 10.

Code: [ Select ]
trace(parseInt("00000011",10));
• Newbie
• Posts: 7
• Loc: Philippines, Cebu

3+ Months Ago

well actually i did that... for the decimal input
but this time im using it for a binary and octal input
if i did use that and put in radix 2 for binary or 8 for octal, it will only return their decimal value, no? i want it in its binary/octal form so then i can pass it on to my convert to decimal function...
• Newbie
• Posts: 7
• Loc: Philippines, Cebu

3+ Months Ago

problem solved...
it seems that leading zero's are interpreted as octal numbers thats why 011 outputs 9
• Genius
• Posts: 13508
• Loc: Florida

3+ Months Ago

spekkio wrote:
if i did use that and put in radix 2 for binary or 8 for octal, it will only return their decimal value, no?

spekkio wrote:
i want it in its binary/octal form so then i can pass it on to my convert to decimal function...

• Newbie
• Posts: 7
• Loc: Philippines, Cebu

3+ Months Ago

[quote="joebert"]
[quote="spekkio"]if i did use that and put in radix 2 for binary or 8 for octal, it will only [b]return their decimal value[/b], no?[/quote]
[quote="spekkio"]i want it in its binary/octal form so then i can pass it on to my [b]convert to decimal function[/b]...[/quote]

[/quote]

LOL... i know

but im experimenting on doing it manual hehehe... do the actual conversion and not use the builtin parseInt function

LOL you may think im crazy but im not... i already knew that

anyway, cheers!
• Genius
• Posts: 13508
• Loc: Florida

3+ Months Ago

If you say so

Cheers

## Post Information

• Total Posts in this topic: 7 posts
• Users browsing this forum: No registered users and 14 guests
• You cannot post new topics in this forum
• You cannot reply to topics in this forum
• You cannot edit your posts in this forum
• You cannot delete your posts in this forum
• You cannot post attachments in this forum

© 1998-2015. Ozzu® is a registered trademark of Unmelted, LLC.