I’m currently converting a Visual Basic application to Ruby because we’re moving it to the web. However when converting some algorithms I’ve run into a problem concerning bit shifting.
How I understand it, the problem lies in the size mask VB enforces on Integer types (as explained Here). Ruby, in practice, doesn’t differentiate in these types.
So the problem:
Visual Basic
Dim i As Integer = 182
WriteLine(i << 24) '-1241513984
Ruby
puts 182 << 24 # 3053453312
I’ve been Googling and reading up on bit shifting the last hours but haven’t found a way, or direction even, to tackle this problem.
You need to replicate what visual basic is doing, namely
For example