And the compass has thirty-two points. In "boxing the compass", one recites them in order clockwise from North to North by West. Any high school geometry student should be about to make a compass rose with the points using only compass and straight edge.
The other day, though, I discovered a property of thirty-two that hadn't occurred to me: it is the smallest positive integer that cannot be a day of a month. I was looking to validate some input to a script we use, and discovered that JavasSript will happily parse '2/31/2019' as a date, but not '2/32/2019'. The former becomes March 3, 2019, the latter is not a valid date. The script was to run under the Microsoft Scripting Host (cscript.exe), but I found that this works the same in a browser console. In what follows, the output in in italic:
for (var i = 29; i < 33; i++) {I'm not sure what to say about this. Obviously, JavaScript has "thirty days hath September" worked out, and it is not saving time or space by skipping leap year calculations:
var dateString = '2/' + i + '/2019';
var d = new Date(dateString);
console.log(dateString + ' -> ' + d);
}
2/29/2019 -> Fri Mar 01 2019 00:00:00 GMT-0500 (Eastern Standard Time)
2/30/2019 -> Sat Mar 02 2019 00:00:00 GMT-0500 (Eastern Standard Time)
2/31/2019 -> Sun Mar 03 2019 00:00:00 GMT-0500 (Eastern Standard Time)
2/32/2019 -> Invalid Date
for (var i = 29; i < 33; i++) {I know how to work around this without much effort. I'm just a little surprised that I should have to.
var dateString = '2/' + i + '/2020';
var d = new Date(dateString);
console.log(dateString + ' -> ' + d);
}
2/29/2020 -> Sat Feb 29 2020 00:00:00 GMT-0500 (Eastern Standard Time)
2/30/2020 -> Sun Mar 01 2020 00:00:00 GMT-0500 (Eastern Standard Time)
2/31/2020 -> Mon Mar 02 2020 00:00:00 GMT-0500 (Eastern Standard Time)
2/32/2020 -> Invalid Date
[Edit: changed "two million" to "two billion"]
“With thirty-two bits one can address about four million locations in memory” Million? Oops!
ReplyDeleteFixed, thanks!
Delete