1

Is there a way to get exact value for division operation like 1/24 to get exact value as

1/24 = 0.04166666666    

1 Answer 1

2

Just use a decimal. You can use the divide method if you want to specify a number of digits.

system.assertEquals(0, 1/24);
system.assertEquals(0.0416666666666666666666666666666667, 1.0/24);
system.assertEquals(0.04167, 1.0.divide(24, 5));
1
  • Devide method seems better option. Jan 22, 2017 at 2:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .