Let you define a macro to explain how many seconds a year has:
The answer is as follows:
#define SECONDS_PER_YEAR 60*60*24*365(UL)
"The advantage is that you can write a formula without having to perform computation by the compiler, saving your mind. The point is that you have also written the source of the results, which are clear and easy to read. Also, the UL shows that you are strict with the data size ,"
"Switch ~ What do you say? Who don't know ?" -- Seeing this, many people must have sneered at this post. I believe this is an answer that many C language players are familiar ?!
SECONDS_PER_YEAR is the second year-seconds/year!
So how many seconds does a year have?Can I change the query method? How do you solve this problem? As we all know, every four years has a leap year, which is not all yet. In every hundred years, you must divide the year by four hundred.
The time for the earth to turn around the sun for a week (that is, 360 degrees) should be 06:09:10 on the 15th day, that is, a star year.
At a certain point of the Earth, the interval between two direct connections is365 05:48:46(More accurate: 365 days, 5 hours, 48 minutes, 45.975456 secondsIs a return year.
A return year is converted into a decimal number, which is about 365.2422 days. In 400, there were more than 96.88 days. In the four-year leap year calculation, there were three fewer leap years in 400, that is, a total of 97 leap years, A leap year is a regression year. The leap year rule is also mentioned in the front side. If it is supplemented by four years, the point must be subtracted. If it is supplemented by the year of the constant star, it is not enough for a four-year leap year, which would keep you three less leap years in four hundred years.
I believe that you have the following answers:
# Define 365*24*60*60 + 5*60*60 + 48*60 + 46 (UL) // Is it clear? I said, you might as well use a calculator ~~ Be sure to add text comments ~!!!
But there was another accident. Did he ask if it was the year of stars? The year of the constant star is defined as follows:
# Define 365*24*60*60 + 6*60*60 + 9*60 + 10 (UL) // you must add a text note ~~ Tell him this is the year of the stars
We can also see that nothing is so accurate, if you press365 days, 5 hours, 48 minutes, 45.975456 secondsThe floating point number should be used.
31556925.9754456 (this is not an absolute precision ~~~)
If you press this number, the 32-bit floating point is enough.
How do you do? Lie down and get shot. You won't have such a simple C language. Go back to the wall.
But there is another way, you tell him that you use calendar year calculation:
#define SECONDS_PER_YEAR 60*60*24*365(UL)
Detour
Deep merit and name, called my research
Take your chastity and logic with you. You are welcome to raise the bar. Please indicate the source for forwarding.