home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / bsd / 10948 < prev    next >
Encoding:
Text File  |  1993-01-06  |  1.2 KB  |  34 lines

  1. Newsgroups: comp.unix.bsd
  2. Path: sparky!uunet!wupost!csus.edu!netcom.com!abe
  3. From: abe@netcom.com (David Abercrombie)
  4. Subject: Doubles rounded when cast to int
  5. Message-ID: <1993Jan6.143337.17276@netcom.com>
  6. Keywords: gcc, floating, integers
  7. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  8. Date: Wed, 6 Jan 1993 14:33:37 GMT
  9. Lines: 23
  10.  
  11. Programs compiled on 386bsd using gcc 1.39 do not seem to 
  12. cast doubles to ints correctly.  K&R says: "When the value of
  13. a floating type is converted to integral type, the fractional 
  14. is discarded...".  However, on my system (and on ref.tfs.com under
  15. gcc 1.39), doubles get _rounded_ to the nearest int during a cast 
  16. (instead of getting truncated).
  17.  
  18. Compiling with gcc 2.3.3 (on ref.tfs.com) provides programs 
  19. that cast doubles to ints properly.
  20.  
  21. Why is this happening?  Feature or bug?  My own silly mistakes?
  22. Is there a fix?
  23.  
  24. Thanks!
  25. --
  26. Dave Abercrombie                abe%lyra@infoserv.com
  27. Oakland, CA                        abe@lyra.UUCP
  28. (510) 652-7131                     abe@netcom.com
  29.  
  30. -- 
  31. Dave Abercrombie                lyra!abe@infoserv.com
  32. Oakland, CA                        abe@lyra.UUCP
  33. (510) 652-7131                     abe@netcom.com
  34.