User Tools

Site Tools


uphp:functions:intval

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
uphp:functions:intval [2017/03/31 13:43]
jeff
uphp:functions:intval [2021/09/13 05:57] (current)
Line 3: Line 3:
 <badge>WMPRO, WMMINI FW >= 1.0</badge> <badge>WMMEGA FW >= 2.0</badge> <badge>WMPRO, WMMINI FW >= 1.0</badge> <badge>WMMEGA FW >= 2.0</badge>
  
-Return the integer value of a number or string+<html>Return the <b><span style="color:green">integer<span style="color:black"></b> value of a <b><span style="color:green">number<span style="color:black"></b> or <b><span style="color:green">string<span style="color:black"></b></html>
  
 ====Description==== ====Description====
  
-<well size="sm"><html><span style="font-size:125%;color:green">int +<well size="sm"><html> 
-<span style="color:black"></html>[[intval]] +<span style="font-size:125%;color:green">int 
-<html><span style="color:green">mixed+<span style="color:black">intval ( 
 +<span style="color:green">mixed
 <span style="color:blue">$value <span style="color:blue">$value
 <span style="color:black">) <span style="color:black">)
 </html></well> </html></well>
  
-Return the integer value by truncating the fractional component of the number+Return the <html><b><span style="color:green">integer<span style="color:black"></b></html> value by rounding
  
 ====Parameter==== ====Parameter====
  
-<html><span style="color:blue"><b>$value</b><span style="color:black"></html>:  A string with a leading number, or a number (int or float)+<html><b><span style="color:blue">$value<span style="color:black"></b>:  A <b><span style="color:green">string<span style="color:black"></b> with a leading number, or a <b><span style="color:green">number<span style="color:black"></b> (<b><span style="color:green">int<span style="color:black"></b> or <b><span style="color:green">float<span style="color:black"></b>)</html>
  
-====Return Value====+====Return Values====
  
-Integer value, or:+<html><b><span style="color:green">Integer<span style="color:black"></b></html> value, or:
   * 0 on failure (for example, strings without a numeric in the leftmost characters)   * 0 on failure (for example, strings without a numeric in the leftmost characters)
-  * 0 on empty arrays +  * 0 on empty <html><b><span style="color:green">array<span style="color:black"></b></html> 
-  * 1 on non-empty arrays +  * 1 on non-empty <html><b><span style="color:green">array<span style="color:black"></b></html> 
-The maximum value possible is a signed integer in the range -2147483648 to 2147483647.+The maximum value possible is a signed <html><b><span style="color:green">integer<span style="color:black"></b></html> in the range -2147483648 to 2147483647.
  
 ====Example==== ====Example====
  
-**Convert the float '1.55' into an integer variable which has a value of 1:**+===Convert the float '1.55' into an integer which has a value of '2'===
  
 <code php> <code php>
Line 42: Line 43:
 The above example will output: The above example will output:
 <code> <code>
-The integer value of 1.550000 is 1+The integer value of 1.550000 is 2
 </code> </code>
  
 ====See Also==== ====See Also====
  
-[[floatval()]] - Return the floating point value of a number or string+[[floatval()]] - <html>Return the <b><span style="color:green">float<span style="color:black"></b> value of a <b><span style="color:green">number<span style="color:black"></b> or <b><span style="color:green">string<span style="color:black"></b></html>
  
-[[strval()]] - Return the string equivalent of a number+[[strval()]] - <html>Return the <b><span style="color:green">string<span style="color:black"></b> equivalent of a <b><span style="color:green">number<span style="color:black"></b></html>
  
-[[is_numeric()]] - Return 1 if the value is numeric (integer, float or numeric string)+[[is_numeric()]] - <html>Check if value is numeric (<b><span style="color:green">int<span style="color:black"></b><b><span style="color:green">float<span style="color:black"></b> or numeric <b><span style="color:green">string<span style="color:black"></b>)</html>
  
-[[ieee754toint()]] - Take floating point value and return an IEEE-754 encoded integer (32 bit) +[[ieee754toint()]] - <html>Convert <b><span style="color:green">float<span style="color:black"></b> value to an IEEE-754 encoded <b><span style="color:green">integer<span style="color:black"></b> (32 bit)</html>
- +
-[[inttoieee754()]] - Take an IEEE-754 encoded integer (32 bit) and return a float+
  
 [[uphp:variables|uPHP Variable Types and Limits]] [[uphp:variables|uPHP Variable Types and Limits]]
 +
 +====Note====
 +
 +In firmware versions released before 8/14/17 this function returned the integer value by truncating the fractional component of the number (it did not round up or down):
 +
 +<badge>WMPRO, WMMINI FW < 1.1068</badge> <badge>WMMEGA FW < 2.1068</badge>
  
uphp/functions/intval.1490967837.txt.gz · Last modified: 2021/09/13 05:56 (external edit)