search
HomePHP LibrariesOther librariesPHP 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?

21Oct2024

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?

17Oct2024

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 Streams: Efficient Data Handling for Large FilesPHP Streams: Efficient Data Handling for Large Files

08Dec2024

Topics: PHP Streams, File Handling in PHP, Large Dataset Processing, CSV Processing, PHP Performance Optimization Table of Contents Introduction Overview of PHP Streams Benefits of Using Streams Hands-On Example with Part-by

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

21Oct2024

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

How Can I Optimize PHP for Handling Large File Uploads?How Can I Optimize PHP for Handling Large File Uploads?

06Nov2024

Fine-Tuning PHP for Large File UploadsUploading hefty files over 500MB can pose a challenge, and PHP configurations play a crucial role in...

How Can I Optimize My Number Theoretic Transform (NTT) and Modular Arithmetic for Fast Squaring of Very Large Numbers?How Can I Optimize My Number Theoretic Transform (NTT) and Modular Arithmetic for Fast Squaring of Very Large Numbers?

18Dec2024

Modular arithmetics and NTT (finite field DFT) optimizationsProblem: I wanted to use NTT for fast squaring (see Fast bignum square...

See all articles