Difference between revisions of "To float"

From Kolmafia
Jump to navigation Jump to search
imported>Eliteofdelete
(Does not work for "anything". Only Booleans and ints.)
imported>Eliteofdelete
(Updated)
Line 11: Line 11:
 
return_type={{#var:return_type}}|
 
return_type={{#var:return_type}}|
 
return_also={{#var:return_also}}|
 
return_also={{#var:return_also}}|
parameter1= '''any''' {{pspan|anything}}|
+
parameter1={{Param|boolean|convert}}|
p1desc={{Pspan|anything}} is any data type that KoLmafia uses|
+
}}|
 +
 
 +
function2={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|int|convert}}|
 +
}}|
 +
 
 +
function3={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|string|convert}}|
 +
p1desc={{Pspan|convert}} is the boolean, int, or string to convert|
 
}}|
 
}}|
  

Revision as of 11:03, 26 January 2015

needs(code_samples);

Function Syntax

float to_float(boolean convert )

float to_float(int convert )

float to_float(string convert )

  • convert is the boolean, int, or string to convert

This function looks for the best float match to the specified input, which varies by datatype. For int types, this function merely tacks ".0" to the end. For booleans, a transparent conversion as per to_int() is performed first, and then converted to a float. All other data types do not work.