Array indexing vs. pointers...

Walter Bright bright at Data-IO.COM
Thu Oct 6 04:24:52 AEST 1988


In article <10332 at s.ms.uky.edu> aash at ms.uky.edu ( Aashi Deacon ) writes:
<<    o	Try very hard to replace divides with other operations, as in:
<<		x / 10
<<	with:
<<		x * .1
<<    o	See if some calculations can be done using integer math.
<Are these two points contradictory?
	Not if x is a double, which I implied but didn't state.
<According to theory, '.1' cannot be represented exactly as a floating
<point number because in base2 it is irrational.  Wouldn't then the
<first be better in this case?
	The result may differ in the last bit of the significand because
	of this. However, in most cases, that is irrelevant and the
	multiply will be significantly faster.



More information about the Comp.lang.c mailing list