home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.bsd
- Path: sparky!uunet!wupost!csus.edu!netcom.com!abe
- From: abe@netcom.com (David Abercrombie)
- Subject: Doubles rounded when cast to int
- Message-ID: <1993Jan6.143337.17276@netcom.com>
- Keywords: gcc, floating, integers
- Organization: Netcom - Online Communication Services (408 241-9760 guest)
- Date: Wed, 6 Jan 1993 14:33:37 GMT
- Lines: 23
-
- Programs compiled on 386bsd using gcc 1.39 do not seem to
- cast doubles to ints correctly. K&R says: "When the value of
- a floating type is converted to integral type, the fractional
- is discarded...". However, on my system (and on ref.tfs.com under
- gcc 1.39), doubles get _rounded_ to the nearest int during a cast
- (instead of getting truncated).
-
- Compiling with gcc 2.3.3 (on ref.tfs.com) provides programs
- that cast doubles to ints properly.
-
- Why is this happening? Feature or bug? My own silly mistakes?
- Is there a fix?
-
- Thanks!
- --
- Dave Abercrombie abe%lyra@infoserv.com
- Oakland, CA abe@lyra.UUCP
- (510) 652-7131 abe@netcom.com
-
- --
- Dave Abercrombie lyra!abe@infoserv.com
- Oakland, CA abe@lyra.UUCP
- (510) 652-7131 abe@netcom.com
-