13 lines
336 B
Python
13 lines
336 B
Python
import fractions
|
|
|
|
from typesystem import Rational
|
|
|
|
def printValue(value, type):
|
|
if isinstance(type, Rational) and int(value) != value:
|
|
decimal = str(float(value))
|
|
if fractions.Fraction(decimal) == value:
|
|
print(f'{value}: {type} = {decimal}')
|
|
else:
|
|
print(f'{value}: {type} ≈ {decimal}')
|
|
else:
|
|
print(f'{value}: {type}')
|