Ceil Function
The Ceil function is used to evaluate the smallest integer not less than the given real number.Ceil (2) = Ceil (1.2) = CEI (1.5) = 2.00
To use this function, you must include the header file . The return
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 (-
2.1 2.6-2.1-2.6Floor: Maximum integer not greater than the argument 2 2-3-3Ceil: Maximum integer not less than argument 3 3-2-2Round: Rounding to nearest integer 2 3-2-3round (num,num_dight) accurate num to num_dight number of digitsFloor (), ceil ()
Link: Play with floor and ceil
UV-10673Play with floor and ceil
Time limit:3000 Ms
Memory limit:Unknown
64bit Io format:% LLD & % LlU
Submitstatus
Description
ProblemPlay with floor and ceilInput:Standard InputOutput:
[C language library function source code]
[This program is compiled in Dev C ++ 4.9.9.2]
Double my_ceil (Double X)
{
Register double ret;
Unsigned short int temp1, temp2;
_ ASM _ ("fnstcw % 0": "= m" (temp1 ));
Temp2 = (temp1 & 0xf3ff) | 0x080
Floor function floor (x), sometimes it is also written as floor (x), its function is "rounding", or "rounded down", that is, take the largest integer not greater than X (and "Rounding", the next rounding is directly remove the decimal part), such as:
Floor returns the largest integer not greater thanRound is the calculation of 4 5 in, when it is greater than its integerRound method, which means "rounding", the algorithm is Math.floor (x+0.5), the original number is added 0.5 and then rounded
Take a direct look at the show:
# Psy Shell v0.3.3 (PHP 5.5.30-cli) by Justin hileman>>> ceil ( -0.5) = -0.0>>> max ( -0.0, 0) = 0.0 >>> Max (Ceil ( -0.5), 0) = 0.0
In the above demo, the Ceil function returns a 0.0 when -0.0,max passes the
A small BUG in maxmin function (PHP) is shown in the following figure:
# Psy Shell v0.3.3 (PHP 5.5.30 — cli) by Justin Hileman>>> ceil(-0.5)=> -0.0>>> max(-0.0, 0)=> 0.0>>> max(ceil(-0.5), 0)=> -0.0
In the above demonstration, the ceil function
ABS
Prototype: extern int ABS (int x );
Usage: # include
Function: calculates the absolute value of integer x.
Description: calculation | x |. If X is not negative, X is returned. Otherwise,-X is returned.
Example:
// Abs. c
# Include # Include
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.