Logo

Programming-Idioms

Declare the floating point number y and initialize it with the value of the integer x .
Implementation
Java

Implementation edit is for fixing errors and enhancing with metadata. Please do not replace the code below with a different implementation.

Instead of changing the code of the snippet, consider creating another Java 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 := float64(x)
import std.conv : to;
int x;
float y = to!float(x);
// or
float y = cast(float) x;
let y = x as f64;
y = x.to_f
y = x / 1
y = fromInteger x :: Double
var
  y: single;
begin
  y := x;
end;
double y = x.toDouble();
y = float(x)
float y = x;
my $y = $x;
int x = 10
float y = (float)x;
System.out.println(y);
$y = (float) $x;
float y = (float)x;
y = x + .0
let y = x + .0
(defparameter *y* (float x))
real :: y
y = x
float y = static_cast<float>(x);
(def y (float x))
y = (16 ^ 13) + x - (16 ^ 13)
Y : constant Float := Float (X);
let y = float_of_int(x)