Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,880 questions

51,806 answers

573 users

How to use the getcontext() function to get the default context in Python

1 Answer

0 votes
from decimal import getcontext, Decimal

context = getcontext()
print(context)

dec = Decimal('1.17')
print(dec)

result = dec**5 
print(result)

context.prec = 3 
result = dec**5 
print(result)




'''
run:

Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999, capitals=1, clamp=0, flags=[], traps=[InvalidOperation, DivisionByZero, Overflow])
1.17
2.1924480357
2.19

'''

 



answered Jul 10, 2023 by avibootz

Related questions

2 answers 211 views
1 answer 167 views
1 answer 105 views
105 views asked May 22, 2024 by avibootz
1 answer 117 views
1 answer 90 views
3 answers 184 views
...