Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Added: | ||||||||
> > |
Floating Point Unit (FPU)
Intro
Why Floating Point?Forth systems traditionally make use of cooperative multitasking. It is very simple and clever. But it has its limits. If you write all your software by yourself, each software part can be cooperative. But if you want to benefit from middleware written by somebody else (and most probably not written in Forth), you can be sure that software is not cooperative (in the context of multitasking). Forth wants to rule your system. I would like to have a Forth system that is cooperative. It should extend the system, to make it interactive and easy to use. The Forth interpreter (called terminal task in Forth jargon) itself is only a thread and can be used as some sort of CLI for testing purposes or could be the main part of the application.Forth MultitaskingAndrew Haley wrote "Forth has been multi-tasking for almost 50 years. It's time to standardize it" and he is right. I will implement his proposed API for Mecrisp-Cube described in A multi-tasking wordset for Standard Forth![]() MULTI , SINGLE , or INIT-MULTI .
| |||||||
Floating Point Unit | ||||||||
Added: | ||||||||
> > | ||||||||
Line: 108 to 134 | ||||||||
#endif | ||||||||
Added: | ||||||||
> > |
Floating Point Wordsf+ ( r1 r2 -- r3 ) Add r1 to r2 giving the sum r3. f- ( r1 r2 -- r3 ) Subtract r2 from r1, giving r3. f* ( r1 r2 -- r3 ) Multiply r1 by r2 giving r3. f/ ( r1 r2 -- r3 ) Divide r1 by r2, giving the quotient r3. fsqrt ( r1 -- r2 ) r2 is the square root of r1. fabs ( r1 -- r2 ) r2 is the absolute value of r1. fnegate ( r1 -- r2 ) r2 is the negation of r1. f>s ( r -- n ) n is the single-cell signed-integer equivalent of the integer portion of r. s>f ( n -- r ) r is the floating-point equivalent of the single-cell value n. f. ( r -- ) Display, with a trailing space, the top number using fixed-point notation: | |||||||
Deleted: | ||||||||
< < | -- ![]() | |||||||
Changed: | ||||||||
< < | Comments | |||||||
> > | -- ![]() | |||||||
Deleted: | ||||||||
< < | ||||||||
\ No newline at end of file | ||||||||
Added: | ||||||||
> > | ![]() This work by Peter Schmid is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. |