FloatValue()

From ElectronicWar

Jump to: navigation, search
Function information for floatValue()
Function floatValue()
Parameters floatValue( int value )
API All
Cost $0
Level N/A
CPU Usage 0
Description Returns a float of the value that was input.


[edit] Challenge Script Example

If the challenge input were an array containing the integer 33, and you had to output the area of a circle, where the radius was the input, you could use the following script:

float radius = floatValue(getInputInt())
float area = getPI()*radius*radius;
setOutputFloat(area);
}

To calculate the area of a circle you use the formula Pi * r2. As Pi is expressed as a float (3.14159) it is necessary to also store the radius as a float. Giving floatValue() the radius getInputInt() will convert it to a float value.

Personal tools