Learn R Programming

binaryLogic (version 0.3.4)

negate: Binary Negation (!)

Description

Negates the binary number x. Negation x -> -x or -x -> x

Usage

negate(x)

Arguments

x
The number to be negated. A binary vector is expected.

Value

  • The negated number of x. Returns a binary vector with signed=TRUE

Details

An »unsigned« number will be returned as »signed« regardless of whether the value is negative. No floating point supported.

See Also

switchEndianess or fillUpToByte.

Examples

Run this code
summary(negate(as.binary(5, signed=TRUE)))
summary(negate(as.binary(-5, signed=TRUE)))
summary(negate(as.binary(5, signed=FALSE)))

Run the code above in your browser using DataLab