User Tools

Site Tools


4rpl:commands:asint

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
4rpl:commands:asint [2022/04/11 14:15] – [Examples] Removed quotations which would imply a String and enhanced Vertu4rpl:commands:asint [2025/02/14 14:57] (current) – external edit 127.0.0.1
Line 6: Line 6:
  
 ===== Description ===== ===== Description =====
-Converts an item on the stack to an integer, and pushes it back to the stack.+Converts (coerces) an item on the stack to an integer, and pushes it back to the stack.
  
 If used on a float, will truncate any decimal value.  i.e. 42.8 asint will return 42. If used on a float, will truncate any decimal value.  i.e. 42.8 asint will return 42.
 +If used on a string, if the string could be numeric (eg. "42"), it will be converted to the corresponding value, if not, the call will return zero.
  
 ===== Examples ===== ===== Examples =====
 <code 4rpl> <code 4rpl>
-42.6 asint ->val #Becomes 42+ 
 +Trace (AsInt(42.6))        # 42 
 +Trace (AsInt("42"))        # 42 
 +Trace (AsInt("Forty-two")) # 0 
 </code> </code>
 +
 +See also: 
 +  * [[AsFloat]]
 +  * [[AsString]]
 +
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
  
4rpl/commands/asint.1649686545.txt.gz · Last modified: 2025/02/14 14:56 (external edit)