previous next top contents index framed top this page unframed
Figure 32–82. cvb (GENERIC)
| $BUILTIN COMPILETIME BITS PROCEDURE cvb (INTEGER i); BITS PROCEDURE cvb (STRING s; OPTIONAL BITS radix); $BUILTIN COMPILETIME BITS PROCEDURE cvb (LONG BITS b); $BUILTIN COMPILETIME BITS PROCEDURE cvb (LONG INTEGER i); $BUILTIN COMPILETIME BITS PROCEDURE cvb (BITS b); |
cvb converts to BITS.
The (LONG) INTEGER forms convert i to the bit pattern for its binary representation, truncated on the left if necessary; i.e., cvs(cvb(i),binary) produces the STRING that is the standard mathematical base-two representation for i's value.
The LONG BITS form discards high-order bits if there are fewer bits in a BITS than in a LONG BITS on the target system.
The BITS form returns its argument.
b := cvb(s) produces the same result as r := s; read(r,b), where r is a temporary STRING variable. The valid bits for radix are binary, hex, and octal (octal is assumed if radix is not specified); s is assumed to contain a value in the specified radix unless s contains an explicit radix specifier ('B, 'H, 'O, or ' (the latter is equivalent to 'O)), in which case the explicit radix specifier overrides the radix bit.
Example 32–83. Use of cvb
| cvb(97) = '141 cvb('723L) = '723 cvb("Location '134 in error.") = '134 cvb("Location 134 in error.") = '134 cvb("134",hex) = '464 = 'H134 cvb("Location 134 in error.",hex) = '312 = 'HCA (because the ca in Location is interpreted as a hexadecimal number) |
MAINSAIL Language Manual, Section 32.82