Pyhton Mixed Fraction Class Readme
Current Version 1.0.3 -= for Python 3.x =-
Easily convert mixed number fractions to floats and more
*Installation:
Save mixed_fractions.py in your python Lib folder
*Importing:
from mixed_fractions import Mixed
*Usage:
Mixed is designed to be interchangeable with Fraction.
>>> Mixed(Mixed(-1,1,2), Mixed(0,1,2), Mixed(0,1,2))
Mixed(-2, 1, 2)
>>> Mixed('-1 2/3')
Mixed(-1, 2, 3)
>>> Mixed(10,-8)
Mixed(-1, 1, 4)
>>> Mixed(Fraction(1,7), 5)
Mixed(0, 1, 35)
>>> Mixed(Mixed(1, 7), Fraction(2, 3))
Mixed(0, 3, 14)
>>> Mixed(Mixed(0, 3, 2), Fraction(2, 3), 2)
Mixed(1, 5, 6)
>>> Mixed('314')
Mixed(314, 0, 1)
>>> Mixed('-35/4')
Mixed(-8, 3, 4)
>>> Mixed('3.1415')
Mixed(3, 283, 2000)
>>> Mixed('-47e-2')
Mixed(0, -47, 100)
>>> Mixed(1.47)
Mixed(1, 2116691824864133, 4503599627370496)
>>> Mixed(2.25)
Mixed(2, 1, 4)
>>> Mixed(Decimal('1.47'))
Mixed(1, 47, 100)
#convert Mixed to float
>>> float(Mixed('6 7/8'))
6.875
>>> float(Mixed(1,2))
0.5
>>> float(Mixed(2,3,4))
2.75
>>> float(Mixed('1/3'))
0.3333333333333333
*Change Log:
1.0.3 Fixed minor string ZeroDivisionError / ValueError issue