Learn R Programming

rdiversity (version 2.2.0)

binAdd: Binary Addition (+)

Description

Adds two binary numbers. (x + y)

Usage

binAdd(x, y)

Arguments

x

summand 1 (binary vector)

y

summand 2 (binary vector)

Value

The sum of x and y. Returns a binary vector.

Details

Little-Endian and unsigned is not supported at the moment. No floating point supported. if x or y is signed the return value will also be signed.

See Also

base::as.logical , base::is.logical, base::raw

Examples

Run this code
# NOT RUN {
five <- as.binary(5); ten <- as.binary(10);
as.numeric(rdiversity:::binAdd(ten, five))
rdiversity:::binAdd(as.binary(c(0,1), logic=TRUE), as.binary(c(1,0), logic=TRUE))
# }

Run the code above in your browser using DataLab