parseFloat()

From Hack Wars Wiki

Jump to: navigation, search


Information for free function parseFloat()
Function parseFloat(string s)
API Attacking, Banking, FTP, Watch, HTTP, Challenges, Hacktendo
Description Attempts to parse a floating point number based on the given string.

Example

This example interprets the float value of s and stores it in amount.

string s = "13.5";
float amount = parseFloat(s);
//amount == 13.5


Some players read float values from files. The problem is that the readLine() function returns the possible float as a string. parseFloat() is used to reinterpret this value as a float.

This example reads the first line of the file bank.txt (which is assumed to be a float), interprets it as a float and finally stores it in the variable named amount.

float amount = parseFloat(readLine("bank.txt", 0));
Personal tools