Page 1 of 1

Java to round to nearest number.

Posted: Tue Nov 19, 2013 3:15 am
by Robert Larsen

My Service Call gives me a decimal number 1.2073544433094996, i then map it to a label. Is there any java I can add to change it to 1.2 or round to closest number?


Java to round to nearest number.

Posted: Tue Nov 19, 2013 3:45 am
by Illya Stepanov

Hi Robert,

try function:
pre
Math.round();
/pre

:: https://developer.mozilla.org/en-US/d...


Java to round to nearest number.

Posted: Tue Nov 19, 2013 3:56 am
by Robert Larsen

I tried that didn't work


Java to round to nearest number.

Posted: Tue Nov 19, 2013 4:23 am
by Illya Stepanov

Can you show how you are using it? (Code example).


Java to round to nearest number.

Posted: Tue Nov 19, 2013 5:12 am
by Robert Larsen

I am adding it to the mapped selection KDR under javascript. Image Imageinline.png?1384837970[/img] [/url]


Java to round to nearest number.

Posted: Tue Nov 19, 2013 9:12 am
by Maryna Brodina

Hello! You need to change JS in mapping instead prereturn Math.round(KillDR);/pre should be prereturn Math.round(value);/pre


Java to round to nearest number.

Posted: Thu Nov 21, 2013 4:00 am
by Robert Larsen

I hadn't tried that but this worked. Image