decimal number round roundup rounddown
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyjitroundnumber-0.0.1.tar.gz.
File metadata
- Download URL: pyjitroundnumber-0.0.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fd3dd68b04df9bb851746d295bfbcfe57612c1222e234474b301035d2c1c9f9
|
|
| MD5 |
e3ea17b2ed5d2b1b206f1b37a9a0c2d7
|
|
| BLAKE2b-256 |
70deb0b350ccba46e40927793346d331ac594ad7f01b6057a565ca941e54f789
|
File details
Details for the file pyjitroundnumber-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pyjitroundnumber-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b653c26a939cf8a88c860ba8fc0703572c200b5b797c3903626ebce452f9909b
|
|
| MD5 |
6adba5db8329b59dadfa6224864d364f
|
|
| BLAKE2b-256 |
fea4aa69c40e52d83e002852e3e163a4855c4d20c932da3c4e87bde726751409
|