-
Notifications
You must be signed in to change notification settings - Fork 71
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
Parse("10.0.0.1/1") #85
Comments
Hi @cnbohu ,
It is because the number of IP addresses is over the max range of the type of If you cast the return value of the var ipRange = IPAddressRange.Parse("10.0.0.1/1") ;
var count = (UInt32)ipRange.AsEnumerable().Count(); Happy Coding ;) |
Thx!
program is unresponsive ... |
Hi @cnbohu,
Becuase that program will count about 300,000,000,000,000,000,000 objects (!). If it takes one microsecond to count one address, it will take more than 9 million years to finish counting this number of addresses...! Instead, use the following expression to get the number of the IPv6 addresses. var count = (UInt128)System.Math.Pow(2, 128 - 60 /* <- the length of the bit mask */ ); |
It is possible, to add a properties or methods, not generate objects,only calculate the count.
|
That's true! int ICollection<IPAddress>.Count => (int)((this.End - this.Begin) + 1); (Actually, the implementation above is more generic, simple, and fast than using the power of two.) That's the reason why your code But unfortunately, the return type of the So many people don't care about the number of addresses in a range, so we haven't exposed such a feature on the |
In my project, need to get CIDR total IPs ,estimate(total * tasks) to customize the execution of scheduled jobs. Like this: 9.9.0.0/16 => 65536 IP x 4 tasks = 262144 queries I write the method to calculation,now function completed. Thank for your work & reply!Hope your features will be available in the future. |
iCount is '-2147483648' ?
The text was updated successfully, but these errors were encountered: