Re: A89: Re: What the heck is wrong with this?!
[Prev][Next][Index][Thread]
Re: A89: Re: What the heck is wrong with this?!
In a message dated 8/18/99 9:07:27 PM Eastern Daylight Time,
zoltan@bendor.com.au writes:
> That would require a float operation, while doing this
>
> x = ( 38 * y ) / 10;
yeah, l found this out a little while ago, it's probably the best way l
think. And, tigcc seems to sort of simplify the expression for you before it
assembles the program.
> would not. Note that you must use the parens, for 38 * ( y / 10 ) is
> not what you want: if y is 1, then y / 10 is 0 (integer division) thus
> your result is 0. Since the compiler without parens could evaluate
> the subexpressions any way it pleases, you must force the order
> explicitly by the usage of them.
>
> If you are a speed freak and a little loss of precision would not
> be a problem, then you would do something like this:
>
> x = ( 3891 * y ) >> 10;
how does the above work?
> which, of course, is equivalent to 3.8035191 * y, and error of 0.09 %
> and you save the fairly expensive integer division.
--TurboSoft
Visit the TURBOSOFT HOMEPAGE: The most current Basic programs created by
Turbosoft for the 89, and the most 89 links.
<A HREF="http://turbosoft.ticalc.org/">http://turbosoft.ticalc.org/</A>
Follow-Ups: