4 ms·
Negative durations are clearly impossible. Just take ABS of the duration to be safe....
by greggyb 7y ago
Negative durations are clearly impossible. Just take ABS of the duration to be safe....
- NullPrefix 7y agoOn the other hand, if there's no such check you might be able to get 100 year call time credit.
- greggyb 7y agoGotta love those rollover minutes.
- xxs 7y agoUnless, of course, you hit MIN_VALUE [abs(min_value) == min_value] One of signs of inexperience is using abs(int) in hash functions...
- greggyb 7y agoGosh, I am spoiled by languages with decent numeric towers. You mention it as a sign of inexperience, and I can't really disagree with you. Just adding a nuance that inexperience can be due to loss of experience as easily as lack of experience.
- xxs 7y agoIf you do hashtable/hashmap on a language that has no fixed integer type... well yeah. But normally you'd like the data structures to map really well to the hardware. Pretty much all modern CPUs are two's complement ones - hence min integer is impossible to convert to anything else (having just the highest/sign bit, and rest zero)