<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 3, 2019 at 9:08 AM Hameer Abbasi <<a href="mailto:einstein.edison@gmail.com">einstein.edison@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
It turns out you're running into a bit-error. In general, the two's complement of -2 ** (n-1) with the bit-length being limited to n bits is itself... No way around that. And integers don't set hardware exceptions so checking for errors like these is hard as well.<br>
<br>
TL;DR: It's an error with how the integer is stored in memory and how you're running out of space.<br>
<br>
Regards,<br>
Hameer Abbasi<br></blockquote><div><br></div><div>More like the eight bit twos complement of -128 is -128, bytes cannot represent 128. Matlab used to (still does?) solve this problem by returning 127 instead :) Basically, the data needs more precision. Returning an unsigned type would lead to it's own problems with unexpected promotions when the result was used. We could, I suppose, raise a warning, although that might be considered noisy. If you use `absolute` instead, you can specify the dtype.</div><div><br></div><div><snip></div><div><br></div><div>Chuck</div></div></div>