Help for this page

Select Code to Download


  1. or download this
    my $fmt = '%.02f';
    if ( sprintf($fmt, $num1) eq sprintf($fmt, $num2) ) {
       print "they're the same, to two decimal places\n";
    }
    
  2. or download this
    my $diff = 0.005;
    if ( abs($num1-$num2) < $diff ) {
      print "they're close enough\n";
    }