From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2007-05-16 05:44:20
"Phil Endecott" <spam_from_boost_dev_at_[hidden]> writes:
> Anthony Williams wrote:
>> I've just implemented some 64-bit (35.28, signed) fixed-point math
>> functions: exp, sqrt, sin, cos. I can post the code if you like.
> Please do.
I've attached the code for my fixed point type. It does sin, cos, exp, sqrt,
ln, tan, atan, floor, ceil, modf, abs, and the full set of normal arithmetic
>> I like the ability to specify the number of bits either side of the decimal
>> point, but this does get in the way for doing the math functions --- you
>> need a table with magic numbers in at the appropriate precision for exp and
> Presumably the tables could be computed at run time once per type.
Yes, but that would add to the app startup cost, or make the first math
function call *very* expensive. The arctan table (for sin and cos) has 30
entries, and the log tables used for exp total 91 entries. 30 calls to atan
and 91 calls to log can take a while. If you increase the precision, then you
need more entries than that.
> There is also the question of what type the result should have.
The same type as the argument seems a sensible start.
-- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk