twos_complement: Function to convert Two's Complement integer to a standard...

View source: R/twos_complement.R

twos_complementR Documentation

Function to convert Two's Complement integer to a standard integer.

Description

twos_complement is vectorised and will convert integers to-and-from (20-bit) binary form to decode the Two's Complement rule.

Usage

twos_complement(x)

Arguments

x

Vector of 20-bit integers.

Value

Numeric vector.

Author(s)

Alexandre Ilha and Stuart K. Grange.

Examples


# A hexadecimal number
hex <- "fff4d"

# Hexadecimal as a base 10 decimal
integer <- strtoi(hex, 16)
integer
1048397

# Decode the Two's Complement rule
twos_complement(integer)
-179


skgrange/threadr documentation built on May 11, 2024, 12:16 p.m.