allard@max.bnl.gov (Rick Allard) (08/30/90)
This program calculates when to avoid pregnancy by counting days and considering the length of recent months. The algorithm is common, see the book Contraceptive Technologies by Robert A. Hatcher for example; the code for Julian dates is from Stephen Luse. [I'd be interested in knowing if there exists a dedicated handheld for this purpose -- hint, hint] To use it press FA and a display like: yr mo d or mo d 1990 assumed then CONT appears, then or by pressing WHEN, the output is: first unsafe day 1/28 next safe day 2/17 This code was designed to be as compact as I could possibly make it while still retaining some I/O ergonomics. (This might be construed as a pun.) So, some things must be done by hand. FAD, the data list must be created before using FA the first time. The data isn't rolled, it accumulates, so old data must be manually thrown away, these are at the *top* of the display. Even though one has the option of entering the year or not, the new year must entered by hand to be used as the default. This code including the two Julian routines uses less than 1000 bytes or about half the memory of a 28C. Oh yes, this writes over any statistical array you may have. Copy freely. Change the numbers if you want your kids to have grandchildren, or adjust for your situation -- I'm always confused whether the intervals are open or closed, but I don't think it makes that much difference. FA << Y "yr mo d or mo d " Y ->STR + " assumed then CONT" + CLLCD 1 DISP HALT CJ DUP GD - <sigma>+ RCL<sigma> 2 ->LIST 'FAD' STO WHEN >> GD << FAD LIST-> DROP STO<sigma> >> WHEN << "next safe day " GD DUP MAX<sigma> 11 - CD SWAP MIN<sigma> 19 - CD "first unsafe day " SWAP + CLLCD DISP + 2 DISP >> CD << + JC ->STR SWAP ->STR "/" + SWAP + SWAP DROP >> Y example 1990 FAD example { 2447912 [[ 39 ] [ 27 ] [ 33 ] [ 32 ]] } JC and CJ from luse@nosc.mil; (available from gmuvax2.gmu.edu either by ftp or by mail to user hp28). CJ - date to Julian Day conversion - This routine generates the Julian day number for a specified date. Expects YYYY in level 3, MM in level 2, and DD in level 1. For example, to calculate the Julian Day Number for September 21, 1988, enter: 1988 ENTER 9 ENTER 21 ENTER CJ. Value returned is 2447426. JC - Julian Day to date conversion - This routine is the inverse of CJ. Given a Julian Day Number in level 1, YYYY is returned to level 3, MM to level 2, and DD to level 1. Note: CJ and JC provide a means of calculating dates from other dates. For example, what is the date 90 days from September 21, 1988? Solution: 1988 ENTER 9 ENTER 21 ENTER CJ 45 + JC. See 1988 in level 3, 11 in level 2, 5 in level 1, indicating that November 5, 1988 is 45 days from September 21, 1988. CJ << << 2.85 - 12 / + >> -> y m d yp << 367 y m yp EVAL * IP y m yp EVAL IP - .75 y m yp EVAL IP * - d + IP .75 y m yp EVAL 100 / IP * - IP 1721115 + >> >> JC << 1721119.2 - DUP DUP 36524.25 / IP SWAP OVER + SWAP 4 / IP - DUP ROT DROP 365.25 SWAP OVER / IP SWAP OVER * SWAP ROT ROT IP - .3 - DUP 30.6 SWAP OVER / IP SWAP OVER * SWAP -> k << SWAP OVER - 1 + SWAP DROP k >> DUP 9 IF > THEN ROT 1 + SWAP 9 - ELSE ROT SWAP 3 + END ROT IP >> ooooooooooooootter#spoon in bowl !!!!!!!!!!!!& RooM & !!!!!!!!!!!!R oooo M
chuck@trantor.harris-atd.com (Chuck Musciano) (08/30/90)
In article <2098@bnlux0.bnl.gov>, allard@max.bnl.gov (Rick Allard) writes: > This program calculates when to avoid pregnancy by counting days and > considering the length of recent months. The algorithm is common, see > the book Contraceptive Technologies by Robert A. Hatcher for example; > the code for Julian dates is from Stephen Luse. > > > [I'd be interested in knowing if there exists > a dedicated handheld for this purpose -- > hint, hint] As a matter of fact, the Rabbit Ovulation Computer does a good job of accurately determining when a woman is ovulating, and tells which days are her fertile time. She must take her temperature each morning (using a thermometer attached to the unit) and record when her periods start. The device is supposed to be quite accurate, and is normally used to help conception. For more information, call The Rabbit Computer Company at 213-479-4106. Chuck Musciano ARPA : chuck@trantor.harris-atd.com Harris Corporation Usenet: ...!uunet!x102a!trantor!chuck PO Box 37, MS 3A/1912 AT&T : (407) 727-6131 Melbourne, FL 32902 FAX : (407) 727-{5118,5227,4004} I'm glad you asked, son. Being popular is the most important thing in the world. -- Homer Simpson