Community discussions

MikroTik App
 
User avatar
rilliam
newbie
Topic Author
Posts: 48
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: 997
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
 
User avatar
rilliam
newbie
Topic Author
Posts: 48
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" )