| View previous topic :: View next topic |
| Author |
Message |
wezel Freshman
Joined: 09 Oct 2003 Posts: 30
|
Posted: Feb 8th, 2004 10:59 AM Post subject: Java calculating |
|
|
Hi
Does anyone knows why, if I try System.out.println(8.2 - 1);, I get 7.199999999999999 as output ?
Thanx at advance !
Wezel _________________ Real Programmers don't comment their code - it's hard to write, it should be hard to read |
|
| Back to top |
|
Andir Centurion

Joined: 21 Dec 2003 Posts: 184 Location: Chicago Area
|
Posted: Feb 9th, 2004 12:24 AM Post subject: |
|
|
I would guess decimal precision....but that's a far out guess. Have you tried assigning it to a single precision variable? _________________ If you happen to see little people sitting on your desk...don't tell anyone or they might think your crazy too. |
|
| Back to top |
|
wezel Freshman
Joined: 09 Oct 2003 Posts: 30
|
Posted: Feb 12th, 2004 06:13 AM Post subject: |
|
|
Hi, Thanx for your reply! I can't use Integer vars (or other var types that don't use decimal numbers) cause it's a calculator I'm making. I tried changing the type from double to float but still the same prob.. Any idea on how to solve this one ?
Thanx at advance !
Wezel _________________ Real Programmers don't comment their code - it's hard to write, it should be hard to read |
|
| Back to top |
|
paulreitz Newbie
Joined: 04 Jun 2005 Posts: 3
|
Posted: Jun 29th, 2005 07:43 AM Post subject: |
|
|
Try this:
System.out.println(8.2f-1f);
8.2-1 is trying to subtract two different data types. |
|
| Back to top |
|
|