|
Boost : |
From: Moore, Paul (Paul.Moore_at_[hidden])
Date: 1999-12-06 09:21:07
From: Kevlin Henney [mailto:Kevlin.Henney_at_[hidden]]
> I'm not sure that it overcomplicates the implementation
> in any profound way, or is indeed a misuse of template
> parameters. Provide a private member function:
>
> void dependent_normalize()
> {
> if(Normalization == normalized)
> normalize();
> }
>
> And in each member function that currently calls
> normalize(), call dependent_normalize() instead. This
> would be compiled in at the same cost as before for
> normalized and at no cost for denormalized.
The problem is that even with denormalised fractions, you have to normalise
sometime. Just not after every operation. Deciding when is the big hit. And
"never" isn't realistic - the user won't know when it is appropriate -
especially in the face of silently-truncating integer operations.
> Anyway, just a thought.
Thanks for it. I think it's confirmed for me that keeping the representation
normalised is the best option, ironically :-)
> I'm not sure that comparisons with the existing standard library
> hold up all that well -- consider the joy that is allocators ;->
:-)
Paul.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk