Logo

Programming-Idioms

Extract floating point value f from its string representation s
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
(read-string s)
(Float/parseFloat s)
float f = std::stof(s);
var f=float.Parse(s);
import std.conv;
float f = s.to!float;
f = num.parse(s);
read (unit=s,fmt=*) f
read(s,'(g0)')f
import "strconv"
f, err := strconv.ParseFloat(s, 64)
read s :: Double
let f = +s
String floatString = "14.5";
float x = Float.parseFloat(floatString);
double y = Double.parseFloat(floatString);
$f = floatval($s);
uses sysutils;
f := s.ToExtended;
uses sysutils;
f := StrToFloat(s);
my $f = $s;
f = float(s)
f = float(s)
import locale
s = u'545,2222'
locale.setlocale(locale.LC_ALL, 'de')
f = locale.atof(s)
f = s.to_f
let f = s.parse::<f32>().unwrap();
let f: f32 = s.parse().unwrap();