Answer to Question #225309 in C++ for Ulando

Question #225309

Write a function to fine the ceiling of a double value and write a function to fine its floor. The ceiling of a number is the smallest integer greater than or equal to that number .the floor of a a number is the largest integer bless than or equal to that integer. For example the ceiling of 5.4 is 6 and the floor of 5.4 is 5.


1
Expert's answer
2021-08-13T16:13:18-0400
// the floor function
int fastFloor(double x) {
    int xi = (int)x;
    return x < xi ? xi - 1 : xi;
}
// the ceil function
int ceil(float num) {
    int inum = (int)num;
    if (num == (float)inum) {
        return inum;
    }
    return inum + 1;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS