JitUtils
Description
Package จัดทำขึ้นมาเพื่อในการปัดเศษทศนิยม
Features
- Function
round_up(): ใช้ในการปัดเศษทศนิยม ขึ้น ⬆⬆ - Function
round_down(): ใช้ในการปัดเศษทศนิยม ลง ⬇⬇
Example coding [main.py]
from src.py_jit_round_number.jit_round_up_down import JitRoundNumber
listNumber = [12.34567890, -12.34567890, 0.54321, -0.54321, 1.1, -1.5, 1.23, 1.543, 22.45, 1352]
''' round_up '''
print('Round Up')
i = 0
for j in range(0, 5):
for l in listNumber:
print(f"ทศนิยม {j} ตำแหน่ง : {JitRoundNumber(number=l, decimals=j).round_up()}")
i += j
if j <= i:
print('\r\t\n')
''' round_down '''
listNumber = [12.34567890, -12.34567890, 0.54321, -0.54321, 1.1, -1.5, 1.23, 1.543, 22.45, 1352]
print('Round Down')
i = 0
for j in range(0, 5):
for l in listNumber:
print(f"ทศนิยม {j} ตำแหน่ง : {JitRoundNumber(number=l, decimals=j).round_down()}")
i += j
if j <= i:
print('\r\t\n')
Test number digit
ค่าที่ใช้ในการทดสอบการเขียน (Unit testing) ตามตารางด้านล่างนี้ โดนมีการเรียกใช้ในส่วนของ Class JitRoundNumber() ออกมาใช้งานตามข้างต้นที่ได้กล่าวมา File Testing (Unit testing)
Round Up (ปัดเศษทศนิยมขึ้น)
| Value | Round Up TO | Result |
|---|---|---|
| 12.3456789 | ทศนิยม 0 ตำแหน่ง | 13 หรือ 13.0 |
| 12.3456789 | ทศนิยม 1 ตำแหน่ง | 12.4 |
| 12.3456789 | ทศนิยม 2 ตำแหน่ง | 12.35 |
| 12.3456789 | ทศนิยม 3 ตำแหน่ง | 12.346 |
| 12.3456789 | ทศนิยม 4 ตำแหน่ง | 12.3457 |
Round Down (ปัดเทศทศนิยลง)
| Value | Round Down TO | Result |
|---|---|---|
| 12.3456789 | ทศนิยม 0 ตำแหน่ง | 12 หรือ 12.0 |
| 12.3456789 | ทศนิยม 1 ตำแหน่ง | 12.3 |
| 12.3456789 | ทศนิยม 2 ตำแหน่ง | 12.34 |
| 12.3456789 | ทศนิยม 3 ตำแหน่ง | 12.345 |
| 12.3456789 | ทศนิยม 4 ตำแหน่ง | 12.3456 |
Referent Knowledge
- realpython.com
python-rounding - kodify.net
round-up-to-the-next-integer-pythons-mathceil-function - kodify.net
round-decimals - knowledgehut.com
python-rounding-numbers - String format operation example with
python 3.6upper versionf"{12.3456:.2f}"-> output12.35f"{1200.3456:,.2f}"-> output1,200.35{:.2f}.format(number)"-> output12.35{:,.2f}.format(currency_value)-> output1,200.35
Release files for pyjitroundnumber 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyjitroundnumber-0.0.1.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyjitroundnumber-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.3 kB
Release files / pyjitroundnumber-0.0.1.tar.gz
| Download URL | pyjitroundnumber-0.0.1.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6fd3dd68b04df9bb851746d295bfbcfe57612c1222e234474b301035d2c1c9f9
|
|
BLAKE2b-256 checksum How to use checksums |
70deb0b350ccba46e40927793346d331ac594ad7f01b6057a565ca941e54f789
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
|
Release files / pyjitroundnumber-0.0.1-py3-none-any.whl
| Download URL | pyjitroundnumber-0.0.1-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b653c26a939cf8a88c860ba8fc0703572c200b5b797c3903626ebce452f9909b
|
|
BLAKE2b-256 checksum How to use checksums |
fea4aa69c40e52d83e002852e3e163a4855c4d20c932da3c4e87bde726751409
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
|