modulus. * * @param mixed $left_operand * @param mixed $right_operand * @param mixed $modulus * @param int $scale * * @return number|string */ public static function powmod( $left_operand , $right_operand , $modulus, $scale = null ) { self::process_parameters( $left_operand, $right_operand ); if ( self::$bcmath && function_exists( 'bcpowmod' ) ) { $result = bcpowmod( $left_operand, $right_operand, $modulus, $scale ); } else { $result = pow( floatval( $left_operand ), floatval( $right_operand ) ) % intval( $modulus ); $result = self::apply_scale( $result, $scale ); } return $result; } /** * Set scale. * * @param int $scale */ public static function scale( $scale ) { if ( self::$bcmath && function_exists( 'bcscale' ) ) { bcscale( $scale ); } else { self::$scale = $scale; } } /** * Square root. * * @param mixed $operand * @param mixed $scale * * @return number|string */ public static function sqrt( $operand, $scale = null ) { if ( $operand === null ) { $operand = 0; } if ( self::$bcmath && function_exists( 'bcsqrt' ) ) { $result = bcsqrt( $operand, $scale ); } else { $result = sqrt( floatval( $operand ) ); $result = self::apply_scale( $result, $scale ); } return $result; } /** * Subtract. * * @param mixed $left_operand * @param mixed $right_operand * @param int $scale * * @return number|string */ public static function sub( $left_operand, $right_operand, $scale = null ) { self::process_parameters( $left_operand, $right_operand ); if ( self::$bcmath && function_exists( 'bcsub' ) ) { $result = bcsub( $left_operand, $right_operand, $scale ); } else { $result = floatval( $left_operand ) - floatval( $right_operand ); $result = self::apply_scale( $result, $scale ); } return $result; } }