tag:blogger.com,1999:blog-21500237.post4049759409356333902..comments2023-04-29T04:08:32.247-04:00Comments on Praise, Curse, and Recurse: The Division Bell Tolls for Me, Part TwoPaul R. Pottshttp://www.blogger.com/profile/04401509483200614806noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-21500237.post-2643474959225051692006-12-07T11:35:00.000-05:002006-12-07T11:35:00.000-05:00Hi alternate moebyus,
You are quite right... I ma...Hi alternate moebyus,<br /><br />You are quite right... I made a mistake in the C code. Actually I copied-and-pasted the wrong version. To get rid of the shift to positive numbers just take out the +denom inside (numer+denom). I have made this change in the original article.<br /><br />There was also a problem in that the declaration of the for loop variable inside the parens after "for" is a C++ construct, also supported in C99, but not C90. I have changed that too.<br /><br />On the platforms I have access to: Mac PowerPC, an embedded PowerPC platform, Win32 and Linux on a Pentium, sizeof(long) is 4 (bytes).Paul R. Pottshttps://www.blogger.com/profile/04401509483200614806noreply@blogger.comtag:blogger.com,1999:blog-21500237.post-72304802271911748902006-12-07T01:22:00.000-05:002006-12-07T01:22:00.000-05:00long val = ( numer + denom ) * 32768 / denom
Paul...<i>long val = ( numer + denom ) * 32768 / denom</i><br /><br />Paul, am I reading this correctly? At numer=-11, this should evaluate to (-11+11)*whatever=0, and not -32768?<br /><br />Shouldn't it be something on the lines of<br /><br /><i> (numer+denom)*32768/denom - 32768 </i><br /><br />Out of curiosity, what is sizeof(long)? Haskell defines Data.Bits.bitSize (1::Int) to be 32 somewhere in the standard...The Alternate Moebyushttps://www.blogger.com/profile/04163363935773353768noreply@blogger.com