«« Next » « Previous
«« Next » « Previous

Link Details

Link 93905 thumbnail
User 246188 avatar

By kbilsted
via firstclassthoughts.co.uk
Published: Jul 10 2008 / 07:22

You're in for some "Double trouble"! This article is a practical guide to describing the major traps and pitfalls associated with using the Javas simple type double. It is a must-read for any professional developer
  • 15
  • 2
  • 1422
  • 568

Comments

Add your comment
User 161039 avatar

mheath replied ago:

1 votes Vote down Vote up Reply

This isn't limited to Java. The floating point unit in your CPU behaves the same way. This is the way that IEEE 754 floating point works. http://en.wikipedia.org/wiki/IEEE_754

User 171053 avatar

apolci replied ago:

0 votes Vote down Vote up Reply

I agree with mheath.
With a different title the article would be a good one.

User 246188 avatar

kbilsted replied ago:

0 votes Vote down Vote up Reply

So its in the IEEE specification that 0/0 should throw an exception while 0.0 / 0.0 shouldn't? I'm not too sure about that!

However, that being said, you are correct a lot of the problems illustrated are tied to IEEE 754, but then again not really. They are tied to the fact that a computer cannot represent all numbers 0.0 - 255.0 while it has no problems representing the numbers 0 - 255.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.