Re:Why floats suck - accurate galaxy-wide coordinates in 128...
by jules on Tuesday May 03, 2011 @08:38AM
(#2509699)
That seems downright stupid.
"How often do you use 1/3 in your calculations. Base 10 is a number system where 1/3 can't be accurately represented."
If you need exactness, use rationals. Don't just use a number system with more prime divisors. If you don't need exactness, use base 2.
Re:Why floats suck - accurate galaxy-wide coordinates in 128...
by arundelo on Tuesday May 03, 2011 @12:51AM
(#2509018)
I'd like hardware that represents fractional parts in binary-coded base-15 -- no rounding on 1/3 as well as 1/10!
Re:Why floats suck - accurate galaxy-wide coordinates in 128...
by klodolph on Tuesday May 03, 2011 @01:11AM
(#2509053)
1/10 would be a repeating number in base-15, 0.1777777...
(Well, technically, 1/10 is not a repeating number in any base, but you know what I mean.)
Re:Why floats suck - accurate galaxy-wide coordinates in 128...
by arundelo on Tuesday May 03, 2011 @08:18AM
(#2509660)
Oops, you're right! I was misremembering something I had figured out once. It's base-30 that does multiples of 2, 10, and 3 (and 5 etc.). (And 30 is pretty close to a power of 2 so that not much space gets wasted if a BCD-like method is used where the underlying representation is base-2.)
Re:Why floats suck - accurate galaxy-wide coordinates in 128...
by palish on Monday May 02, 2011 @05:19PM
(#2507879)
"I wrote some CAD routines once that used decimal arithmetic rather than binary and was amazed at how much better it worked in terms of edges lining up and when you approximate non-square surfaces you get much better tesselation."
That's precisely what I'm working on. What did you use?
P.S. Use 0.125, not 0.100
Re:Why floats suck - accurate galaxy-wide coordinates in 128...
by ChuckMcM on Monday May 02, 2011 @05:40PM
(#2507969)
I used the Java decNumber class (linked off Mike's web site) and the Java 2D API. Once the 3D API came out it seemed like the visualization code at least should use that. Converting to/from decimals to floats was unnecessarily painful at the time.
He got interested in decimal math early on but not because 'floats' such by binary floats really suck. That is a number system where .1 can't be accurately represented. How often do you use .1 in your calculations? He has a couple of examples of 34 digit precision which is representable in a 128 bit quantity. (3.7 bits per digit). Straight BCD would of course be 32 digits minus the digits which represent the exponent.
I wrote some CAD routines once that used decimal arithmetic rather than binary and was amazed at how much better it worked in terms of edges lining up and when you approximate non-square surfaces you get much better tesselation.
And of course for history buffs the IBM 1620 used decimal as a native representation for numbers. Now that we've got lots of transistors to play with, perhaps its a good time to revisit the way we represent numbers.
[1] http://speleotrove.com/decimal/