## counting the days since 1600/1/1

Joel
Posts: 58
Joined: Fri Jan 15, 2016 1:36 pm
Flag:

### Re: counting the days since 1600/1/1

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?)

GeorgeMcGinn
Posts: 495
Joined: Sat Sep 10, 2016 6:37 am
IMac
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:

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 pm
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?)
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)
https://www.georgemcginn.com
https://www.cosmologyandspace.blog

Henko
Posts: 882
Joined: Tue Apr 09, 2013 12:23 pm
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)

Dav
Posts: 302
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

GeorgeMcGinn
Posts: 495
Joined: Sat Sep 10, 2016 6:37 am
IMac
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!
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)
https://www.georgemcginn.com
https://www.cosmologyandspace.blog