Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Lua

Idiom #79 Convert integer to floating point number

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

y = (16 ^ 13) + x - (16 ^ 13)
y = x + .0

While + .0 makes no difference inside the language, it will flag it as a fractional number in the C runtime
Y : constant Float := Float (X);

New implementation...