PHPBignum
Added functionallities
PHP를위한 Bignum 라이브러리.
| 유형 | 덧셈 | 빼기 | 분할 | 곱셈 | 제곱근 | 힘 |
|---|---|---|---|---|---|---|
| 큰 | 완료 | 완료 | 완료 | 완료 | 완료 | 완료 |
| Bigfloat | 완료 | 완료 | 완료 | 완료 | 완료 | 완료 |
프로젝트를 복제하고 프로젝트 디렉토리로 이동하여 composer install 실행하면 잘해야합니다! 오, 또한 테스트를 실행하려면 vendor/phpunit/phpunit/phpunit tests/ 수행해야합니다.
패키지는 composer require hpez/php-bignum
<?php
// BigInteger Addition
$ bigInt1 = new BigInt( ' 123456 ' )
$ bigInt2 = new BigInt ( ' 654321 ' );
$ bigInt1 -> add ( $ bigInt2 );
echo $ bigInt1 ; // "777777"
// BigFloat Addition
$ bigFloat1 = new BigFloat ( ' 123456.111 ' );
$ bigFloat2 = new BigFloat ( ' 654321.22 ' );
$ bigFloat1 -> add ( $ bigFloat2 )
echo $ bigFloat1 ; // "777777.331"
// BigInteger Subtraction
$ bigInt3 = new BigInt ( ' 777777 ' );
$ bigInt4 = new BigInt ( ' 654321 ' );
$ bigInt3 -> sub ( $ bigInt4 );
echo $ bigInt3 ; // "123456"
// BigFloat Subtraction
$ bigFloat3 = new BigFloat ( ' 123456.111 ' );
$ bigFloat4 = new BigFloat ( ' 654321.22 ' );
$ bigFloat3 -> sub ( $ bigFloat4 );
echo $ bigFloat3 ; // results "530865.109"
// BigInteger Division
$ bigInt5 = new BigInt ( ' 777777 ' );
$ bigInt6 = new BigInt ( ' 654321 ' );
$ bigInt5 -> div ( $ bigInt6 );
echo $ bigInt5 ; // "1"
// BigFloat Division
$ bigFloat5 = new BigFloat ( ' 123456.111 ' );
$ bigFloat6 = new BigFloat ( ' 654321.22 ' );
$ bigFloat5 -> div ( $ bigFloat6 );
echo $ bigFloat5 ; // "0.188678"
// BigInteger Multiplication
$ bigInt7 = new BigInt ( ' 777777 ' );
$ bigInt8 = new BigInt ( ' 654321 ' );
$ bigInt7 -> multiply ( $ bigInt8 );
echo $ bigInt7 ; // "508915824417"
// BigFloat Multiplication
$ bigFloat7 = new BigFloat ( ' 123456.111 ' );
$ bigFloat8 = new BigFloat ( ' 654321.22 ' );
$ bigFloat7 -> multiply ( $ bigFloat8 );
echo $ bigFloat7 ; // "80779953165.97542"
// BigInteger Modulo
$ bigInt9 = new BigInt ( ' 777777 ' );
$ bigInt10 = new BigInt ( ' 654321 ' );
$ bigInt9 -> mod ( $ bigInt10 );
echo $ bigInt9 ; // "123456"
// BigInteger Power
$ bigInt11 = new BigInt ( ' 777777 ' );
$ bigInt12 = new BigInt ( ' 1 ' );
$ bigInt11 -> pow ( $ bigInt12 );
echo $ bigInt11 ; // "777777"
// BigFloat Power
$ bigFloat9 = new BigFloat ( ' 12345.12345 ' );
$ bigInt13 = new BigInt ( ' 3 ' );
$ bigFloat9 -> pow ( $ bigInt13 );
echo $ bigFloat9 // "1881422405168.320420453463625"
// BigInteger Square Root
$ bigInt14 = new BigInt ( ' 10000 ' );
$ bigInt15 -> sqrt ();
echo $ bigInt14 ; // "100"
// BigFloat Square Root
$ bigFloat10 = new BigFloat ( ' 2 ' );
$ bigFloat11 -> sqrt ( 7 );
echo $ bigFloat10 ; // "1.4142136"
// BigInteger Lesser-Than
$ bigInt16 = new BigInt ( ' 1234567890 ' );
$ bigInt17 = new BigInt ( ' 1234567891 ' );
echo $ bigInt16 -> isLesserThan ( $ bigInt17 ); // True
$ bigInt18 = new BigInt ( ' 1234567891 ' );
$ bigInt19 = new BigInt ( ' 1234567891 ' );
echo $ bigInt18 -> isLesserThan ( $ bigInt19 ); // False
// BigInteger Bigger-Than
$ bigInt20 = new BigInt ( ' 1234567891 ' );
$ bigInt21 = new BigInt ( ' 1234567890 ' );
echo $ bigInt20 -> isBiggerThan ( $ bigInt21 ); // True
$ bigInt22 = new BigInt ( ' 1234567891 ' );
$ bigInt23 = new BigInt ( ' 1234567891 ' );
echo $ bigInt22 -> isBiggerThan ( $ bigInt23 ); // False 이 프로젝트의 목표는 PHP 언어를위한 완전한 Bignum 라이브러리를 만드는 것이므로 표에 언급 된 작업 이외의 작업도 추가해야합니다 (Trigonometric Functions, ...).
문제 또는 풀 요청 형태의 모든 기여는 환영받는 것 이상입니다! 또한 궁금한 점이 있으시면 기존 문제에 대한 새로운 이슈를 만들거나 의견을 제시하십시오.