3 ms·
I think it was Microsoft BASIC that stored time as a floating point number. What a bad idea. Converting from it to an integer and then converting back to float
by WalterBright 3y ago
I think it was Microsoft BASIC that stored time as a floating point number. What a bad idea. Converting from it to an integer and then converting back to float would cause the time to "drift" due to rounding errors.
It's the same reason why you should never use floating point numbers for account balances.
- adzm 3y agoThe VARIANT date type uses a floating point number; the whole number portion is the day (days past 1900 January 1) and the fractional part is the time. Not sure about classic BASIC; I don't really recall there being a specific time type, though I know later things like Visual Basic and etc would just use the VARIANT date type above with a 0 day component. I like Windows' FILETIME which stores time as 100-nanosecond intervals since the beginning of the year 1601. C#'s DateTime is similar but uses an epoch of 0001 January 1. I know JavaScript and others simply use the usual unix Epoch but with milliseconds rather than seconds, so time() * 1000.
- eyelidlessness 3y agoI don’t know why but this just reminded me of how I discovered that SQL Server stores times in increments of .000, .003, .007 seconds. I wasn’t even using SQL Server (directly), just trying to understand what looked like data corruption as an API consumer. That discovery was a precursor to probably the second worst six-month stretch of my entire life (this one was caused by mishandling of time zones, and not the fault of SQL Server, but the previous experience helped me identify the issue).