Home > Backend Development > PHP Problem > bcsub is a php extension

bcsub is a php extension

藏色散人
Release: 2023-03-08 19:14:02
Original
1845 people have browsed it

bcsub is not an extension of PHP, but a built-in function in PHP. The bcsub function accepts two arbitrary precision numbers as strings and returns the subtraction of the two numbers after scaling the result to the specified precision.

bcsub is a php extension

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

The bcsub() function in PHP is a built-in function , used to subtract one arbitrary-precision number from another. This function accepts two arbitrary-precision numbers as strings and returns the subtraction of the two numbers after scaling the result to the specified precision.

bcsub — Subtraction of 2 arbitrary-precision numbers

Description

bcsub ( string $left_operand , string $right_operand [, int $scale = int ] ) : string
Copy after login

Subtract the right operand from the left operand.

Parameter

left_operand
Copy after login

The left operand of string type.

right_operand
Copy after login

The right operand of string type.

scale
Copy after login

This optional parameter is used to set the decimal point after the decimal point in the result. Number of decimal places. You can also set a global default number of decimal places for all functions by using bcscale().

Return value

Return the result after subtraction to the string type.

Example

<?php
$a = &#39;1.234&#39;;
$b = &#39;5&#39;;
echo bcsub($a, $b);     // -3
echo bcsub($a, $b, 4);  // -3.7660
?>
Copy after login

Recommended study: " PHP video tutorial

The above is the detailed content of bcsub is a php extension. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template