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.
- Ada
- C
- Caml
- Clojure
- C++
- C#
- D
- Dart
- Elixir
- Fortran
- Go
- Haskell
- JS
- Java
- Java
- Java
- Java
- Lisp
- Lua
- Lua
- PHP
- Pascal
- Perl
- Python
- Ruby
- Rust
Y : constant Float := Float (X);
float y = (float)x;
The (float) isn't really necessary, unless x is a double type. The compiler will cast x automatically.
let y = float_of_int(x)
(def y (float x))
float y = static_cast<float>(x);
float y = x;
double y = x.toDouble();
No implicit conversion
y = x / 1
The / operator always returns a float.
real :: y
y = x
y := float64(x)
The cast must be explicit.
y = fromInteger x :: Double
let y = x + .0
You might say "Wait! All JavaScript numbers are floats!"
They certainly always behave like they are on the outside, but on the inside they treat some numbers as integers.
They certainly always behave like they are on the outside, but on the inside they treat some numbers as integers.
int x = 10
float y = (float)x;
System.out.println(y);
Float y = Float.parseFloat(String.valueOf(x));
float y = x;
(defparameter *y* (float x))
y = (16 ^ 13) + x - (16 ^ 13)
$y = (float) $x;
var
y: single;
begin
y := x;
end;
my $y = $x;
in perl they are just scalars, there is no distinction between an int and a float
y = float(x)
y = x.to_f