wangtongada / gmpy

Automatically exported from code.google.com/p/gmpy
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Dyadic fractions and whole numbers #88

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. from gmpy2 import mpfr
2. mpfr(0.5)

What is the expected output? What do you see instead?
mpfr('0.5') was expected. I see "Invalid floating point operation" error.

What version of the product are you using? On what operating system?
gmpy2 2.0.3 64 bit win 7, PyScripter

Please provide any additional information below.
Numbers of the form 2^m except for 0.0 will give the same problem.
Thanks for reading.

Original issue reported on code.google.com by philippl...@gmail.com on 19 Jul 2014 at 7:23

GoogleCodeExporter commented 8 years ago
Actually only powers of 2 is affected.

Original comment by philippl...@gmail.com on 19 Jul 2014 at 7:25

GoogleCodeExporter commented 8 years ago
Does is work if you use a string? i.e. mpfr("0.5")

Original comment by casevh on 19 Jul 2014 at 7:27

GoogleCodeExporter commented 8 years ago
It apperas to work when it is a string.

Original comment by philippl...@gmail.com on 19 Jul 2014 at 7:28

GoogleCodeExporter commented 8 years ago
Interesting. What CPU do you have? (gmpy2 may be trying to use the instruction 
set from a different CPU)

Original comment by casevh on 19 Jul 2014 at 7:32

GoogleCodeExporter commented 8 years ago
Intel i3 M 350 2.27 GHz

Original comment by philippl...@gmail.com on 19 Jul 2014 at 7:34

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Also, addition and subtraction gives the same error with powers of 2. So,

    0.5 + mpfr(12.3)
or, 

    0.5 + mpfr(str(0.5))

breaks.

But,

    mpfr(str(0.5))+mpfr(str(1.0))

works.

Original comment by philippl...@gmail.com on 19 Jul 2014 at 7:43

GoogleCodeExporter commented 8 years ago
This is strange. I can't recreate the issue. What happens if you try: mpfr(0) + 
0.5

Can you test it outside of PyScripter?

What version of Python are you using?

Original comment by casevh on 19 Jul 2014 at 7:43

GoogleCodeExporter commented 8 years ago
I'll build a special version of gmpy2 to try and get better error messages. 
That may take a couple of days. 

What is the output of:

import sys
sys.version

Original comment by casevh on 19 Jul 2014 at 8:03

GoogleCodeExporter commented 8 years ago
Python 2.7

mpfr(0) + 0.5 breaks in PyScripter 2.5.3.0 x64

There are no problems due to this issue in IDLE shell, however.

Original comment by philippl...@gmail.com on 19 Jul 2014 at 8:07

GoogleCodeExporter commented 8 years ago
'2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)]'

Thanks for your replies, sounds like interesting work if anything.

Original comment by philippl...@gmail.com on 19 Jul 2014 at 8:10

GoogleCodeExporter commented 8 years ago
for your information, when used with pylab, the plotting sections, 

pylab.ylim(0.0, 1.4*max(P))

would give an error when operating on a list of type mpfr, P. The following 
workaround works though,

pylab.ylim(0.0, 1.4*float(max(P))) 

Original comment by philippl...@gmail.com on 19 Jul 2014 at 9:30

GoogleCodeExporter commented 8 years ago
I've identified a possible cause. A test version is available at:

https://dl.dropboxusercontent.com/u/32175932/gmpy2-2.0.4.win-amd64-py2.7.exe

If it fixes this specific issue, there are still more changes I need to make 
for a complete fix.

Original comment by casevh on 21 Jul 2014 at 3:38

GoogleCodeExporter commented 8 years ago
I've made 2.0.4b1 available via PyPI. Can you test the new version?

Original comment by casevh on 5 Aug 2014 at 5:37

GoogleCodeExporter commented 8 years ago
Sad to say that it still does not work. Thanks anyway. Sorry for not posting, I 
am quite hesitant about these things. It is highly possible that there is a 
problem with my PyScripter. My computer needs a remake, sorry again, and thanks 
for all this.

I have a (conspiracy) theory that instead of compromising the ciphers that 
people use, they compromise the rand stream. But that's another story...

Original comment by philippl...@gmail.com on 5 Aug 2014 at 6:19

GoogleCodeExporter commented 8 years ago
Btw, I confirm that gmpy2.version() gives:

'2.0.4b1'

Original comment by philippl...@gmail.com on 5 Aug 2014 at 6:26

GoogleCodeExporter commented 8 years ago
nvm about the cryptic comment, that almost misses the whole point

Original comment by philippl...@gmail.com on 8 Aug 2014 at 3:57