Logo

Programming-Idioms

History of Idiom 79 > diff from v27 to v28

Edit summary for version 28 by VermilionWizard:
[C] Wrong language from previous edit.

Version 27

2018-03-02, 17:00:40

Version 28

2018-03-02, 17:01:18

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 or decimal 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.