Calendar Functions (simpler leap year calculation)

Frank Adams franka at mmintl.UUCP
Fri Sep 19 08:06:20 AEST 1986


In article <886 at ihdev.UUCP> pdg at ihdev.UUCP (55224-P. D. Guthrie) writes:
>Or if you want a complex cpp macro
>to return the number of days in a year......
>
>#define num_day(x) ((x)%4 ? (x)%100 ? (x)%400 ? 366 : 355 : 356 : 355)

If you want a macro which gives the right answer, you might instead try:

#define num_day(x) ((x)%4 ? (x)%100 ? (x)%400 ? 366 : 365 : 366 : 365)

Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108



More information about the Comp.lang.c mailing list