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

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.

Examples

summary(rdiversity:::negate(as.binary(5, signed=TRUE)))
#>   Signedness  Endianess value<0 Size[bit] Base10
#> 1     signed Big-Endian    TRUE        16     -5
summary(rdiversity:::negate(as.binary(-5, signed=TRUE)))
#>   Signedness  Endianess value<0 Size[bit] Base10
#> 1     signed Big-Endian   FALSE        16      5
summary(rdiversity:::negate(as.binary(5, signed=FALSE)))
#>   Signedness  Endianess value<0 Size[bit] Base10
#> 1     signed Big-Endian    TRUE         8     -5