5 ms·
The question is what you try to achieve. At a certain precision you won't get any difference in any rasterized image anymore so you do not really care anymore.
by legulere 5y ago
The question is what you try to achieve. At a certain precision you won't get any difference in any rasterized image anymore so you do not really care anymore. The SVG standard agrees there and states that 32 bit floating point is enough.
IEEE binary floating point numbers are widely supported and performant.
You can easily sidestep problems with errors of calculation (which includes already parsing decimal floats into binary floats, and happens here also with addition) by keeping the error smaller than what you care about: Read in as double precision float and use double for calculation, convert back to single precision before converting to decimal floating point. The error you will do in double precision will be smaller than what you loose converting to single precision.
You can use that for SVG path optimization where you will run across 0.1+0.2!=0.3 problems.
If you really want exact measurements, then you would want fractional numbers, so you can also cut lengths in e.g. three precisely.