I don't think you can get rid of them, you just have to manage it.
If you swap in the following line you'll get the results as you expect.
my $frac = sprintf("%.9g", ($num - $int) );
This is simply rounding to an arbitrary 9 decimal points. Obviously you need to look at the formulas you're working with but this should serve in a lot of cases.
UPDATE: I didn't notice you actually gave a sprintf example. So, Yes, that is the easiest way to get rid of this problem. Infact the O'Reilly Perl CookBook gives examples just like this.
---
my name's not Keith, and I'm not reasonable.