DEC
Return Decimal Value of ASCII String
This numeric function returns the decimal integer value of an ASCII character string.
Syntax
Section titled “Syntax”DEC (string-value [,ERR=line-ref|,ERC=error-code])string-value- is a string whose numeric equivalent ranges from 0 through +/-.99999999999999E+141.
line-ref- is the program line number or label to branch to if an error is produced by this function.
error-code- is a programmer-defined error code. Valid values are positive or negative whole numbers.
Remarks
Section titled “Remarks”The DEC function is similar to the ASC function, but the ASC function operates on only a single character. The DEC function is the reverse of the BIN function.
The DEC function treats the leftmost bit as a sign bit and generates a negative integer if that bit is set to (1) or a positive integer if that bit is clear (0). The ASC function does not use the highest bit as a sign bit.
Examples
Section titled “Examples”DEC ("A")returns the value 65; the decimal code for the character “A”.
LET X = DEC (B$)If B$=“AB”, this statement assigns X the value 16706.
DEC (BIN(193,1))returns the value -63 because this BIN function causes the sign (leftmost) bit to be set to 1 and DEC interprets it as a negative value.
See also
Section titled “See also”From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF