Syntax
% format-modifier b(counter-name)
Purpose
The "%b" format item represents the value of the counter item as a binary string. The characters are determined by converting each byte in the binary representation of the counter into the character that represents the value of that byte. A counter with a value of zero (0) would be expressed in one byte as the character "%0#", a value of 1 as the character "%1#", and so on.
In fact, when the field-width is 1, the "%b" format item is the dynamic analog of the content "%#" modifier.
The following modifiers can be used with the "%b" format:
- "number". The byte order modifier consists only of a positive number. It does not contain an identifying character.
- "number f". The field-width modifier is allowed with the "%b" format. The "f" modifier requires a preceding positive number. It specifies the maximum number of bytes to which to convert the value. The specified number cannot be greater than the maximum size of a counter representation which currently is 4. The "f" format modifier with the "%b" format item can contain a value less than the number required to hold the formatted string. This effectively truncates the formatted string.
Note that when both the ordering and field-width modifiers are specified, the field-width modifier must appear first. Otherwise, OmniMark cannot tell when the first modifier ends and the second begins.
To convert a number to a multi-character string, both the length of the desired string and the order of the characters in it need to be known. The following outputs the value in the counter "temp" in four characters with high-to-low ordering, using the "f" modifier to specify the length:
- The default length is 1 (one). If the specified field-width is greater than the number of bytes needed to print the value, zero-value bytes ("%0#") are used to print the value, and they are placed as specified by the order.
- The byte ordering is determined by the following (in order of precedence):
- The byte order modifier on the "%b" format item.
- The ordering specified by the
binary
modifier on the stream to which the value is being written.
- The
binary-output
declaration.
- The byte ordering defaulting to 0.
- For example, if we were converting the value 16,909,060 (1 * 256^3 +2 * 256^2 +4 *1) to a string, the following table shows the string each byte modifier would produce:
- "%4f0b": "%10r(1,2,3,4)"
- "%4f1b": "%10r(2,1,4,3)"
- "%4f2b": "%10r(3,4,1,2)"
- "%4f3b": "%10r(4,3,2,1)"
- The "4f" modifier is necessary to convert all four bytes of the value to a string. Otherwise, only the least significant byte would be used.
Generated: April 21, 1999 at 2:01:01 pm
If you have any comments about this section of the documentation, send email to [email protected]
Copyright © OmniMark Technologies Corporation, 1988-1999.