dec2bcd {convertBCD}R Documentation

Convert decimal numbers to binary-coded decimal (BCD) form. ~~ ~~

Description

The input decimal values are converted to one or two vectors of class "raw" , representing an integer and optionally a decimal portion of a number.

Usage

dec2bcd(x, endian = c("little", "big"))

Arguments

x

Decimal numbers. Can be one of the following classes: numeric, bigz, character.

endian

The order of bytes desired in the raw BCD output.

Details

The BCD format reserves a full byte for each character (number) in an input value. While this is memory-expensive, it guarantees the exact value is stored, unlike class numeric or others, which are subject to binary expansion rounding errors. There is no standard for indicating the location of a decimal point in BCD data, which is why the integer and decimal portion are returned separately. .

Value

A list containing: intx , a vector of strings representing the integer parts of the decimal number decx, a vector of strings representing the decimal parts of the decimal number, if any.

Author(s)

Carl Witthoft, carl@witthoft.com

See Also

bcdToInteger , bcd2dec

Examples

foo <- dec2bcd('37.852')
bar <- bcd2dec(foo$xint[[1]],foo$xdec[[1]])


[Package convertBCD version 1.0 Index]