¡@

Home 

python Programming Glossary: prec

How to define a decimal class holding 1000 digits in python?

http://stackoverflow.com/questions/19980840/how-to-define-a-decimal-class-holding-1000-digits-in-python

a context with 1000 decimal digits context decimal.Context prec 1000 decimal.setcontext context From now on computations will.. context From now on computations will use 1000 digits precision. Example decimal.setcontext decimal.Context prec 1000 pi.. precision. Example decimal.setcontext decimal.Context prec 1000 pi decimal.Decimal '3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113'..

Nicely representing a floating-point number in python

http://stackoverflow.com/questions/2663612/nicely-representing-a-floating-point-number-in-python

like a work round and it's not quite perfect. The maximum precision is 15 significant digits. def f number sigfig return .15f.. decimal.Decimal n decimal.Decimal d ctx decimal.Context prec 60 result ctx.divide numerator denominator while ctx.flags decimal.Inexact.. decimal.Inexact ctx.flags decimal.Inexact False ctx.prec 2 result ctx.divide numerator denominator return result def..

Converting a python numeric expression to LaTeX

http://stackoverflow.com/questions/3867028/converting-a-python-numeric-expression-to-latex

lacking. import ast class LatexVisitor ast.NodeVisitor def prec self n return getattr self 'prec_' n.__class__.__name__ getattr.. ast.NodeVisitor def prec self n return getattr self 'prec_' n.__class__.__name__ getattr self 'generic_prec' n def visit_Call.. self 'prec_' n.__class__.__name__ getattr self 'generic_prec' n def visit_Call self n func self.visit n.func args ' '.join..

Python: Is there a way to keep an automatic conversion from int to long int from happening?

http://stackoverflow.com/questions/4362338/python-is-there-a-way-to-keep-an-automatic-conversion-from-int-to-long-int-from

X python 2.6.1 to a python long int which is of arbitrary precision. Even though the types are not the same they are similar.. all operations on that variable are now done in arbitrary precision. The arbitrary precision operations are orders of magnitude.. are now done in arbitrary precision. The arbitrary precision operations are orders of magnitude slower than the native..

Inaccurate Logarithm in Python

http://stackoverflow.com/questions/931995/inaccurate-logarithm-in-python

. Example from decimal import Decimal Context ctx Context prec 20 two Decimal 2 ctx.divide ctx.power two Decimal 31 .ln ctx..