Silent overflow in absolute()
See original GitHub issuePython:
In [117]: abs(-2147483646)
Out[117]: 2147483646
In [118]: abs(-2147483647)
Out[118]: 2147483647
In [119]: abs(-2147483648)
Out[119]: 2147483648L
In [120]: abs(-2147483649)
Out[120]: 2147483649L
In [121]: abs(-2147483650)
Out[121]: 2147483650L
NumPy:
In [93]: absolute(array([-2147483646]))
Out[93]: array([2147483646])
In [94]: absolute(array([-2147483647]))
Out[94]: array([2147483647])
In [95]: absolute(array([-2147483648]))
Out[95]: array([-2147483648])
In [96]: absolute(array([-2147483649]))
Out[96]: array([2147483649], dtype=int64)
In [97]: absolute(array([-2147483650]))
Out[97]: array([2147483650], dtype=int64)
In C this is undefined because abs() returns an int and there’s no +2147483648, but NumPy should convert to int64? and then absolute(array(-2**63))
should convert to object array with longs instead of returning -9223372036854775808?
Related to https://github.com/numpy/numpy/issues/593?
Issue Analytics
- State:
- Created 9 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Absolute position and Overflow:hidden
I need to show child element which is bigger than it's parent element, but without removing overflow:hidden; is this possible? parent element ...
Read more >Simple Hack to Silence your Overflow! - YouTube
After a near disaster with a leak in my overflow I was inspired to make this video where I show you how I...
Read more >How to make absolute positioned elements overlap their ...
Let me show you a neat trick. But first, if you're trying to mess with these absolute/relative properties you really should be aware...
Read more >The Joel Test: 12 Steps to Better Code
Do programmers have quiet working conditions? Do you use the best tools money can ... You absolutely have to keep track of bugs...
Read more >Invisible reCAPTCHA - Google Developers
Programmatically invoke the challenge. Configuration. JavaScript resource (api.js) parameters; g-recaptcha tag attributes and grecaptcha.render ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s awful, but all integer overflow cases are awful; is this one so much worse that it needs special cases like this? (I don’t know the answer. Having proper integer overflow detection in general would certainly help some in this case and many others, though.)
Sure - but I think that risk (of type promotion when using uints) is way less bad than returning a negative number from
(u)abs
…