Recent

Author Topic: accurate floating point  (Read 6791 times)

max

  • Guest
accurate floating point
« on: June 11, 2005, 02:44:51 am »
i'm not sure if this feature exists but it would be really nice if there was an easy way to have __mathematically accurate__ software floating point emulation, perhaps by checking a checkbox in compiler options.  i notice that if you make a for loop to add 0.0001 (for example) icrementally to itself many times the hardware floating point gives really wacky and inaccurate results and this happens with most compilers/programming languages. a really nice/accurate floating point-emu option would set lazarus way ahead of the crowd.

matthijs

  • Hero Member
  • *****
  • Posts: 537
accurate floating point
« Reply #1 on: June 11, 2005, 09:38:00 am »
It cannot be done by the compiler. You have to do it with software libraries. It is impossible to be accurate of you have only a limited amount of on/off switches. A number is stored as a few 0's en 1's.  And the higher the accurasy you want the  more switches you need. :)
So look for some libraries on the net, there are several.
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

max

  • Guest
accurate floating point
« Reply #2 on: June 23, 2005, 06:19:07 am »
i'm thinking there would be a better storage technique for floating point if (in binary or hex) the numbers right of the decimal point would have fixed place values insead of the wacky scheme that IEEE came up with example:
(in binary -- place values (expressed in base 10)...)
... 8 4 2 1   .   (.5) (.25) (.125) ...
    0 1 0 1   .     1      1       0
(binary encoding for 5.75 (base 10)(4+1+(.5)+(.25))
this way the fp value would be reliably encoded in a manner that would make mathematical sense.. this seems like a good
candidate for an RFC because it looks like it would be much faster if newly released hardware (like IBM's cell architecture(thank god they plan to support open hardware (IBM's the _real_ pioneer not m$)) would internally support this because it works as native binary insead of all sorts of work-arounds for the IEEE method where everything ends up trying to encode base 10 (w/ hardware (!) -- how silly, not to mention wasteful)

matthijs

  • Hero Member
  • *****
  • Posts: 537
accurate floating point
« Reply #3 on: June 23, 2005, 07:31:35 am »
Would you care to tell me how you would store 0.11111111111111 ?
If there really is a feasable and better storage technique this would have been introduced a long time ago.
What ever you choose you always end up with a limited amount of space to store a number in.
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

Anonymous

  • Guest
accurate floating point
« Reply #4 on: June 23, 2005, 04:49:54 pm »
Max, are you using single or double for your calculations ? Double has about 12 significant digits IIRC, while single has only 4 or 5.

 

TinyPortal © 2005-2018