No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

bcpow

(PHP 4, PHP 5, PHP 7)

bcpowRaise an arbitrary precision number to another

Description

bcpow ( string $base , string $exponent [, int $scale = 0 ] ) : string

Raise base to the power exponent.

PHP: bcpow - Manual Home of Manuel PHP  Contents Haut

Parameters

base

The base, as a string.

exponent

The exponent, as a string. If the exponent is non-integral, it is truncated. The valid range of the exponent is platform specific, but is at least -2147483648 to 2147483647.

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: bcpow - Manual Home of Manuel PHP  Contents Haut

Return Values

Returns the result as a string.

PHP: bcpow - Manual Home of Manuel PHP  Contents Haut

Changelog

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

PHP: bcpow - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 bcpow() example

<?php

echo bcpow('4.2''3'2); // 74.08

?>

PHP: bcpow - Manual Home of Manuel PHP  Contents Haut

Notes

Note:

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

<?php
echo bcpow('5''2'2);     // prints "25", not "25.00"
?>

PHP: bcpow - Manual Home of Manuel PHP  Contents Haut

See Also

  • bcpowmod() - Raise an arbitrary precision number to another, reduced by a specified modulus
  • bcsqrt() - Get the square root of an arbitrary precision number

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-bcpow.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