weird code
In the midst of some sleep deprivation, I wrote some weird code:
int areequal(float a, float b, float c, float d)
{
return (a == b == c == d);
}
Anyone know what this does? I thought it would return 1 if they were all equal, but it doesn't seem to.
Mike C.
http://www.coolgroups.com/zoomer/
Quite easy -
a == b returns 0 or 1,
and since a == b == c is the same as (a == b) == c, then it checks if c is 0 or 1, based on a and b's equality.
etc.
a == b returns 0 or 1,
and since a == b == c is the same as (a == b) == c, then it checks if c is 0 or 1, based on a and b's equality.
etc.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement