How not to write a loop, revisited
jrv%sdimax2 at mitre-bedford.arpa
jrv%sdimax2 at mitre-bedford.arpa
Fri Jun 24 05:43:02 AEST 1988
> If this scares you, good! Floating-point can be a nasty nemesis of
> the numerically naive. Claes' advice is sound:
> USE INTEGERS FOR COUNTING.
>
> Peter Klausler @ Compiler Development, Cray Research, Inc.
> ...!{ihnp4!cray,sun!tundra}!hall!pmk
I suggest the revision
Use integer values for counting.
^^^^^^
I believe that floating point arithmetic is exact as long as all the values
are integers with not too many bits - and they typically allow more bits than
a long would. If there are exceptions to this, I'd like to hear about them.
- Jim Van Zandt
More information about the Comp.lang.c
mailing list