Suggestion: Sexagesimal notation in Spin/PASM
Phil Pilgrim (PhiPi)
Posts: 23,514
It would be handy to allow sexagesimal (base 60, e.g. deg:min:sec, hr:min:sec, etc.) notation in Spin programs. Simply put, a number like
2:30:30 (2 hrs, 30 min., 30 sec)
would evaluate to 9030 (the number of seconds). IOW it evaluates to the units of whatever the last block represents. You could have as few or many blocks as you want, viz:
2:30 == 150 (minutes, or whatever units the 30 represents)
It would work with floating point, too:
-135:48:43.78 (i.e. 135°48'43.78"W) == -((135 * 60 + 48) * 60 + 43.78) == -488_923.78
It would come in handy when dealing with time, e.g.
next_clock_minute := (next_clock_minute + 2:30) // 24:00
IOW, you don't have to do the math in your head or with a calculator.
Use of the colon in this way would not conflict with its other use in the obj section, so its meaning is unambiguous and could easily be implemented in the compiler.
-Phil
2:30:30 (2 hrs, 30 min., 30 sec)
would evaluate to 9030 (the number of seconds). IOW it evaluates to the units of whatever the last block represents. You could have as few or many blocks as you want, viz:
2:30 == 150 (minutes, or whatever units the 30 represents)
It would work with floating point, too:
-135:48:43.78 (i.e. 135°48'43.78"W) == -((135 * 60 + 48) * 60 + 43.78) == -488_923.78
It would come in handy when dealing with time, e.g.
next_clock_minute := (next_clock_minute + 2:30) // 24:00
IOW, you don't have to do the math in your head or with a calculator.
Use of the colon in this way would not conflict with its other use in the obj section, so its meaning is unambiguous and could easily be implemented in the compiler.
-Phil
Comments
MyTime : = T#11d_12h_15m_32s_299ms;
Converts to a 32 bit number in milliseconds.
MyDate : = TOD#2:30:30;
-Phil