PDA

View Full Version : Converting standard form numbers to ints


ollie101
04-27-2009, 09:20 AM
Hi,

I need to find a way to convert standard form numbers into ints. By standard form I mean like this 2.3E-20 or this -4.127E-22.

The only way I can think of doing this would to be using charAt() and searching for minus signs and then somehow sticking the 0's where they need to be in the int using a loop of some kind

Can anyone help?

BubikolRamios
04-28-2009, 10:10 AM
This should give you a clue:


BigInteger zzzzzz = BigInteger.valueOf(Integer.valueOf("2.2118353849861e+40"));


thought, don't know if this can except ulimited range of numbers, and I have it comented out so I dont know if it works.

also apache has NumberUtils:


public static BigInteger createBigInteger(String str) {
if (str == null) {
return null;
}
return new BigInteger(str);
}