J
Jamis Buck
Using Ruby/DL, it seems as though a 32-bit integer with the MSB set
cannot be converted to a long integer:
require 'dl'
DL::dlopen("libc.so.5") do |libc|
isdigit = libc['isdigit', 'CH']
p 0x40000000.class
print(isdigit.call(0x40000000), "\n")
p 0x80000000.class
print(isdigit.call(0x80000000), "\n")
end
The above will print the first one successfully, even though 0x40000000
is a Bignum. The second one results in an error:
in `call': bignum too big to convert into `long' (RangeError)
Is this a bug, or a feature? Is there a workaround? Any advice would be
appreciated.
Thanks,
Jamis
cannot be converted to a long integer:
require 'dl'
DL::dlopen("libc.so.5") do |libc|
isdigit = libc['isdigit', 'CH']
p 0x40000000.class
print(isdigit.call(0x40000000), "\n")
p 0x80000000.class
print(isdigit.call(0x80000000), "\n")
end
The above will print the first one successfully, even though 0x40000000
is a Bignum. The second one results in an error:
in `call': bignum too big to convert into `long' (RangeError)
Is this a bug, or a feature? Is there a workaround? Any advice would be
appreciated.
Thanks,
Jamis