Note the .0 on the 1024 to force it to a float value.
There was already a .0 in the statement, so the 1024 value was dividing a float by an int, which will operate as expected. It is not strictly necessary for all operands to be the same type.
Note the .0 on the 1024 to force it to a float value.
There was already a .0 in the statement, so the 1024 value was dividing a float by an int, which will operate as expected. It is not strictly necessary for all operands to be the same type.
Ambiguity is the devil's plaything. Mixing types in a mathematical calculation is a bad thing - regardless of what is "meant" to happen. If you have mixed types, ALWAYS cast them to the correct type. If you have mixed literals, ALWAYS caste them into the most precise / longest type (either with a .0 for floats, or with suffixes). It avoids both compiler issues with you assuming it will do one thing and the compiler doing another, and it also means you can instantly see what the operations are going to do.
Also, do not be afraid to use excessive numbers of brackets in your maths - it forces the order of precedence to be what you expect it to be, and a change in compiler version won't mean a chance change in calculation precedence breaking your code.