Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 10, 2016, 08:13:15 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: What Every Computer Scientist Should Know About Floating-Point Arithmetic  (Read 8288 times)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,435
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
I recently went through some stress when I made the mistake of using floating point numbers to represent DonationCredits on this website.  Here is a LONG article (originally from 1991) on floating point representations, very cool though it's a LOT to take in..

http://docs.sun.com/...68/ncg_goldberg.html

Quote
Floating-point arithmetic is considered an esoteric subject by many people. This is rather surprising because floating-point is ubiquitous in computer systems. Almost every language has a floating-point datatype; computers from PCs to supercomputers have floating-point accelerators; most compilers will be called upon to compile floating-point algorithms from time to time; and virtually every operating system must respond to floating-point exceptions such as overflow. This paper presents a tutorial on those aspects of floating-point that have a direct impact on designers of computer systems.



from http://del.icio.us/

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,029
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
floating-point is pretty evil... NEVER use floats (or doubles or extendeds or...) for anything involving money or other people's lives. S'ok for 3D graphics, though.
- carpe noctem

app103

  • That scary taskbar girl
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 5,666
    • View Profile
    • App's Apps
    • Read more about this member.
    • Donate to Member
I recently went through some stress when I made the mistake of using floating point numbers to represent DonationCredits on this website. 

That's what you get for doing things the hard way instead of listening to me.  :P

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 7,986
    • View Profile
    • Dales Computer Services
    • Donate to Member
LOL - I could have warned you - never use real number representations where integer use is possible !!
« Last Edit: August 14, 2006, 11:22:35 AM by Carol Haynes »

rkarman

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 27
    • View Profile
    • Arca Eclipse (chatserver for ares)
    • Donate to Member
aside from not using floating point math but fixed point math, also watch out to design your database with the "decimal" type (fixed point) and not the "float" type ;)

housetier

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 1,321
    • View Profile
    • Donate to Member
Re: What Every Programmer Should Know About Floating-Point Arithmetic
« Reply #5 on: August 14, 2006, 11:37:50 AM »
Here is a not-so-long aticle about problems with floating point arithmetic. I thought about opening a new thread but luckily I used my quicksearch-hack to find this thread.

...do we ever stop to think what goes on inside that floating point unit and whether we can really trust it?

I hate to cast aspersions on its good name but when I hear stories of space craft crashing, inconsistent information on bank statements and pensioners being short changed (...), I start to realise that there is a real danger of misusing floating point numbers...
© The Register.

I will look out for the follow-up article and hope it will be good.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
This thread was before my time :)

I think the following points to the follow-up article referred to by housetier:

  Floating point numbers - what else can be done?

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,845
    • View Profile
    • Donate to Member
IIUC, in current versions of JavaScript the only kinds of numbers there are are IEEE 754...

Renegade

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,220
  • Tell me something you don't know...
    • View Profile
    • Renegade Minds
    • Donate to Member
IIUC, in current versions of JavaScript the only kinds of numbers there are are IEEE 754...

So, is that enough for me to get some of you all on the JavaCrap hatred bandwagon? :P


(I ******* hate JavaCrap.)



Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker