=pod Sub : isEqualFloat Desc : to compare two floating point numbers and find out if they are equal Args : float1, float2, delta value(optinal) or 0.00001 Returns : True if they are apart by the delta value, false otherwise =cut sub isEqualFloat($$$) { my( $float1, $float2, $delta ) = @_; $delta ||= 0.00001; # default value of delta abs( $float1 - $float2 ) < $delta } # call as if ( isEqualFloat( 1.98, ( 1.8 * (1 + 10/100) )) ) { ... } # for high precision comparison if ( isEqualFloat( 1.98, ( 1.8 * (1 + 10/100) ), 0.0000001 ) ) { ... }