In practice, floating-point errors are seldom a problem. Look at your output carefully and see how small the error really is. The default print format can be annoying (as you have discovered). You can avoid this by using printf to round to your required precision.