Integer and Float Conversions
There are some rules to convert Floating Point and Integer Values.
9.0 / 2 = 4.5
9 / 2.0 = 4.5
9.0 / 2.0 = 4.5
- If there is an operation between an integer an integer, then the output will also be integer.
- If there is an operation between a real number and a real number, then the output will also be a real number.
- If there is an operation between an integer and a real number, then the output will be real number. The integer is first promoted to a real number and then the operation is performed. So, the result is real.
9.0 / 2 = 4.5
9 / 2.0 = 4.5
9.0 / 2.0 = 4.5
0 comments: