Problem Solving: Float and Integer Truncating

Learn to write a program that takes floating point value and print ceiling and floor integers using the concepts we have learned so far.

This lesson will teach us to write a program that takes a floating number and prints floor and ceiling integers.

So let’s get to it!

Ceiling integer

The ceiling integer function gives the smallest nearest integer that is greater than or equal to the specified real value of a floating value. The ceil integer function is denoted by:

ceil(x)=xceil(x)= \lceil x \rceil

For example, if x=5.5x = 5.5, the Ceiling integer function will convert it to 66. Similarly, if x=5.5x = -5.5, the Ceiling integer function will give us 5-5.

You may consider the ceil function as moving in the forward (right) direction of the x-axis line and reaching the nearest integer.

Get hands-on with 1200+ tech skills courses.