From: George H. <geo...@us...> - 2006-01-24 09:13:30
|
Update of /cvsroot/win32forth/win32forth/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23232/win32forth/doc Modified Files: p-index.htm Added Files: p-float.htm Log Message: gah: Further documentation and dexing (work in progress) Index: p-index.htm =================================================================== RCS file: /cvsroot/win32forth/win32forth/doc/p-index.htm,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** p-index.htm 15 Jan 2006 09:25:49 -0000 1.10 --- p-index.htm 24 Jan 2006 09:13:21 -0000 1.11 *************** *** 137,140 **** --- 137,141 ---- <li><a href="p-classes.htm">Win32Forth Classes</a></li> <li><a href="p-classdbg.htm">Class Debugging Words</a></li> + <li><a href="p-float.htm">Floating point words in Win32Forth</a></li> <li><a href="p-module.htm">Using the Module Wordset</a></li> <li><a href="p-task.htm">Using the Task Wordset</a></li> --- NEW FILE: p-float.htm --- <html> <head> <meta http-equiv="Content-Language" content="en-gb"> <meta name="GENERATOR" content="dexh00"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title> W32F float</title><style><!-- h1 { font-family: Tahoma; font-size: 24pt; font-weight: bold } h2 { font-family: Tahoma; font-size: 18pt; font-weight: bold } --> </style> </head> <body><h1 align="center"> <a href="mailto:win...@ya...?subject=DOC:Doc error in $Id: p-float.htm,v 1.1 2006/01/24 09:13:21 georgeahubert Exp $"> <img border="0" src="TELLUS.gif" align="left" width="32" height="32"></a> <img border="0" src="FORTHPRO.gif" width="32" height="32"> Win32Forth</h1> <hr /><h1>Floating point words in Win32Forth </h1><hr /><p>Win32Forth implements the full ANSI floating-point and floating-point extension wordsets as well as a number of useful extra words. It uses a separate floating-point stack (implemented in the USER area for task safety). </p><p>The floating-point words can be compiled as 8 bit (for speed) or 10 bit (for accuracy). The default when the system is built is 8 bit, but can be set to 10 bit (in src\extend.f) by altering the CONSTANT B/FLOAT and re-extending the system (using setup.exe). If the CONSTANT is not defined then the file automatically creates it and compiles the code for 10 bit floats. </p><p>The only error that is thrown is for FP stack Underflow (error code -45); arithmetic operations which produce values too large to be represented use infinity, while indeterminate results produce NANs. </p><h2>Glossary </h2><pre><b><a name="0">code finit ( -- ) \ W32F Floating extra </a></b></pre><p>Clears the floating-point stack & sets the appropriate byte mode. It is executed by the system on start-up and by the default exception handler. Users generally don't need to call this word in a single-task program. Tasks in a multi-task program should execute this word before executing any other floating-point words. </p><h3>Memory Access </h3><pre><b><a name="0">code F@ ( addr -- ) ( FS: -- r ) \ ANSI Floating </a></b></pre><p>Fetch a float. </p><pre><b><a name="0">code SF@ ( addr -- ) ( FS: -- r ) \ ANSI Floating ext </a></b></pre><p>Fetch a 32 bit (short) float. </p><pre><b><a name="0">code DF@ ( addr -- ) ( FS: -- r ) \ ANSI Floating ext </a></b></pre><p>Fetch a 64 bit (double) float. </p><pre><b><a name="0">code F! ( addr -- ) ( fs: r -- ) \ ANSI Floating </a></b></pre><p>Store a float. </p><pre><b><a name="0">code SF! ( addr -- ) ( fs: r -- ) \ ANSI Floating ext </a></b></pre><p>Store a 32 bit (short) float. </p><pre><b><a name="0">code DF! ( addr -- ) ( fs: r -- ) \ ANSI Floating ext </a></b></pre><p>Store a 64 bit (double) float. </p><pre><b><a name="0">code F+! ( addr -- ) ( fs: r -- ) \ W32F Floating extra </a></b></pre><p>Add the value to a float. </p><pre><b><a name="0">: FVARIABLE ( compiling -<name>- -- ; run-time -- addr) \ ANSI Floating </a></b></pre><p>Define a floating-point variable in the dictionary. The contents are undefined. </p><pre><b><a name="0">: FVALUE ( compiling -<name>- -- FS: r -- ; run-time FS: -- r ) \ W32F Floating extra </a></b></pre><p>Define a floating point value initialised from the FP stack. </p><pre><b><a name="0">: FTO \ W32F Floating extra </a></b></pre><p><b> Interpreting: ( -<fvalue>- -- FS: r -- ) <br /> Compiling: ( -<fvalue>- -- Run-time: FS: r -- ) </b> </p><p>Store r into -<fvalue>-. If -<fvalue>- is not defined with fvalue then memory may be corrupted; no checks are made so the user should take care. FTO should not be POSTPONEd. </p><pre><b><a name="0">: FCONSTANT \ ANSI Floating </a></b></pre><p><b> Compiling: ( -<name>- ) ( F: r -- ) <br /> </b><b> Run-time: ( F: -- r ) </b> <br /> </p><p>Define an FP constant. </p><h3>Stack operations </h3><pre><b><a name="0">code FDROP ( fs: r -- ) \ ANSI Floating </a></b></pre><p>Remove r from the floating-point stack. </p><pre><b><a name="0">code FDUP ( fs: r -- r r ) \ ANSI Floating </a></b></pre><p>Duplicate the top entry on the floating-point stack. </p><pre><b><a name="0">code FSWAP ( fs: r1 r2 -- r2 r1 ) \ ANSI Floating </a></b></pre><p>Exchange the top 2 FP numbers. </p><pre><b><a name="0">code FOVER ( fs: r1 r2 -- r1 r2 r3 ) \ ANSI Floating </a></b></pre><p>Copy the 2nd FP stack number to the top of the FP stack. </p><pre><b><a name="0">code FROT ( fs: r1 r2 r3 -- r2 r3 r1 ) \ ANSI Floating </a></b></pre><p>Rotate the top 3 FP stack numbers. </p><pre><b><a name="0">code FPICK ( n -- ) ( fs: -- r ) \ W32F Floating extra </a></b></pre><p>Copy the n'th number from the FP stack. </p><pre><b><a name="0">: FNIP ( fs: r1 r2 -- r2 ) \ W32F Floating extra </a></b></pre><p>Remove the 2nd FP stack entry. </p><h3>FP Stack operations on pairs of entries </h3><p>The following words can be used for pairs of FP numbers and are useful for dealing with complex numbers or 2-dimensional vectors on the FP stack. </p><pre><b><a name="0">code F2DROP ( fs: r1 r2 -- ) \ W32F Floating extra </a></b></pre><p>Remove the top 2 FP stack entries. </p><pre><b><a name="0">: F2DUP ( fs: r1 r2 -- r1 r2 r3 r4 ) \ W32F Floating extra </a></b></pre><p>Duplicate the top 2 FP stack entries. </p><pre><b><a name="0">: F2SWAP ( fs: r1 r2 r3 r4 -- r3 r4 r2 r1 ) \ W32F Floating extra </a></b></pre><p>Swap the top pair of floating-point numbers with the second pair. </p><pre><b><a name="0">: F2NIP ( fs: r1 r2 r3 r4 -- r3 r4 ) \ W32F Floating extra </a></b></pre><p>Remove the 2nd pair of FP stack entries. </p><h3>Constants </h3><pre><b><a name="0">code fpi ( fs: -- r ) \ W32F Floating extra </a></b></pre><p>Push the value 3.141596... on to the FP stack. </p><pre><b><a name="0">code f1.0 ( fs: -- r ) \ W32F Floating extra </a></b></pre><p>Push the value 1.0 on to the FP stack. </p><pre><b><a name="0">code fL2t ( fs: -- r ) \ W32F Floating extra </a></b></pre><p>Push the value of log base 2 of 10. </p><pre><b><a name="0">code fL2e ( fs: -- r ) \ W32F Floating extra </a></b></pre><p>Push the value of log base 2 of e. </p><pre><b><a name="0">code fLog2 ( fs: -- r ) \ W32F Floating extra </a></b></pre><p>Push the value of log base 10 of 2. </p><pre><b><a name="0">code fLn2 ( fs: -- r ) \ W32F Floating extra </a></b></pre><p>Push the vlue of ln 2 (the natural logarithm). </p><pre><b><a name="0"> f1.0 fconstant f0.0 ( FS: -- r ) \ W32F Floating extra </a></b></pre><p>Push plus zero. </p><pre><b><a name="0"> f0.0 fconstant finf ( FS: -- r ) \ W32F Floating extra </a></b></pre><p>Push plus infinity. </p><pre><b><a name="0"> f1.0 fconstant f2.0 ( FS: -- r ) \ W32F Floating extra </a></b></pre><p>Push 2.0 </p><h3>Rounding Modes </h3><pre><b><a name="0">code FLOOR ( fs: f1 -- fs: f2 ) \ ANSI Floating </a></b></pre><p>Set rounding mode to round to -infinity. </p><pre><b><a name="0">code FCEIL ( fs: f1 -- fs: f2 ) \ W32F Floating wxtra </a></b></pre><p>Set rounding mode to round to +infinity. </p><pre><b><a name="0">code FTRUNC ( fs: f1 -- fs: f2 ) \ W32F Floating extra </a></b></pre><p>Set rounding mode to truncate. </p><pre><b><a name="0">code FROUND ( fs: f1 -- fs: f2 ) \ ANSI Floating </a></b></pre><p>Set rounding mode to round to nearest. </p><h3>Integer to float coversion </h3><h3>Comparison operators </h3><h3>Maths operators </h3><h3>Output conversion. </h3><pre><b><a name="0">: PRECISION ( -- u ) \ ANSI Floating ext </a></b></pre><p>Return the number of significant digits currently used by (F.), (FE.), (FS.), F., FE., or FS. as u. </p><pre><b><a name="0">: SET-PRECISION ( u -- ) \ ANSI Floating ext </a></b></pre><p>Set the number of significant digits currently used by (F.), (FE.), (FS.), F., FE., or FS. to u. </p><pre><b><a name="0">: min-precision ( u -- ) \ W32F Floating extra </a></b></pre><p>Set the number of significant digits currently used by (F.), (FE.), (FS.), F., FE., or FS. to u if it is greater than the present setting. </p><h3>Format FP number to a buffer </h3><p>The following words are for formatting floating point numbers as counted strings in the buffer whose address supplied so they can be used for purposes other than printing the numbers to the console. The string is not null terminated. </p><pre><b><a name="0">: (F.) ( addr -- ) ( F: r -- ) \ W32F Floating extra </a></b></pre><p>Format the top number on the floating-point stack using fixed-point notation: </p><pre> [-] <digits>.<digits0> </pre><hr><p>Document $Id: p-float.htm,v 1.1 2006/01/24 09:13:21 georgeahubert Exp $</p> </body></html> |