Le 24/06/2012 11:03, Lorenzo Marcantonio a écrit :
It seems that the 'official' way of rounding BIUs is something like:

fval < 0 ? fval - 0.5 : fval + 0.5

i.e. 'away from zero', since the double-to-int C is a truncation (i.e. 'toward 
to zero'')...
what is the rationale for this? is this to preserve, for example, the usual 
symmetry of packages?


I am afraid I do not really understand your question.
In float to integer conversions, rounding creates a smaller error than 
truncating.
And truncating fval < 0 ? fval - 0.5 : fval + 0.5 is the right way to round a 
value that must be converted to integer BIU.

By the way, your recent issue when reading your board file in kicad nanometer 
version is a truncating issue,
when scaling float values read in files to integer internal units.
When using rounding conversion instead of truncating, it happens no more.

--
Jean-Pierre CHARRAS




_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to