View source: R/01genericSupport.r
rawToAmigaInt | R Documentation |
Convert raw data into 8, 16, or 32-bit signed or unsigned integer values, conform Amiga specifications.
rawToAmigaInt(x, bits = 8, signed = F)
x |
A vector of class |
bits |
Number of bits that represents the integer value. Should be 8 or a positive multitude of 8. |
signed |
A |
The Commodore Amiga has specified the following data formats to represent integer data: BYTE (signed 8-bit integer), UBYTE (unsigned 8-bit integer), WORD (signed 16-bit integer), UWORD (unsigned 16-bit integer), LONG (signed 32-bit integer), ULONG, (unsigned 32-bit integer). This function converts raw data into such integers. Note that WORD and UWORD are also referred to as SHORT and USHORT respectively.
A numeric
value (or a vector
of values),
representing the integer data represented by the provided
raw
data. Note that R defines integer
as 32-bit
signed integers and cannot store the 32-bit signed values.
Therefore a numeric
value is returned rather than an
explicit integer
.
Pepijn de Vries
Other raw.operations:
amigaDateToRaw()
,
amigaIntToRaw()
,
displayRawData()
,
rawToAmigaDate()
,
rawToBitmap()
## Let's start by obtaining unsigned 8-bit integers:
rawToAmigaInt(as.raw(0:255))
## note that this is the same as:
as.numeric(as.raw(0:255))
## but with this function we can also get signed values:
rawToAmigaInt(as.raw(0:255), signed = TRUE)
## Furthermore 32 or 16-bit integers can also be obtained.
## Let's look at 16-bit integers:
rawToAmigaInt(as.raw(0:255), 16)
## Note that 16-bit integers require twice as many bytes
## as 8 bit integers:
length(rawToAmigaInt(as.raw(0:255), 16))
length(rawToAmigaInt(as.raw(0:255), 8))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.