Download the PHP package hypetechpl/php-decimal without Composer

On this page you can find all versions of the php package hypetechpl/php-decimal. 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 php-decimal

An arbitrary-precision Decimal class type for PHP

Latest Version on Packagist

This library is similar to decimal.js, all business logic credits and copyrights go to Michael Mclaughlin and yours contributors.

The piggly/php-decimal is fully compatible with PHP and so fast as decimal.js library. See below all features attached to it.

Features

This library is mainly composed by Decimal class. A Decimal is composed by coefficients, exponent and sign. It can handle integer and float values with an arbitrary-precision.

Here precision is specified in terms of significant digits rather than decimal places, and all calculations are rounded to the precision (similar to Python's decimal module) rather than just those involving division.

This library also adds the trigonometric functions, among others, and supports non-integer powers, which makes it a significantly larger library.

Usage

Decimal can handle integers, floats, strings and Decimal objects:

A value can also be in binary, hexadecimal or octal if the appropriate prefix is included:

A Decimal is immutable in the sense that it is not changed by its methods, always returning a new object.

All methods which returns Decimal values can be chained.

Many method names have a shorter alias.

There are many ways to convert a Decimal to an string,

and almost all methods are available as static.

Decimal can handle with INF and NAN values.

There are many methods to do any checks to Decimal.

By the way, there is a toFraction method with an optional maximum denominator argument.

All calculations are rounded according to the number of significant digits and rounding mode specified by the precision and rounding properties of the DecimalConfig object.

Each Decimal class is associated to a DecimalConfig. It may be the global configuration, or a custom configuration to that specific decimal number.

For advanced usage, multiple Decimal can be created, each with their own independent configuration which applies to all Decimal numbers created from it.

The value of a Decimal object is stored in a floating point format in terms of its digits, exponent and sign.

For further information see the decimal.js API since this library is fully compatible with it.

Installation

Composer

  1. At you console, in your project folder, type composer require piggly/php-decimal;
  2. Don't forget to add Composer's autoload file at your code base require_once('vendor/autoload.php);.

Manual install

  1. Download or clone with repository with git clone https://github.com/piggly-dev/php-decimal.git;
  2. After, goes to cd /path/to/piggly/php-decimal;
  3. Install all Composer's dependencies with composer install;
  4. Add project's autoload file at your code base require_once('/path/to/piggly/php-decimal/vendor/autoload.php);.

Dependencies

The library has the following external dependencies:

TODO

In code, there annotations @todo with some improvements that this library may need.

Changelog

See the CHANGELOG file for information about all code changes.

Testing the code

This library uses the PHPUnit. We carry out tests of all the main classes of this application.

You must always run tests with PHP 7.3 and greater. Any changes at this library need to pass of all oldest and newests tests.

!! Some tests are heavy, be careful while testing them, they may require huge memory available.

Contributions

See the CONTRIBUTING file for information before submitting your contribution.

Credits

decimal.js

Support the project

Piggly Studio is an agency located in Rio de Janeiro, Brazil. If you like this library and want to support this job, be free to donate any value to BTC wallet 3DNssbspq7dURaVQH6yBoYwW3PhsNs8dnK ❤.

License

MIT License (MIT). See LICENSE.


All versions of php-decimal with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || 8.0 || ^8.3
ext-bcmath Version ^7.3 || ^8.3
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 hypetechpl/php-decimal contains the following files

Loading the files please wait ....