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/04/11 15:24]
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 <html><b><span style="color:green">integer<span style="color:black"></b></html> value of a <html><b><span style="color:green">number<span style="color:black"></b></html> or <html><b><span style="color:green">string<span style="color:black"></b></html>+<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"> +<well size="sm"><html>
-<html>+
 <span style="font-size:125%;color:green">int <span style="font-size:125%;color:green">int
-<span style="color:black"> +<span style="color:black">intval ( 
-</html> +<span style="color:green">mixed
-[[intval]] +
-<html><span style="color:green">mixed+
 <span style="color:blue">$value <span style="color:blue">$value
 <span style="color:black">) <span style="color:black">)
-</html> +</html></well>
-</well>+
  
-Return the <html><b><span style="color:green">integer<span style="color:black"></b></html> 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><b><span style="color:blue">$value<span style="color:black"></b></html>:  A <html><b><span style="color:green">string<span style="color:black"></b></html> with a leading number, or a <html><b><span style="color:green">number<span style="color:black"></b></html> (<html><b><span style="color:green">int<span style="color:black"></b></html> or <html><b><span style="color:green">float<span style="color:black"></b></html>)+<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====
  
 <html><b><span style="color:green">Integer<span style="color:black"></b></html> value, or: <html><b><span style="color:green">Integer<span style="color:black"></b></html> value, or:
Line 35: Line 31:
 ====Example==== ====Example====
  
-**Convert the float '1.55' into an integer 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 47: 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 <html><b><span style="color:green">float<span style="color:black"></b></html> value of a <html><b><span style="color:green">number<span style="color:black"></b></html> or <html><b><span style="color:green">string<span style="color:black"></b></html>+[[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 <html><b><span style="color:green">string<span style="color:black"></b></html> equivalent of a <html><b><span style="color:green">number<span style="color:black"></b></html>+[[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()]] - Check if a value is numeric (<html><b><span style="color:green">int<span style="color:black"></b></html>, <html><b><span style="color:green">float<span style="color:black"></b></html> or numeric <html><b><span style="color:green">string<span style="color:black"></b></html>)+[[is_numeric()]] - <html>Check if a 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()]] - <html>Convert a <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> [[ieee754toint()]] - <html>Convert a <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>
  
 [[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.1491924244.txt.gz · Last modified: 2021/09/13 05:56 (external edit)