You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get a result i don't expect when i add a small number to larger number. In the decimal system it is obvious that the result is mathematically wrong.
I tried a higher precision, and this didn't work. After reading issue #112 i tried to set emin but this didn't change anything.
Any idea how to get the number i expected?
#!/usr/bin/env python3
from bigfloat import *
precision(300)
#Doesn't change anything if this line is here or not
Context(precision=300, emin=-9999999)
#########################
# add 21, works somewhat#
#########################
r = BigFloat(1)
a = BigFloat(10**33)
r = r + 21*(1/a)
print(r)
print(int(r*10**40))
########################
# add 22, doesn't work #
########################
r = BigFloat(1)
a = BigFloat(10**35)
r = r + 22*(1/a)
print(r)
print(int(r*10**40))
I get a result i don't expect when i add a small number to larger number. In the decimal system it is obvious that the result is mathematically wrong.
I tried a higher precision, and this didn't work. After reading issue #112 i tried to set
emin
but this didn't change anything.Any idea how to get the number i expected?
What i expected:
What i got:
Other things i tried:
emax=999999
import bigfloat
instead offrom bigfloat import *
and then usingr = bigfloat.BigFloat("1",bigfloat.precision(4000))
No success so far.
Version:
The text was updated successfully, but these errors were encountered: