Shop Learn P1 Docs P2 Docs Events
P2 Taqoz V2.8 Floating Point Library — Parallax Forums

P2 Taqoz V2.8 Floating Point Library

when I had a close look at HP-85 calculator computers in the net these days, I thought, this interactive calculator mode looks very nice! It was done in BASIC then.
So, what can we do, if we want to have an interactive floating point calculator but don't want to loose all those powerful features, that are already present in Taqoz? - Do it as a RPN calculator! And of course, you can use the floating point library in your Forth programs too. Well, I know "real men do not use floating point math"....

This is an adoption of a Library by Klaus Schleisiek. - Many thanks! There is a nice description of it:
The original source code is from:

Unfortunately Taqoz is a non-standard Forth. So some words had to be translated. And there have been some traps hidden well. For example "2/" is unsigned in Taqoz.... It was very helpful to have the library running in GForth in parallel.

The picture shows some calculations. On Top the stack is displayed in hex, decimal, and float. The dup statements have been inserted, to preserve the old values.
Have fun!


  • Christof Eb.Christof Eb. Posts: 852
    edited 2023-02-13 10:04

    Is it slow? Oh, yes it is: about 100 times slower than normal integer Forth and 600 times slower than optimized HUB assembler in this test.
    As the floats are handled using the normal stack, SWAP and OVER act just as normal. There is much to do to add 2 floats with "f+".....

    \ normal Forth version:
    : fiboForth ( n -- nfibo )  \ Fibonacci Reihe, liefert letztes Ergebnis
        0 1 
        ROT 1 - FOR 
            SWAP OVER  
        SWAP DROP
    : fiboFloat ( n -- nfibo )  
        0 float 1 float
        ROT 1 - FOR 
            SWAP OVER  
        SWAP DROP
        integer \ result as integer
Sign In or Register to comment.