0.9b (c) 1995 Peter Childs
>>---C2D(string -+-----+-)------>< +-,n--+
C2D returns the decimal value of the binary representation of string. If the result cannot be expressed as a whole number, an error results. That is, the result must not have more digits than the current setting of NUMERIC DIGITS.
If string is the null string, then 0 is returned.
If n is not specified, string is processed as an unsigned binary number.
Here are some examples:
C2D('09'X) -> 9 C2D('81'X) -> 129 C2D('FF81'X) -> 65409 C2D('a') -> 97 /* ASCII */
If n is specified, the given string is padded on the left with 00x characters (note, not sign-extended), or truncated on the left to n characters. The resulting string of n hexadecimal digits is taken to be a signed binary number: positive if the leftmost bit is OFF, and negative, in two's complement notation, if the leftmost bit is ON. If n is 0, then 0 is always returned.
Here are some examples:
C2D('81'X,1) -> -127 C2D('81'X,2) -> 129 C2D('FF81'X,2) -> -127 C2D('FF81'X,1) -> -127 C2D('FF7F'X,1) -> 127 C2D('F081'X,2) -> -3967 C2D('F081'X,1) -> -127 C2D('0031'X,0) -> 0
Implementation maximum: The input string cannot have more than 250 characters that will be significant in forming the final result. Leading sign characters (00x and ffx) do not count toward this total.
Inf-HTML End Run - Successful