4 ms·
Or you could go the Amazon AWS for C route and give make a define with the name of MilicsecondsPerSecond, and a separate define that makes that at 1000. If you
by SlowRobotAhead 6y ago
Or you could go the Amazon AWS for C route and give make a define with the name of MilicsecondsPerSecond, and a separate define that makes that at 1000.
If you want to go full spectrum the other way.
- necovek 6y agoLet's call that a "natural constant": while not strictly coming from nature, it is coming from a very familiar and widespread convention. There are other numbers like that (12, 24, 60 come to mind; 365 has a similar familiarity but has lots of gotchas; I am sure many developers will immediately understand 1024 too). But that's also mostly due to how they will be used. Contrast and compare: — a = b * 24 — a = b * HOURS_PER_DAY — uptime_in_hours = 24 * uptime_in_days I like the last one best, but if given a choice between the first or the second, I'd prefer to be reading the second. FWIW, I am not advocating for use of units in variable names at all times — but if you are converting between units, put them in either your variable or constant names. Basically, I interpret the rule of no-literals as a reminder to think of the readibility of any statement involving them.
- klyrs 6y ago> Basically, I interpret the rule of no-literals as a reminder to think of the readibility of any statement involving them. Now that is an excellent rule, if slightly too specific.