HP Forums

Full Version: Extract from Time
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

Is there a command to convert "Time" to a decimal value?

I need this to calculate the fraction of a day according to "Time"


Cheers

Jan
Maybe
Code:
HMS→(Time)
?
hello,

HMS-> will not do what you think/want.
HMS-> will convert a real number which is represent HMS values (with the decimal part in the [0 to 0,6[ range into a number with a decimal part in the [0..1[ range.

however the Time function does NOT return a number encoded in HMS, but a number DISPLAYED in HMS format (which is different).
To remove the HMS display flag, add that number to 0.
0+Time will return what you want (the 'format' of the first of 2 operands does take precedence over the format of the second one)...

HMS-> functions are there because old habits die hard, but HMS encoding is "bad" (as in crossing the streams"), as base 60 and base 10 conversions always lead to precision lost.
This is why Prime is privileging DISPLAY in HMS with internal encoding staying in decimal.

Cyrille
Hello Cyrille,

did you try this?
(10-12-2015 06:52 AM)cyrille de brébisson Wrote: [ -> ]hello,
HMS-> will not do what you think/want.
...
For me HMS-> does the same as "0+".
(10-12-2015 06:52 AM)cyrille de brébisson Wrote: [ -> ]HMS-> will not do what you think/want.
HMS-> will convert a real number which is represent HMS values (with the decimal part in the [0 to 0,6[ range into a number with a decimal part in the [0..1[ range.

I strongly suspect that this is not correct. If it were correct, then HMS→(1.3) would return 1.5 (as on other HP calculators), but it doesn't. HMS→(1.3) returns 1.3, and in general the HMS→ function simply returns any real argument unchanged. All it does is turn off the HMS display flag for HMS-format inputs. That makes it perfect for what the OP wanted, and less cryptic than 0+Time or approx(Time) or evalf(Time) or anything like that.
Hello,

Yep, I stand corrected, HMS-> and ->HMS only changes the display flag but does not change the real's value.

Thanks Joe for shining, as always, light on such issues!

Cyrille
Reference URL's