Home  >  Article  >  Backend Development  >  How to round without rounding in php

How to round without rounding in php

藏色散人
藏色散人Original
2021-05-17 10:47:522331browse

In PHP, you can use the floor function to perform rounding without rounding. The syntax format of this function is "float floor (float value)", which returns the next integer that is not greater than value, and replaces value with Decimal parts are rounded off.

How to round without rounding in php

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

floor rounding

Syntax format: float floor (float value)

Returns the next integer that is not greater than value, and rounds the decimal part of value.

The type returned by floor() is still float, because the range of float values ​​is usually larger than that of integer.

echo floor(4.3); // 4
echo floor(9.999); // 9

floor() function introduction

floor() function rounds down to the nearest integer.

Syntax

floor(x)

Parameters

x Required. A number.

Description

Returns the next integer not greater than x, and rounds the decimal part of x. The type returned by floor() is still float because the range of float values ​​is usually larger than that of integer.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to round without rounding in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn