Share Link
Copied to clipboard
Embed on Your Page
Copied to clipboard
We Stand with Ukraine
<no name> by Anonymous
The examples from reddit;
100/0.5f  gives: 200
(float)100/0.5f  gives: 200
100f/0.5f gives: 200

If dividing an int by a float or vice-versa, the result will be a float;
100/0.9f gives: 111.111115 (float)
0.9f/100 gives: 0.009
A value with a deciminal point in it is taken as a double;
100/0.9 gives: 111.11111111111111 (double precision)

If dividing two ints, explicit coercion is required;
100/200 gives: 0
100f/200 gives: 0.5
(float)100/200 gives: 0.5
100/200.0 gives: 0.5 (double)

Even if writing to a designated float you need to coerce first, otherwise the rounding will be built in; 
float x = 100/200; => x == 0
float y = 100f/200; => y == 0.5
Cached Result
Last Run: 9:08:20 pm
Compile: 0.008s
Execute: 0.07s
Memory: 3.09Mb
CPU: 0.078s