Fournit une classe dédiée aux calculs sur des nombres décimaux
Project description
Decimal
This class is used to compute real result from decimal calcul. By example, if we wan't to calcule 0.1 + 0.2, we'd like to have 0.3, but really, we obtain 0.30000000000004. So, this class allow to be precize computing with pows of 10 and treating only integers. Then, the result for 0.1 + 0.2 is 0.3.
Tests
To verify results, tests are presents. For that, it's possible to launch pytest to check calcul.
Operations
Plus
- Decimal.plus(0.1, 0.2) => 0.3
- Decimal.plus(0.1, 0.02) => 0.12
- Decimal.plus(0.200, 0.02) => 0.22
- Decimal.plus(1, 2) => 3
- Decimal.plus(1, 0.2) => 1.2
- Decimal.plus(0.000005, 1) => 1.000005
Minus
- TestDecimal.Operation(5, 3) => 2
- TestDecimal.Operation(3, 4) => -1
- TestDecimal.Operation(3.5, 4) => -0.5
- TestDecimal.Operation(3.5, 0.05) => 3.45
- TestDecimal.Operation(1, 3) => -2
- TestDecimal.Operation(0.1, 0.3) => -0.2
- TestDecimal.Operation(0.1, 0.2) => -0.1
- TestDecimal.Operation(0.3, 0.2) => 0.1
- TestDecimal.Operation(0.8, 9) => -8.2
Times
- Decimal.times(2, 1.5) => 3
- Decimal.times(3, 4) => 12
- Decimal.times(3.5, 4) => 14
- Decimal.times(3.5, 0.05) => 0.175
Divide
- Decimal.divide(6, 1.5) => 4
- Decimal.divide(3, 4) => 0.75
- Decimal.divide(3.5, 4) => 0.875
- Decimal.divide(3.5, 0.05) => 70
- Decimal.divide(1, 3) => 0.3333333333333333
- Decimal.divide(0.1, 0.3) => 0.3333333333333333
- Decimal.divide(0.1, 0.2) => 0.5
- Decimal.divide(0.8, 9) => 0.08888888888888889
Modulo
- Decimal.modulo(6, 1.5) => 0
- Decimal.modulo(3, 2) => 1
- Decimal.modulo(9.5, 2) => 1.5
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
decimalcalcul-2.4.tar.gz
(3.4 kB
view details)
Built Distribution
File details
Details for the file decimalcalcul-2.4.tar.gz
.
File metadata
- Download URL: decimalcalcul-2.4.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1660e80a2529fcf8ee4876902e7176da132b7012e0d08e04142359e549202f5d |
|
MD5 | bc291040e9b306c519b46a0888b86808 |
|
BLAKE2b-256 | 763f019a43104042e89921db00d661bb43c31b1df51ade22d4c726291dd67c3a |
File details
Details for the file DecimalCalcul-2.4-py3-none-any.whl
.
File metadata
- Download URL: DecimalCalcul-2.4-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49b8a84aeff85134c158d7a8b805deb8e65b5e9cadbc91e9f4a82ee71612dbb6 |
|
MD5 | 04ce31be76ab47369cc5212dd057047c |
|
BLAKE2b-256 | 1eb2acdc6d33f6f482c6c3892f26459b9eaf952aa4ea73eea2a66f9ee26be4dd |