Logo

Programming-Idioms

History of Idiom 79 > diff from v31 to v32

Edit summary for version 32 by programming-idioms.org:
[C] Comments emphasis x

Version 31

2018-04-03, 22:28:36

Version 32

2018-06-24, 09:48:33

Idiom #79 Convert integer to floating point number

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

Idiom #79 Convert integer to floating point number

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

Code
float y = (float)x;
Code
float y = (float)x;
Comments bubble
The (float) isn't really necessary, unless x is a double type. The compiler will cast x automatically.
Comments bubble
The (float) isn't really necessary, unless x is a double type. The compiler will cast x automatically.