Computa' shit

Ishmael

Literotica Guru
Joined
Nov 24, 2001
Posts
84,005
OK you geeks. Strut your stuff. I'm going to pose some common problems. Your job? Solve them. In computerese no less.

The first correct answer posted WINS and all expense paid ...... well, you really don't win shit. Just some bragging rights.

So, here's the first prob.

What is the precise formula for the calculation of leap years?

Tick Tock folks.

Ishmael
 
ok...its not in geek-speak...but i did use the computa' to find it...



http://www.polysyllabic.com/Julian.html

"For those interested, the rough formula is Y = 1/(MCY - 365.2422), where MCY is the mean civil year length in days. To even more precise, and take into account the gradually decreasing length of the tropical year, we need to consider the calendar over a specific span of years, and replace the approximate value for the tropical year with: 365.24231533 - (y1 + y2) * 3.06713e-8, where y1 is the start year and y2 the stop year in astronomical years (= Common Era, but for BCE dates, use negative number and add one, e.g., 1 BC = 0, 2 BC = -1, etc.). This kind of precision will be irrelevant unless we have precise astronomical observations in the relevant years against which to compare it. Otherwise, either formula should really be rounded to the nearest 10th."

i'll take 'erotic astronomy' for $500 Ish...

-wink-
 
Each year is actually 365.25 days, so the forth year that add an additional day.
 
ba-dow!



http://www.asnap.com/ppb/feb99.html

Because there is a surplus of 674.5553 seconds per year, one leap day would be subtracted every 128 years. This reduces the error to a deficit of only 0.4447 seconds, requiring the insertion of only one "correction day" per 70,962,151 days, or about 23 days short of 194,288 years. If you're quick with your math, you know that 128 and 194,288 are both divisible by 4. In a nutshell, leap years would be those divisible by 4, except for 2176 and subsequent years divisible by 128. All years divisible by 194,288 would contain 367 days. Problem solved! The next two years that are divisible by 128 will be 2048 and 2176. If we make 2176 the first non-leap year, we would have the time of several human generations for the rule to become established in textbooks, and more than enough time for the calendar manufacturers to prepare their product lines! And this formula would run like clockwork until the year 3,033,077!



well?
-batting lashes-
 
alright Ish... i wanna know what google you are using... cuz mine obvously isnt working right...

-wry grin-
 
honeylick said:
ba-dow!



http://www.asnap.com/ppb/feb99.html

Because there is a surplus of 674.5553 seconds per year, one leap day would be subtracted every 128 years. This reduces the error to a deficit of only 0.4447 seconds, requiring the insertion of only one "correction day" per 70,962,151 days, or about 23 days short of 194,288 years. If you're quick with your math, you know that 128 and 194,288 are both divisible by 4. In a nutshell, leap years would be those divisible by 4, except for 2176 and subsequent years divisible by 128. All years divisible by 194,288 would contain 367 days. Problem solved! The next two years that are divisible by 128 will be 2048 and 2176. If we make 2176 the first non-leap year, we would have the time of several human generations for the rule to become established in textbooks, and more than enough time for the calendar manufacturers to prepare their product lines! And this formula would run like clockwork until the year 3,033,077!



well?
-batting lashes-

Reduce that to either psuedo code, or any other language that you like and I'll consider. :D

Ishmael
 
drained maybe... geek-speak will do that...

satiated, no...

thats a whole other type of talkin'
-wink-
 
If we are talking about the calendar, leap years are every year divisible by 4, except for those that are divisible by 100, unless they are also divisible by 400.

Someone else can write the code.
 
Harbinger said:
If we are talking about the calendar, leap years are every year divisible by 4, except for those that are divisible by 100, unless they are also divisible by 400.

Someone else can write the code.

WE HAVE A WINNER!!!!!!!!!

Well stated.

The psuedo code for the above would be:

if (year mod 4 != 0)
{use 28 for days in February}

else if (year mod 400 == 0)
{use 29 for days in February}

else if (year mod 100 == 0 {use 28 for days in February}

else

{use 29 for days in February}

Congrats.

Next problem coming up.

Ishmael
 
float UserInputYear
float Calc
float Result

Calc = UserInputYear - 1988
If (Calc < 0)
Calc = Calc * -1

If ((Result = Calc Modulus 4) == 1)
This is a leap year
else
This is not a leap year


Or something to this effect.

Edited to include
Damn too slow
 
Cool. After a year and a half of posting my little ass off I finally won something.
 
Oh shit. I just realized I won some kind of geek award. And said it was cool. I'm so embarrassed. You tricked me.:eek:
 
Back
Top