$int: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m Added examples of negative numbers fixed a typo. |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 4: | Line 4: | ||
* ''N'' is the number with decimals you want to handle. | * ''N'' is the number with decimals you want to handle. | ||
== Note == | |||
The difference between $int and [[$floor]] is only visible with negative numbers. For example: | |||
$floor(5.6) ;returns 5 | |||
$int(5.6) ;returns 5 | |||
$floor(-5.6) ;returns -6 | |||
$int(-5.6) ;returns -5 | |||
== Examples == | == Examples == | ||
$int([[$pi]]) | $int([[$pi]]) ;will return ''3'' | ||
$int(9312412.3213) - will return '' | $int(9312412.3213) ;will return ''9312412'' | ||
[[var]] %i = 2.5 | |||
[[$calc]](%i - $int(%i)) ;will return ''0.5'' | |||
$calc(%i % 1) ;will also return ''0.5'' | |||
The above example shows how to return the remainder from a decimal number. | |||
== See also == | == See also == | ||
* [[$round]] | |||
[[$round]] | * [[$ceil]] | ||
* [[$floor]] | |||
[[Category:Text and Number Identifiers]] | [[Category:Text and Number Identifiers]] |
Latest revision as of 08:32, 12 June 2012
Returns the specified integer number without rounding.
$int(N)
- N is the number with decimals you want to handle.
Note
The difference between $int and $floor is only visible with negative numbers. For example:
$floor(5.6) ;returns 5 $int(5.6) ;returns 5 $floor(-5.6) ;returns -6 $int(-5.6) ;returns -5
Examples
$int($pi) ;will return 3 $int(9312412.3213) ;will return 9312412
var %i = 2.5 $calc(%i - $int(%i)) ;will return 0.5 $calc(%i % 1) ;will also return 0.5
The above example shows how to return the remainder from a decimal number.