3 ms·
Besides using decimals instead of floats for your frame-rate use case (definitely a better fit), using a Python fraction may be a more useful representation for
by webmaven 10y ago
Besides using decimals instead of floats for your frame-rate use case (definitely a better fit), using a Python fraction may be a more useful representation for aspect ratios:
https://docs.python.org/3/library/fractions.html https://docs.python.org/3/library/fractions.html
Also possibly useful in that context (and bringing us back full circle to the OP's subject), Python 3.6 has added the as_integer_ratio() method to Decimal instances:
https://docs.python.org/3.6/library/decimal.html#decimal.Decimal.as_integer_ratio https://docs.python.org/3.6/library/decimal.html#decimal.Dec...