Path: utzoo!utgpu!water!watmath!clyde!burl!codas!killer!wnp From: wnp@killer.UUCP (Wolf Paul) Newsgroups: comp.sys.ibm.pc Subject: Re: day of week Message-ID: <3170@killer.UUCP> Date: 1 Feb 88 04:19:51 GMT References: <141900013@occrsh.ATT.COM> Reply-To: wnp@killer.UUCP (Wolf Paul) Organization: The Unix(R) Connection BBS, Dallas, Tx Lines: 41 In article <141900013@occrsh.ATT.COM> fubar@squid.UUCP writes: ] ]From squid!fubar Thu Jan 28 04:22 CDT 1988 remote from occrsh ]Subject: day of week ] ]*** ]*** PLEASE send replies to ihnp4!occrsh!squid!david ]*** ] ]>(Square brackets denote the greatest integer function.) ]So: ]Thursday, Jan 28, 1988, should yield 4: ] N = 28 (number of day within month) ] M = 11 (Jan = 11) ] C = 19 (Hundreds w/in year) ] Y = 88 (rest of year??) ] L = 1 (1988 is leap year) ] = (N + [2.6M - 0.2] + Y + [Y/4] + [C/4] - 2C - (1+L)[M/11]) mod 7 ] = (28 + [(2.6*11)-0.2] + 88 + [88/4] + [19/4] - (2*19) - (1+1)*[11/11]) mod 7 ] = (28 + [28.4] + 88 + [22] + [4.75] - 38 - 2) mod 7 ] = (28 + 29 + 88 + 22 + 5 - 38 - 2) mod 7 ] = 132 mod 7 ] = 6 ?? ] ]What is the correct formula for this? Seems to me the formula is ok, but your calculations are not. The greatest integer in 28.4 is 28, not 29; in 4.75 it is 4, not 5. Thus, the last few lines of your calculation above should read: = (28 + 28 + 88 + 22 + 4 - 38 - 2) mod 7 = 130 mod 7 = 4 "greatest integer" is not the same as rounding up to the next highest integer :-) ... Wolf Paul ihnp4!killer!wnp