version 1.132, 2004/11/28 20:20:37
|
version 1.133, 2004/12/08 12:47:29
|
Line 7599 doc-base
|
Line 7599 doc-base
|
doc-hex |
doc-hex |
doc-decimal |
doc-decimal |
|
|
|
|
@cindex '-prefix for character strings |
@cindex '-prefix for character strings |
@cindex &-prefix for decimal numbers |
@cindex &-prefix for decimal numbers |
|
@cindex #-prefix for decimal numbers |
@cindex %-prefix for binary numbers |
@cindex %-prefix for binary numbers |
@cindex $-prefix for hexadecimal numbers |
@cindex $-prefix for hexadecimal numbers |
|
@cindex 0x-prefix for hexadecimal numbers |
Gforth allows you to override the value of @code{base} by using a |
Gforth allows you to override the value of @code{base} by using a |
prefix@footnote{Some Forth implementations provide a similar scheme by |
prefix@footnote{Some Forth implementations provide a similar scheme by |
implementing @code{$} etc. as parsing words that process the subsequent |
implementing @code{$} etc. as parsing words that process the subsequent |
Line 7611 number in the input stream and push it o
|
Line 7612 number in the input stream and push it o
|
@cite{Number Conversion and Literals}, by Wil Baden; Forth Dimensions |
@cite{Number Conversion and Literals}, by Wil Baden; Forth Dimensions |
20(3) pages 26--27. In such implementations, unlike in Gforth, a space |
20(3) pages 26--27. In such implementations, unlike in Gforth, a space |
is required between the prefix and the number.} before the first digit |
is required between the prefix and the number.} before the first digit |
of an (integer) number. Four prefixes are supported: |
of an (integer) number. The following prefixes are supported: |
|
|
@itemize @bullet |
@itemize @bullet |
@item |
@item |
@code{&} -- decimal |
@code{&} -- decimal |
@item |
@item |
|
@code{#} -- decimal |
|
@item |
@code{%} -- binary |
@code{%} -- binary |
@item |
@item |
@code{$} -- hexadecimal |
@code{$} -- hexadecimal |
@item |
@item |
@code{'} -- base @code{max-char+1} |
@code{0x} -- hexadecimal, if base<33. |
|
@item |
|
@code{'} -- numeric value (e.g., ASCII code) of next character; an |
|
optional @code{'} may be present after the character. |
@end itemize |
@end itemize |
|
|
Here are some examples, with the equivalent decimal number shown after |
Here are some examples, with the equivalent decimal number shown after |
in braces: |
in braces: |
|
|
-$41 (-65), %1001101 (205), %1001.0001 (145 - a double-precision number), |
-$41 (-65), %1001101 (205), %1001.0001 (145 - a double-precision number), |
'AB (16706; ascii A is 65, ascii B is 66, number is 65*256 + 66), |
'A (65), |
'ab (24930; ascii a is 97, ascii B is 98, number is 97*256 + 98), |
-'a' (-97), |
&905 (905), $abc (2478), $ABC (2478). |
&905 (905), $abc (2478), $ABC (2478). |
|
|
@cindex number conversion - traps for the unwary |
@cindex number conversion - traps for the unwary |