Boost logo

Boost :

From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2003-07-15 16:23:00


Bill,

Bill Seymour <bill-at-the-office_at_[hidden]> wrote in message
news:3F14585D.A9FF8A22_at_pobox.com...
> I've upload fixdec23.zip to the Yahoo files section.
>
> I made some changes that Jens suggested to allow compiling with
> Comeau and gcc; and I've made the is_bounded and is_modulo fixes
> that Fernando suggested along with interoperatability with
> unsigned as well as int.
>
Great,

> Fernando,
>
> I think that max_scale needs to be a constant expression
> because it's used in the definition of numeric_limits<decimal>:
>
> BOOST_STATIC_CONSTANT(int, digits=boost::fixdec::max_scale);
> BOOST_STATIC_CONSTANT(int, digits10=boost::fixdec::max_scale);
>
Couldn't these be implemented right in terms of
numeric_limits<int_type>::digits?

> And I think I'm right about numeric_limits<>::digits10. I believe
> it's intended to be mean that, if the value is N, then /all/ N-digit
> numbers can be represented. numeric_limits<decimal>::digits10 can't
> be 19 because only a subset of 19-digit numbers are representable.
>
> Also, I think that your statement:
> >
> > ... __int64 support 18 digits at most.
> >
> is factually incorrect. Your implementation's __int64 should support
> anything up to 10**63 - 1 or (with commas as thousands separators)
> 9,223,372,036,854,775,807. That's a 19-digit number.
>

You're right on both accounts.

All numbers with 'N=digits10' digits should be representable, including
N-nines.
That explains why numeric_limits<__int64>::digits10 is 18 even though
numeric_limits<__int64>::max() is a 19 digit number.
The leading digit, being a partial digit, cannot be accounted for in
'digits10'.

Fernando Cacciola


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