On Fri, 16 Oct 2026 23:31:07 -0500
Krishna Myneni <kris…@ccreweb.org> wrote:
> On 10/8/26 3:07 PM, peter wrote:
> ...
> > : f.n ( F:fp n -- )
> ...
> > over 0< if
> > dup 0 <= if nip 0 swap else \ negative e and n
> > swap over 1- negate max swap \ limit negative n
> > else swap over 1024 swap - min swap then then \ limit positive n
> ...
>
> > Here is the code for (F.N)
> >
> > \ (F.N) print float with n decimals to string
>
> > : (f.n) ( F:fp n -- )
> ...
> > over 0< if
> > dup 0 <= if nip 0 swap else \ negative e and n
> > swap over 1- negate max swap \ limit negative n
> > else swap over 1024 swap - min swap then then \ limit positive n
> ...
> The code snippets above use a control structure of the form
>
> IF ... IF ... ELSE ... ELSE ... THEN THEN
>
> Is this consistent with the standard?
>
> --
> Krishna
Thanks for noticing this! It might be standard but it does not do
what it should! The limit positive n does not execute when it should.
Here is a version that corrects this.
over 0 >= if
swap over 1024 swap - min swap else \ limit positive n
dup 0<= if nip 0 swap else \ limit negative n when e negative
1 over - rot max swap then then \ limit negative n
It worked correctly until I added the test for negative n and e!
BR
Peter