Why X and Y property of Object2D Doubles

The X and Y property of an Object2D store the pixel location of the Shape. Why would these be Doubles rather than Integers?

And given that they are Doubles, if you are trying to compare them with an Integer, do you have to be careful about rounding errors.

``if someOval.X = 500 Then``

And getting an inadvertent False because someOval.X is stored as 499.999999999

actually in my opinion ALL coordinates for any graphics object should be a double…
There are cases for applying a zoom factor for example…

Apple for example using CGFloat for everything (CG=CoreGraphics)… this way there is no problem dealing with multiple resolutions, scaling etc.

``if abs(someOval.x-500)<1 then ``

Thanks for pitching in Dave. I guess that the reason it bothers me is that

``If Abs(someOval.x - 500) < 1 Then``

seems to clutter the code (and is something else I have to remember)

And perhaps actually?

``If Abs(someOval.x - 500) < .5 Then``

to cover the possibility that someOval.x is 500.99999 (intended as 501)

``````Function Dbl_EQUAL(v1 as double, v2 as double, tolerance as double=0.5) as boolean
return Abs(v1-v2)<tolerance
End Function``````

If you store integer values in a Double variable, there is never an issue with rounding. A double can store integer values with no loss of precision, up to 53 bits of data. It’s only when you use a fractional value or a value greater than 54 bits do you have an issue.