if (sprintf("%.3f",$x) == sprintf("%.3f",$y)) { print "IS equal to 3 dp\n"; };