sizes, bitfields, etc

Leo de Wit leo at philmds.UUCP
Thu Aug 11 20:08:56 AEST 1988


In article <12933 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
   [stuff deleted]...
|	... {
|		bits	a:(ROUNDUP(3,BITS_PER_BYTE));
|		bits	c:(ROUNDUP(11,BITS_PER_BYTE));
|		...
|
|where ROUNDUP is a compile-time expression that rounds its first
|argument up to the nearest multiple of its second argument:
|
|	/* nb. beware overflow in (x)+(y)-1 below */
|	#define ROUNDUP(x, y)  (floor(((x) + (y) - 1) / (y)) * (y))

Compile-time expression? This would imply that the compiler knows of floor()
- which I doubt, because math.h declares floor as
extern double floor();
furthermore the argument of floor should be double, and it looks like an
integer expression.
Any comments, Chris?

                        Leo.



More information about the Comp.lang.c mailing list