mmaechler / R-bitops

R package 'bitops' -- implementing bitwise operations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integer overflow

dlrobertson opened this issue · comments

A bit contrived, but the following will not yield the expected output when built from master

    bitShiftL(x, 32) # yields the value of x
    bitShiftL(2147483647, 32) # yields 2147483647
    bitShiftL(5, 31) # yields the same

I see. I haven't created the package, just too maintenances at a time the previous maintainer "disappeared".

My current inclination would be to either just document the behavior, or additionally also give a warning, but not change it. What's your use case? How did you find the problem?

No use case, I was more or less playing around. I originally was trying to find out what the difference was between bitops and the bitwise functions in base. I was figuring out if a logical or arithmetic shift was used when I thought I'd test what happened when I did something that should be undefined.

bitwise will always return NA in these cases.

Awesome documentation additions!