Using float or int for coordinates for graphic operations

I'm developing a graphic editor which should not be limited too much in virtual space and precision. Before .net I used Int32 for the coordinates since the calculations are fast and I can address a huge virtual canvas with a good precision. Now .net comes up with float for most graphic operations. First tests showed that it's an advantage for text draw operations with small fonts. How will it affect my project if I use everywhere float for coordinates? What are the pros and cons?
LVL 10
ptmcompAsked:
Who is Participating?
 
caner_elciCommented:
Well, the main need for floating numbers for coordinates is of course the need of high precision while calculating coordinates. If you are developing an engineering application, such as a CAD software, I strongly suggest you to use floats instead of integers. That just because you will possibly need an X coordinate like 15.374 there. As far as I know, GDI+ uses the same implementation for both floats and integers. Because GDI+ has its built-in transformation methods, Scale, Translate, Rotate etc, it has to do its operations in float mode. That's you'll not notice any performance issues while using floats. The only difference between floats and integers is that integer classes (Point, Size etc.) have some additional methods than floats (PointF, SizeF etc). As an example, you'll not see Offset method in PointF, altough it exists in Point class. Only reason to use integers might be laziness, because if you are working with exact coordinates, it will be hard to round the float variables.

From some real time experiences:
I've used floats in a GIS (Geographical Information Systems) application and some image processing applications. In all other designers, viewers and graphical applications, I used integers and they were enough for me.

Caner ELCI
0
 
ptmcompAuthor Commented:
I decided to use floats everywhere. I use matrix transformations string draw and zooming and you convinced me to use floats.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.