3 ms·
Remember timecube guy? Seen on a 16-bit DSP... struct timecube { uint16_t millisecond_of_minute; uint16_t minute_of_month; uint16_
by brandmeyer 6y ago
Remember timecube guy? Seen on a 16-bit DSP...
struct timecube {
uint16_t millisecond_of_minute;
uint16_t minute_of_month;
uint16_t month_and_year;
};
- timerol 6y agoThat's clever. I might steal that at some point. Or combine into a millisecond_of_month on a 32 bit processor. For people that don't play with bits often: Unsigned 16-bit integers have their max as 65,536. Storing data often wastes most of the bits, since a field that goes from 0-1000 doesn't fit in an 8-bit integer, and C doesn't have native integers between 8 and 16 bits long. (You can mask out relevant fields, but that's annoying.) So there are 1000 * 60 = 60,000 milliseconds in a minute, which is an impressively good use of the space available. There are also a max of 60 * 24 * 31 = 44,640 minutes in a month, which is pretty good usage of the second value as well. The final 16 bits are probably 4 bits for month and 12 bits for the year, going up to 4096. Alternatively it could be using it as something like month_of_common_era to get it out to year 65536/12 = 5461.
- brandmeyer 6y agoIt also cooperates with leap seconds, by counting faithfully up to 61,000 on such a minute. IIRC, month and year was a 4-bit and 12-bit bitfield just as you describe.