This language bar is your friend. Select your favorite languages!

Idiom #146 Convert string to floating point number

Extract floating point value f from its string representation s

import "strconv"
f, err := strconv.ParseFloat(s, 64)
import std.conv;
float f = s.to!float;
f = num.parse(s);
read s :: Double
sysutils
f := StrToFloat(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();

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org

Related idioms