Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

bcpowmod(3) [php man page]

BCPOWMOD(3)								 1							       BCPOWMOD(3)

bcpowmod - Raise an arbitrary precision number to another, reduced by a specified modulus

SYNOPSIS
string bcpowmod (string $left_operand, string $right_operand, string $modulus, [int $scale = int]) DESCRIPTION
Use the fast-exponentiation method to raise $left_operand to the power $right_operand with respect to the modulus $modulus. PARAMETERS
o $left_operand - The left operand, as a string. o $right_operand - The right operand, as a string. o $modulus - The modulus, as a string. o $ scale -This optional parameter is used to set the number of digits after the decimal place in the result. You can also set the global default scale for all functions by using bcscale(3). RETURN VALUES
Returns the result as a string, or NULL if $modulus is 0. NOTES
Note Because this method uses the modulus operation, numbers which are not positive integers may give unexpected results. EXAMPLES
The following two statements are functionally identical. The bcpowmod(3) version however, executes in less time and can accept larger parameters. <?php $a = bcpowmod($x, $y, $mod); $b = bcmod(bcpow($x, $y), $mod); // $a and $b are equal to each other. ?> SEE ALSO
bcpow(3), bcmod(3). PHP Documentation Group BCPOWMOD(3)

Check Out this Related Man Page

BCPOW(3)								 1								  BCPOW(3)

bcpow - Raise an arbitrary precision number to another

SYNOPSIS
string bcpow (string $left_operand, string $right_operand, [int $scale]) DESCRIPTION
Raise $left_operand to the power $right_operand. PARAMETERS
o $left_operand - The left operand, as a string. o $right_operand - The right operand, as a string. o $ scale -This optional parameter is used to set the number of digits after the decimal place in the result. You can also set the global default scale for all functions by using bcscale(3). RETURN VALUES
Returns the result as a string. EXAMPLES
Example #1 bcpow(3) example <?php echo bcpow('4.2', '3', 2); // 74.08 ?> NOTES
Note bcpow(3) may return a result with fewer digits after the decimal point than the $scale parameter would indicate. This only occurs when the result doesn't require all of the precision allowed by the $scale. For example: Example #2 bcpow(3) scale example <?php echo bcpow('5', '2', 2); // prints "25", not "25.00" ?> SEE ALSO
bcpowmod(3), bcsqrt(3). PHP Documentation Group BCPOW(3)
Man Page

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

bc calculate problem

Hi , this is the first time i use bc to calculate and i would have decimal result , i use the following : toto=400;scale=1 echo $toto / 1000|bc scale to adjust the numbers after the command would have in this case 0.4 as result and i wonder why i have always 0 as result. Somebody can... (2 Replies)
Discussion started by: Nicol
2 Replies

2. UNIX for Dummies Questions & Answers

Help in modulus operator in Bash

Hi, I would like to know given that i have two columns and I would like to take the positive integer of the differences between the two columns. which means |3-2|=1; |2-3|=1 as well. I would like to know do Bash recognize | | as well for this purposes? Thanks. -Jason (2 Replies)
Discussion started by: ahjiefreak
2 Replies

3. Shell Programming and Scripting

ModInverse in perl

Hi, I am trying to calculate inverse modulus of a mod n ie., a ^ -1 mod n. Is there a function in Perl that does this for me. If not, can someone help me with the code? Thanks in advance. Thanks, Sundeep. (0 Replies)
Discussion started by: eamani_sun
0 Replies

4. Shell Programming and Scripting

awk Division and modulus

I need to read the file divide 3 column with 2nd and run a modulus of 10 and check whether the remainder is zero or not if not print the entire line. cat filename | awk '{ if ($3 / $2 % 10 != 0) print $0}' Whats wrong with it ? (4 Replies)
Discussion started by: dinjo_jo
4 Replies

5. UNIX for Dummies Questions & Answers

Help on Modulus

Hello All, I am trying to do a simple calculation using modulus (%) as shown below. But some how it is not showing me correct result. It says "0.166667" is equal to "0" which is wrong. Could you please help me how can i make it work. Thanks a lot. #!/bin/ksh attempt_count=10 SLEEP=60... (7 Replies)
Discussion started by: Ariean
7 Replies

6. Shell Programming and Scripting

Script no conditionals

Hello, pro scripters, noob here, I am complete noob in this and I have to write a program which: Calculates the modulus of two numbers which the user enters with keyboard. Number interval 1-9. These two numbers that were entered and modulus which was calculated are stored in a separate file.... (1 Reply)
Discussion started by: IrmantasID
1 Replies