Should rand() return a RAND_MAX value for 32 bit target?
Vincent Lefevre
vincent+gcc@vinc17.org
Thu Sep 20 16:12:00 GMT 2018
On 2018-09-20 17:58:30 +0200, Vincent Lefevre wrote:
> On 2018-09-20 23:21:23 +0800, Liu Hao wrote:
> > `2147483647` is an integer constant. This rule only describes floating
> > constants, so it does not apply.
>
> Actually the fact that it is a constant doesn't matter, but...
>
> > According to '6.3.1.8 Usual arithmetic conversions', here `2147483647`
> > is converted to a value having type `float`, which is then compared with
> > `f` using the internal `long double` type.
>
> The conversion of the int needs to be done with the precision and
> range of long double since this is neither an assignment nor a cast.
Similarly, for
float a, b;
double c;
(a + b) + c;
I would expect the result of a + b to be kept in long double instead
of being converted to double due to the operand c.
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the Gcc-help
mailing list