{"id":20744216,"url":"https://github.com/021-projects/numeric","last_synced_at":"2026-03-03T19:03:12.304Z","repository":{"id":225014499,"uuid":"764858318","full_name":"021-projects/numeric","owner":"021-projects","description":null,"archived":false,"fork":false,"pushed_at":"2026-02-14T01:37:42.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-14T08:32:14.848Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/021-projects.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-02-28T20:51:35.000Z","updated_at":"2026-02-14T01:37:46.000Z","dependencies_parsed_at":"2024-02-28T21:47:14.788Z","dependency_job_id":"26b5e061-546a-45db-b694-a6a6d7334bd2","html_url":"https://github.com/021-projects/numeric","commit_stats":null,"previous_names":["021-projects/numeric"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/021-projects/numeric","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fnumeric","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fnumeric/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fnumeric/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fnumeric/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/021-projects","download_url":"https://codeload.github.com/021-projects/numeric/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/021-projects%2Fnumeric/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30056056,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T18:21:05.932Z","status":"ssl_error","status_checked_at":"2026-03-03T18:20:59.341Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-17T07:14:43.140Z","updated_at":"2026-03-03T19:03:12.281Z","avatar_url":"https://github.com/021-projects.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 021/numeric\n\nA PHP library to convenient work with arbitrary precision numbers.\n\u003cp\u003e\n\u003ca href=\"https://github.com/021-projects/numeric/actions/workflows/tests-php-8.1.yml\"\u003e\u003cimg src=\"https://github.com/021-projects/numeric/actions/workflows/tests-php-8.1.yml/badge.svg?branch=main\" alt=\"Tests\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/021/numeric\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/021/numeric\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/021/numeric\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/021/numeric\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/021/numeric\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/021/numeric\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Requirements\n\n- PHP 8.1 or higher\n\nLibrary is based on [Brick\\Math](https://github.com/brick/math) package:\n\u003e Although the library can work seamlessly on any PHP installation, it is highly recommended that you install the [GMP](https://www.php.net/manual/en/book.gmp.php) or [BCMath](https://www.php.net/manual/en/book.bc.php) extension to speed up calculations. The fastest available calculator implementation will be automatically selected at runtime.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require 021/numeric\n```\n\n## Usage\n\n```php\nuse function O21\\Numeric\\Helpers\\num;\n\n$number = num('123.456');\n\necho $number-\u003eadd('0.544')-\u003eget();\n```\n\n### Calculations\n\nAll computational functions accept as an argument a value of one of the following\ntypes: `string`, `float`, `int`, `\\O21\\Numeric\\Numeric`, `\\Brick\\Math\\BigNumber`.\n\n| Function | Description                     |\n|----------|---------------------------------|\n| `add`    | Adds a value to a number        |\n| `sub`    | Subtracts a value from a number |\n| `mul`    | Multiplies a number by a value  |\n| `div`    | Divides a number by a value     |\n\n### Comparisons\n\nAll comparison functions accept as an argument a value of one of the following\ntypes: `string`, `float`, `int`, `\\O21\\Numeric\\Numeric`, `\\Brick\\Math\\BigNumber`.\n\n| Function             | Description                                                                                         |\n|----------------------|-----------------------------------------------------------------------------------------------------|\n| `equals`             | Checks if two values are equal. It returns true if the values are equal and false otherwise.        |\n| `greaterThan`        | Compares two values and returns true if the first value is greater than the second one.             |\n| `lessThan`           | Compares two values and returns true if the first value is less than the second one.                |\n| `greaterThanOrEqual` | Compares two values and returns true if the first value is greater than or equal to the second one. |\n| `lessThanOrEqual`    | Compares two values and returns true if the first value is less than or equal to the second one.    |\n\n### Formatting\n\n| Function     | Description                                                                                                |\n|--------------|------------------------------------------------------------------------------------------------------------|\n| `positive`   | Returns a number represented as positive.                                                                  |\n| `negative`   | Returns a number represented as negative.                                                                  |\n| `scale`      | Converts a number to a  given scale, using rounding if necessary.                                          |\n| `get`        | Returns a number as string. By default removes trailing zeros. Use the `raw: true` option to disable this. |\n| `__toString` | Returns a `get` function result                                                                            |\n\n### Helpers\n\nNamespace: `O21\\Numeric\\Helpers`\n\n| Function  | Description                                                                                                                                        |\n|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `num`     | Creates a new `Numeric` instance                                                                                                                   |\n| `num_min` | Returns a minimum value from a given values. Support any of these types: `string`, `float`, `int`, `\\O21\\Numeric\\Numeric`, `\\Brick\\Math\\BigNumber` |\n| `num_max` | Returns a maximum value from a given values. Support any of these types: `string`, `float`, `int`, `\\O21\\Numeric\\Numeric`, `\\Brick\\Math\\BigNumber` |\n| `to_bn`   | Converts any of these types `string`, `float`, `int`, `\\O21\\Numeric\\Numeric`, `\\Brick\\Math\\BigNumber` to `\\Brick\\Math\\BigNumber`                   |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F021-projects%2Fnumeric","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F021-projects%2Fnumeric","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F021-projects%2Fnumeric/lists"}