Boost logo

Boost :

Subject: Re: [boost] [safe_numerics] review
From: John McFarlane (john_at_[hidden])
Date: 2017-03-10 19:44:04


I think most people would categorize that the same as overflow caused by
narrowing conversion and as such should be a run time check like any other
narrowing conversion. As such it should be supported with runtime overflow
check.

On Fri, Mar 10, 2017, 11:11 AM Peter Dimov via Boost <boost_at_[hidden]>
wrote:

> John McFarlane wrote:
>
> > Conversion from integers to real numbers is not so much *unsafe* as
> > *lossy*. Users intuitively understand that `int n = 0.5;` will not define
> > a variable with value 0.5 and this is often exactly what they intend,
> > e.g.: [...]
>
> Converting to int a floating-point value that (absent the fractional part)
> cannot be represented in int is undefined behavior, so it is, in fact,
> unsafe, in addition to lossy.
>
>
> _______________________________________________
> 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