I find some strange behavior with a double in multiplication with a non rational number concerning its precision. The precision of stdout is enough as seen in type-1 result. If I multiply it with 1/8, everything is fine. But If I but this non rational number into brackets, it results in a 0-value!
Can someone explain me, why a bracket in this case ruins the calculation?
When both sides of the / operator are integers, it is treated as integer division and the result will be an integer. Therefore 1/8 is zero, which means the above line of code is the same as d3*0
EDIT:
d3*1/8 works because the compiler first does d3*1, which results in a double (since d3 is a double). It then does the result of that /8... and since one side is a double, it does floating point division. So it works as expected.
The other way you can solve this is to force the compiler to do floating point division by making either (or both) sides of the / operator a floating point: