I need to convert a negative number to a positive number. My attempt is as below.
Math.abs(-4.0);
It will return 4 as the answer. But I need 4.0 as the answer. Here I don't know the decimal places to be set. For different numbers, there's a different decimal point value. Actually, that will totally depend on the web socket output. According to the input value, the server-side defined different floating points which there's not any pattern according to our requirement.
So in js, is there any better way to handle this without getting decimal places separately?