PHP/Math/abs

Материал из Web эксперт
Версия от 10:06, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

abs( ) function returns the absolute value of the parameter

   <source lang="html4strict">

<?

   abs(50); // 50
   abs(-12); // 12

?>

 </source>
   
  


Calling the Built-in abs() Function

   <source lang="html4strict">

<html> <head><title>Calling the Built-in abs() function</title></head> <body>

<?php

   $num = -321;
   $newnum = abs( $num );
   print $newnum;

?>

</body> </html>

 </source>
   
  


You can either send a floating-point number or an integer to abs( )

   <source lang="html4strict">

<?

   abs(50.1); // 50.1
   abs(-12.5); // 12.5

?>

 </source>