Community discussions

 
User avatar
rilliam
newbie
Topic Author
Posts: 30
Joined: Thu Mar 12, 2009 7:34 pm

Round decimal number

Tue Aug 20, 2019 11:59 am

Is it possible to round a number like 2555.550055 to 2555.55 ?
 
User avatar
cdiedrich
Forum Veteran
Forum Veteran
Posts: 899
Joined: Thu Feb 13, 2014 2:03 pm
Location: Basel, Switzerland // Bremen, Germany
Contact:

Re: Round decimal number

Tue Aug 20, 2019 12:56 pm

Haven't found a real round function, but you may get lucky with this decimal calculation script and specify the decimal point place.
-Chris
Christopher Diedrich
MTCNA, MTCUME, MTCWE
Basel, Switzerland
Bremen, Germany

There are 10 types of people: Those who understand binary and those who don't.
There are two types of people: Those who can extrapolate from incomplete data
 
User avatar
rilliam
newbie
Topic Author
Posts: 30
Joined: Thu Mar 12, 2009 7:34 pm

Re: Round decimal number  [SOLVED]

Tue Aug 20, 2019 1:04 pm

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" )

Who is online

Users browsing this forum: No registered users and 7 guests