Fixed length unsigned arithmetic emulation
Go to file
Anton Smirnov db1995f4cd Changelog for 1.2.1 2023-09-05 01:47:38 +03:00
docs Fix invalid type in docs 2023-07-08 02:01:29 +03:00
src Fix multiplication of corrupted values in case of int overflow 2023-09-05 01:41:25 +03:00
tests Overflow regression 2023-09-05 01:40:30 +03:00
.gitattributes Update rtd config 2023-07-08 01:54:21 +03:00
.gitignore Documentation 2022-09-01 00:46:13 +03:00
.gitlab-ci.yml GMP is not used here 2023-09-05 01:05:51 +03:00
.readthedocs.yaml Update rtd config 2023-07-08 01:54:21 +03:00
CHANGELOG.md Changelog for 1.2.1 2023-09-05 01:47:38 +03:00
LICENSE.md Apply license 2022-08-26 02:29:45 +03:00
README.md Example in the readme 2023-03-10 00:27:22 +02:00
composer.json Stable code standard 2023-02-22 22:28:06 +02:00
phpcs.xml Update code style 2022-09-15 03:54:20 +03:00
phpunit.xml.dist Tests meta 2022-08-26 11:05:06 +03:00

README.md

Unsigned Arithmetic for PHP

Packagist PHP Packagist Gitlab pipeline status Codecov

The lib was created as a helper for the random-polyfill.

Installation

composer require 'arokettu/unsigned'

Example

<?php
use Arokettu\Unsigned as u;
$a = u\from_int(1234567890123456789, 24);
$b = u\from_hex('123456789abcdef01234567890abcdef', 24);
// 1234567890123456789 * 0x123456789abcdef01234567890abcdef =
$c = u\mul($a, $b);
var_dump(u\to_dec($c)); // 29873897512945703720213152879288233401251320475301467035

Documentation

Read full documentation here: https://sandfox.dev/php/unsigned.html

Also on Read the Docs: https://php-unsigned.readthedocs.io/

Support

Please file issues on our main repo at GitLab: https://gitlab.com/sandfox/unsigned/-/issues

License

The library is available as open source under the terms of the 2-Clause BSD License.