Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-05-09 15:36:22


> Beman Dawes wrote:
>
>
> At 02:50 PM 5/9/2001, Rainer Deyke wrote:
>
> >> - A template class with the template parameter being the number
> >> of digits to the right of the decimal point.
> >
> >I think there's also a need for non-decimal fixed-point numbers (i.e.
> >hexadecimal digits to the right of the hexadecimal point or such). For
> >this reason I would prefer it if there was instead a template argument
> >N such that multiplies of 1/N are reprsented exactly.
>
> That really sounds like a different class to me. Keep a basic fixed point
> class simple. Parameterization discourages users (to quote Jerry
Schwarz).
>
> >> Represent at least 18 decimal digits exactly. (The 18 comes
> >> from prior art on IBM mainframes, and also turns out to be
> >> convenient if the internal representation is a 64-bit int.)
> >
> >I would make the internal representation type another template argument.
>
> No, please don't turn this into a Swiss army knife class. The underlying
> representation is an implementation detail, and shouldn't be part of the
> interface parameterization. If the machine has special fixed point
> hardware (like the decimal arithmetic on some mainframes) the
> implementation should be able to use that hardware.
>
> Classes intended for very wide use and eventual standardization need to be
> kept focused. The committee will reject submissions for having too many
> features much more often than for having too few features. Users will do
> the same.
>
I'm not sure if this particular parametrization -which would be defaulted-
would
actually discourage users; but if in your experience that's the case here, I
recommend
at least two default variations, one with an efficient internal
representation and another with
a flexible representation, allowing arbitrary large numbers. Some
applicatiosn will need that range flexibility.

> George Heintzelman wrote:
>
>
> Yes, and you must be able to do binary operations with all numeric
> types without having to do explicit type conversions; using a
> float/double operand should give a float/double result,

I don't think that mixed operations with floating point values should give a
floating point result.
If the class has absent/explicit constructors from fp types, this will
prevent many usual expressions;
and if it has regular constructors from fp-types it will produce too many
temporaries and conversions.

Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com


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