cfbolz changed the topic of #pypy to: PyPy, the flexible snake (IRC logs: https://botbot.me/freenode/pypy/ ) | use cffi for calling C | mac OS and Fedora are not Windows
<samth>
the code in rlib.longlong2float seems to overflow for some large values (this happens only when interpreted). I wrote a workaround in my code that seems to do the right thing (https://github.com/pycket/pycket/commit/00d63ab76c323d64582b41cba95f68cc4426cb37) but I'm not sure that it's the right thing in general. Any thoughts before I submit a patch?
<samth>
cc cfbolz
globalThis is now known as graingert
<arigato>
samth: I didn't look in detail, but note that C (and gcc) is particularly picky about overflows on signed arithmetic: it must not occur in C code
<arigato>
so if you do "val += rarithmetic.r_int64(ord(v)) << (i * 8)" then a picky C compiler might incorrectly conclude that val cannot be negative, and derive bogus results from that
<arigato>
furthermore, this would occur only *before* the commit you pointed to, but not *after*, because after the commit that line is inside an "except OverflowError" so no longer uses a bare C "+"
Garen has quit [Read error: Connection reset by peer]
Garen has joined #pypy
<arigato>
so that's a theoretical problem only at this point in time
<arigato>
the real problem you're having is simply that "val += xxx" doesn't automatically wrap longlong overflows to negative values, in plain Python
<arigato>
so (before translation) you get sometimes a number that uses all 64 bits, but isn't negative, and this is out of bounds
<arigato>
a fix for both problems is to use unsigned arithmetic when computing "val", and then cast the result to a signed longlong
<arigato>
using longlong2float.longlong2float(rlib.rarithmetic.longlongmask(val))
<samth>
arigato: ah, ok, I'll try that then. Certainly would be better than the copy and paste I did
arigato has quit [Remote host closed the connection]
adamholmberg has quit [Remote host closed the connection]
adamholmberg has joined #pypy
adamholmberg has quit [Read error: Connection reset by peer]