-
Notifications
You must be signed in to change notification settings - Fork 0
toBinary()
Evgheniy Kovaliov edited this page May 10, 2023
·
1 revision
Method that allows you convert ip address to binary form.
Ip address must be correct. (see validation)
Parameters:
-
ip: string— ip address to convert.
Return:
-
binaryIp: string— binary ip address.
Invalide ip address!:
- entered argument is not a correct ip address.
ipv4.toBinary('123.123.123.123'); // '01111011.01111011.01111011.01111011'
ipv4.toBinary('0.0.0.0'); // '00000000.00000000.00000000.00000000'
ipv4.toBinary('255.255.255.255'); // '11111111.11111111.11111111.11111111'
ipv4.toBinary('10.0.0.1'); // '00001010.00000000.00000000.00000001'
ipv4.toBinary('196.128.64.0'); // '11000100.10000000.01000000.00000000'
ipv4.toBinary('128.0.0.0'); // '10000000.00000000.00000000.00000000'
ipv4.toBinary('100.200.100.200'); // '01100100.11001000.01100100.11001000'
ipv4.toBinary('10.255.255.256'); // Error: Invalide ip address!
ipv4.toBinary('10.0.0.one'); // Error: Invalide ip address!
ipv4.toBinary('127.0.0.0.10'); // Error: Invalide ip address!- Is used in other methods.
Author: Evgheniy Kovaliov <kovaliov.evgeniy11@gmail.com>
For ip version 4
For ip version 6