Bc.php 585 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace UCore\Helper;
  3. use UCore\Exception\CodeException;
  4. /**
  5. * BC的再封装
  6. */
  7. class Bc
  8. {
  9. /**
  10. * 除法
  11. *
  12. * @param $num1
  13. * @param $num2
  14. * @param int $scale
  15. * @param string $error
  16. * @return string
  17. */
  18. static public function div($num1, $num2, int $scale = 0, $error = '0')
  19. {
  20. if (empty($num1)) {
  21. if(is_null($error)){
  22. throw new CodeException("bc_div 0 ");
  23. }
  24. return (string) $error;
  25. }
  26. return bcdiv((string)$num1, (string)$num2, $scale);
  27. }
  28. }