Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. function percentage_deadband($value,$previous,$deadband)
  4. {
  5. if($previous==0 || $value==0)
  6. {
  7. return false;
  8. }
  9. $n = $value / $previous * 100;
  10. if($n > 100){
  11. return $n - $deadband > 100;
  12. }
  13. if($n < 100){
  14. return 100 - $n > $deadband;
  15. }
  16. if($n == 100){
  17. return false;
  18. }
  19. return false;
  20. }
  21.  
  22.  
  23. function numeric_deadband($value,$previous,$deadband)
  24. {
  25. if($previous==0 || $value==0 || $previous == $value)
  26. {
  27. return false;
  28. }
  29. if($previous > $value){
  30. return $previous - $deadband > $value;
  31. }else{
  32. return $value - $previous > $deadband;
  33. }
  34. return false;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement