Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Java to round to nearest number.

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?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Java to round to nearest number.

Hi Robert,

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

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

Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Java to round to nearest number.

I tried that didn't work

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Java to round to nearest number.

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

Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Java to round to nearest number.

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Java to round to nearest number.

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

Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Java to round to nearest number.

I hadn't tried that but this worked. Image

Return to “Issues”