I am currently doing a percentage of difference calculation like
$calc = ($value/$expected)*100
which works perfect as long as $value is actually less than $expected.
If it is greater $calc moves to greater than 100%.
Should I just have two thresholds I should check on
if ($calc <= 90 || $calc >= 110)
or is there a way to make it so even greater differences comes out as a percentage of difference less than 100
maybe:
$calc = $value < $expected ? $value/$expected : $expected/$value
or is there something easier I'm missing?
i.e.
actual/expect calc
90/100 = 90%
99/100 = 99%
110/100 = 90%
101/100 = 99%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
![[noevil] [noevil] [noevil]](/data/assets/smilies/noevil.gif)
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
$calc = ($value/$expected)*100
which works perfect as long as $value is actually less than $expected.
If it is greater $calc moves to greater than 100%.
Should I just have two thresholds I should check on
if ($calc <= 90 || $calc >= 110)
or is there a way to make it so even greater differences comes out as a percentage of difference less than 100
maybe:
$calc = $value < $expected ? $value/$expected : $expected/$value
or is there something easier I'm missing?
i.e.
actual/expect calc
90/100 = 90%
99/100 = 99%
110/100 = 90%
101/100 = 99%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
![[noevil] [noevil] [noevil]](/data/assets/smilies/noevil.gif)
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;