Float vs Double

DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #25
Actually, it is not true that integers up to a certain value are exactly represented by floats. They can be, but usually aren't. You can represent integers exactly in a denormalised float, but typically not in a normalised one. Usually, your floats will be normalised, so they are off.

This little annoyance only matters in comparisons, all you have to do is to cast everything to float (eg write 2.0f not 2.0), and then compare. That should give the expected results.
Quote this message in a reply
Post Reply 


Messages In This Thread
Float vs Double - bwalters - Dec 10, 2005, 10:04 AM
Float vs Double - Cochrane - Dec 10, 2005, 10:38 AM
Float vs Double - bwalters - Dec 10, 2005, 10:52 AM
Float vs Double - zKing - Dec 10, 2005, 12:18 PM
Float vs Double - OneSadCookie - Dec 10, 2005, 03:56 PM
Float vs Double - zKing - Dec 10, 2005, 04:29 PM
Float vs Double - jfaller - Dec 12, 2005, 10:58 AM
Float vs Double - Zekaric - Dec 12, 2005, 11:18 AM
Float vs Double - zKing - Dec 12, 2005, 11:40 AM
Float vs Double - Oblivion - Dec 12, 2005, 03:58 PM
Float vs Double - Najdorf - Dec 19, 2005, 11:08 AM
Float vs Double - ThemsAllTook - Dec 19, 2005, 12:40 PM
Float vs Double - Najdorf - Dec 19, 2005, 03:05 PM
Float vs Double - Fenris - Dec 19, 2005, 04:15 PM
Float vs Double - jfaller - Dec 20, 2005, 07:07 AM
Float vs Double - Fenris - Dec 20, 2005, 09:21 AM
Float vs Double - Zekaric - Dec 20, 2005, 10:25 AM
Float vs Double - Fenris - Dec 20, 2005, 12:29 PM
Float vs Double - OneSadCookie - Dec 20, 2005, 12:39 PM
Float vs Double - skyhawk - Dec 20, 2005, 01:10 PM
Float vs Double - Zekaric - Dec 20, 2005, 01:45 PM
Float vs Double - Fenris - Dec 20, 2005, 05:40 PM
Float vs Double - Zekaric - Dec 20, 2005, 06:10 PM
Float vs Double - jfaller - Jan 3, 2006, 02:44 PM
Float vs Double - DoG - Jan 3, 2006 03:49 PM
Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  float value changes when passed to function kendric 5 3,147 Nov 15, 2009 01:57 PM
Last Post: kendric