Floor () and ceil () Functions

Source: Internet
Author: User
Tags floor function
In C language library functions, the floor function syntax is as follows:
# Include <math. h>
Double floor (double Arg );
Function: returns the maximum integer of no more than Arg. For example,
X = 6.04;
Y = floor (X );
The value of Y is 6.0.
The Ceil function corresponds to the floor function.

Interestingly, floor refers to the floor in English, while Ceil refers to the ceiling, which vividly describes the mathematical operations of the bottom and top rounding.


Note: If the number of values is not a numerical value, floor returns an error value # value! Or # name ?.
If the number is the opposite of the Significance symbol, the function floor returns the error value # num !.

Regardless of the positive and negative numbers of the number, the absolute value of the number of workers decreases. If the number is exactly a multiple of significance, No rounding is required.


Floor
Purpose: round the number of distinct to the end of the absolute value, so that it is equal to the multiple of the nearest significance.
Syntax: floor (number, significance)
Number: number is a value to be rounded, and significance is a multiple of the value.
Instance: Assuming a1 = 22.5, the formula "= floor (A1, 1)" returns 22; = floor (-2.5,-2) returns-2.
"Make it equal to a multiple of the nearest significance", for example:
Suppose a1 = 22.5, then the formula "= floor (A1, 1)" returns a multiple of and 22 closest to 1.
Suppose a1 = 22.5, then the formula "= floor (A1, 3)" returns a multiple of 21,21 closest to 3.
Suppose a1 = 25.8, then the formula "= floor (A1, 3)" is a multiple of 24, and 24 is the closest to 3.

Floor () and ceil () Functions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.