www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/06/10/02:52:04

Date: Mon, 10 Jun 2002 08:13:10 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
cc: djgpp-workers AT delorie DOT com
Subject: Re: Patches for building with gcc 3.1 - tests chunk
In-Reply-To: <3D03BEF4.78F989@phekda.freeserve.co.uk>
Message-ID: <Pine.SUN.3.91.1020610081018.21236D-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019