1

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

1/24 = 0.04166666666    
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));
  • Devide method seems better option. – Pranay Jaiswal Jan 22 '17 at 2:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.