Name | precnumber JSON |
Version |
0.0.1
JSON |
| download |
home_page | |
Summary | Precise Numbers |
upload_time | 2023-08-27 22:26:16 |
maintainer | |
docs_url | None |
author | Pierre Quereuil |
requires_python | |
license | |
keywords |
python
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
## Float Point Arithmetic is Imprecise
Many new python coders will be frustrated at the seemingly nonsensical way the language handles floating point numbers: even operations as simple as 0.1 + 0.2 should be easy to compute, right? Turns out floating point number storage yields many issues, and many minds smarter than me decided imprecision is better than storage and processing cost. The idea of this project is to invert that notion, storing floating point numbers as ratios.
```python
0.1 + 0.2 == 0.3 #True
Number.parse("0.1") + Number.parse("0.2") == Number.parse("0.3") #False
Number.parse("0.92") / Number.parse("245") #23/6125
```
## Operation Examples
This library provides all basic arithmetic operations needed for numbers: addition, substration, multiplication, and division, as well as helper functions such as floor, ceil, opposite, inverse, and the equality operator.
```python
Number.parse("3.2") + Number.parse("4.7") #79/10
Number.parse("9.21") - Number.parse("18.45") #231/-25
Number.parse("1.6") * Number.parse("2.4") #96/25
Number.parse("1.4") / Number.parse("3.3") #14/33
Number.parse("1.5") == Number(3, 2) #True
Number.parse("3.4").floor() #3
Number.parse("0.2").ceil() #1
Number.parse("-3").opposite() #3
Number.parse("0.5").inverse() #2
```
Raw data
{
"_id": null,
"home_page": "",
"name": "precnumber",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python",
"author": "Pierre Quereuil",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/a9/61/83b85e297068a029151eed49a3bd068a36659f042217bd83fccf8cdaa40e/precnumber-0.0.1.tar.gz",
"platform": null,
"description": "\n## Float Point Arithmetic is Imprecise\n\nMany new python coders will be frustrated at the seemingly nonsensical way the language handles floating point numbers: even operations as simple as 0.1 + 0.2 should be easy to compute, right? Turns out floating point number storage yields many issues, and many minds smarter than me decided imprecision is better than storage and processing cost. The idea of this project is to invert that notion, storing floating point numbers as ratios.\n\n```python\n0.1 + 0.2 == 0.3 #True\nNumber.parse(\"0.1\") + Number.parse(\"0.2\") == Number.parse(\"0.3\") #False\nNumber.parse(\"0.92\") / Number.parse(\"245\") #23/6125\n```\n\n## Operation Examples\n\nThis library provides all basic arithmetic operations needed for numbers: addition, substration, multiplication, and division, as well as helper functions such as floor, ceil, opposite, inverse, and the equality operator.\n\n```python\nNumber.parse(\"3.2\") + Number.parse(\"4.7\") #79/10\nNumber.parse(\"9.21\") - Number.parse(\"18.45\") #231/-25\nNumber.parse(\"1.6\") * Number.parse(\"2.4\") #96/25\nNumber.parse(\"1.4\") / Number.parse(\"3.3\") #14/33\nNumber.parse(\"1.5\") == Number(3, 2) #True\nNumber.parse(\"3.4\").floor() #3\nNumber.parse(\"0.2\").ceil() #1\nNumber.parse(\"-3\").opposite() #3\nNumber.parse(\"0.5\").inverse() #2\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "Precise Numbers",
"version": "0.0.1",
"project_urls": null,
"split_keywords": [
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a96183b85e297068a029151eed49a3bd068a36659f042217bd83fccf8cdaa40e",
"md5": "57483c897ebffd0b1bab28c8ff5733f9",
"sha256": "1c93c97ca5e211cde9897437714bc3b004c5874fbc55bf9c40f1375b60dd3cb9"
},
"downloads": -1,
"filename": "precnumber-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "57483c897ebffd0b1bab28c8ff5733f9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3205,
"upload_time": "2023-08-27T22:26:16",
"upload_time_iso_8601": "2023-08-27T22:26:16.261386Z",
"url": "https://files.pythonhosted.org/packages/a9/61/83b85e297068a029151eed49a3bd068a36659f042217bd83fccf8cdaa40e/precnumber-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-27 22:26:16",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "precnumber"
}