-
Notifications
You must be signed in to change notification settings - Fork 0
getHostsCount()
Evgheniy Kovaliov edited this page May 10, 2023
·
3 revisions
Method that allows you get total number of hosts in ip network by prefix.
Ip prefix must be correct. (see validation)
Parameters:
-
prefix: number— ip prefix.
Return:
-
number— number of hosts.
Invalide ip prefix!:
- entered argument is not a correct ip prefix.
ipv4.getHostsCount(32); // 1
ipv4.getHostsCount(0); // 4294967296
ipv4.getHostsCount(31); // 2
ipv4.getHostsCount(16); // 65536
ipv4.getHostsCount(4); // 268435456
ipv4.getHostsCount(25; // 128
ipv4.getHostsCount('25'); // Error: Invalide prefix entered!
ipv4.getHostsCount('128.64.0.0/8'); // Error: Invalide prefix entered!
ipv4.getHostsCount([16]); // Error: Invalide prefix entered!
ipv4.getHostsCount(false); // Error: Invalide prefix entered!- Is used in
getNetworkInfo()method.
Author: Evgheniy Kovaliov <kovaliov.evgeniy11@gmail.com>
For ip version 4
For ip version 6