BC Math Binary Calculator

suggest change

Introduction

BCMath calculates with numbers of any size, passed as strings. The scale argument is the number of digits after the decimal point. It is exact decimal arithmetic, unlike PHP's binary floats.

Syntax

Parameters

bcadd | Add two arbitrary precision numbers. |
— | — |left_operand | The left operand, as a string. |right_operand | The right operand, as a string. |scale | An optional parameter to set the number of digits after the decimal place in the result. |bccomp | Compare two arbitrary precision numbers. |left_operand | The left operand, as a string. |right_operand | The right operand, as a string. |scale | An optional parameter to set the number of digits after the decimal place which will be used in the comparison.|bcdiv | Divide two arbitrary precision numbers. |left_operand | The left operand, as a string. |right_operand | The right operand, as a string. |scale | An optional parameter to set the number of digits after the decimal place in the result. |bcmod | Get modulus of an arbitrary precision number. |left_operand | The left operand, as a string. |modulus | The modulus, as a string. |bcmul | Multiply two arbitrary precision numbers. |left_operand | The left operand, as a string. |right_operand | The right operand, as a string. |scale | An optional parameter to set the number of digits after the decimal place in the result. |bcpow | Raise an arbitrary precision number to another. |left_operand | The left operand, as a string. |right_operand | The right operand, as a string. |scale | An optional parameter to set the number of digits after the decimal place in the result. |bcpowmod | Raise an arbitrary precision number to another, reduced by a specified modulus. |left_operand | The left operand, as a string. |right_operand | The right operand, as a string. |modulus | The modulus, as a string. |scale | An optional parameter to set the number of digits after the decimal place in the result. |bcscale | Set default scale parameter for all bc math functions. |scale | The scale factor. |bcsqrt | Get the square root of an arbitrary precision number. |operand | The operand, as a string. |scale | An optional parameter to set the number of digits after the decimal place in the result. |bcsub | Subtract one arbitrary precision number from another. |left_operand | The left operand, as a string.|right_operand |The right operand, as a string. |scale | An optional parameter to set the number of digits after the decimal place in the result. |

Remarks

If you omit scale, BCMath uses the current scale. That scale starts at 0, so results are integral until bcscale() changes it. bcmod() does not take a scale.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents