Page 1 of 1

Round decimal number

Posted: Tue Aug 20, 2019 11:59 am
by rilliam
Is it possible to round a number like 2555.550055 to 2555.55 ?

Re: Round decimal number

Posted: Tue Aug 20, 2019 12:56 pm
by cdiedrich
Haven't found a real round function, but you may get lucky with this decimal calculation script and specify the decimal point place.
-Chris

Re: Round decimal number  [SOLVED]

Posted: Tue Aug 20, 2019 1:04 pm
by rilliam
I figured out a way to do it using a nested :find inside a :pick (its not actually rounding it though)
    :local rawLat "3820.0410"
    :local rawLon "-12242.2638"

    :local latDecimalPosition [:pick $rawLat -1 ([:find $rawLat "." -2]+3) ]
    :local lonDecimalPosition [:pick $rawLon -1 ([:find $rawLon "." -2]+3) ]

:log info ("$latDecimalPosition"."N/$lonDecimalPosition"."W" )