To float: Difference between revisions
Jump to navigation
Jump to search
imported>Bale mNo edit summary |
imported>Eliteofdelete No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
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= | parameter1={{Param|boolean|convert}}| | ||
}}| | }}| | ||
function_description=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 | 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| | |||
}}| | |||
function_description=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|to_int()]] is performed first, and then converted to a float. All other data types do not work.| | |||
code1={{CodeSample| | |||
title=Code Samples| | |||
description=Following example shows basic to_float operations.|| | |||
code= | |||
<syntaxhighlight> | |||
int first = 25; | |||
print("Int "+first+" gives "+to_float(first), "green"); | |||
foreach it in $booleans[] | |||
print("Boolean "+it+" gives "+to_float(it), "blue"); | |||
</syntaxhighlight>| | |||
moreinfo= | |||
It gives the following output. | |||
<pre> | |||
Int 25 gives 25.0 | |||
Boolean true gives 1.0 | |||
Boolean false gives 0.0 | |||
</pre> | |||
}}| | |||
}} | }} | ||
[[Category:Datatype Conversions]] | [[Category:Datatype Conversions]] |
Latest revision as of 14:46, 26 January 2015
Function Syntax
float to_float(boolean 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.
Code Samples
Following example shows basic to_float operations.
int first = 25;
print("Int "+first+" gives "+to_float(first), "green");
foreach it in $booleans[]
print("Boolean "+it+" gives "+to_float(it), "blue");
It gives the following output.
Int 25 gives 25.0 Boolean true gives 1.0 Boolean false gives 0.0