We often use the PHP to take the whole function, mainly: Ceil,floor,round,intval.1, Ceil--into a method to take the wholeDescriptionfloat ceil (float value)Returns the next integer not less than value, in which value is entered if there is a
echo ceil (4.3); 5
echo ceil (9.999); 10
?>
Copy Code2, floor-to take the whole method of rounding the float floor (float $value) returns the next integer not less than value, rounding out the fractional part of value. The
[BestCoder Round #7] hdu 4985 Little Pony and Permutation (find loop section ),
Little Pony and Permutation
Problem Description
As a unicorn, the ability of using magic is the distinguishing feature among other kind of pony. being familiar with
The following is the PHP to take the whole function: the difference between the ceil,floor,round,intval is described in detail, the need for friends can come to the reference
We often use the PHP to take the whole function, mainly: Ceil,floor,round,
There is a bug in the round function in DelphiOnce the parameter is a number such as xxx.5If XXX is odd then it will Round upIf XXX is an even number then it will Round downFor example Round (17.5) =18But Round (12.5) =12The following function
Fix (number) and Int (numbers) are integral parts of the returned digits.
When number is positive, the two return the same value. For example: Fix (3.6) =3,int (3.6) = 3.
When number is negative, Fix removes the decimal part directly, and INT
Decimal Example:
PHP retains two decimal places and rounded up
Copy Code code as follows:
$n = 0.1265489;
Echo sprintf ("%.2f", $n); 0.13
You can see we used the sprintf function to format the $n%.2f is the target format,
PHP rounding, rounding, round function Use example, rounding round
Decimal Example:
PHP reserved two decimal places and rounded
Copy the Code code as follows:$n = 0.1265489;Echo sprintf ("%.2f", $n); 0.13
As you can see, we used the sprintf
php to take the integer function commonly used in four ways:
1. Direct rounding, discard decimals, keep integers: intval ();2. Rounded rounding: round ();3. Take the whole up, there are decimals plus 1:ceil ();4. Take the whole down: floor ().
One,
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.