> Note that modern compilers like gcc or clang will produce something like is_leap_year2 from is_leap_year1, so there is not much point in doing this in C source, but it might be useful in other programming languages.
The optimizations that compilers can achieve kind of amaze me.
Indeed, the latest version of cal from util-linux keeps it simple in the C source:
But this is wrong and can only represent dates after the specific year when they switched from the Julian to Gregorian calendar!
For more on this, I recommend reading and implementing a function that calculates the day of the week [1]. Then you can join me in the special insanity hell of people that were trying to deal with human calendars.
And then you should implement a test case for the dates between Thursday 4 October 1582 and Friday 15 October 1582 :)
The problem is, which "specific" year? The English were using "old-style" dates long after 1582. Better not to try to solve this intractable problem in software, but instead annotate every old date you receive with its correct calendar, which may even be a proleptic Gregorian calendar in some fields of study.
(How do you determine the correct calendar? Through careful inspection of context! Alas, people writing the dates rarely indicated this, and later readers tend to get the calendars hopelessly mangled up. Not to mention the changes in the start of the year. At least the day of week can act as an indicator, when available.)
Where reform_year is the year the Gregorian calendar was adopted in the specific context specified (defaults to 1752 which is the year it was adopted by GB and therefore also the US).
I like how the linux one is also easier to understand because it doesn't perform three sequential checks which actually invert the last two conditions plus a default return. That's the kind of stuff that can make you crazy if you ever have to debug it.
I wondered 3 minutes "this is not right" til I realized that
if ((y % 25) != 0) return true;
was actually checking for different from 0 (which in hindsight makes also sense because the century years by default are not leap unless they divide by 400)
I remember not liking the characters and wondering why should I read this, but now I have come to appreciate the value of understanding the view points of other people in spite of how I might feel about their actions and words or be distanced from their existence by virtue in this case of the wealth and privilege available to them.
> So, there you have it: "all you have to do" is deploy a few hectares of radiators in space, combined with heat pumps that can dissipate gigawatts of thermal load…
Starcloud’s whitepaper suggests a 4 km × 4 km radiator. For comparison, the James Web Space Telescope has a sunshield measuring 21 m × 14 m and the International Space Station measures 109 m × 73 m.
I was wondering if these server racks in space would need to be specifically designed for enough radiative cooling. Apparently the answer is “yes”: the radiators would be expansive and placed on the reverse side of the solar panels.
Starcloud is developing a lightweight deployable radiator design with a very
large area - by far the largest radiators deployed in space - radiating primarily towards deep space, which has an average temperature of about 2.7 Kelvin or -270°C. The radiators can be positioned in-line with the solar
arrays as shown in Figure 3, with one side exposed to sunlight.
…
Figure 3. A data center in Sun Synchronous Orbit, showing a 4km x 4km deployed solar array and radiators.
It took me several seconds to recognize this acronym for a test I took decades ago but haven’t thought about since.
reply