Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #135278 > unrolled thread
| Started by | Krishna Myneni <krishna.myneni@ccreweb.org> |
|---|---|
| First post | 2026-07-26 16:00 -0500 |
| Last post | 2026-08-13 07:24 -0500 |
| Articles | 4 — 1 participant |
Back to article view | Back to comp.lang.forth
prelim test code for Forth big number code (FSL #47) Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-26 16:00 -0500
Re: prelim test code for Forth big number code (FSL #47) Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-08-02 21:33 -0500
Re: prelim test code for Forth big number code (FSL #47) Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-08-05 06:47 -0500
Re: prelim test code for Forth big number code (FSL #47) Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-08-13 07:24 -0500
| From | Krishna Myneni <krishna.myneni@ccreweb.org> |
|---|---|
| Date | 2026-07-26 16:00 -0500 |
| Subject | prelim test code for Forth big number code (FSL #47) |
| Message-ID | <1145sgl$2mg4t$1@dont-email.me> |
I ported Len Zettel's big number code, big.4th (Forth Scientific Library
algorithm #47) to kForth, and added some preliminary test code to it.
The existing version on the FSL website (May 1999 revision) does not
include any test code. The test code passes on kForth-64/32/Win-32 and
is listed below.
A glossary of words has also been added (see below).
See
https://github.com/mynenik/kForth-64/blob/master/forth-src/fsl/big.4th
The file big.4th is now a part of all three kForth repos (64-bit Linux,
32-bit Linux, and Win32). To load and run the tests from kForth:
include ans-words
include modules
true value test-code? \ comment this line to skip testing
include fsl/big
--
Krishna Myneni
Glossary (User level words):
\ MAKE_BIG_NUMBER ( caddr1 u1 -- addr2) Convert string to big number
\ <BIG# ( --) Begin big number pictured output
\ BIGHOLD ( c -- ) Append char c to beginning of big pictured output
\ BIG# ( addr -- addr) Generate next character from big number at
addr
\ BIG#S ( addr -- addr) Convert all digits of big number at addr
\ BIGSIGN ( n --) Put minus sign in big pictured output if n < 0
\ #BIG> ( addr1 -- caddr2 u2) End big number pictured output
\ BIG ( <cccc> -- addr) Parse, convert, return big number
\ BIG. ( addr --) Print a big number
\ BIGNEGATE ( addr --) Negate big number at addr
\ BIGABS ( addr --) Apply absolute value to big number at addr
\ BIG0= ( addr -- flag) Test big number is zero.
\ BIG0<> ( addr -- flag) Test big number is not zero.
\ BIG0< ( addr -- flag) Test big number is negative.
\ BIG= ( addr1 addr2 -- flag) Test equality for two big numbers
\ BIG< ( addr1 addr2 -- flag) Test less than for two big numbers
\ BIG+S ( addr n --) Add single to big number at addr
\ BIG*S ( addr n -- ) Multiply single to big number at addr
\ BIG/MODS ( addr n1 -- n2) Divide big number by n1, n2 is remainder
\ BIG+ ( addr1 addr2 -- addr3) Add two big numbers, return sum
\ BIG- ( addr1 addr2 - addr3) Subtract big numbers, return diff
\ BIG* ( addr1 addr2 -- addr3) Multiply big numbers, return prod
\ BIG/ ( addr1 addr2 -- addr3) Divide big numbers, return quotient
\ BIGMOD ( addr1 addr2 -- addr3) Divide big numbers, return remainder
\ BIG/MOD ( addr1 addr2 -- addr3 addr4) Divide, return remainder and
quotient
Note: If you are using the original May 1999 version of big.4th, make
the following changes to the test code below:
1. Replace "BIG-HERE" with "HERE"
2. Replace "BIG," with ","
=== snipped from kForth port of big.4th ===
[DEFINED] TEST-CODE? [IF]
TEST-CODE? [IF]
BASE @ DECIMAL
[UNDEFINED] T{ [IF] include ttester [THEN]
COMMENT Partial testing of the big number words.
COMMENT Tests assume BIG= works.
0 ptr b1
0 ptr b2
0 ptr b3
TESTING MAKE_BIG_NUMBER
t{ biggest s>d <# #s #> make_big_number to b1 -> }t
t{ b1 @ -> 1 }t
t{ b1 cell+ @ -> biggest }t
t{ 0 1 <# #s #> make_big_number to b2 -> }t
t{ b2 @ -> 2 }t
t{ b2 cell+ @ 0 bigbase b2 cell+ cell+ @ UM* D+ -> 0 1 }t
TESTING <BIG# BIG#s #BIG>
create sbuf 32 allot
variable slen
t{ -1 0 <# #s #> dup slen ! sbuf swap move -> }t
t{ sbuf slen @ make_big_number to b1 -> }t
t{ b1 <big# big#s #big> sbuf slen @ compare -> 0 }t
TESTING BIG*S
\ "big factorial"
: big! ( n -- addr )
big-here 1 big, 1 big, \ addr of new big 1
swap abs 1+ 200 min
1 do dup I BIG*S loop ;
t{ 100 big!
big
93,326,215,443,944,152,681,699,238,856,266,700,490,715,968,264,381,621,468,592,963,895,217,599,993,229,915,608,941,463,976,156,518,286,253,697,920,827,223,758,251,185,210,916,864,000,000,000,000,000,000,000,000
big= -> true }t
TESTING BIG* BIG/
t{ big 199,928,740,922,274,529,000,090,300,055,888,888 to b1 -> }t
t{ big 20,384,923,712 to b2 -> }t
t{ big 4,075,532,131,536,778,795,187,572,407,750,484,318,228,512,256 to
b3 -> }t
t{ b1 b2 big* b3 big= -> true }t
t{ big 9,807,676,680,417,617,105,678,884 to b3 -> }t
t{ b1 b2 big/ b3 big= -> true }t
t{ big 288,265,561,597,526,014
big 17,593,259,786,239
big/
big 16384 big= -> true }t
BASE !
[THEN]
[THEN]
=== end of test code from big.4th ===
[toc] | [next] | [standalone]
| From | Krishna Myneni <krishna.myneni@ccreweb.org> |
|---|---|
| Date | 2026-08-02 21:33 -0500 |
| Message-ID | <114oump$vdib$1@dont-email.me> |
| In reply to | #135278 |
On 7/26/26 16:00, Krishna Myneni wrote:
> I ported Len Zettel's big number code, big.4th (Forth Scientific Library
> algorithm #47) to kForth, and added some preliminary test code to it.
> The existing version on the FSL website (May 1999 revision) does not
> include any test code. The test code passes on kForth-64/32/Win-32 and
> is listed below.
>
> A glossary of words has also been added (see below).
>
> See
> https://github.com/mynenik/kForth-64/blob/master/forth-src/fsl/big.4th
>
> The file big.4th is now a part of all three kForth repos (64-bit Linux,
> 32-bit Linux, and Win32). To load and run the tests from kForth:
>
The big number code can be used to perform correct conversion of
IEEE-754 double precision numbers to ascii strings. Below is a proof of
concept demonstration for kForth-64. The dtoa.4th. code demonstrates
conversion of simple cases: normal dp floats, limited number of
converted digits, limited positive and negative exponents -- it is not
yet useful for general dp floats. Some of the limitations stem from the
big number package itself (I think) while others are the simplicity of
the present code, compared to something like dtoa.c.
In addition to fsl/big.4th I needed to add a few more big number words,
big-extras.4th, which is not yet a part of the kForth packages, but is
appended below. The other include files are included in kForth packages.
The dtoa.4th code is presently limited to 64-bit Forths with a separate
floating point stack. This is not an intrinsic limitation however.
--
Krishna Myneni
Proof of concept examples for converting double precision floating point
numbers to big whole numbers.
Note the differences in the exact representations for 1 through 3.
Number 4 is the example Anton Ertl gave using a GNU glibc library
function in a separate thread. Number 5 shows proper handling of the sign.
1)
1.508e0 df>big big.
15080000000000000071054273576010018587112426757812500 ok
2)
1.508e2 df>big big.
1508000000000000113686837721616029739379882812500000000 ok
3)
1.508e3 df>big big.
15080000000000000000000000000000000000000000000000000000 ok
4)
0.1e0 df>big big.
1000000000000000055511151231257827021181583404541015 ok
5)
-0.1e0 df>big big.
-1000000000000000055511151231257827021181583404541016 ok
While the word BIG. is used to print the converted big number, the big
number pictured output words from big.4th may be used to go from a big
number to a string in the usual manner e.g.
0.1e0 df>big <big# big#s #big> type
1000000000000000055511151231257827021181583404541015 ok
Other words BIGSIGN and BIGHOLD and BIG# may be used in similar fashion
to the ordinary SIGN HOLD and # in pictured output for standard Forth.
The location of the decimal point in the output string can be determined
from the length of the output.
=== Begin dtoa.4th ===
\ dtoa.4th
\
\ Convert IEEE-754 double-precision floating point to a decimal string.
\
\ K. Myneni
\ 2026-08-02
\
include ans-words
include modules
include ieee-754
include fsl/big
include fsl/extras/big-extras
[UNDEFINED] fp-stack? [IF]
: fp-stack? [DEFINED] fdepth literal ;
[THEN]
1 CELLS 4 = CONSTANT 32bit?
1 CELLS 8 = CONSTANT 64bit?
64bit? FP-STACK? and 0= [IF]
cr .( Currently requires 64-bit + separate FP stack!)
cr
QUIT
[THEN]
BASE @
HEX
8000000000000000 constant DP_SIGNBIT_MASK
000FFFFFFFFFFFFF constant DP_FRACTION_MASK
7FF0000000000000 constant DP_EXPONENT_MASK
DECIMAL
52 constant DP_FRACTION_BITS \ number of binary digits in fraction
1023 constant DP_EXPONENT_BIAS
8 constant BIG_DBL \ max no. of cells for big number mantissa
\ BIG number constants and variables
create 5^52 BIG_DBL CELLS allot 5 52 big_s^n 5^52 big-move
create 10^52 BIG_DBL CELLS allot 10 52 big_s^n 10^52 big-move
create mantissa BIG_DBL CELLS allot
: get-df-fraction ( -- ud) ( F: r -- )
FP@ @ DP_FRACTION_MASK and s>d ;
\ Convert an IEEE-754 double precision float to a big integer
: df>big ( -- addr) ( F: r -- )
fdup fexponent DP_EXPONENT_BIAS - >R
fdup F0< >R
FABS
get-df-fraction drop >R
big-here dup 5^52 big>here R> ( a1 a1 ufraction) ( F: r)
big*s 10^52 big+
fdrop
R> IF dup bignegate THEN \ restore the sign of the big number
dup
R> dup 0< IF \ handle exponent
\ !!!! correct handling of negative exponents is still needed !!!
abs nip 1 swap lshift
big-here swap 1 big, big, big/
ELSE
1 swap lshift big*s
THEN
;
=== End dtoa.4th ===
=== Begin fsl/extras/big-extras.4th ===
\ big-extras.4th
\
\ Additional definitions for big number arithmetic
\ using FSL #47 big.4th
\
\ K. Myneni, 2026-8-01
\
\ Move a big number from src address to destination
: big-move ( addr1 addr2 -- )
OVER @ ABS 1+ CELLS \ Number of address units in the number
MOVE ;
\ "big factorial"
: big! ( n -- addr )
big-here 1 big, 1 big, \ addr of new big 1
swap abs 1+ 200 min
1 do dup I BIG*S loop ;
\ Raise single length signed integer to a positive
\ integer power and return the result as a big number
: big_s^n ( n1 n2+ -- addr)
dup 0= IF
2drop big-here 1 big, 1 big, EXIT
THEN
swap dup >r ( upow n) ( R: n)
0< IF -1 ELSE 1 THEN big, ( upow) ( R: n)
r> dup abs big, ( upow n)
swap >r ( n) ( R: upow)
big-here 2 cells -
swap r> ( addr n upow)
1 ?DO 2dup big*s LOOP drop ;
=== End fsl/extras/big-extras.4th ===
[toc] | [prev] | [next] | [standalone]
| From | Krishna Myneni <krishna.myneni@ccreweb.org> |
|---|---|
| Date | 2026-08-05 06:47 -0500 |
| Message-ID | <114v7rm$2tvd3$1@dont-email.me> |
| In reply to | #135293 |
On 8/2/26 21:33, Krishna Myneni wrote:
> On 7/26/26 16:00, Krishna Myneni wrote:
>> I ported Len Zettel's big number code, big.4th (Forth Scientific
>> Library algorithm #47) to kForth, and added some preliminary test code
>> to it. The existing version on the FSL website (May 1999 revision)
>> does not include any test code. The test code passes on kForth-64/32/
>> Win-32 and is listed below.
>>
>> A glossary of words has also been added (see below).
>>
>> See
>> https://github.com/mynenik/kForth-64/blob/master/forth-src/fsl/big.4th
>>
>> The file big.4th is now a part of all three kForth repos (64-bit
>> Linux, 32-bit Linux, and Win32). To load and run the tests from kForth:
>>
>
> The big number code can be used to perform correct conversion of
> IEEE-754 double precision numbers to ascii strings. Below is a proof of
> concept demonstration for kForth-64. The dtoa.4th. code demonstrates
> conversion of simple cases: normal dp floats, limited number of
> converted digits, limited positive and negative exponents -- it is not
> yet useful for general dp floats. Some of the limitations stem from the
> big number package itself (I think) while others are the simplicity of
> the present code, compared to something like dtoa.c.
>
...
> === Begin dtoa.4th ===
> \ dtoa.4th
> \
> \ Convert IEEE-754 double-precision floating point to a decimal string.
> \
> \ K. Myneni
> \ 2026-08-02
> \
>
> include ans-words
> include modules
> include ieee-754
> include fsl/big
> include fsl/extras/big-extras
> ...
I have updated the file ieee-754.4th which is included from dtoa.4th.
There were bugs in it that I did not uncover until dtoa.4th forced me to
look at it more closely. The change description and the latest
ieee-754.4th are appended below. The file is also updated in all
kForth-32/Win32/64 git repos.
The problem with loss of precision in dtoa.4th when the exponent is
negative is due to performing a division on big numbers instead od
obtaining both quotient and remainder. This should be easy to fix.
--
KM
=== begin commit message ===
Date: Tue Aug 4 15:16:08 2026 -0500
Fix problems and bugs with ieee-754.4th
1. Definitions of MAKE-IEEE-DFLOAT and FFRACTION did
not work on 64-bit systems. These problems have been
fixed.
2. Fixed definitions of FNORMAL? and FSUBNORMAL?
3. Defined useful constants:
DP_EXPONENT_BIAS
DP_EXPONENT_MAX_NORM
DP_EXPONENT_MIN_NORM
4. Added test code for the following words:
FSIGNBIT
FFRACTION
FEXPONENT
MAKE-IEEE-DFLOAT
The test code runs on both 32-bit and 64-bit systems.
=== end commit message ===
=== Begin ieee-754.4th ===
\ ieee-754.4th
\
\ Provides additional definitions for IEEE 754 double-precision
\ floating point arithmetic on x87 FPU.
\
\ GLOSSARY:
\
\ Generic construction of a double-precision float from its
\ binary fields:
\
\ MAKE-IEEE-DFLOAT ( signbit udfraction uexp -- r nerror )
\ ( signbit udfraction uexp -- nerror ) ( F: -- r)
\
\ Binary fields of IEEE 754 floating point values
\
\ FSIGNBIT ( F: r -- ) ( -- minus? )
\ FEXPONENT ( F: r -- ) ( -- uexp )
\ FFRACTION ( F: r -- ) ( -- udfraction )
\
\ FINITE? ( F: r -- ) ( -- flag )
\ FNORMAL? ( F: r -- ) ( -- flag )
\ FSUBNORMAL? ( F: r -- ) ( -- flag )
\ FINFINITE? ( F: r -- ) ( -- flag )
\ FNAN? ( F: r -- ) ( -- flag )
\
\ Exception flag words
\
\ GET-FFLAGS ( excpts -- flags )
\ CLEAR-ALL-FFLAGS ( -- )
\
\ IEEE 754 special values:
\
\ +INF ( F: -- r )
\ -INF ( F: -- r )
\ +NAN ( F: -- r )
\ -NAN ( F: -- r )
\
\ To be implemented:
\
\ FCOPYSIGN ( F: r1 r2 -- r3 )
\ FNEARBYINT ( F: r1 -- r2 )
\ FNEXTUP ( F: r1 -- r2 )
\ FNEXTDOWN ( F: r1 -- r2 )
\ FSCALBN ( n -- ) ( F: r -- r*2^n )
\ FLOGB ( F: r -- e )
\ FREMAINDER ( F: x y -- r q )
\ CLEAR-FFLAGS ( excepts -- )
\ SET-FFLAGS ( excepts -- )
\ FENABLE ( excepts -- )
\ FDISABLE ( excepts -- )
\
\
\ These words are based on the Optional IEEE 754 Binary Floating
\ Point word set(s) proposed by David N. Williams [1]. A few of
\ the words provided here are additional convenience words which
\ are not part of the proposals in Ref. 1.
\
\ K. Myneni, 2020-08-20
\ Revs. 2020-08-27, 2022-08-02, 2026-02-08, 2026-08-04
\
References:
\ 1. David N. Williams, Proposal Drafts for Optional IEEE 754
\ Binary Floating Point Word Set, 27 August 2020.
\ http://www-personal.umich.edu/~williams/archive/forth/ieeefp-drafts/
\
BASE @
DECIMAL
0e fconstant F=ZERO
1023 constant DP_EXPONENT_BIAS
2046 constant DP_EXPONENT_MAX_NORM \ max exponent for normalized numbers
1 constant DP_EXPONENT_MIN_NORM \ min exponent for normalized numbers
1 cells 4 = constant 32-bit?
1 cells 8 = constant 64-bit?
HEX
\ Make an IEEE 754 double precision floating point value from
\ the specified bits for the sign, binary fraction, and exponent.
\ Return the fp value and error code with the following meaning:
\ 0 no error
\ 1 exponent out of range
\ 2 fraction out of range
fvariable temp
32-bit? [IF]
: MAKE-IEEE-DFLOAT ( signbit udfraction uexp -- r nerror )
dup 800 u< invert IF 2drop 2drop F=ZERO 1 EXIT THEN
14 lshift
3 pick 1F lshift or >r
2dup 0 100000 du< invert IF
r> 2drop 2drop F=ZERO 2 EXIT
THEN
r> or [ temp 4 + ] literal L! temp L!
drop temp df@ 0 ;
[ELSE]
: MAKE-IEEE-DFLOAT ( signbit udfraction uexp -- r nerror )
dup 800 u< invert IF 2drop 2drop F=ZERO 1 EXIT THEN
34 lshift
3 pick 3F lshift or >r \ set sign bit
2dup $10000000000000. du< invert IF
r> 2drop 2drop F=ZERO 2 EXIT
THEN drop
r> or temp !
drop temp df@ 0 ;
[THEN]
: FSIGNBIT ( F: r -- ) ( -- minus? )
temp df! [ temp 4 + ] literal UL@ 80000000 and 0<> ;
: FEXPONENT ( F: r -- ) ( -- u )
temp df! [ temp 4 + ] literal UL@ 14 rshift 7FF and ;
32-bit? [IF]
: FFRACTION ( F: r -- ) ( -- ud )
temp df! temp UL@ [ temp 4 + ] literal UL@ 000FFFFF and ;
[ELSE]
: FFRACTION ( F: r -- ) ( -- ud)
temp df! temp @ 000FFFFFFFFFFFFF and 0 ;
[THEN]
: FINITE? ( F: r -- ) ( -- [normal|subnormal]? ) fexponent 7FF <> ;
: FNORMAL? ( F: r -- ) ( -- normal? )
fdup
fexponent 1 DP_EXPONENT_MAX_NORM 1+ within >r
F0= r> or ;
: FSUBNORMAL? ( F: r -- ) ( -- subnormal? )
fdup ffraction D0= invert >r fexponent 0= r> and ;
: FINFINITE? ( F: r -- ) ( -- [+/-]Inf? )
finite? invert ;
: FNAN? ( F: r -- ) ( -- nan? )
fdup FEXPONENT 7FF = >r FFRACTION D0= invert r> and ;
\ Exception bits in fpu status word
1 constant FINVALID
4 constant FDIVBYZERO
8 constant FOVERFLOW
10 constant FUNDERFLOW
20 constant FINEXACT
FINVALID FDIVBYZERO or FOVERFLOW or FUNDERFLOW or FINEXACT or
constant ALL-FEXCEPTS
32-bit? [IF]
[DEFINED] getFPUstatusX86 [IF]
: GET-FFLAGS ( excepts -- flags )
getFPUstatusX86 fpu-status @ and ;
: CLEAR-ALL-FFLAGS ( -- ) clearFPUexceptionsX86 ;
: CLEAR-FFLAGS ( excepts -- )
;
: SET-FFLAGS ( excepts -- )
;
: FENABLE ( excepts -- )
;
: FDISABLE ( excepts -- )
;
: FCOPYSIGN ( F: r1 r2 -- r3 )
;
: FNEARBYINT ( F: r1 -- r2 )
;
: FNEXTUP ( F: r1 -- r2 )
;
: FNEXTDOWN ( F: r1 -- r2 )
;
: FSCALBN ( r n -- r*2^n )
;
: FLOGB ( F: r -- e )
;
: FREMAINDER ( F: x y -- r q )
;
[ELSE]
cr .( Some functions are not available.) cr
[THEN]
[ELSE]
cr .( Some functions are for 32-bit system only!) cr
[THEN]
\ Constants representing -INF +INF -NAN +NAN
true 0 0 7FF make-ieee-dfloat 0= [IF] fconstant -INF [ELSE] fdrop [THEN]
[DEFINED] -INF [IF] -INF fnegate fconstant +INF [THEN]
true 1 0 7FF make-ieee-dfloat 0= [IF] fconstant -NAN [ELSE] fdrop [THEN]
[DEFINED] -NAN [IF] -NAN fnegate fconstant +NAN [THEN]
BASE !
[DEFINED] test-code? [IF]
test-code? [IF]
[UNDEFINED] T{ [IF] include ttester [THEN]
BASE @
DECIMAL
fvariable r1
fvariable r2
-4.450147717014402272114819593418263951869639092703291296e-308 FCONSTANT
DFLOAT_MIN
1.797693134862315708145274237317043567980705675258449966e+308
FCONSTANT DFLOAT_MAX
TESTING FSIGNBIT FFRACTION FEXPONENT
DECIMAL
t{ 0.0e0 FSIGNBIT -> false }t
t{ -0.0e0 FSIGNBIT -> true }t
t{ 1.0e-3 FSIGNBIT -> false }t
t{ -1.0e+3 FSIGNBIT -> true }t
t{ +INF FSIGNBIT -> false }t
t{ -INF FSIGNBIT -> true }t
t{ DFLOAT_MIN FSIGNBIT -> true }t
t{ DFLOAT_MAX FSIGNBIT -> false }t
t{ 0.0e0 FFRACTION -> 0 S>D }t
t{ -0.0e0 FFRACTION -> 0 S>D }t
t{ 1.0e0 FFRACTION -> 0 S>D }t
t{ -1.0e0 FFRACTION -> 0 S>D }t
HEX
64-bit? [IF]
t{ DFLOAT_MIN FFRACTION -> FFFFFFFFFFFFF S>D }t
t{ DFLOAT_MAX FFRACTION -> FFFFFFFFFFFFF S>D }t
[ELSE]
t{ DFLOAT_MIN FFRACTION -> FFFFFFFF FFFFF }t
t{ DFLOAT_MAX FFRACTION -> FFFFFFFF FFFFF }t
[THEN]
DECIMAL
t{ 0.0e0 FEXPONENT -> 0 }t
t{ 1.0e-1 FEXPONENT DP_EXPONENT_BIAS - -> -4 }t
t{ DFLOAT_MIN FEXPONENT -> DP_EXPONENT_MIN_NORM }t
t{ DFLOAT_MAX FEXPONENT -> DP_EXPONENT_MAX_NORM }t
TESTING MAKE-IEEE-DFLOAT
HEX
64-bit? [IF]
t{ 1 FFFFFFFFFFFFF 0 1 MAKE-IEEE-DFLOAT -> DFLOAT_MIN 0 rx}t
t{ 0 FFFFFFFFFFFFF 0 7FE MAKE-IEEE-DFLOAT -> DFLOAT_MAX 0 rx}t
[ELSE]
t{ 1 FFFFFFFF FFFFF 1 MAKE-IEEE-DFLOAT -> DFLOAT_MIN 0 rx}t
t{ 0 FFFFFFFF FFFFF 7FE MAKE-IEEE-DFLOAT -> DFLOAT_MAX 0 rx}t
[THEN]
DECIMAL
t{ 1.508e1 r1 df! -> }t
t{ r1 df@ fsignbit r1 df@ ffraction r1 df@ fexponent MAKE-IEEE-DFLOAT ->
1.508e1 0 rx}t
BASE !
[THEN]
[THEN]
=== End ieee-754.4th ===
[toc] | [prev] | [next] | [standalone]
| From | Krishna Myneni <krishna.myneni@ccreweb.org> |
|---|---|
| Date | 2026-08-13 07:24 -0500 |
| Message-ID | <115kd1k$1kf49$1@dont-email.me> |
| In reply to | #135278 |
On 7/26/26 16:00, Krishna Myneni wrote:
> I ported Len Zettel's big number code, big.4th (Forth Scientific Library
> algorithm #47) to kForth, and added some preliminary test code to it.
> The existing version on the FSL website (May 1999 revision) does not
> include any test code. The test code passes on kForth-64/32/Win-32 and
> is listed below.
> ...
Updated versions of the kForth port of the FSL big.4th module and the
extra definitions for big number arithmetic in big-extras.4th are now
part of the kForth-64/32/Win32 repos on ccreweb.org and on github.com.
With regard to discussion of floating point output in recent threads,
these Forth library codes can be used to implement a high quality
REPRESENT capable of output of a large number of digits. They may also
be used to perform accurate range reduction for large angle arguments to
trigonometric functions.
--
KM
===
Date: Wed Aug 12 23:13:39 2026 -0500
Revise FSL module big.4th and add big-extras.4th
1. Increase big number output buffer size in big.4th
2. Additional big number words provided in big-extras.4th
On branch master
modified: forth-src/fsl/big.4th
new file: forth-src/fsl/extras/big-extras.4th
===
https://ccreweb.org/software/kforth
https://github.com/mynenik
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.forth
csiph-web