| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Leap years |
Answering msg from Paul Edwards to rowan_crowe,
on Monday January 22 1996 at 23:18
r>> Based on the above, I've written a C callable ASM function to
r>> decide whether it's a leap year. I'm sure it's been done zillions
r>> of times in C too, but here's my particular solution.
PE> Here's the C code I have. It is unattributed, so I will have
PE> to dig up another version or write my own or something later
PE> on...
PE> #ifndef ISLEAP
PE> #define ISLEAP
PE> #define isleap(year) ((((year%4)==0) && ((year%100)!=0)) ||
PE> ((year%400)==0)) #endif
Cworr! Borland C++ generates almost *exactly* the same hand-written ASM
that I posted. It is a fairly logical evaluation, I guess.
BTW, the algorithm I used says:
LeapYear if Year Mod 4 = 0
EXCEPT if Year Mod 100 = 0
UNLESS Year Mod 1000 = 0
I presume the last should actually be 400. Do you have any official
documentation to confirm this? (I seem to remember you posting something
like that some time ago...)
---
* Origin: Jelly-Bean software development, Melbourne AUST. (3:635/727.1)SEEN-BY: 50/99 632/103 348 998 633/371 634/384 635/402 503 544 727 638/102 SEEN-BY: 639/252 640/230 690/718 711/401 410 413 430 808 809 934 713/888 SEEN-BY: 800/1 7877/2809 @PATH: 635/727 632/348 635/503 50/99 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.