Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

gmp_init(3) [php man page]

GMP_INIT(3)								 1							       GMP_INIT(3)

gmp_init - Create GMP number

SYNOPSIS
GMP gmp_init (mixed $number, [int $base]) DESCRIPTION
Creates a GMP number from an integer or string. PARAMETERS
o $number - An integer or a string. The string representation can be decimal, hexadecimal or octal. o $base - The base. The base may vary from 2 to 36. If base is 0 (default value), the actual base is determined from the leading charac- ters: if the first two characters are 0x or 0X, hexadecimal is assumed, otherwise if the first character is "0", octal is assumed, otherwise decimal is assumed. RETURN VALUES
A GMP number resource in PHP 5.5 and earlier, or a GMP object in PHP 5.6 and later. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.2 | | | | | | | The $base was extended from 2 to 36, to 2 to 62 | | | and -2 to -36. | | | | +--------+---------------------------------------------------+ NOTES
Note To use the extended base introduced in PHP 5.3.2, then PHP must be compiled against GMP 4.2.0 or greater. EXAMPLES
Example #1 Creating GMP number <?php $a = gmp_init(123456); $b = gmp_init("0xFFFFDEBACDFEDF7200"); ?> NOTES
Note It is not necessary to call this function if you want to use integer or string in place of GMP number in GMP functions, like gmp_add(3). Function arguments are automatically converted to GMP numbers, if such conversion is possible and needed, using the same rules as gmp_init(3). PHP Documentation Group GMP_INIT(3)

Check Out this Related Man Page

GMP_DIV_QR(3)								 1							     GMP_DIV_QR(3)

gmp_div_qr - Divide numbers and get quotient and remainder

SYNOPSIS
array gmp_div_qr (GMP $n, GMP $d, [int $round = GMP_ROUND_ZERO]) DESCRIPTION
The function divides $n by $d. PARAMETERS
o $n - 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 $d - The number that $n 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 - See the gmp_div_q(3) function for description of the $round argument. RETURN VALUES
Returns an array, with the first element being [n/d] (the integer result of the division) and the second being (n - [n/d] * d) (the remainder of the division). EXAMPLES
Example #1 Division of GMP numbers <?php $a = gmp_init("0x41682179fbf5"); $res = gmp_div_qr($a, "0xDEFE75"); printf("Result is: q - %s, r - %s", gmp_strval($res[0]), gmp_strval($res[1])); ?> SEE ALSO
gmp_div_q(3), gmp_div_r(3). PHP Documentation Group GMP_DIV_QR(3)
Man Page

5 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Convert hexadecimal to decimal base

Hello ! Does anyone knows how can I convert hexadecimal to decimal base in the ksh or csh script ?? Thanks ! Witt (1 Reply)
Discussion started by: witt
1 Replies

2. HP-UX

GMP multi precision math library

Hello all, I'm having trouble building the GNU Multi Precision (GMP 4.1.3) on the HP Intel Itanium 2 HP-UX 11i I'm hoping someone out there has had some experience building GMP on this platform. After running the ./configure and doing a make I get an error saying: `.rodata` is not a section ... (3 Replies)
Discussion started by: vyl
3 Replies

3. Shell Programming and Scripting

Help with shell scripting

HI guys, I need to check the base.txt file with the base.lck file and get a resulting base file which checks the last number in the base.lck file and starts with the number after the numbers in the base.lck file. Here the base.txt is the list of numbers. The base.lck file is something like a... (8 Replies)
Discussion started by: vishva79
8 Replies

4. Programming

Library linking with GMP

I am trying to set up the gnu multiple precision arithmetic library for some c++ programming I have to do. I am using a system with mac osx 10.6.3 and do NOT have root user access. I'm trying to use gmp 5.0.1. Since I don't have root user access, I had to install to a different directory Thus... (3 Replies)
Discussion started by: bluejayek
3 Replies

5. Shell Programming and Scripting

[Solved] Decoding a base 64 string

Is it possible to decode a base 64 string in linux or unix. If so, related commands or reference notes would be really helpful. (1 Reply)
Discussion started by: chandu123
1 Replies