Fixed length unsigned arithmetic emulation
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Anton Smirnov c43c42d13e Example in the readme 3 months ago
docs Document from/to dec 3 months ago
src from/to dec 3 months ago
tests from/to dec 3 months ago
.gitattributes ./gitattributes from template 3 months ago
.gitignore Documentation 9 months ago
.gitlab-ci.yml CI 9 months ago Changelog for 1.1.0 3 months ago Apply license 9 months ago Example in the readme 3 months ago
composer.json Stable code standard 3 months ago
phpcs.xml Update code style 9 months ago
phpunit.xml.dist Tests meta 9 months ago

Unsigned Arithmetic for PHP

Packagist PHP Packagist Gitlab pipeline status Codecov

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


composer require 'arokettu/unsigned'


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


Read full documentation here:

Also on Read the Docs:


Please file issues on our main repo at GitLab:


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