Mixing char and int types as parameters in portable (summary).

John Gilmore gnu at sun.uucp
Wed Mar 21 19:47:29 AEST 1984


> Therefore it makes little sense to declare the formal parameters of a
> function to be type char or float, since actual arguments never will be.

I disagree.  For example, a char or short can be multiplied much
faster on a 68000 than a (32-bit) int or long.  Also, if the parameter
is declared to be a char, one-byte compares can be done on it, rather
than 4-byte compares.  Since the "conversion" from an int to a char or
short costs nothing, but gains something, you might as well just say
what you mean and call it a char.

This is NOT true for IEEE float, since the float format and the
double format have different bit configurations (more exponent bits
in the doubles).  Conversion to float will cost, but then computation
can be cheaper, so it's a tradeoff.  (Our C compiler has a switch to
generate float expressions in float rather than double, to save time.)



More information about the Comp.lang.c mailing list