This is a discussion on What's the best way to make an expression evaluate as a double? within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by King Mir That's why the minimal solution is to convert the 2. Alternatively you could cast MARGIN. ...
I'm not getting what you are trying to say. Certainly if you declare the included constants as doubles there wouldn't be a problem. . .
(though I would still advise using 2.0 and 1.0, since the other way technically involves a cast.)
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
I have seen a lot of people who prefer for magic numbers to be explicitly assigned to a constant variable. Though you could always define them with an explicit cast too. Or just cast them as you said. But assuming there is no explicit cast defined, then you won't need a cast at all since everything will be promoted to a double until the point where you assign it to a non-double valued variable.