Please create an account to participate in the Slashdot moderation system


Forgot your password?
DEAL: For $25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 Internet speed test! ×
User Journal

Journal Chacham's Journal: Article: What Comp Scientists Should Know About Float Math 5

What Every Computer Scientist Should Know About Floating-Point Arithmetic

Old article, just saw it in this message. Google will give many results.

Too advanced for me, but it certainly looks interesting.

Humpty Dumpty looked doubtful, " I 'd rather see that done on paper," he said.
Alice couldn't help smiling as she took out her memorandum-book, and worked the sum for him:


Humpty Dumpty took the book, and looked at it carefully. "That seems to be done right-" he began.

"You're holding it upside down!" Alice interrupted.

"To be sure I was!" Humpty Dumpty said gaily, as she turned it round for him. "I thought it looked a little queer. As I was saying, that seems to be done right though I haven't time to look it over thoroughly just now---and that shows that there are three hundred and sixty-four days when you might get unbirthday presents ---"

This discussion has been archived. No new comments can be posted.

Article: What Comp Scientists Should Know About Float Math

Comments Filter:
  • I had all of this as part of my Software Engineering Degree, in algorithm class (which did NOT teach me to spell apparently). Is the author saying they're skipping this stuff now?
    • No they are not skipping this stuff now.

      They just teach it using powerpoint slides which suck so much that nobody learns it.

      Of course the REAL lesson here is:


      If you DO have to rely on innate float or double types, read up very closely on how they are handled on whatever platform the code will be executed on!

      Good APIs have precision math libraries though. After the first 50 or so significant figures, I typically stop caring. :)

      Ok ok, it depends on use. I
  • Three final examples: x = x cannot be replaced by the boolean constant true, because it fails when x is a NaN; -x = 0 - x fails for x = +0; and x < y is not the opposite of x >= y, because NaNs are neither greater than nor less than ordinary floating-point numbers.

    I don't quite understand the -x = 0 - x one, however. I'm almost positive that -(+0) yields (-0), so I'm guessing that they're saying that 0 - (+0) yields (+0). Seems to me that 0 - (positive anything) should yield (negative anything). Of

He who steps on others to reach the top has good balance.