bigfloat

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Apr 8 14:03:05 PDT 2009


Bill Baxter wrote:
> On Thu, Apr 9, 2009 at 5:46 AM, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>> Paul D. Anderson wrote:
>>> Walter Bright Wrote:
>>>
>>>> Paul D. Anderson wrote:
>>>>> b) the features and functions that should be included.
>>>> I'd say NaNs and unordered comparisons. In other words, it should support
>>>> the same semantics as float, double and real do.
>>>>
>>>> If you've got the time and interest, adding all the functions in std.math
>>>> would be great!
>>> I'm not sure I can sign up for ALL of std.math. I'm sure I'll need
>>> help.  I can do roots, powers and transcendental functions, though.
>>> Maybe not very efficiently (power series).
>>>
>>> (If very high precision numbers are questionable, how valuable are
>>> high precision sine and cosine??)
>>>
>>> Paul
>> Would be great if we could enlist Don's help. Don? :o)
>>
>> In only slightly related news, the "new, new" Phobos2 offers custom
>> floating-point numbers, see
>>
>> http://erdani.dreamhosters.com/d/web/phobos/std_numeric.html
>>
>> They aren't infinite precision (which makes their utility orthogonal on
>> bigfloat's), but they allow fine tweaking of floating point storage. Want to
>> cram floats in 16 or 24 bits?
> 
> Awesome.  So we can use it to create the IEEE Halfs that are used by
> graphics cards?

It was a big motivator. The example in the dox does exactly that:

alias CustomFloat!(1, 5, 10) HalfFloat;

>> Care about numbers in [0, 1) at maximum
>> precision? Give CustomFloat a shot.
> 
> By this do you mean you can get a fixed point format? (i'm guessing
> so, just by setting exp bits to zero.)  If so, then that's very cool
> too.

Interesting. I haven't tested exp bits to zero, but that should be 
definitely workable. What I meant was still floating point, but with 
only negative (or zero) powers. You can do that because you have control 
over the bias.

One thing - alias this should greatly simplify using custom floats. It's 
not in there yet.


Andrei



More information about the Digitalmars-d mailing list