Boost logo

Boost :

From: Michael Marcin (mmarcin_at_[hidden])
Date: 2007-04-18 22:39:18

Neal Becker wrote:
> Michael Marcin wrote:
>> Phil Endecott wrote:
> [...]
>> I think a Boost worthy implementation (which mine certainly isn't in
>> its present form) would require at least:
>> - optional overflow/underflow detection
> Programmable overflow/underflow behavior, probably specified as a
> template paramater.
> * ignore overflow
> * throw on overflow
> * limit on overflow

I'd also add assert on overflow, which I would have as default in debug
builds and ignore as default in release builds.
The question is how does one do this cleanly?
Bear in mind that, at least for my purposes, it is necessary that
sizeof(fixed<16,16>) == sizeof(GLfixed).

I'd also like to multiply and divide fixed-point numbers without using a
larger intermediate type when possible.
I'd also like to be able to store 16-bit fixed-point types as 32-bit ints
for performance or 16-bit shorts for size but I don't have any idea how to
specify this cleanly.

Looking through the code Phil linked to it looks like it's using a lot of
floating-point arithmetic. Isn't fixed-point math generally used where
floating-point doesn't offer enough precision or a FPU doesn't exist? For
me I don't have a FPU so this is not too useful.

I've uploaded my current fixed-point code.

Please have a look through it.

Michael Marcin

Boost list run by bdawes at, gregod at, cpdaniel at, john at