10 Mar
2017
10 Mar
'17
7:10 p.m.
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.