Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 BigDecimal
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
HeavenAgain




PostPosted: 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 Shocked
Sponsor
Sponsor
Sponsor
sponsor
Euphoracle




PostPosted: 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




PostPosted: 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 Sad
how about the exact number part? Rolling Eyes
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: