# Trying to convert 0025 into an integer.. Pls help!

I'm grabbing a value from a database that returns numbers like 0025 or 0042. It really means 25 and 42. How do I put thos values into a javascript variable while letting it know that its an integer? Javascript doesn't like numbers with double zeros in front of it.  It returning 0025 as 21 for some reason. How do I convert 0025 to 25?
###### Who is Participating?

x

Systems architectCommented:
Oh, the default radix for numbers starting with zero is eight (octal numbers).

0

Principal Systems EngineerCommented:
0

Commented:
If there are some numbers with decimals, use parseFloat(NumberFromDatabase). If there aren't any decimal numbers, just integers, use: parseInt(NumberFromDatabase) as in the comment above.
0

Systems architectCommented:
You have to put the radix as second parameter of the parseInt() method.
Like this:

var theNum = parseInt("0025", 10);

0

Principal Systems EngineerCommented:
Use this one...

while (z.charAt(0)=="0")
{
z=z.substring(1,z.length);
}

// Case all 0
if (!z.length) { z="0"; }
return z;
}
0

Author Commented:
AH HAH!!! Zvonko, thanks again. That was the problem
0

Systems architectCommented:
You are welcome.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.