Home  >  Article  >  Backend Development  >  Implementation method of converting php to positive number

Implementation method of converting php to positive number

PHPz
PHPzOriginal
2020-09-25 14:13:352350browse

The implementation method of converting php to positive number: first create a PHP sample file; then define a negative number; then use the "abs($a);" method to convert the specified negative number into a positive number; finally use echo output conversion The result is enough.

Implementation method of converting php to positive number

Recommendation: "PHP Video Tutorial"

PHP negative number to positive number

Function: abs ()

$a = -1;
$b = abs($a);

abs() function returns the absolute value of a number.

Syntax

abs(x)

Parameters

x Required. A number.

Description

Returns the absolute value of parameter x. If the parameter x is a float, the return type is also a float, otherwise an integer is returned (because float usually has a larger value range than an integer).

The above is the detailed content of Implementation method of converting php to positive number. 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