in reply to Percentage module in Math::?

I agree with most of the others. This is module madness if we need a module to do division.

I will ad this to what the others have said though. Be careful of divide by zero. You may want to do something like this.

my $percent = ($second_number ? $first_number/$second_number : undef);
And then check $percent for undef.
--
I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.

Replies are listed 'Best First'.
Re^2: Percentage module in Math::?
by ysth (Canon) on Dec 09, 2007 at 06:23 UTC
      If $second_number is a negative zero, shouldn't that give negative undef? (Just kidding.)

      Unless $first_number is also negative. (Being equally serious.)

      Cheers,
      Rob