How to round an HMS number? [SOLVED]

01012018, 04:53 PM
(This post was last modified: 07212018 09:56 AM by JMB.)
Post: #1




How to round an HMS number? [SOLVED]
I'd like to know if it is posible to round the seconds in a number written in HMS format.
Here is an example. I'd like to round the number 15º16'16.99968" to 15º16'17". The function ROUND produces the following results: ROUND(15º16'16.99968", 0) > 15º00'00" ROUND(15º16'16.99968", 1) > 15º18'00" ROUND(15º16'16.99968", 2) > 15º16'12" ROUND(15º16'16.99968", 3) > 15º16'15.6" ROUND(15º16'16.99968", 4) > 15º16'17.04" It seams that ROUND first converts 15º16'16.99968" to its decimal equivalent 15.2713888, then rounds this value to the specified number of decimal places (for example for 3 decimal places > 15.271) and then converts this value back to the HMS format (15º16'15.6") So, does anyone know how to get 15º16'17"? 

01012018, 05:01 PM
Post: #2




RE: How to round an HMS number?
I don't know it this could help you, but I do as above in my program Effemeridi (Ephemeris) with angles:
Code:
HNY! Salvo ∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C  DM42 WP34s :: Prime Soft. Lib 

01012018, 05:58 PM
Post: #3




RE: How to round an HMS number?
(01012018 05:01 PM)salvomic Wrote: I don't know it this could help you, but I do as above in my program Effemeridi (Ephemeris) with angles: Thanks Salvo! Your function applied to my case →HMS(IP(HMS→(15º16'16.99968")*3600)/3600) returns 15º16'16"  it truncates as its name suggests. Inspired by your function I've found that →HMS(ROUND(HMS→(15º16'16.99968")*3600,0)/3600) returns 15º16'17"  the answer I was looking for. HNY! 

01012018, 05:59 PM
Post: #4




RE: How to round an HMS number?
(01012018 05:58 PM)JMB Wrote: Thanks Salvo! Your function applied to my case →HMS(IP(HMS→(15º16'16.99968")*3600)/3600) returns 15º16'16"  it truncates as its name suggests. Happy! :) ciao ∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C  DM42 WP34s :: Prime Soft. Lib 

01012018, 06:04 PM
Post: #5




RE: How to round an HMS number?
Hello,
Remember that unlike the 48 series of calculators, the HMS functions don't actually change the value underneath. Rather, they just set a flag to display/interpret the underlying value as a HMS input. This is why you can do things directly like SIN(<dms_number>), or +  * / and it will work directly without the need to do intermediate conversions like on the old system. It is much more convenient for every case EXCEPT the one you've found when you are trying to round a value like you are doing. TW Although I work for the HP calculator group, the views and opinions I post here are my own. 

01012018, 06:15 PM
Post: #6




RE: How to round an HMS number?
Thanks for your explanation, Tim.


07212018, 10:02 AM
Post: #7




RE: How to round an HMS number? [SOLVED]
With the new firmware version 2.0.0.13865 (2018 07 06), the behavior of ROUND (and also TRUNC) has been changed. Now using 0, 2 and 4 as the second argument, you can round to the nearest degree, minute or second.
The function ROUND produces now the following results: ROUND(15º16'16.99968", 0) > 15º00'00" ROUND(15º16'16.99968", 2) > 15º16'00" ROUND(15º16'16.99968", 4) > 15º16'17" 

07212018, 12:44 PM
(This post was last modified: 07212018 12:53 PM by Tim Wessman.)
Post: #8




RE: How to round an HMS number? [SOLVED]
Also handles sig figs since a negative value into ROUND/TRUNC does total sigits, not after the dot.
Yes, this thread was the spur to get that changed. TW Although I work for the HP calculator group, the views and opinions I post here are my own. 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)