Speed up development with full-stack environments for every branch.

Learn More

Get modulus of an arbitrary precision number with bcmod() function [bcmath and php-bcmath]

23 Runs 66 Views 8 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

<?php

/**
 * BC Math
 * Get modulus of an arbitrary precision number with bcmod() function
 */
//dividing different sets of numbers
$result_1 = bcmod('8','10');
$result_2 = bcmod('10','8');
$result_3 = bcmod('10','0');

echo '<center>';
echo '<br /><div style="background-color:yellow;color:#000;padding:10px;width:500px;font-size:16px">
bcmod(left_operand,modulus) Returns the modulus as a string, or NULL if modulus is 0
</div><br />';
echo '<br /><div style="background-color:green;color:#fff;padding:10px;width:500px;font-size:16px">
bcmod("8","10") will output ' . $result_1 . '
</div><br />';
echo '<br /><div style="background-color:green;color:#fff;padding:10px;width:500px;font-size:16px">
bcmod("10","8") will output ' . $result_2 . '
</div><br />';
echo '<br /><div style="background-color:red;color:#fff;padding:10px;width:500px;font-size:16px">
bcmod("10","0") will output NULL
</div><br />';
echo '</center>';
?>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).