C is not superfluous (Re: "for" loops (was Re: C++ vs. Modula2))

Shankar Unni shankar at hpclscu.HP.COM
Tue Feb 7 10:48:50 AEST 1989


> I guess it is obvious to me, not to others: If the increment that the user
> wrote was 0.1, with one digit to the right of the decimal point, the
> compiler should obviously use 10 as the denominator because 0.1 = 1/10.  If
> the user wrote a loop that incremented by 0.127, the compiler writer should
> use 1000 for the divisor, because the user had 3 digits to the right of the
> decimal.   Any increment the user can type into their program can be exactly

What you want is BCD (blecchh!!). Be sure you want to ask for this. Because
the programmer could just as well have written:

   float f = 1.27;

   /* LOTS OF STATEMENTS */
      
   for (g = 0.0; g < 100.0; g += f) { /* ... */ }
   
What? you want to treat *your* case specially, but not this more general
one? Like: IF, in the for loop, the increment statement is a single
statement of the form LOOP_INDEX += INCREMENT, and the INCREMENT is a
floating-point constant, THEN do your special fiddling...

Really!
---
Shankar.



More information about the Comp.lang.c mailing list