Download the PHP package scruoge/lib-fractions without Composer

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

lib-fractions

License: MIT PHP Version

A PHP library for precision mathematical calculations using rational numbers. This library operates on the rational domain, providing exact decimal representation without the precision loss inherent in floating-point arithmetic.

Features

Installation

Install via Composer:

Requirements

Quick Start

API Reference

Constructor Methods

create(int $significand, int $exponent = 0, int $denominator = 1): RationalExp

Creates a rational number with explicit components.

fromNumber(int|float $number, int $digits = -1, int $roundMode = PHP_ROUND_HALF_UP): RationalExp

Creates a rational number from an integer or float.

zero(): RationalExp and one(): RationalExp

Convenience methods for common values.

Arithmetic Operations

All arithmetic operations return a new RationalExp instance:

Utility Methods

equals(RationalExp $that): bool

Checks if two rational numbers are equal.

toFloat(): float

Converts the rational number to a float (may lose precision).

jsonSerialize(): array

Serializes the rational number for JSON encoding.

Advanced Usage

Working with Fractions

Precision Control

When converting from floats, you can control precision and rounding:

Financial Calculations

Perfect for monetary calculations where precision is crucial:

Development

Setup

Clone the repository and install dependencies:

Running Tests

Code Style

This project uses PHP-CS-Fixer for code formatting:

Project Structure

Use Cases

This library is particularly useful for:

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests (composer test)
  5. Fix code style (composer cs-fix)
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

Please ensure all tests pass and follow the existing code style.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Sergey N. Kruk - [email protected]


For more examples and detailed documentation, please refer to the test files in the test/ directory.


All versions of lib-fractions with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
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 scruoge/lib-fractions contains the following files

Loading the files please wait ...