Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

# Math::GMPq 0.28

Company: Sisyphus
Date Added: November 19, 2013  |  Visits: 199

Math::GMPq is a bigrational Perl module utilising the Gnu MP (GMP) library. Basically this module simply wraps all of the 'mpq' (rational number) functions provided by that library. The documentation below extensively plagiarises the GMP documentation (which can be found at http://gmplib.org). See also the Math::GMPq test suite for examples of usage.<br /><br />SYNOPSIS<br /><br /> use Math::GMPq qw(:mpq);<br /><br /> my \$str = '123542/4'; # numerator = 123542<br /> # denominator = 4<br /> my \$base = 10;<br /><br /> # Create the Math::GMPq object<br /> my \$bn1 = Rmpq_init(); # Value set to 0/1<br /><br /> # Assign a value.<br /> Rmpq_set_str(\$str, \$base);<br /><br /> # Remove any factors common to both numerator and<br /> # denominator so that gcd(numerator, denominator) == 1.<br /> Rmpq_canonicalize(\$bn1);<br /><br /> # or just use the new() function:<br /> my \$rational = Math::GMPq->new('1234/1179');<br /><br /> # Perform some operations ... see 'FUNCTIONS' below.<br /><br /> .<br /> .<br /><br /> # print out the value held by \$bn1 (in octal):<br /> print Rmpq_get_str(\$bn1, 8), "<br />"; # prints '170513/2'<br /><br /> # print out the value held by \$bn1 (in decimal):<br /> print Rmpq_get_str(\$bn1, 10); # prints '61771/2'.<br /><br /> # print out the value held by \$bn1 (in base 29)<br /> # using the (alternative) Rmpq_out_str()<br /> # function. (This function doesn't print a newline.)<br /> Rmpq_out_str(\$bn1, 29);<br />

 Requirements: No special requirements Platforms: *nix, Linux Keyword: Common,  Denominator,  Documentation,  Factors,  Function,  Gcdnumerator,  Library,  Mathgmpq,  Mathgmpq 0 28,  Module,  Numerator,  Operations,  Perform,  Print,  Prints,  Rational,  Rmpq Strbn Users rating: 0/10