Rechercher une fonction PHP

bcmul

(PHP 4, PHP 5, PHP 7)

bcmulMultiply two arbitrary precision numbers

Description

bcmul ( string $left_operand , string $right_operand [, int $scale = 0 ] ) : string

Multiply the left_operand by the right_operand.

PHP: bcmul - Manual Home of Manuel PHP  Contents Haut

Parameters

left_operand

The left operand, as a string.

right_operand

The right operand, as a string.

scale

This optional parameter is used to set the number of digits after the decimal place in the result. If omitted, it will default to the scale set globally with the bcscale() function, or fallback to 0 if this has not been set.

PHP: bcmul - Manual Home of Manuel PHP  Contents Haut

Return Values

Returns the result as a string.

PHP: bcmul - Manual Home of Manuel PHP  Contents Haut

Changelog

Version Description
7.3.0 bcmul() now returns numbers with the requested scale. Formerly, the returned numbers may have omitted trailing decimal zeroes.

PHP: bcmul - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 bcmul() example

<?php
echo bcmul('1.34747474747''35'3); // 47.161
echo bcmul('2''4'); // 8
?>

PHP: bcmul - Manual Home of Manuel PHP  Contents Haut

Notes

Note:

Before PHP 7.3.0 bcmul() 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 bcmul() scale example

<?php
echo bcmul('5''2'2);     // prints "10", not "10.00"
?>

PHP: bcmul - Manual Home of Manuel PHP  Contents Haut

See Also

  • bcdiv() - Divide two arbitrary precision numbers

Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-function.bcmul.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut