Skip to main content

decimal number round roundup rounddown

Project description

JitUtils

Power By N|Solid

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.6 upper version
    • f"{12.3456:.2f}" -> output 12.35
    • f"{1200.3456:,.2f}" -> output 1,200.35
    • {:.2f}.format(number)" -> output 12.35
    • {:,.2f}.format(currency_value) -> output 1,200.35

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

pyjitroundnumber-0.0.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyjitroundnumber-0.0.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

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

Hashes for pyjitroundnumber-0.0.1.tar.gz
Algorithm Hash digest
SHA256 6fd3dd68b04df9bb851746d295bfbcfe57612c1222e234474b301035d2c1c9f9
MD5 e3ea17b2ed5d2b1b206f1b37a9a0c2d7
BLAKE2b-256 70deb0b350ccba46e40927793346d331ac594ad7f01b6057a565ca941e54f789

See more details on using hashes here.

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

Hashes for pyjitroundnumber-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b653c26a939cf8a88c860ba8fc0703572c200b5b797c3903626ebce452f9909b
MD5 6adba5db8329b59dadfa6224864d364f
BLAKE2b-256 fea4aa69c40e52d83e002852e3e163a4855c4d20c932da3c4e87bde726751409

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page