Boost logo

Boost :

Subject: Re: [boost] [fixed_point] Request for interest in a binary fixed point library
From: Christopher Kormanyos (e_float_at_[hidden])
Date: 2012-04-11 16:33:00


<snip> > There are difficult decisions to make about the result types of arithmetic operations, analogous to this: >  int32_t a, b; >  int64_t c; >  c = a+b;  // oops. <snip> > It is tempting to make the return type of e.g. operator+ large enough > to accommodate the largest possible sum, and to truncate only when > the assignment occurs. <snip> Well, everyone dies, as mentioned below, roll-their-own fixed-point. There will be lots of valid opinions on this one. But I have had good results from the following policy: 1) Forbid binary arithmetic among fixed-points with non-like parameter types. 2) Support copy construction and copy assignment of differing types, whereby *this and the LHS of copy-assign, respectively, determine the digits in the result --- be it larger or smaller (compile-time enable_if is handy here). <snip> > It is perhaps because of this that everyone tends to "roll their own", > and no standard implementation has emerged. Which, quite frankly, I have done one time too many. I definitely crave fixed-point support. Good luck on the project. Best regards, Chris.


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