|
Hi Tadashi I was trying to calculate the number of days on the basis of your(Zeller's) formula for August 26th,2000. I am getting some wrong results. I introduced the Zeller's formula as a column of computer tips in my home page for Japanese programmers. (Of course I know there is a function for calculation of the day of week in RPG iv.) Zeller's formula is known as below. There are two types. (I) (yy2+[yy2/4]+[yy1/4]+[26(mm+1)/10]-(2*yy1)+dd)mod 7 August 26th,2000 = (00 + [00/4] + [20/4] + [26(08+1)/10] - (2*20) + 26) mod 7 = (00 + 00 + 5 + [26(9)/10] - 40 + 26) mod 7 = (00 + 00 + 5 + (234/10) - 40 + 26) mod 7 = (00 + 00 + 5 + 23 - 40 + 26) mod 7 = (28 - 40 + 26) mod 7 = (54 - 40) mod 7 = (14) mod 7 = 0, is this the number of days. MOD(n,d) = n - d*INT(n/d) MOD(14,7) = 14 - 7*INT(14/7) = 14 - 7*INT(2) = 14 - 7*2 = 14 - 14 = 0 I do not know where and what I am missing, Pl. could you inform me. Thanks With Regards jaydeep ****************************************************************************8 Tadashi wrote I introduced the Zeller's formula as a column of computer tips in my home page for Japanese programmers. (Of course I know there is a function for calculation of the day of week in RPG iv.) Zeller's formula is known as below. There are two types. (I) (yy2+[yy2/4]+[yy1/4]+[26(mm+1)/10]-(2*yy1)+dd)mod 7 (II) (yyyy+[yyyy/4]-[yyyy/100]+[yyyy/400]+[(2.6*mm)+1.6]+dd) mod 7 (In Jan. and Feb. mm must be 13,14 in the last year). On March 1st,2000 one visitor asked 'The formula (I) returned a wrong data, is this a kind of Y2K problem?' ?Y2K? Zeller's formula is an official one, there must be no problem. I uploaded the EXCEL example and I showed it worked correctly for him. But, the other visitor asked me again 'Why does (-24) mod 7 come to 4? Please explain it.' I was confused. February 29th,2000 = 99+[99/4]+[19/4]+[26(14+1)/10]-(2*19)+29) mod 7 =(99+24+4+39-38+29)mod 7=(157) mod 7= 3 (=Tuesday) March 1st,2000 = 00+[00/4]+[20/4]+[26(3+1)/10]-(2*20)+1) mod 7 =(00+00+5+10-40+1)mod 7=(-24) mod 7= 4 (=Wednesday) Certainly I could get the day of week, so it seemed to work well. BUT, what was mod(-24,7)=4 ??? I felt it strange. The RPG code (DIV and MVR) returned -3.(i.e. -24-(-3 *7)=-24+21=-3). When I saw the help text of the MOD function in Excel, I was surprised. In the help of mod it says, MOD(n,d) = n - d*INT(n/d) <Examples> MOD(3,2) = 1 MOD(-3,2) = 1 <=== Hey! Why mod(-3,2)=1??? I think it must be -1. Oh, IIIII Seeeee. INT is in there! Can you see the 'INT' in MOD(n,d) above? And in the help of INT,it says INT(8.9)=8, INT(-8.9)= -9. So, now I can see why MOD(-3,2)=1, and MOD(-24,7)=4. MOD(-3,2)=-3-2*INT(-3/2)=-3-2*INT(-1.5)=-3-2*(-2)=-3+4=1. MOD(-24,7)=-24-7*INT(-24/7)=-24-7*INT(-3.4)=-24-7*(-4)=-24+28=4. It still seems a strange thing for me. Can you accept this result? That's why I posted my message. After I posted the message, I checked the book of an algorithm of C language, and I knew there were some functions, named FLOOR,or CEILING. floor(2.718)=2, floor(-2.718)=-3 ceiling(2.718)=3, ceiling(-2.718)=-2 If these functions are real one, INT behaves like FLOOR. BTW, what is floor or ceiling for ? I don't know C Language well. I bought the book of an algorithm of C as my pillow <g>. +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.