Implement the "unum" representation in D ?
francesco cattoglio
francesco.cattoglio at gmail.com
Thu Feb 20 23:42:35 PST 2014
On Friday, 21 February 2014 at 05:21:53 UTC, Frustrated wrote:
>
> I think though adding a "repeating" bit would make it even more
> accurate so that repeating decimals within the bounds of maximum
> bits used could be represented perfectly. e.g., 1/3 = 0.3333...
> could be represented perfectly with such a bit and sliding fp
> type. With proper cpu support one could have 0.3333... * 3 = 1
> exactly.
>
> By having two extra bits one could represent constants to any
> degree of accuracy. e.g., the last bit says the value represents
> the ith constant in some list. This would allow very common
> irrational constants to be used: e, pi, sqrt(2), etc...
Unfortunately maths (real world maths) isn't made by "common"
constants. More, such a "repeating bit" should become a
"repeating counter", since you usually get a certain number of
repeating digits, not just a single one.
> For floating points, the 3rd last bit could represent a
> repeating
> decimal or they could be used in the constants for common
> repeating decimals. (since chances are, repeated calculations
> would not produce repeating decimals)
Things like those are cool and might have their application (I'm
thinking mostly at message passing via TCP/IP), but have no real
use in scientific computation. If you want good precision, you
might as well be better off with bignum numbers.
More information about the Digitalmars-d
mailing list