C/C ++ obtains the entire function Ceil (), floor ()

Source: Internet
Author: User
Tags floor function

Use the floor function. Floor (x) returns the largest integer less than or equal to X.
For example, floor (10.5) = 10 floor (-10.5) =-11

Use the ceil function. Ceil (x) returns the smallest integer greater than X.
For example, Ceil (10.5) = 11 Ceil (-10.5) =-10


Floor () is rounded to negative infinity, floor (-10.5) =-11;
Ceil () is rounded to positive infinity, Ceil (-10.5) =-10

 

Fix

Integer in the zero direction, for example, fix (-1.3) =-1; fix (1.3) = 1;

Floor

Integer toward negative infinity, such as floor (-1.3) =-2; floor (1.3) = 1;

Ceil

Returns an integer in the positive infinity direction, for example, Ceil (-1.3) =-1; Ceil (1.3) = 2;

Round

Round to the nearest integer, such as round (-1.3) =-1; round (-1.52) =-2; round (1.3) = 1; round (1.52) = 2

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.