Reference float()

float()

Converts a String to a floating point (decimal) Number.

float() converts strings that resemble numbers, such as '12.34', into numbers.

The parameter, str, is the string value to convert. For example, calling float('12.34') returns the number 12.34. If an array of strings is passed, as in float(['12.34', '56.78']), then an array of numbers will be returned.

Note: If a string can't be converted to a number, as in float('giraffe'), then the value NaN (not a number) will be returned.

Examples

Syntax

float(str)
float(ns)

Parameters

str
String:

string to convert.

ns
String[]:

array of strings to convert.

Returns

Number: converted number.
This page is generated from the comments in src/utilities/conversion.js . Please feel free to edit it and submit a pull request!

Related References