Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Aug 1999 00:12:01 +0100
From:      Mark Ovens <mark@ukug.uk.freebsd.org>
To:        chat@freebsd.org
Subject:   Correct casting in ANSI C
Message-ID:  <19990830001201.C265@marder-1>

next in thread | raw e-mail | index | archive | help
To achieve *strict* ANSI compliance, what is the correct way to                 
use cast(s) in the following code.                                              
                                                                                
gcc doesn't complain, even with ``-Wall'', but Sun's ANSI C compiler            
gives a warning like "the semantics of SCONV change in ANSI C; use              
an explicit cast". Do I need to cast each int (& the literal 1000),             
or just cast the whole expression?                                              
                                                                                
        int i = 123, j = 57, k = 500;                                           
        double d;                                                               
                                                                                
        d = i / j + k / 1000;                                                   

-- 
STATE-OF-THE-ART: Any computer you can't afford.
OBSOLETE: Any computer you own.
________________________________________________________________
      FreeBSD - The Power To Serve http://www.freebsd.org
      My Webpage http://ukug.uk.freebsd.org/~mark/
mailto:mark@ukug.uk.freebsd.org              http://www.radan.com



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990830001201.C265>