PHP | gmp_strval() Function Last Updated : 25 Apr, 2018 Comments Improve Suggest changes Like Article Like Report The gmp_strval() is an inbuilt function in PHP which returns the string value of a GMP number. (GNU Multiple Precision: For large numbers). Syntax: string gmp_strval ( GMP $num, int $base ) Parameters: The function accepts two parameters $num and $base as shown above and described below. $num - The function accepts one GMP number $num and returns its string value. This parameter can be a GMP object in PHP version 5.6 and later, or we are also allowed to pass a numeric string provided that it is possible to convert that string to a number. $base - This parameter specifies the base of the returned number by the function. The base values for the $base are from 2 to 62 and -2 to -36. This is an optional parameter and the default value is 10. Return Value: The function returns string value of the given GMP number $num. Examples: Input : $num = "110" $base = 2 Output : 6 Input : $num = "110" Output : 110 Below programs illustrate the gmp_strval() function: Program 1: The program below demonstrates the working of gmp_strval() function when numeric string is passed as an argument and the second parameter is absent. php <?php // PHP program to demonstrate the gmp_strval() function // when the argument is numeric string and // the second parameter is missing echo gmp_strval("10"); ?> Output: 10 Program 2: The program below demonstrates the working of gmp_strval() function when numeric string is passed as an argument and the second parameter is present. php <?php // PHP program to demonstrate the gmp_strval() function // when the argument is numeric string and // the second parameter is present echo gmp_strval("10", 2); ?> Output: 1010 Program 3: The program below demonstrates the working of gmp_strval() function when GMP number is passed and second parameter is absent. php <?php // PHP program to demonstrate the gmp_strval() function // when the argument is GMP number and // the second parameter is missing $num = gmp_init("101", 2); //// gmp_strval converts GMP number to string // representation in given base(default 10). echo gmp_strval($num); ?> Output: 5 Program 4: The program below demonstrates the working of gmp_strval() function when GMP number is passed as an argument and the second parameter is present. php <?php // PHP program to demonstrate the gmp_strval() function // when the argument is numeric string and // the second parameter is present $num = gmp_init("1010", 2); // GMP number in base 8 echo gmp_strval($num, 8); ?> Output: 12 Reference: http://php.net/manual/en/function.gmp-strval.php; Comment More infoAdvertise with us Next Article PHP | gmp_strval() Function T Twinkl Bajaj Follow Improve Article Tags : Misc Web Technologies PHP PHP-gmp Practice Tags : Misc Similar Reads PHP strval() Function The PHP strval() function converts a given variable to a string. It takes a scalar variable (like integers, floats, and booleans) and converts it to its string representation. For arrays, objects, and resources, it does not work and may produce unexpected results.Syntaxstrval( $variable ) Parameter: 3 min read PHP | gmp_sqrt() Function The gmp_sqrt() is a built-in function in PHP which is used to calculate the square root of a GMP number (GNU Multiple Precision : For large numbers). This function returns only the integral part of the square root of the GMP number. Syntax: gmp_sqrt ( $num ) Parameters: This function accepts a GMP n 2 min read PHP | gmp_sqrtrem() Function The gmp_sqrtrem() is a built-in function in PHP which is used to calculate the square root of a GMP number (GNU Multiple Precision : For large numbers) with remainder. This function also returns only the integral part in the square root of the GMP number as the gmp_sqrt() function. The remainder is 2 min read PHP | gmp_scan1() Function The gmp_scan1() is an inbuilt function which is used to scan "1" in the GMP number(GNU Multiple Precision : For large numbers) starting from given index which move towards most significant bits in the number. Syntax: gmp_scan1($num, $index) Parameters: This function accepts two parameters as explain 2 min read PHP | gmp_scan0() Function The gmp_scan0() is an inbuilt function which is used to scan "0" in a GMP number(GNU Multiple Precision : For large numbers) starting from given index which move towards most significant bits in the number. Syntax: gmp_scan0($num, $index) Parameters: This function accepts two parameters as explained 2 min read PHP | gmp_sub() Function The gmp_sub() is an in-built function in PHP which returns the subtraction of the two GMP numbers.(GNU Multiple Precision: For large numbers) Syntax: gmp_sub($num1, $num2) Parameters: This function accepts two GMP numbers $num1 and $num2 as mandatory parameters shown in the above syntax. These param 2 min read PHP | gmp_xor() Function The gmp_xor() is an in-built function in PHP which is used to calculate the XOR of 2 GMP numbers (GNU Multiple Precision : For large numbers). Syntax: gmp_xor( $num1, $num2 ) Parameters: This function accepts two GMP numbers $num1 and $num2 as mandatory parameters shown in the above syntax. These pa 2 min read PHP mb_strlen() Function The mb_strlen() is an inbuilt PHP function that returns the string length in an integer. Syntax: mb_strlen($string, $encoding ): intParameters: This function accepts 2 parameters that are described below: $string: The string parameter whose lengths need to be determined. It is a required parameter.$ 1 min read PHP | gmp_random() Function The gmp_random() function is an inbuilt function in PHP which generates a random number. The range of random number will be in between zero and the number of bits per limb ( A limb is an internal GMP mechanism. The number of bits in a limb is not static and it can vary from system to system. Usually 2 min read PHP | gmp_setbit() Function The gmp_setbit() function is an inbuilt function in PHP which is used to set the bit index in given $num. Syntax: void gmp_setbit( GMP $num, int $index, bool $bit_on ) Parameters: This function accepts three parameters as mentioned above and described below: $num: It is a required parameter. This pa 2 min read Like