+ 5

What is the difference between round() and ceil()????

It will be very glad to me, if you give me the description of this kind of numerical operation or a link. Thank you.

31st Jul 2020, 2:46 AM
Md Arif Shahriyar Sohan
Md Arif Shahriyar Sohan - avatar
3 ответов
+ 3
Ceil will round the number to the highest integer, while Round will round the number to the nearest integer. Here is an example: import math print(math.ceil(0.1) == 1) # True print(round(0.1) == 0) # True print(round(0.51) == 1) # True
31st Jul 2020, 3:03 AM
Javier Ballesteros
Javier Ballesteros - avatar
+ 1
ceil() takes a decimal number, and if it is -not- an integer, it will truncate (aka cut off the end) the values past the decimal point, and add 1 to it an easier way of explaining it is by rounding up. round() works in a similar way, it takes a decimal value (0 to 1, non-inclusive) and if it is not already an integer, it will round down if the trailing decimal digits are < than 0.5, and round up if it is >= .5 you can experiment in desmos.com, but you should examine y and x values and keep in mind x = input, y = output ceil() and round() are built in functions in desmos, and you can specify equations for the website to display, i found it incredibly useful when programming, and i hope you do too
31st Jul 2020, 3:10 AM
E E
E E - avatar
0
Ceil() takes the number and rounds it to the nearest integer above its current value, whereas floor() rounds it to the nearest integer below its current value.👍🏻👍🏻
1st Aug 2020, 3:36 AM
Sadhu Maheswari