I have a Point3d
class for which I created a scalar multiplication operator like so:
Point3d operator*(double mul) { return {x*mul, y*mul, z*mul}; }
This does not seem to multiply doubles correctly. In my testing when I multiply a Point3d
object by 10^-6
and then check the x
coordinate, I get .000002
.
But, when multiplying the components by hand I get 2.1584e-06
.
The former definitely only has 1 digit of precision because if the operator is too small the Point3d
goes to 0.0
. Why is this happening?