← Back to team overview

kicad-developers team mailing list archive

Re: EDA in a better (open and free) world :-)]

 

Tim Hanson wrote:
I also believe pcbnew internal units will be changed in a next future
from 1/10000 inch to a smaller unit (1/100000 inch or 1/10000 mm)
to handle properly small pad and track sizes in inches and mm because
modern components are smaller and smaller and use a small metric grid.
This also is a reason to change the .brd file format

--

Jean-Pierre CHARRAS


Jean-Pierre,

This confused me when I first started looking at the internal PCB
code, and I still do not understand it: why don't we use
floating-point numbers?

thanks,
Tim


There are indications that this is common to use integer multiples of an internal unit, at least those indications are in the specctra dsn spec, which has been now swallowed by the largest of EDA software vendors. I kind of think of it like a pixel-ization of the board space. It comes in handy when comparing two coordinates for equality. You want fine enough granularity (a.k.a. precision) so as to do any practical positioning, but you do not want more granularity than this because you can run into "off by a small amount errors", which would cause your equality checks to fail. Then when doing an equality test, you would have to see if any two IEEE floats were within a tolerable amount of each other to be considered "equal". Instead if integers are used, the "float to integer rounding" takes care of that "off by a little" error for you. As long as you use a consistent rounding algorithm to your internal units, then equality can be done with ==.

With this scheme, math calculations along the way to the final coordinates can be done in floats, it is just the final object storage that is conveniently done in integer format. It is not inconceivable that there are other workable ways of doing it however. I think mechanical CAD packages use floating point numbers for example. But they do not have the same need for all the equality testing of coordinates which are used in the continuity testing logic.

Dick








References