To float: Difference between revisions
Jump to navigation
Jump to search
imported>Eliteofdelete Updated |
imported>Eliteofdelete No edit summary |
||
Line 33: | Line 33: | ||
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.| | 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