But 20000000 is also not equal to 20000001 - so what?
You are probably referring to the fact that it can happen that you assign a number to a floating point variable, and when you read it again, it has changed slightly, due to rounding. But this does only happen with “long” numbers (in terms of the number of digits when you write them down). And I can’t imagine any situation in a script in which this would be a problem. If you can, please tell me.
Here’s what I will do:
I will introduce a new type named “TTimeValue” which is used all over mAirList whenever a duration or a position is referenced. At the time being, this type is equal to int64:
type
TTimeValue = int64;
But you don’t need to know this. All you have to know is that it is “some sort” of number which you can add, subtract or multiply - apart from that, it’s a “black box” to you.
Moreover, I will introduce a number of functions to convert a TTimeValue to or from other well known types, for example “number of seconds given as a floating point number” or “TDateTime to be used with FormatDateTime”. As long as you rely on these functions, you don’t have to care about what’s really the internal representation, and your code will also become much easier to read.
Example for old code:
item.SetDuration(1300000000);
SystemLog('The duration is now ' + FormatDateTime('h:nn:ss', item.GetDuration/10000000/24/60/60));
New code:
item.SetDuration(SecondsToTimeValue(130));
SystemLog('The duration is now ' + FormatDateTime('h:nn:ss', TimeValueToDateTime(item.GetDuration));
Admittedly, it takes some time to convert your code (I did this yesterday night for mAirList), and the word “TimeValue” will appear in your dreams for a few nights, but it’s really easier to read later, and after all it’s future-proof. If I ever decide to finally change the internal representation to floating point or quantum numbers at some time in the future, I will just adjust the functions accordingly, and you’ll be on the safe side.
This must be “modern programming”: Throw away all well-known generic types and use custom types with pre-defined interfaces instead. We’re just one step away from Java 