-4

I have to divide 495/116533, i tried using long and double; but it's returning 0.0;

Once if i able to capture that value (0.004247) then i can use round of methods; Please help me how to capture complete value( which data type it supports?)

Rakesh B
  • 47
  • 1
  • 1
  • 9

1 Answers1

1

For 4 decimals do:

(double) (Math.round(value * 10000) / 10000)

The number of zeroes is how many decimals you want to round to.

Essentially what you need to do is to first multiply your number by a factor of X so that only the section you want to show is in front of the decimal place, then you can round it using the Math.round function. After that, just divide it back by X in order to put the decimal back in the right spot.

Aify
  • 3,543
  • 3
  • 24
  • 43