# Programming-Idioms

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

``(parse-double s)``
``(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);``
``f = String.to_float(s)``
``read(s,'(g0)')f``
``read (unit=s,fmt=*) f``
``import "strconv"``
``f, err := strconv.ParseFloat(s, 64)``
``read s :: Double``
``let f = +s``
``````double f = Double.parseDouble(s);
``````
``Float f = Float.valueOf(s);``
``Double f = Double.valueOf(s);``
``\$f = floatval(\$s);``
``uses sysutils;``
``f := s.ToExtended;``
``uses sysutils;``
``f := StrToFloat(s);``
``my \$f = \$s;``
``import locale``
``````s = u'545,2222'
locale.setlocale(locale.LC_ALL, 'de')
f = locale.atof(s)``````
``f = float(s)``
``f = float(s)``
``f = s.to_f``
``let f = s.parse::<f32>().unwrap();``
``let f: f32 = s.parse().unwrap();``

programming-idioms.org