Logo

Programming-Idioms

Declare the floating point number y and initialize it with the value of the integer x .
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
Y : constant Float := Float (X);
float y = (float)x;
let y = float_of_int(x)
(def y (float x))
float y = static_cast<float>(x);
float y = x;
import std.conv : to;
int x;
float y = to!float(x);
// or
float y = cast(float) x;
double y = x.toDouble();
y = x / 1
real :: y
y = x
y := float64(x)
y = fromInteger x :: Double
let y = x + .0
int x = 10
float y = (float)x;
System.out.println(y);
Float y = Float.parseFloat(String.valueOf(x));
(defparameter *y* (float x))
y = (16 ^ 13) + x - (16 ^ 13)
y = x + .0
$y = (float) $x;
var
  y: single;
begin
  y := x;
end;
my $y = $x;
y = float(x)
y = x.to_f
let y = x as f64;