Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ip_operators

Operators for IP addresses


Description

ip_address vectors support the following operators:

  • bitwise logic operators: ! (NOT), & (AND), | (OR), ^ (XOR)

  • bitwise shift operators: %<<% (left shift), %>>% (right shift)

  • arithmetic operators: + (addition), - (subtraction)

Examples

# use ip_to_binary() to understand these examples better

# bitwise NOT
!ip_address("192.168.0.1")

# bitwise AND
ip_address("192.168.0.1") & ip_address("255.0.0.255")

# bitwise OR
ip_address("192.168.0.0") | ip_address("255.0.0.255")

# bitwise XOR
ip_address("192.168.0.0") ^ ip_address("255.0.0.255")

# bitwise shift left
ip_address("192.168.0.1") %<<% 1

# bitwise shift right
ip_address("192.168.0.1") %>>% 1

# addition of integers
ip_address("192.168.0.1") + 10

# subtraction of integers
ip_address("192.168.0.1") - 10

ipaddress

Tidy IP Addresses

v0.5.1
MIT + file LICENSE
Authors
David Hall [aut, cre] (<https://orcid.org/0000-0002-2193-0480>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.