Boost logo

Boost :

From: Ruben Perez (rubenperez038_at_[hidden])
Date: 2025-01-17 21:30:52


On Fri, 17 Jan 2025 at 22:22, Christopher Kormanyos <e_float_at_[hidden]> wrote:
>
> > 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.

Hm, would you? If I understood correctly, decimals are suited for
exact calculations, while standard floating point values are intended
for approximate calculations. In this line of thought, I think it
would make sense for decimals to be much more strict with losing
precision than floats. That is, rounding will almost always happen
with a float literal, while rounding with a decimal literal is more
likely to be a programmer error (I'd say).

Of course, you know your users and the field better than me.


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