Variable overloading problem - please help

Hi

I have a simple program that needs to read in a decimal OR octal OR hexadecimal number, calculate the result into a decimal value and spit it out to the user. However I am little concerned as to what type can I use so the user doesn't over load my variable. when I use long double (and then getting rid of the .x portion) it gives me an ugly out put, but when I use int, or long int I am fine until I have a 20digit number as an entry and then it craps out on me.. What should I do so I can take any number for example 123456789123456789123456789 and still not lose precision

Thank you for your help

[622 byte] By [HowardAa] at [2007-9-27 7:32:18]
# 1

> should I do so I can take any number for example

> 123456789123456789123456789 and still not lose

> precision

You (and the user) must be prepared to lose precision if the number that is entered is too large.

Now, if you do not need to store the value at all you might want to take a hack at parsing the input directly to another string that when printed will represent the decimal value....

kleinka at 2007-7-8 11:27:54 > top of Java-index,Archived Forums,Java Programming...
# 2
The BigInteger class allows you to handle very large integers.
DrClapa at 2007-7-8 11:27:54 > top of Java-index,Archived Forums,Java Programming...