Download the PHP package mpd/util-strint-cmp without Composer

On this page you can find all versions of the php package mpd/util-strint-cmp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package util-strint-cmp

StringInt Comparator

mpd\Util\StrIntCmp
Packagist Version Packagist Dependency Version GitHub License

Library to compare large integers with arbitrary precisions, provides own pure php implementation, but can also use bcmath or GMP on background when available

Installation

composer require mpd/util-strint-cmp
Compatible ^php7.1, ^php8. Tests require php8

Usage

For performance reasons valid integer strings are assumed and no additional validation is done, it's your responsibility to provide valid format [+-]?[0-9]+. You can use isValidInt() to check if you cant be sure. invalid integers are basically undefined behaviour.
Yes + prefixed numbers are handled correctly too.
Note -0 is considered UB, depending on backend -0 == 0 or -0 < 0

Motivation

We have been in need to compare large numbers with arbitrary precision anywhere, which is problematic on some hostings, and problems starts earlier than you might think.

platform (64bit scope)
When host system is 32bit php int is to, larger numbers silently become floats which sometimes results in incorrect results

polyfill
you can easily solve this by using libraries like bcmath or gmp... but these are not written in php, they are php extensions which needs to be installed physically in the system, and most standard web hosting dost let you touch that, they are sometimes available, but you need to modify your code depending on which one is available and sometimes there is none.
This library isolates you from this, you just call compare method, and receive result. It has its own pure php implementation, but prefers to use gmp/bcmath when available for better performance.

writing new
Research for similar library wasn't much successful, few pure php math implementations was found, but they usually looks abandoned since php5 was new and tends to be very large, and also don't act as "polyfill"

only comparators?
Idea of universal polyfill is tempting, but currently there is no need for more functionality rather for things being quickly done, and it also allows this lib to be small.
On internal or even external request it might become reality.
But anyway if you're doing that sensitive operations maybe you should look for better hosting that provides php extension.

Testing

composer run test
Test set is mainly based on random asserts generated by gen.py <no of tests>. Note due to how phpunit works, is not recommended creating more than about 500k asserts. this already takes quite long and requires nearly 4gb of ram for some reason. These generated tests are not included for size reasons. generate your own by running script, which also results in better testing. if you found values that don't work correctly send them to us please.
Recommendations for some critical values welcomed.


All versions of util-strint-cmp with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mpd/util-strint-cmp contains the following files

Loading the files please wait ....