Repeating digits of rational numbers
Project description
This package provides a way to access repeating decimals in the decimal representation of rational numbers.
class object
>>> from dvtDecimal import *
Once package importation completed, you have to create a rational number using:
- one of its fraction representation
>>> f = dvtDecimal(-604, 260)
for the fraction whose numerator is -604 and denominator is 260.
- its usual decimal representation
>>> f = dvtDecimal(2.5)
- the repeating decimals as a string
>>> f = dvtDecimal('00765')
thus creating a number (w/o irregular part) between 0 and 1. In the example, 0.007650076500765... and so on.
object methods
Once you created the object for example, you can access to those methods and variables:
>>> f.dispResults()
For fraction: -604 / 260
integer part : -2
irregular part : 0.3
periodic part : [2, 3, 0, 7, 6, 9]
mixed fraction : [-2, 21, 65]
Operation in Python gives : -2.3230769230769233
>>> f.initValues
[-604, 260]
>>> f.simpValues
[-151, 65]
>>> f.isDecimal()
False
>>> f.dotWrite(20)
-2.32307692307692307692
>>> f.intPart
-2
>>> f.irrPart
0.3
>>> f.repPart
[2, 3, 0, 7, 6, 9]
>>> f.repPartC
230769
>>> f.periodLen
6
>>> f.gcd
4
>>> f.mixedF
[-2, 21, 65]
>>> f.sign
-1
Entering via repeating decimals string allows:
>>> f = dvtDecimal('0123456789')
>>> f = dvtDecimal(*f.simpValues)
>>> f.simpValues
[13717421, 1111111111]
dvtDecimal also supports minimal operations (+,-,*,/) in between elements of the class but also with integers:
>>> f = dvtDecimal(1, 5)
>>> g = dvtDecimal(10, 3)
>>> h = f + g
>>> h.mixedF
[3, 8, 15]
>>> i = f / g
>>> i.mixedF
[0, 3, 50]
>>> f = dvtDecimal(1, 5)
>>> g = 5
>>> h = f * g
>>> h.isDecimal()
True
>>> f = dvtDecimal(1, 5)
>>> g = dvtDecimal(7, 5)
>>> h = f - g
>>> h.simpValues
[-6, 5]
further...
More operations!
about
dvtDecimal is rather an attempt to publish on the PyPi
packages
index than a fully completed python project, I do not recommend
dvtDecimal usage for professionnal use. You have to consider this
package as an experiment.
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
Hashes for dvtDecimal-0.9.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3835242950c5801b8da4b9e4613e5a50d6caf47187130271eb911112af5e160e |
|
MD5 | 3bc0577acbb7cff34fa635533abe3e77 |
|
BLAKE2b-256 | 536386f12a6b296bc4e387896c4a82209245081d47672c14064b6d5c167fb40f |