BCMath.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * A class for arbitrary precision math functions implemented using bcmath
  4. *
  5. * PHP version 5.3
  6. *
  7. * @category PHPPasswordLib
  8. * @package Core
  9. * @subpackage BigMath
  10. * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
  11. * @copyright 2011 The Authors
  12. * @license http://www.opensource.org/licenses/mit-license.html MIT License
  13. * @version Build @@version@@
  14. */
  15. namespace SecurityLib\BigMath;
  16. /**
  17. * A class for arbitrary precision math functions implemented using bcmath
  18. *
  19. * @category PHPPasswordLib
  20. * @package Core
  21. * @subpackage BigMath
  22. */
  23. class BCMath extends \SecurityLib\BigMath {
  24. /**
  25. * Add two numbers together
  26. *
  27. * @param string $left The left argument
  28. * @param string $right The right argument
  29. *
  30. * @return A base-10 string of the sum of the two arguments
  31. */
  32. public function add($left, $right) {
  33. return bcadd($left, $right, 0);
  34. }
  35. /**
  36. * Subtract two numbers
  37. *
  38. * @param string $left The left argument
  39. * @param string $right The right argument
  40. *
  41. * @return A base-10 string of the difference of the two arguments
  42. */
  43. public function subtract($left, $right) {
  44. return bcsub($left, $right);
  45. }
  46. }