In PHP, the round () function rounds a floating point number. In PHP, the round () function rounds a floating point number. in this article, the round () function rounds a floating point number. The round () function in PHP is used to round the
This article mainly introduces how the round () function in PHP rounds floating-point numbers. It summarizes various common usage of the round () function through detailed examples, it is a very practical technique. If you need it, you can refer to
This article mainly introduces how the round () function in PHP rounds floating-point numbers. it summarizes various common usage of the round () function through detailed examples, it is a very practical technique. if you need it, you can refer to
This example describes how the round () function in PHP rounds the floating-point numbers. Share to everyone for your reference. The specific methods are as follows:
Syntax: Round (X,PREC)
Parameters
Describe
X
SyntaxRound (x, prec) parameter descriptionX is optional. Specifies the number to be rounded.Prec is optional. Specifies the number of digits after the decimal point.
DescriptionReturns the result of rounding x to the specified precision prec
SyntaxRound (x, prec) parameter descriptionX is optional. Specifies the number to be rounded.Prec is optional. Specifies the number of digits after the decimal point.DescriptionReturns the result of rounding x to the specified precision prec (number
This article is the official HTML5 training course for h5edu institutions, mainly introduces: JavaScript intensive tutorial--javascript Math (Arithmetic) object The function of the Math object is: Perform common arithmetic tasks. Round () How to use
A ceil is a function that gets a value upward;
Floor is the function of rounding out the decimal place to get a value;
Round is a function that is used for rounding.
CeilDefinition and Usage:
The Ceil () function rounds up to the nearest
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
Code of the rounding function in php (floor function, ceil function, round and intval), ceilintval. The rounding function code (floor function, ceil function, round and intval) in php can be used together with ceilintvalfloor function and ceil
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.