Subject: Re: [boost] [safe_numerics] review
From: Peter Dimov (lists_at_[hidden])
Date: 2017-03-10 19:10:26


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.