This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
uphp:functions:intval [2017/03/06 14:14] jeff |
uphp:functions:intval [2021/09/13 05:57] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ======intval====== | ======intval====== | ||
| + | |||
| < | < | ||
| - | Return the integer value of a number or string | + | < |
| ====Description==== | ====Description==== | ||
| - | <well size=" | + | |
| - | <span style=" | + | <well size=" |
| - | < | + | <span style=" |
| - | <span style=" | + | <span style=" |
| - | <span style=" | + | <span style=" |
| + | <span style=" | ||
| + | <span style=" | ||
| </ | </ | ||
| - | Return the integer | + | Return the < |
| - | ====Parameters==== | + | ====Parameter==== |
| - | < | + | |
| - | ====Return | + | < |
| - | Integer value, or: | + | |
| + | ====Return | ||
| + | |||
| + | < | ||
| * 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 < |
| - | * 1 on non-empty | + | * 1 on non-empty |
| - | The maximum value possible is a signed integer in the range -2147483648 to 2147483647. | + | The maximum value possible is a signed |
| ====Example==== | ====Example==== | ||
| - | Convert the float ' | + | |
| + | ===Convert the float ' | ||
| <code php> | <code php> | ||
| <? | <? | ||
| - | $f=1.55; | + | |
| - | $i=intval($f); | + | $i=intval($f); |
| - | print(" | + | print(" |
| ?> | ?> | ||
| </ | </ | ||
| + | |||
| The above example will output: | The above example will output: | ||
| < | < | ||
| - | The integer value of 1.550000 is 1 | + | The integer value of 1.550000 is 2 |
| </ | </ | ||
| ====See Also==== | ====See Also==== | ||
| - | [[floatval()]] - Return the floating point value of a number or string | ||
| - | [[is_numeric()]] - Return | + | [[floatval()]] - < |
| + | |||
| + | [[strval()]] - < | ||
| + | |||
| + | [[is_numeric()]] - < | ||
| + | |||
| + | [[ieee754toint()]] - < | ||
| + | |||
| + | [[uphp: | ||
| + | |||
| + | ====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): | ||
| - | [[ieee754toint()]] - Take a floating point value and return an IEEE-754 encoded integer (32 bit) | + | < |
| - | [[inttoieee754()]] - Take an IEEE-754 encoded integer (32 bit) and return a float | ||