Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/4th/lib/fexp.4th

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


\ 4tH library - FEXP - Copyright 2008 J.L. Bezemer
\ You can redistribute this file and/or modify it under
\ the terms of the GNU General Public License

[UNDEFINED] fexp [IF]
[UNDEFINED] +taylor [IF] include lib/taylor.4th [THEN]

: (!) over * swap 1+ swap ; 

: ^integer               ( float -- integer fraction)
  fdup f>d 2dup d>f f- 1 s>f 2dup d0< -rot dabs d>u
  0 ?do e f* loop if 1 s>f fswap f/ then fswap
;

: ^fraction              ( integer fraction -- float)
  1 dup dup s>f fswap fover
  begin over 13 < while (!) dup +taylor repeat
  drop drop fdrop fdrop f*
;

: fexp ^integer ^fraction ;

[DEFINED] 4TH# [IF]
hide (!)
hide ^integer
hide ^fraction
[THEN]
[THEN]

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.