{"id":15642475,"url":"https://github.com/jordanrl/fermat","last_synced_at":"2025-08-20T16:31:10.920Z","repository":{"id":48699206,"uuid":"43982162","full_name":"JordanRL/Fermat","owner":"JordanRL","description":"A library providing math and statistics operations for numbers of arbitrary size.","archived":false,"fork":false,"pushed_at":"2023-12-18T23:27:57.000Z","size":10869,"stargazers_count":65,"open_issues_count":4,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-10T00:42:14.580Z","etag":null,"topics":["arbitrary-precision","bigint","biginteger","bignum","bignumber","complex-numbers","fermat","gaussian-distribution","math","matrices","matrix-calculations","matrix-functions","php","php8","poisson-distribution","precision","science","scientific-computations","statistics","trigonometry"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JordanRL.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":["JordanRL"]}},"created_at":"2015-10-09T22:00:01.000Z","updated_at":"2024-08-21T04:43:36.000Z","dependencies_parsed_at":"2023-12-26T23:25:16.172Z","dependency_job_id":null,"html_url":"https://github.com/JordanRL/Fermat","commit_stats":{"total_commits":620,"total_committers":5,"mean_commits":124.0,"dds":0.09193548387096773,"last_synced_commit":"52df632de7a62a975574cd4e1596fffd60ae30b5"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanRL%2FFermat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanRL%2FFermat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanRL%2FFermat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanRL%2FFermat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JordanRL","download_url":"https://codeload.github.com/JordanRL/Fermat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230438185,"owners_count":18225870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arbitrary-precision","bigint","biginteger","bignum","bignumber","complex-numbers","fermat","gaussian-distribution","math","matrices","matrix-calculations","matrix-functions","php","php8","poisson-distribution","precision","science","scientific-computations","statistics","trigonometry"],"created_at":"2024-10-03T11:56:22.458Z","updated_at":"2024-12-19T13:07:04.716Z","avatar_url":"https://github.com/JordanRL.png","language":"PHP","funding_links":["https://github.com/sponsors/JordanRL"],"categories":[],"sub_categories":[],"readme":"# Fermat\r\n\r\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/JordanRL/Fermat/tree/master.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/JordanRL/Fermat/tree/master) [![Test Coverage](https://api.codeclimate.com/v1/badges/ce0c5761a8f0d3d37cf2/test_coverage)](https://codeclimate.com/github/JordanRL/Fermat/test_coverage) [![Maintainability](https://api.codeclimate.com/v1/badges/ce0c5761a8f0d3d37cf2/maintainability)](https://codeclimate.com/github/JordanRL/Fermat/maintainability) [![Latest Stable Version](https://poser.pugx.org/samsara/fermat/v/stable)](https://packagist.org/packages/samsara/fermat) [![Total Downloads](https://poser.pugx.org/samsara/fermat/downloads)](https://packagist.org/packages/samsara/fermat) [![License](https://poser.pugx.org/samsara/fermat/license)](https://packagist.org/packages/samsara/fermat)\r\n\r\n**This project is unit tested against 8.1, and merges are not accepted unless the tests pass.**\r\n\r\n## Installation\r\n\r\nTo install, simply require the package using composer:\r\n\r\n    composer require \"samsara/fermat:^2.1\"\r\n    \r\nOr include it in your `composer.json` file:\r\n\r\n```json\r\n{\r\n    \"require\": {\r\n        \"samsara/fermat\": \"^2.1\"\r\n    }\r\n}\r\n```\r\n\r\nThe project namespace is `Samsara\\Fermat\\Core\\*`. You can view the project on [Packagist](https://packagist.org/packages/samsara/fermat).\r\n\r\n### Modules\r\n\r\nModules are the namespaces outside of `Samsara\\Fermat\\Core` and provide functionality beyond integer, decimal, and rational numbers.\r\n\r\nAll of these modules depend on the Core namespace, while some depend on each other to various degrees.\r\n\r\n- `Samsara\\Fermat\\Complex`: Provides complex number functionality. **NOTE:** Imaginary numbers are directly supported by `Core`. Complex numbers are numbers that have both a real part and an imaginary part.\r\n- `Samsara\\Fermat\\Coordinates`: Provides different coordinate systems that can be used to characterize points and their relations to each other.\r\n- `Samsara\\Fermat\\Expressions`: Provides various expressions, generally algebraic, that can be handled as a function instead of as a value.\r\n- `Samsara\\Fermat\\LinearAlgebra`: Provides for math involving matrices and vectors.\r\n- `Samsara\\Fermat\\Stats`: Provides for math involving statistics *and* probabilities.\r\n\r\n## Documentation\r\n\r\nThe `Samsara\\Fermat\\Core\\Numbers` factory class provides a way to use the Value classes in Fermat without being as specific as those classes may require. Consider the following code:\r\n\r\n```php\r\n\u003c?php\r\n\r\nuse Samsara\\Fermat\\Core\\Core\\Numbers;\r\n\r\n$five = Numbers::make(Numbers::IMMUTABLE, 5);\r\n$ten = Numbers::make(Numbers::IMMUTABLE, '10');\r\n\r\necho $five-\u003eadd($ten); // Prints: \"15\"\r\n```\r\n\r\nNote that the `make()` method allows you to provide both an int and a string as the value. In fact, it also allows you to provide a float. The first argument is the specific class that will be used for the value, the second argument is the value itself. The third and fourth arguments are optional and represent the scale (in number of decimal places) and the base of the number respectively. The scale and base arguments will only accept integer values.\r\n\r\nIf you do not specify a scale value, and you are using the default values, it automatically has a scale of either 10, or the string length of the input value, whichever is greater.\r\n\r\nHere is an example of using the factory method to make a value that is in a base other than base10:\r\n\r\n```php\r\n\u003c?php\r\n\r\nuse Samsara\\Fermat\\Core\\Core\\Numbers;\r\nuse Samsara\\Fermat\\Core\\Core\\Enums\\NumberBase;\r\n\r\n// Value in base5\r\n$five = Numbers::make(Numbers::IMMUTABLE, '10', null, NumberBase::Five); \r\n// Value in base10\r\n$ten = Numbers::make(Numbers::IMMUTABLE, '10'); \r\n\r\necho $ten-\u003eadd($five); // Prints: \"15\" (The sum in base10)\r\necho $five-\u003eadd($ten); // Prints: \"30\" (The sum in base5)\r\n```\r\n\r\nYou can also use a `Fraction` and `Number` together:\r\n\r\n```php\r\n\u003c?php\r\n\r\nuse Samsara\\Fermat\\Core\\Core\\Values\\ImmutableDecimal;\r\nuse Samsara\\Fermat\\Core\\Core\\Values\\ImmutableFraction;\r\n\r\n$five = new ImmutableDecimal(5);\r\n$oneQuarter = new ImmutableFraction(1, 4);\r\n\r\necho $five-\u003eadd($oneQuarter); // Prints: \"5.25\"\r\n// The asDecimal() method is called on $oneQuarter\r\n\r\necho $oneQuarter-\u003eadd($five); // Prints: \"21/4\"\r\n// Calls getValue() on $five and instantiates a new ImmutableFraction\r\n```\r\n\r\nYou can read the full documentation for Fermat [here](https://jordanrl.github.io/Fermat/).\r\n\r\n## Contributing\r\n\r\nPlease ensure that pull requests meet the following guidelines:\r\n\r\n- New files created in the pull request must have a corresponding unit test file, or must be covered within an existing test file.\r\n- Your merge may not drop the project's test coverage below 80%.\r\n- Your merge may not drop the project's test coverage by MORE than 5%.\r\n- Your merge must pass CI build tests for PHP 8.1.\r\n\r\nFor more information, please see the section on [Contributing](CONTRIBUTING.md)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjordanrl%2Ffermat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjordanrl%2Ffermat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjordanrl%2Ffermat/lists"}