In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Php rounding function code related to the introduction, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
The combination of floor function and ceil function can make the data processed by php more real and reliable.
First, let's look at the floor function:
Syntax:
Float floor (float value)
Description:
Returns the next integer not greater than value, rounding off the fractional portion of value. The type returned by floor () is still float, because the range of float values is usually larger than integer.
Example 1 of floor ()
Example 2 of floor ()
Output:
0
0
five
five
-6
-6
2. Ceil function:
Syntax:
Float ceil (float value)
Description:
Returns the next integer not less than value, and value takes one place if it has a decimal part. The type returned by ceil () is still float, because the range of float values is usually larger than integer.
Ceil () example:
See the difference between these two functions.
We will often use it when paging.
/ / Page number calculation:
$lastpg=ceil ($totle/$displaypg); / / the last page, which is also the total number of pages, is much more convenient with ceil. $lastpg=$lastpg? $lastpg: 1; / / No entry is displayed, set the last page to 1$ page=min ($lastpg,$page); $prepg=$page-1; / / previous page $nextpg= ($page==$lastpg? 0: $page+1); / / next page $firstcount= ($page-1) * $displaypg
Of course, if you need to set the precision, you need to use the round function.
3. Round function:
Syntax:
Float round (float val [, int precision])
Description:
Returns the result that val is rounded based on the specified precision precision (the number of digits after the decimal point). Precision can also be negative or zero (default).
Round () example
4. Intval- transforms variables into integers
Variables are converted to integer types.
Syntax: int intval (mixed var, int [base])
Return value: integer
Function type: PHP system function
Content description
This function converts a variable to an integer type. The omitted parameter base is the base of the transformation, with a default value of 10. The converted variable var can be any type of variable other than an array or class.
Example intval ()
Note: if intval is character type, it will be automatically converted to 0, such as
Intval ('abc')
Output result 0
If it is
Intval ('5fd')
The output is
five
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.