half and quad

Don Clugston dac at nospam.com.au
Mon Oct 15 00:11:10 PDT 2007


Janice Caron wrote:
> On 10/13/07, Nathan Reed <nathaniel.reed at gmail.com> wrote:
>> Frits van Bommel wrote:
>>> Janice Caron wrote:
>>>> real16, real32, real64, real80, real128...
>>> I'd prefer floatN over realN, as that's a more accurate description of
>>> the type.
>>> (Floating-point types can't represent all real numbers)
>> Integer types can't represent all integers, either...
> 
> Yeah, I had that in mind. An "intN" may represent that subset of the
> integers which may be expressed in N bits. Likewise "realN" may
> represent that subset of the reals which may be expressed in N bits.
> 
> You could certainly argue that all floats are rational, but they don't
> store all rational numbers exactly either. As soon as an operation
> requires it, they start rounding. A float actually represents a kind
> of "fuzzy real" - that is, the true real that it tries to represent
> exists somewhere within plus or minus some error bound of the rational
> value, and it tries to keep that error bound as small as possible.

That's not right. There's nothing fuzzy about floats. They're just a mapping 
from the infinite set of real numbers into a small subset. A float always 
represents a single true real, and it represents it exactly. It's just that not 
many reals are representable. (The roundoff error exists in the operations, not 
the representation).

The representable reals are all rational, except -0, +/- Infinity, and NaN.

> That said, realN or floatN -- I'd be happy either way. If we get
> realN, then I'd want complexN, not crealN (Yuk!), but if we get floatN
> then I guess cfloatN would do.



More information about the Digitalmars-d mailing list