(50G) Easter date

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (https://www.hpmuseum.org/forum/forum-10.html)
+--- Forum: General Software Library (https://www.hpmuseum.org/forum/forum-13.html)
+--- Thread: (50G) Easter date (/thread-23106.html)



(50G) Easter date - Gil - 2025-02-09 01:53 PM

According to algorithm given by Jean Meus in Astronomical Algorithms.


RE: (50G) Easter date - 2old2randr - 2025-02-10 08:32 AM

Here is an alternative implementation of the same algorithm. It runs almost three times as fast as yours because all intermediate results are left on the stack (hopefully, the comments help). Also, IDIV2 is really slow so only IP and FP are used.

Cheers
Sudhir

Code:
«
    DUP
    IF 1583. < THEN "Year < 1583" DOERR END      @ Gregorian calendar only
    DUPDUP
    19. MOD                                      @ y mod 19: a
    SWAP
    100. / DUP FP 100. * SWAP IP                 @ y/100: c(rem), b(quot)
    DUP
    4. / DUP FP 4. * SWAP IP                     @ b/4: e(rem), d(quot)
    ROT DUP DUP
    8. + 25. / IP                                @ IP((b+8)/25): f
    - 1. + 3. / IP                               @ IP((b-f+1)/3): g
    - SWAP - 15. + 4. PICK 19. * + 30. MOD       @ 19a+b-d-g+15 mod 30: h
    ROT
    4. / DUP FP 4. * SWAP IP                     @ c/4: k(rem), i(quot)
    4. ROLL
    2. * SWAP 2. * + SWAP - 32. + OVER - 7. MOD  @ 32+2e+2i-h-k mod 7: l
    ROT OVER
    22. * + 3. PICK 11. * + 451. / IP            @ IP((a+11h+22l)/451): m
    7. * - + 114. + 31. /                        @ (h+l-7m+114)/31: p(rem), n(quot)
    DUP FP 31. * 1. RND 1. + SWAP IP             @ mm=n, dd=p+1
    IF -42 FC? THEN SWAP END
    100. / + SWAP 1000000. / +                   @ d.mmyyyy or m.ddyyyy
»