On 10/19/26 9:44 AM, Krishna Myneni wrote:
> On 10/19/26 8:41 AM, peter wrote:
...
>> Nice to see that you could integrate it in kForth!
>>
>> I have also introduced it in ntf64/lxf64.
>> I liked the possibility to directly specify how many digits to print
>> instead of setting precision (that I half of the time misspell!)
>>
>> I might do a FS.N where n would be significant digits
>>
>
> Do you mean decimal places? The latest strings library in kForth-x has (FS.N) where n is decimal places. I think this corresponds to Fortran 90's ES<w>.<n> format, but haven't verified it yet.
>
> Normal FS. and (FS.) converts to output in significant digits specified via PRECISION.
>
...
From strings.4th:
\ Convert r to a scientific notation string, caddr u pair,
\ with n decimal places
: (fs.n) ( n -- a u ) ( F: r -- ) \ ( r n -- a u )
precision >r 1+ set-precision (fs.) strbufmove
r> set-precision ;
(FS.) is an intrinsic word in kForth, but it is easy to write using REPRESENT. I think I posted it in a previous thread.
FS.N where n is decimal places is often what users want.
--
KM