BigDecimal
Author |
Message |
HeavenAgain
|
Posted: Thu Nov 08, 2007 7:44 pm Post subject: BigDecimal |
|
|
im trying to to print the exact value of R^n, where R is a real number ( 0.0 < R < 99.999 ) and n is an integer such that 0 < n <= 25.
well.. problem is, it just wont let you, so i figured to use BigDecimal, but whenver BigDecimal stores a float number, eg. 1.1 it gives a bunch of useless stuffs at the end
code: | BigDecimal num = new BigDecimal(1.1);
System.out.println(num);
System.out.println(num.pow(2)); |
see the output, why is that?
and how would you do output the exact value, Formatter? or something else...
Thanks |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Euphoracle
|
Posted: Thu Nov 08, 2007 9:56 pm Post subject: RE:BigDecimal |
|
|
BigDecimal doesn't actually use regular arithmetics, it does what MS Calculator does, allowing you to perform arithmetic on huge numbers, albiet at the cost of time. (or at least that's what I've been told) |
|
|
|
|
|
HeavenAgain
|
Posted: Thu Nov 08, 2007 9:59 pm Post subject: RE:BigDecimal |
|
|
yeah... its a weird strange thing, im going to stay away from it now
how about the exact number part? |
|
|
|
|
|
|
|