• Sometimes Forth is just fun!

    From Hans Bezemer@[email protected] to comp.lang.forth on Tue May 19 15:43:07 2026
    From Newsgroup: comp.lang.forth

    After all that IEEE-754 stuff, I had to do something with it. Because
    there was something I wanted to do for a long time - if just to honor
    the programmers that came up with it:

    : finvsqrt ( f -- 1/sqrt f)
    fdup f>ieee-sf 2/ negate 1597463007 + ieee-sf>f
    fswap f2/ fover fdup f* f* fnegate 3 s>f f2/ f+ f*
    ;

    16 s>f finvsqrt f. cr depth . fdepth .

    And it does this:

    $ pp4th -x zenisqrt.4th
    0.249576787396195506538282980998661071
    0 0

    :-)

    Hans Bezemer
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From minforth@[email protected] to comp.lang.forth on Tue May 19 20:19:09 2026
    From Newsgroup: comp.lang.forth

    Am 19.05.2026 um 15:43 schrieb Hans Bezemer:
    After all that IEEE-754 stuff, I had to do something with it. Because
    there was something I wanted to do for a long time - if just to honor
    the programmers that came up with it:

    : finvsqrt                             ( f -- 1/sqrt f)
      fdup f>ieee-sf 2/ negate 1597463007 + ieee-sf>f
      fswap f2/ fover fdup f* f* fnegate 3 s>f f2/ f+ f*
    ;

    16 s>f finvsqrt f. cr depth . fdepth .

    And it does this:

    $ pp4th -x zenisqrt.4th
    0.249576787396195506538282980998661071
    0 0

    :-)

    Hans Bezemer

    Thanks for this little piece of nostalgia :-)

    Some background:
    https://en.wikipedia.org/wiki/Fast_inverse_square_root

    --- Synchronet 3.22a-Linux NewsLink 1.2