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.
- Clojure
- Clojure
- Clojure
- C++
- C#
- D
- Dart
- Elixir
- Fortran
- Fortran
- Go
- Haskell
- JS
- Java
- Java
- Java
- PHP
- Pascal
- Pascal
- Perl
- Python
- Python
- Python
- Ruby
- Rust
- Rust
(parse-double s)
(read-string s)
Uses the Clojure reader to parse a string into a float and is thus platform agnostic.
(Float/parseFloat s)
This calls down to Java, and thus only when running Clojure on that platform.
float f = std::stof(s);
var f=float.Parse(s);
f = num.parse(s);
f = String.to_float(s)
read(s,'(g0)')f
read (unit=s,fmt=*) f
read s :: Double
You can convert to Double or to Float.
let f = +s
The unary + operator converts its argument to a double precision floating point.
double f = Double.parseDouble(s);
Will throw NullPointerException if s is null or NumberFormatException if s does not actually represent a float.
Float f = Float.valueOf(s);
Double f = Double.valueOf(s);
f := s.ToExtended;
* Works correctly in Lazarus IDE v. >= 1.8.0.
* Type Float = Extended
* Type Float = Extended
my $f = $s;
s = u'545,2222'
locale.setlocale(locale.LC_ALL, 'de')
f = locale.atof(s)
When working with different locale decimal and thousand separators you have to use locale.atof
f = float(s)
f = float(s)
f = s.to_f
This method never raises an exception.