Home PHP Libraries Other libraries PHP library for handling very large numbers
PHP library for handling very large numbers
<?php
namespace Moontoast\Math;
class BigNumberTest extends \PHPUnit_Framework_TestCase
{
    protected function setUp()
    {
        ini_set('bcmath.scale', 0);
    }
    /**
     * @covers Moontoast\Math\BigNumber::__construct
     * @covers Moontoast\Math\BigNumber::getValue
     * @covers Moontoast\Math\BigNumber::getScale
     * @covers Moontoast\Math\BigNumber::setValue
     * @covers Moontoast\Math\BigNumber::filterNumber
     * @covers Moontoast\Math\BigNumber::setDefaultScale
     */
    public function testConstruct()
    {
        $bn1 = new BigNumber('9,223,372,036,854,775,808');
        $this->assertSame('9223372036854775808', $bn1->getValue());
        $this->assertEquals(0, $bn1->getScale());
        $bn2 = new BigNumber(2147483647);
        $this->assertSame('2147483647', $bn2->getValue());
        $this->assertEquals(0, $bn2->getScale());

This is a PHP library for processing extremely large numbers. Friends who need it can download it and use it.

Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

Does PHP Offer a BigInteger Class for Large Integer Handling? Does PHP Offer a BigInteger Class for Large Integer Handling?

21 Oct 2024

BigInteger Class in PHPDoes PHP include a BigInteger class for handling large integers? If so, how is it accessed and utilized?Answer:While PHP does not natively include a BigInteger class, external libraries can provide this functionality. Two notab

What is the Most User-Friendly Form Validation Library for PHP with Comprehensive Features and Robust Error Handling? What is the Most User-Friendly Form Validation Library for PHP with Comprehensive Features and Robust Error Handling?

17 Oct 2024

Easiest Form Validation Library for PHPPHP boasts a plethora of validation libraries, each with its own strengths and weaknesses. To identify the ideal choice for your project, it's essential to consider factors such as simplicity, flexibility, and e

PHP example code for reading very large files PHP example code for reading very large files

08 Aug 2016

: This article mainly introduces the example code for reading very large files in PHP. Students who are interested in PHP tutorials can refer to it.

PHP encapsulation class sharing for quickly reading large CSV files line by line (also applicable to other very large text files)_PHP Tutorial PHP encapsulation class sharing for quickly reading large CSV files line by line (also applicable to other very large text files)_PHP Tutorial

13 Jul 2016

Sharing of encapsulation classes for PHP to quickly read large CSV files line by line (also applicable to other very large text files). The reading of large CSV files has been described before (code examples of PHP reading and processing large CSV files line by line), but there are still some problems in how to quickly and completely operate large files.

What Mechanisms Does PHP Provide for Handling Large Integers? What Mechanisms Does PHP Provide for Handling Large Integers?

21 Oct 2024

PHP's Built-in BigInteger ClassPHP offers built-in support for handling large-scale integers through the BigInteger class. This class provides efficient operations for manipulating integers beyond the typical integer range.Accessing the BigInteger Cl

Example code for reading very large files with PHP, _PHP tutorial Example code for reading very large files with PHP, _PHP tutorial

13 Jul 2016

Example code for reading very large files in PHP. PHP example code for reading very large files. The problem caused by the large amount of data is that a single file is very large. It is not easy to open this file. Don't count on Notepad, it will crash decisively. Go

See all articles