Reduce the effect of float number (rounding) error
We are implementing some geometric algorithms but found the effect of float numb开发者_开发知识库er calculation error is big. Is there any guide lines to reduce this kind of effects?
The algorithms contains many parts and is very complex. One of the example is to calculate the intersects between a line and a spline (serials of bezier curve). When the line position close to the end point of bezier the result is unstable.
Thanks
- Use algorithms which are less sensitive to floating point error (see numerical stability)
- Use wider types (ex.
double
instead offloat
)
精彩评论