Hi George
thanks for sticking to the subject.
Well, FLOOR doesn't actually round up. It rounds down. It eliminates all decimal places of any rational number and is used to implement DIV, the "complementary" to MOD in SB.
By using DIV it is possible to actually count something, whereas MOD would just deliver ...you know.
For my understanding the use of the DIV-function of two natural numbers is a prerequisite for the implementation of the MOD-function.
Anyway, I would appreciate it if you would give me an alternative to using FLOOR to implement the DIV function and be it for the excercise. (although I don't see any ambiguities when using the FLOOR function...Mr. Kibernetik?)
counting the days since 1600/1/1
- GeorgeMcGinn
- Posts: 435
- Joined: Sat Sep 10, 2016 6:37 am
- My devices: IPad Pro 10.5in
IMac
Linux i386
Windows 7 & 10 - Location: Venice, FL
- Flag:
- Contact:
Re: counting the days since 1600/1/1
Hi Joel,
On October 7th post, I provided a working program that displays the year you input. It will use MOD and then based on IF statements, it will teill you whether it is a Century Leap Year, Regular Leap Year, Non-Century Leap Year, or Not A Leap Year.
Here is the code again:
You should be able to adapt that code easilly into your project.
George.
On October 7th post, I provided a working program that displays the year you input. It will use MOD and then based on IF statements, it will teill you whether it is a Century Leap Year, Regular Leap Year, Non-Century Leap Year, or Not A Leap Year.
Here is the code again:
Code: Select all
'*** Input Year in box at top of the screen
INPUT Y
'*** Perform MOD functions on year divided by 4, 100, and 400
L=Y%4
C100=Y%100
C400=Y%400
'*** Logic test to see if year is a Century, Normal, or not a Leap Year
IF L=0 AND (C100=0 AND C400=0) THEN
PRINT "Year "&Y&" is a Century Leap Year"
GOTO endPROG
ELSE
PRINT "Year "&Y&" is not a Century Leap Year"
IF L=0 AND (C100<>0 AND C400<>0) THEN
PRINT "Year "&Y&" is a normal Leap Year"
ELSE
PRINT "Year "&Y&" is not a Leap Year"
ENDIF
ENDIF
endPROG:
STOP
You should be able to adapt that code easilly into your project.
George.
Joel wrote: ↑Mon Oct 09, 2017 10:13 pmHi George
thanks for sticking to the subject.
Well, FLOOR doesn't actually round up. It rounds down. It eliminates all decimal places of any rational number and is used to implement DIV, the "complementary" to MOD in SB.
By using DIV it is possible to actually count something, whereas MOD would just deliver ...you know.
For my understanding the use of the DIV-function of two natural numbers is a prerequisite for the implementation of the MOD-function.
Anyway, I would appreciate it if you would give me an alternative to using FLOOR to implement the DIV function and be it for the excercise. (although I don't see any ambiguities when using the FLOOR function...Mr. Kibernetik?)
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)
-
- Posts: 814
- Joined: Tue Apr 09, 2013 12:23 pm
- My devices: iPhone,iPad
Windows - Location: Groningen, Netherlands
- Flag:
Re: counting the days since 1600/1/1
Here is a function that return 1 if yr is a leap year and 0 if it is not.
def leap(yr) = 1-min(1,yr%4)+min(1,yr%100)-min(1,yr%400)
def leap(yr) = 1-min(1,yr%4)+min(1,yr%100)-min(1,yr%400)
- Dav
- Posts: 279
- Joined: Tue Dec 30, 2014 5:12 pm
- My devices: iPad Mini, iPod Touch.
- Location: North Carolina, USA
- Contact:
Re: counting the days since 1600/1/1
wow! This functions would come in handy in my gigbook program, so it can handle any year. I had to hard code leap year data.
- Dav
- Dav
- GeorgeMcGinn
- Posts: 435
- Joined: Sat Sep 10, 2016 6:37 am
- My devices: IPad Pro 10.5in
IMac
Linux i386
Windows 7 & 10 - Location: Venice, FL
- Flag:
- Contact:
Re: counting the days since 1600/1/1
That formula works too, and is what I use in my cosmology programs, but I wanted to use another way to help explain it better.
Joel, either way works, but I always will use a formula as it is cleaner and takes less number of lines. Only if you need to do extra processing between parts of the formula, then use the logic way with IF statements.
Dav, with your coding skills I was wondering why you hardcoded Leap-Years. Sometimes we go back to the way we first learned something as it is familiar and comfortable.
You're still the best!
Joel, either way works, but I always will use a formula as it is cleaner and takes less number of lines. Only if you need to do extra processing between parts of the formula, then use the logic way with IF statements.
Dav, with your coding skills I was wondering why you hardcoded Leap-Years. Sometimes we go back to the way we first learned something as it is familiar and comfortable.
You're still the best!
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)