Not slow... no one has provided the right anser yet.
Try 4.0/9.0
C++ will usually assume integer data type when you type a number. The decimal point or "floating point" will make the compiler treat ur number as a float. Simply casting it will still only get you the same answer as kibble.
x = 9.0f/2.0f
Use decimals when declaring floats
If u use simple number, the answer will be a simple number. If you use a decimal number, the answer will be a decimal number.
ok ty for all who helped me and told me to use decimels, it worked. i had assumed the compiler would make x 4.5 as defualt, an because the x is an int, it would just cut off the .5 part unless floated
Originally Posted by why06
Not slow... no one has provided the right anser yet.
Try 4.0/9.0
C++ will usually assume integer data type when you type a number. The decimal point or "floating point" will make the compiler treat ur number as a float. Simply casting it will still only get you the same answer as kibble.
Originally Posted by freedompeace
x = (float)9 / 2;
Last I checked, 9.0, 9.0f and casting 9 as a float do the same thing. (I've never checked, but meh)