
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
PHP – How to set or get the default scale parameter for all bc math functions using bcscale() function?
In PHP, bcscale() function is used to set the default parameter for all bc math functions. This function sets the default scale parameter for all following calls to the bc math functions that do not explicitly specify a scale parameter.
Syntax
int bcscale($scale)
Parameters
The $bcscale() parameter accepts only a single parameter and it is the mandatory integer type parameter. This parameter shows the number of digits which come after the decimal. Its default value is 0.
Return Value
The $bcscale() function returns the old scale value.
Example 1
<?php // default scale : 5 bcscale(5); // The default scale value as 5 echo bcadd('107', '6.5596'), "
"; // this is not the same without bcscale() echo bcadd('107', '6.55957', 1), "
"; // the default scale value as 5 echo bcadd('107', '6.55957'), "
"; ?>
Output
113.55960 113.5 113.55957
Example 2
<?php // set default scale 5 bcscale(5); // set the default scale value as 5 echo bcadd('107', '6.5596'), "
"; // this is not the same without bcscale() echo bcadd('107', '6.55957', 1), "
"; // Changed the default scale value bcscale(3); // the default scale value as 5 echo bcadd('107', '6.55957'), "
"; ?>
Output
113.55960 113.55 113.559
- Related Articles
- How to set a default parameter value for a JavaScript function?
- How to set default parameter values to a function in Python?
- How to get or set the resolution of an image using imageresolution() function in PHP?
- How to set the style for line drawing using imagesetstyle() function in PHP?
- How to set the tile image for filling using imagesettile() function in PHP?
- How to check antialias functions be used or not by using imageantialias() function in PHP?
- How to set the image thickness for line drawing using imgesetthickness() function in PHP?
- PHP – How to get or set the path of a domain?
- How to set same scale for subplots in Python using Matplotlib?
- How to get the clipping rectangle using imagegetclip() function in PHP?
- PHP – Set the current setting for character encoding conversion using iconv_set_encoding() function
- How to get resource ID using get_resource_id() function in PHP and PHP 8?
- How to set a single pixel using imagesetpixel() function in PHP?
- How can I set the default value of my Tkinter Scale widget slider to 100?
- How to get a list of parameter names inside Python function?

Advertisements