Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

different result between IPAddress and IPAddr when call to_i #121

Closed
malongshuai opened this issue Sep 6, 2020 · 1 comment
Closed

different result between IPAddress and IPAddr when call to_i #121

malongshuai opened this issue Sep 6, 2020 · 1 comment

Comments

@malongshuai
Copy link

>> require 'ipaddr'
>> require 'ipaddress'
>> IPAddr.new("172.16.10.1/24").to_i
=> 2886732288
>> IPAddress("172.16.10.1/24").to_i
=> 2886732289
@Adam21e
Copy link

Adam21e commented Sep 6, 2020

Looks like the subnet affects IPAddr and it returns the network IP 172.16.10.0 and not the IP address.

>> IPAddr.new("172.16.10.1").to_i
=> 2886732289

I would consider 2886732289 to be the expected result as the subnet shouldn't matter when converting an IP address to an integer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants