Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2025-01-16 18:25:06


Matt Borland wrote:
> > Has there been given any thought to making decimal32 and it's brethren
> > "safe" in the sense that Boost.Safe Numerics types are "safe"? Seems
> > to me to be a worthy idea given the types of applications that this
> > decimal32 would be meant to support.
>
> We have not looked into a safe version, but we follow the normal IEEE 754
> convention where overflow, underflow, div by 0, etc. result in +/-INF and
> NAN. I think (but have no tried) that the decimal types fulfill all of the Safe
> Numerics conceptual requirements for Numeric<T>, and then could be used
> with Safe Numerics if that safety is desired.

IEEE floating point doesn't have undefined behavior, so it's always "safe" in
the "no undefined behavior" sense. (Assuming that floating point exceptions
are disabled. When they are enabled, it's not so clear.)


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