Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-05-14 08:54:38


----- Original Message -----
From: Bill Seymour <bsey_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, May 14, 2001 9:20 AM
Subject: Re: [boost] Fixed-Point Decimal Interface

> I've been thinking about some of the points that Skaller
> and others brought up. How's this?
>
> - I agree that functions such as abs() should be friends,
> not members. I'm concerned, though, that some compilers
> can't handle template friends. As a compromise, I suggest
> leaving such functions in the class as helpers for the free
> functions, and either leaving them undocumented or (better IMO)
> documenting them as implementation details that have to be
> public for portability to non-conforming implementations.
>
All right. But have them only inside apropriate #ifdef/#endif pairs, so that
conformant
compilers don't even see them.

> - I see Skaller's point about the two-argument ctor being
> confusing. At first I thought about suggesting to users
> that they think of the comma as a decimal point; but then
> I caught myself writing an octal constant. 8-) I think
> I've found a use for this ctor, though:
>
> numeric_limits< decimal<Scale> >::epsilon();
>
> returns decimal<Scale>(0, 1). I suggest making this ctor
> one of the "public implementation details" mentioned above.
>
Perhaps 'Named Constructors' can help here:

template<int Scale = >
class decimal
{
public:

  static decimal<Scale> CreateThisWay ( int_type ipart, int_type frac ) ;

}

However, I can't come up with a sensible name so this might be just as
useless!

> - I still think that users ought to be able to mix decimals
> of different scale factors in expressions. I suggest that
> the result type always be the type of the left-hand argument.
> Users can always get a different type with an explicit cast

I would use max(scaleL,scaleR);

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