docs(core): correct sign handling note in number conversion docs
The doc comments still claimed a leading + binds as a sign. It does not: sf64 converts +7 as the double 7 with DPL 1, and the code follows that. Only a leading - is a sign.
This commit is contained in:
@@ -34,10 +34,10 @@ use crate::optimizer::optimize;
|
|||||||
// Number conversion
|
// Number conversion
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Characters that force double-cell conversion when they appear after the
|
/// Characters that force double-cell conversion, following `SwiftForth`'s
|
||||||
/// leftmost digit, following `SwiftForth`'s input number conversion rules.
|
/// input number conversion rules.
|
||||||
///
|
///
|
||||||
/// A leading `-` or `+` is a sign rather than punctuation, which keeps `-1`
|
/// A leading `-` is the one exception: it binds as a sign, which keeps `-1`
|
||||||
/// a single-cell number while `1-2` converts as a double.
|
/// a single-cell number while `1-2` converts as a double.
|
||||||
const DOUBLE_PUNCTUATION: [u8; 6] = *b",.+-/:";
|
const DOUBLE_PUNCTUATION: [u8; 6] = *b",.+-/:";
|
||||||
|
|
||||||
@@ -2779,10 +2779,10 @@ impl<R: Runtime> ForthVM<R> {
|
|||||||
/// Try to convert a token to a number, following `SwiftForth`'s input
|
/// Try to convert a token to a number, following `SwiftForth`'s input
|
||||||
/// number conversion rules.
|
/// number conversion rules.
|
||||||
///
|
///
|
||||||
/// Punctuation (`,` `.` `+` `-` `/` `:`) anywhere after the leftmost digit
|
/// Punctuation (`,` `.` `+` `-` `/` `:`) forces double-cell conversion, so
|
||||||
/// forces double-cell conversion, so `12.34`, `1,234`, `12:30:45` and
|
/// `12.34`, `1,234`, `12:30:45` and `2026-08-06` all convert as doubles.
|
||||||
/// `2026-08-06` all convert as doubles. A leading `-` or `+` is a sign, not
|
/// Only a leading `-` escapes this and binds as a sign, which keeps `-1`
|
||||||
/// punctuation, which keeps `-1` single-cell.
|
/// single-cell; a leading `+` stays punctuation, so `+7` is the double 7.
|
||||||
///
|
///
|
||||||
/// `DPL` counts up once per digit from [`DPL_INIT`] and resets to zero at
|
/// `DPL` counts up once per digit from [`DPL_INIT`] and resets to zero at
|
||||||
/// every punctuation character, so it ends up holding the digit count right
|
/// every punctuation character, so it ends up holding the digit count right
|
||||||
|
|||||||
Reference in New Issue
Block a user