Difference between revisions of "To boolean"

From Kolmafia
Jump to navigation Jump to search
imported>Eliteofdelete
(Does not work on slots, elements, items, etc.)
imported>Eliteofdelete
m
Line 19: Line 19:
  
 
* As indicated, integers return true for anything except 0, even negative values.
 
* As indicated, integers return true for anything except 0, even negative values.
* floats return true for anything except -1.0 to 1.0 (not inclusive).  This is because to_int(float) truncates the float.
+
* floats return true for anything except -1.0 to 1.0 (not inclusive).  This is because to_int(float) truncates the float.|
  
 
needscode=yes|
 
needscode=yes|

Revision as of 07:23, 21 January 2015

needs(code_samples);

Function Syntax

boolean to_boolean( any anything)

  • anything is any basic data type that KoLmafia uses

Datatype behaviour: This function converts the supplied datatype to a boolean value. For strings, this means that it will return false for everything except "true". For all other datatypes, it returns to_int(anything) != 0. More details:

  • As indicated, integers return true for anything except 0, even negative values.
  • floats return true for anything except -1.0 to 1.0 (not inclusive). This is because to_int(float) truncates the float.

    See Also

to_int()