in reply to Calculating base difference of numbers

Are we talking about basis points? Mathematically they are defined simply as 1/100-th of 1% or .0001.
  • Comment on Re: Calculating base difference of numbers

Replies are listed 'Best First'.
Re^2: Calculating base difference of numbers
by Anonymous Monk on May 31, 2008 at 22:02 UTC
    Yes...and I feel stupid that I can't work it out...should be a simple mathematical equation.
      my $diff = ($new*10000) - ($old*10000);
      Or if you want to round it,
      my $diff = 0 + sprintf '%.0f', ($new*10000) - ($old*10000);

      Update: The *10000 can be factored out: ($new-$old)*10000

        If you run the math that doesn't work.

        old => 100.25 new => 100.26

        diff = (100.26 * 10000) - (100.25 * 10000)
        = 100

        when in fact the basis point movement is 1