{"id":29562394,"url":"https://github.com/pronamic/wp-number","last_synced_at":"2025-07-18T17:37:12.868Z","repository":{"id":57045204,"uuid":"346015458","full_name":"pronamic/wp-number","owner":"pronamic","description":"WordPress Number library.","archived":false,"fork":false,"pushed_at":"2024-12-17T12:49:33.000Z","size":187,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-30T16:52:45.335Z","etag":null,"topics":["calculator","decimal","floating-point","i18n","library","number","php","wordpress"],"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/pronamic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2021-03-09T13:28:01.000Z","updated_at":"2024-12-17T12:49:35.000Z","dependencies_parsed_at":"2024-06-07T13:03:05.171Z","dependency_job_id":"bdf698ed-f074-44a2-936e-0ee83f8fe3d5","html_url":"https://github.com/pronamic/wp-number","commit_stats":{"total_commits":105,"total_committers":3,"mean_commits":35.0,"dds":"0.17142857142857137","last_synced_commit":"d458eb39b216fb9e61b4ddbca8db52897f81e24e"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/pronamic/wp-number","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pronamic%2Fwp-number","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pronamic%2Fwp-number/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pronamic%2Fwp-number/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pronamic%2Fwp-number/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pronamic","download_url":"https://codeload.github.com/pronamic/wp-number/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pronamic%2Fwp-number/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265086514,"owners_count":23709321,"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":["calculator","decimal","floating-point","i18n","library","number","php","wordpress"],"created_at":"2025-07-18T17:37:12.216Z","updated_at":"2025-07-18T17:37:12.855Z","avatar_url":"https://github.com/pronamic.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003ePronamic WordPress Number\u003c/h3\u003e\n\n\u003cp align=\"center\"\u003e\n\tWordPress Number library.\n\u003c/p\u003e\n\n[![Latest Stable Version](http://poser.pugx.org/pronamic/wp-number/v)](https://packagist.org/packages/pronamic/wp-number)\n[![Total Downloads](http://poser.pugx.org/pronamic/wp-number/downloads)](https://packagist.org/packages/pronamic/wp-number)\n[![Latest Unstable Version](http://poser.pugx.org/pronamic/wp-number/v/unstable)](https://packagist.org/packages/pronamic/wp-number)\n[![License](http://poser.pugx.org/pronamic/wp-number/license)](https://packagist.org/packages/pronamic/wp-number)\n[![codecov](https://codecov.io/gh/pronamic/wp-number/branch/main/graph/badge.svg?token=NB3B1FS1CP)](https://codecov.io/gh/pronamic/wp-number)\n[![Coverage Status](https://coveralls.io/repos/github/pronamic/wp-number/badge.svg?branch=main)](https://coveralls.io/github/pronamic/wp-number?branch=main)\n\n## Table of contents\n\n- [Getting Started](#getting-started)\n- [Usage](#usage)\n- [Design Principles](#design-principles)\n\n## Getting Started\n\n### Installation\n\n```\ncomposer require pronamic/wp-number\n```\n\n## Usage\n\n```\n$number = Number::from_float( 123.50 )-\u003eadd( 0.45 );\n\necho \\esc_html( $number-\u003eformat_i18n( 2 ) );\n```\n\n## Design Principles\n\n### A number is a number\n\n\u003e In general, a number is a number, not a string, and this means that any programming language treats a number as a number. Thus, the number by itself doesn't imply any specific format (like using .000021 instead of 2.1e-5). This is nothing different to displaying a number with leading zeros (like 0.000021) or aligning lists of numbers. This is a general issue you'll find in any programming language: if you want a specific format you need to specify it, using the format functions of your programming language.\n\u003e \n\u003e Unless you specify the number as string and convert it to a real number when needed, of course. Some languages can do this implicitly.\n\nhttps://stackoverflow.com/a/1471792\n\n### Number in exponential form / scientific notation\n\n\u003e 2.1E-5 is the same number as 0.000021. That's how it prints numbers below 0.001. Use printf() if you want it in a particular format.\n\u003e \n\u003e **Edit** If you're not familiar with the `2.1E-5` syntax, you should know it is shorthand for 2.1×10-5. It is how most programming languages represent numbers in scientific notation.\n\nhttps://stackoverflow.com/a/1471694\n\n### Leading zeros\n\nIn https://github.com/moneyphp/money it is not allowed to use leading zeros:\n\n\u003e Leading zeros are not allowed\n\n_Source:_ https://github.com/moneyphp/money/search?q=leading+zero\n\nThis probably has somehting to do with the following user note:\n\n\u003e Be careful with GMP - it considers leading zeros in a number string as meaning the number is in octal, whereas 'bc' doesn't:\n\u003e\n\u003e `gmp_strval(\"000100\", 10) =\u003e 64`\n\u003e\n\u003e `bcmul(\"000100\", \"1\") =\u003e 100`\n\n_Source:_ https://www.php.net/manual/en/book.gmp.php#106521\n\n```php\n\u003c?php\n$a = 1234; // decimal number\n$a = 0123; // octal number (equivalent to 83 decimal)\n$a = 0x1A; // hexadecimal number (equivalent to 26 decimal)\n$a = 0b11111111; // binary number (equivalent to 255 decimal)\n$a = 1_234_567; // decimal number (as of PHP 7.4.0)\n?\u003e\n```\n\n_Source:_ https://www.php.net/manual/en/language.types.integer.php\n\n\u003e A leading zero in a numeric literal means \"this is octal\". But don't be confused: a leading zero in a string does not. Thus:\n\u003e `$x = 0123;          // 83`\n\u003e `$y = \"0123\" + 0     // 123`\n\n_Source:_ https://www.php.net/manual/en/language.types.integer.php#111523\n\n## Links\n\n- https://0.30000000000000004.com/\n\n[![Pronamic - Work with us](https://github.com/pronamic/brand-resources/blob/main/banners/pronamic-work-with-us-leaderboard-728x90%404x.png)](https://www.pronamic.eu/contact/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpronamic%2Fwp-number","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpronamic%2Fwp-number","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpronamic%2Fwp-number/lists"}