Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

gmp_div_q(3) [php man page]

GMP_DIV_Q(3)								 1							      GMP_DIV_Q(3)

gmp_div_q - Divide numbers

SYNOPSIS
GMP gmp_div_q (GMP $a, GMP $b, [int $round = GMP_ROUND_ZERO]) DESCRIPTION
Divides $a by $b and returns the integer result. PARAMETERS
o $a - The number being divided. Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric string provided that it is possible to convert the latter to a number. o $b - The number that $a is being divided by. Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric string provided that it is possible to convert the latter to a number. o $round - The result rounding is defined by the $round, which can have the following values: o GMP_ROUND_ZERO: The result is truncated towards 0. o GMP_ROUND_PLUSINF: The result is rounded towards +infinity. o GMP_ROUND_MINUSINF: The result is rounded towards -infinity. Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric string provided that it is pos- sible to convert the latter to a number. RETURN VALUES
A GMP number resource in PHP 5.5 and earlier, or a GMP object in PHP 5.6 and later. EXAMPLES
Example #1 gmp_div_q(3) example <?php $div1 = gmp_div_q("100", "5"); echo gmp_strval($div1) . " "; $div2 = gmp_div_q("1", "3"); echo gmp_strval($div2) . " "; $div3 = gmp_div_q("1", "3", GMP_ROUND_PLUSINF); echo gmp_strval($div3) . " "; $div4 = gmp_div_q("-1", "4", GMP_ROUND_PLUSINF); echo gmp_strval($div4) . " "; $div5 = gmp_div_q("-1", "4", GMP_ROUND_MINUSINF); echo gmp_strval($div5) . " "; ?> The above example will output: 20 0 1 0 -1 NOTES
Note This function can also be called as gmp_div(3). SEE ALSO
gmp_div_r(3), gmp_div_qr(3). PHP Documentation Group GMP_DIV_Q(3)

Check Out this Related Man Page

Math::GMP(3pm)						User Contributed Perl Documentation					    Math::GMP(3pm)

NAME
Math::GMP - High speed arbitrary size integer math SYNOPSIS
use Math::GMP; my $n = new Math::GMP 2; $n = $n ** (256*1024); $n = $n - 1; print "n is now $n "; DESCRIPTION
Math::GMP was designed to be a drop-in replacement both for Math::BigInt and for regular integer arithmetic. Unlike BigInt, though, Math::GMP uses the GNU gmp library for all of its calculations, as opposed to straight Perl functions. This can result in speed improvements. The downside is that this module requires a C compiler to install -- a small tradeoff in most cases. Also, this module is not 100% compatible to Math::BigInt. A Math::GMP object can be used just as a normal numeric scalar would be -- the module overloads most of the normal arithmetic operators to provide as seamless an interface as possible. However, if you need a perfect interface, you can do the following: use Math::GMP qw(:constant); $n = 2 ** (256 * 1024); print "n is $n "; This would fail without the ':constant' since Perl would use normal doubles to compute the 250,000 bit number, and thereby overflow it into meaninglessness (smaller exponents yield less accurate data due to floating point rounding). METHODS
Although the non-overload interface is not complete, the following functions do exist: new $x = Math::GMP->new(123); Creates a new Math::GMP object from the passed string or scalar. $x = Math::GMP->new('abcd', 36); Creates a new Math::GMP object from the first parameter which should be represented in the base specified by the second parameter. bfac $x = Math::GMP->new(5); $x->bfac(); # 1*2*3*4*5 = 120 Calculates the factorial of $x and modifies $x to contain the result. band $x = Math::GMP->new(6); $x->band(3); # 0b110 & 0b11 = 1 Calculates the bit-wise AND of it's two arguments and modifies the first argument. bxor $x = Math::GMP->new(6); $x->bxor(3); # 0b110 & 0b11 = 0b101 Calculates the bit-wise XOR of it's two arguments and modifies the first argument. bior $x = Math::GMP->new(6); $x->bior(3); # 0b110 & 0b11 = 0b111 Calculates the bit-wise OR of it's two arguments and modifies the first argument. bgcd $x = Math::GMP->new(6); $x->bgcd(4); # 6 / 2 = 2, 4 / 2 = 2 => 2 Calculates the Greatest Common Divisior of it's two arguments and returns the result. legendre jacobi fibonacci $x = Math::GMP->fibonacci(16); Calculates the n'th number in the Fibonacci sequence. probab_prime $x = Math::GMP->new(7); $x->probab_prime(10); Probabilistically Determines if the number is a prime. Argument is the number of checks to perform. Returns 0 if the number is definitely not a prime, 1 if it may be, and 2 if it is definitely is a prime. BUGS
As of version 1.0, Math::GMP is mostly compatible with the old Math::BigInt version. It is not a full replacement for the rewritten Math::BigInt versions, though. See the SEE ALSO section on how to achieve to use Math::GMP and retain full compatibility to Math::BigInt. There are some slight incompatibilities, such as output of positive numbers not being prefixed by a '+' sign. This is intentional. There are also some things missing, and not everything might work as expected. SEE ALSO
Math::BigInt has a new interface to use a different library than the default pure Perl implementation. You can use, for instance, Math::GMP with it: use Math::BigInt lib => 'GMP'; If Math::GMP is not installed, it will fall back to it's own Perl implementation. See Math::BigInt and Math::BigInt::GMP or Math::BigInt::Pari or Math::BigInt::BitVect. AUTHOR
Chip Turner <chip@redhat.com>, based on the old Math::BigInt by Mark Biggar and Ilya Zakharevich. Further extensive work provided by Tels <tels@bloodgate.com>. perl v5.14.2 2009-09-17 Math::GMP(3pm)
Man Page