Diff for /gforth/float.fs between versions 1.2 and 1.5

version 1.2, 1994/05/07 14:55:49 version 1.5, 1994/06/17 12:34:59
Line 1 Line 1
 \ High level floating point                            14jan94py  \ High level floating point                            14jan94py
   
 : faligned ( addr -- f-addr )  
   [ 1 floats 1- ] Literal + [ -1 floats ] Literal and ;  
   
 : falign ( -- )  
   here dup aligned swap  
   ?DO  bl c,  LOOP ;  
   
 : f, ( f -- )  here 1 floats allot f! ;  : f, ( f -- )  here 1 floats allot f! ;
   
 \ !! have create produce faligned pfas  \ !! have create produce faligned pfas
 : fconstant  ( r -- )  : fconstant  ( r -- )
   Create falign f,    falign here f,  Create A,
   DOES>  faligned f@ ;    DOES>  @ f@ ;
   
 : fvariable  : fvariable
   Create falign 0 f,    falign here 0. d>f f, AConstant ;
   DOES>  faligned ;  
   
 : fdepth  ( -- n )  f0 @ fp@ - [ 1 floats ] Literal / ;  : fdepth  ( -- n )  f0 @ fp@ - [ 1 floats ] Literal / ;
   
Line 34 Line 26
 : -zeros ( addr u -- addr' u' )  : -zeros ( addr u -- addr' u' )
   BEGIN  dup  WHILE  1- 2dup + c@ '0 <>  UNTIL  1+  THEN ;    BEGIN  dup  WHILE  1- 2dup + c@ '0 <>  UNTIL  1+  THEN ;
   
 : f.  ( r -- )  scratch represent 0=  : f$ ( f -- n )  scratch represent 0=
   IF  2drop  scratch 3 min type  EXIT  THEN    IF  2drop  scratch 3 min type  rdrop  EXIT  THEN
   IF  '- emit  THEN  dup >r 0<    IF  '- emit  THEN ;
   IF  '0 emit  
   : f.  ( r -- )  f$ dup >r 0<
     IF    '0 emit
   ELSE  scratch r@ min type  r@ precision - zeros  THEN    ELSE  scratch r@ min type  r@ precision - zeros  THEN
   '. emit r@ negate zeros    '. emit r@ negate zeros
   scratch r> 0 max /string 0 max -zeros type space ;    scratch r> 0 max /string 0 max -zeros type space ;
   \ I'm afraid this does not really implement ansi semantics wrt precision.
   \ Shouldn't precision indicate the number of places shown after the point?
   
 : fe. ( r -- )  scratch represent 0=  : fe. ( r -- )  f$ 1- s>d 3 fm/mod 3 * >r 1+ >r
   IF  2drop  scratch 3 min type  EXIT  THEN  
   IF  '- emit  THEN  1- s>d 3 fm/mod 3 * >r 1+ >r  
   scratch r@ min type '. emit  scratch r> /string type    scratch r@ min type '. emit  scratch r> /string type
   'E emit r> . ;    'E emit r> . ;
   
 : fs. ( r -- )  scratch represent 0=  : fs. ( r -- )  f$ 1-
   IF  2drop  scratch 3 min type  EXIT  THEN    scratch over c@ emit '. emit 1 /string type
   IF  '- emit  THEN  1- >r    'E emit . ;
   scratch 1 min type '. emit  scratch 1 /string type  
   'E emit r> . ;  : fnumber ( string -- r / )
     ?dup IF  dup count >float 0=
 : fnumber ( string -- r / )  dup count >float 0=             IF    defers notfound
   IF  defers notfound  ELSE  drop  THEN ;             ELSE  drop state @
                    IF  postpone FLiteral  THEN  THEN  THEN ;
   
 ' fnumber IS notfound  ' fnumber IS notfound
   

Removed from v.1.2  
changed lines
  Added in v.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>