,---------------. | Contributions | `---------------´ ,------------------------------------------ | 2021-05-21 17:58:29 JimPeterson wrote: | referenceImplementation - Possible Reference Implementation | see: https://forth-standard.org/standard/string/DivSTRING#contribution-203 `------------------------------------------ Would this be a sufficient reference implementation?: ``` : /STRING DUP >R - SWAP R> CHARS + SWAP ; ``` Are there no checks for when u2 might go negative (or, really, wraps around, as it's considered unsigned)? ,---------. | Replies | `---------´ ,------------------------------------------ | 2021-05-21 22:33:11 ruv replies: | referenceImplementation - Possible Reference Implementation | see: https://forth-standard.org/standard/string/DivSTRING#reply-695 `------------------------------------------ > Are there no checks for when u2 might go negative? Formally, _u2_ cannot be negative since it's an unsigned number (a number that is interpreted as an unsigned number). See [data type symbols](https://forth-standard.org/standard/usage#table:datatypes) and their meaning. In some use-cases it could be a problem if _n_ > _u1_, but it's out of the scope of the standard, if a user tries to shoot himself in the foot. OTOH, it could be a correct and expected intermediate result. > Would this be a sufficient reference implementation? Yes, I think. Other possible variants: ``` : /string ( c-addr1 u1 n -- c-addr2 u2 ) tuck - >r chars + r> ; : /string ( c-addr1 u1 n -- c-addr2 u2 ) tuck - -rot chars + swap ; ```