Path: utzoo!attcan!uunet!husc6!bbn!uwmcsd1!leah!itsgw!sun.soe.clarkson.edu!batcomputer!eacj From: eacj@batcomputer.tn.cornell.edu (Julian Vrieslander) Newsgroups: comp.sys.mac.programmer Subject: Float to integer conversion problem in LSC 3.0? Keywords: Lightspeed, LSC, conversion Message-ID: <5813@batcomputer.tn.cornell.edu> Date: 8 Aug 88 04:45:23 GMT Reply-To: eacj@tcgould.tn.cornell.edu (Julian Vrieslander) Organization: Cornell Theory Center, Cornell University, Ithaca NY Lines: 23 I hope someone can explain this one for me. The following code fragment is a simplified version of a routine that was giving me unexpected results. The results below were obtained in LightspeedC version 3.0, running under System 6.0: double d; long m,n; m = 126.0; /* m becomes 126 */ d = 12.6 * 10.0; /* d becomes 126 */ n = d; /* n becomes 125 !! */ I cannot understand why n gets "rounded down" to 125. Am I missing something subtle about C syntax or IEEE type conversions, or is this a bug in SANE or LSC? The variable values shown in the comments were verified with the LSC debugger and with my own debugging dialog. If I use the debugger to force a value of 126.0 into d before the last line is executed, then n gets the correct result. What's happening here? -- Julian Vrieslander "Don't rush me... you'll get a rotten miracle." Neurobiology & Behavior, W250 Mudd Hall, Cornell University, Ithaca NY 14853 UUCP: {cmcl2,decvax,rochester,uw-beaver,ihnp4}!cornell!batcomputer!eacj INTERNET: eacj@tcgould.tn.cornell.edu BITNET: eacj@CRNLTHRY