|
Boost : |
From: Christopher Kormanyos (e_float_at_[hidden])
Date: 2025-01-17 21:57:15
>>> Question:>>> I've noticed that this:>>>>>> 1.23456789098787237982792742932938492382342382342002934932_df>>> Compiles, although it truncates the>>> value to 1.234568. Would it make>>> sense to somehow tell the user "hey,>>> this literal is too long"
>> It would absolutely make sense,>> but then you would need the same thing>> to happen for float, double and>> long double in the Standard, which>> isn't going to happen.>> So Decimal follows suit.
> That's not the same. Base 2 floats> don't need a fixed number of decimal> digits to be represented unambiguously,> but decimal floats do.
Oh that's a good point. It goesinto the direction of languagespecification.
When we talk about adding valueto this library today, we couldhave the discussion. I guesswe would need to figure out a portableway to provide such compile-time info.
This might seem a bit skeptical frommy side, but, as much as I agree,I don't feel that it really leadsanywhere in the case of DecimalTODAY.
I don't believe it's within the scopeor purpose of Decimal to figureout how to inform the client"Hey, your fixed-point representationjust walked off its digits".
That would be something for theStandard, and perhaps evensomething for fixed-point ingeneral.
- Chris
On Friday, January 17, 2025 at 10:31:28 PM GMT+1, Peter Dimov via Boost <boost_at_[hidden]> wrote:
Christopher Kormanyos wrote:
>Â > Question:
> > I've noticed that this:
> >
> 1.23456789098787237982792742932938492382342382342002934932_d
> f
> > Compiles, although it truncates the> value to 1.234568. Would it make>
> sense to somehow tell the user "hey,> this literal is too long"
> It would absolutely make sense, butthen you would need the same thing
> tohappen for float, double and longdouble in the Standard, which isn'tgoing to
> happen.
> So Decimal follows suit.
That's not the same. Base 2 floats don't need a fixed number of decimal
digits to be represented unambiguously, but decimal floats do.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk