Math ceil | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Math ceil

Why Math.ceil(3/2) gives 1 and not 2?

7th Mar 2022, 6:14 PM
Marco Ginato
Marco Ginato - avatar
1 Answer
+ 5
3/2 results 1 so ceil(1) is 1. (int/int=int) If you trying to get 1.5 as result then use a double type data like Math.ceil(3.0/2) ; give 2, because 3.0/2 = 1.5
7th Mar 2022, 6:16 PM
Jayakrishna 🇮🇳