Mail Archives: djgpp-workers/2002/06/10/02:52:04
On Sun, 9 Jun 2002, Richard Dawe wrote:
> `-Wbad-function-cast (C only)'
> Warn whenever a function call is cast to a non-matching type. For
> example, warn if `int malloc()' is cast to `anything *'.
>
> So when we cast rand()'s return value to a double, we get an error.
Are you saying that int and double do not match? They are both
arithmetic types, and the number of significant digits supported by a
double (about 17) is more than enough to represent all 32-bit integers.
> Do we actually need to cast the return value?
We need it to force the division to be done in floating point (as opposed
to two integers). But there are other ways of doing that, some of which
I mentioned in this thread several days ago.
- Raw text -