Boost logo

Boost :

Subject: Re: [boost] Fixed point integer proposal
From: John Bytheway (jbytheway+boost_at_[hidden])
Date: 2009-06-25 13:41:44


Soren Holstebroe wrote:
>> For example, does a(24bit) x b(24bit) -> c(24bit), or c(48bit)?
>>
>> My preference is to be explicit about these issues, meaning 24bit x 24bit ->
>> 24 bit. If you want more, you cast the operands first. Similarly there
>> were some questions on division.
>
> In my template N bit x N bit equals N bit per default.
> The number one design criteria was speed. Why would you use fixed
> point instead of floats if not for speed?

For reproducibility. I have several times wanted to not use floating
point because its behaviour may change depending on architecture /
compiler / compiler options. In some cases fixed point would have been
fine, and it would be nice to see it in Boost. The alternative seems to
be to roll my own fixed (or floating!) point type, which would be more
difficult and error-prone and probably slower.

Nevertheless, I think N bit x N bit equals N bit is sensible.

John Bytheway


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk