Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Other Languages

Post new topic   Reply to topic
Java calculating
View previous topic :: View next topic  
Author Message
wezel
Freshman


Joined: 09 Oct 2003
Posts: 30

PostPosted: Feb 8th, 2004 10:59 AM    Post subject: Java calculating Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Andir
Centurion


Joined: 21 Dec 2003
Posts: 184
Location: Chicago Area

PostPosted: Feb 9th, 2004 12:24 AM    Post subject: Reply with quote

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
View user's profile Send private message
wezel
Freshman


Joined: 09 Oct 2003
Posts: 30

PostPosted: Feb 12th, 2004 06:13 AM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
paulreitz
Newbie


Joined: 04 Jun 2005
Posts: 3

PostPosted: Jun 29th, 2005 07:43 AM    Post subject: Reply with quote

Try this:

System.out.println(8.2f-1f);

8.2-1 is trying to subtract two different data types.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Other Languages All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic