Discussion:
Test REPRESENT corner cases
(too old to reply)
dxf
2024-07-04 14:04:29 UTC
Permalink
Test REPRESENT corner cases

: t0 ( r u -- )
pad 16 [char] x fill
pad swap represent drop
swap cr ." Exp: " . ." Sign: " . pad 16 dump ;

\ Ideally it rounds-down to 0.0
: t1 ( -- ) 0.4e 0 t0 ;

\ Ideally it rounds-up to 1.0
: t2 ( -- ) 0.9e 0 t0 ;

\ Ideally it returns the full string -Inf
: t3 ( -- ) -1e 0e f/ 1 t0 ;

: testall t1 t2 t3 ;

testall


--
Win32Forth: a 32 Bit Forth for Windows 95/98/ME/NT4/W2K/XP/VISTA/W7/W8/W10
Version: 6.15.05 Build: 4

testall
Exp: 0 Sign: 0
195FE0 | 34 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |4xxxxxxxxxxxxxxx|
Exp: 0 Sign: 0
195FE0 | 39 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |9xxxxxxxxxxxxxxx|
Exp: 2147483647 Sign: -1
195FE0 | 49 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |Ixxxxxxxxxxxxxxx| ok
ok

--
NT/FORTH (C) 2005 Peter Fälth Version 1.6-983-824 Compiled on 2017-12-03

testall
Exp: 1 Sign: 0
Address 0 1 2 3 4 5 6 7 8 9 A B C D E F |0123456789ABCDEF|
013F1120 30 78 78 78 78 78 78 78 |........0xxxxxxx|
013F1130 78 78 78 78 78 78 78 78 |xxxxxxxx........|

Exp: 1 Sign: 0
Address 0 1 2 3 4 5 6 7 8 9 A B C D E F |0123456789ABCDEF|
013F1120 31 78 78 78 78 78 78 78 |........1xxxxxxx|
013F1130 78 78 78 78 78 78 78 78 |xxxxxxxx........|

Exp: 0 Sign: 0
Address 0 1 2 3 4 5 6 7 8 9 A B C D E F |0123456789ABCDEF|
013F1120 2D 78 78 78 78 78 78 78 |........-xxxxxxx|
013F1130 78 78 78 78 78 78 78 78 |xxxxxxxx........|
ok

--
VFX Forth 64 for Windows x64
© MicroProcessor Engineering Ltd, 1998-2023
Version: 5.43 [build 4241]
Build date: 22 December 2023

testall
Exp: 1 Sign: 0
0000:0000:01C2:EB00 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000

Exp: 1 Sign: 0
0000:0000:01C2:EB00 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 1000000000000000

Exp: 3 Sign: -1
0000:0000:01C2:EB00 49 6E 66 20 20 20 20 20 20 20 20 20 20 20 20 20 Inf
ok
NDP Potential Exception: NDP SW = 0524
Hans Bezemer
2024-07-06 13:28:57 UTC
Permalink
Post by dxf
Test REPRESENT corner cases
: t0 ( r u -- )
pad 16 [char] x fill
pad swap represent drop
swap cr ." Exp: " . ." Sign: " . pad 16 dump ;
\ Ideally it rounds-down to 0.0
: t1 ( -- ) 0.4e 0 t0 ;
\ Ideally it rounds-up to 1.0
: t2 ( -- ) 0.9e 0 t0 ;
\ Ideally it returns the full string -Inf
: t3 ( -- ) -1e 0e f/ 1 t0 ;
: testall t1 t2 t3 ;
testall
--
Win32Forth: a 32 Bit Forth for Windows 95/98/ME/NT4/W2K/XP/VISTA/W7/W8/W10
Version: 6.15.05 Build: 4
testall
Exp: 0 Sign: 0
195FE0 | 34 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |4xxxxxxxxxxxxxxx|
Exp: 0 Sign: 0
195FE0 | 39 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |9xxxxxxxxxxxxxxx|
Exp: 2147483647 Sign: -1
195FE0 | 49 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |Ixxxxxxxxxxxxxxx| ok
ok
--
NT/FORTH (C) 2005 Peter Fälth Version 1.6-983-824 Compiled on 2017-12-03
testall
Exp: 1 Sign: 0
Address 0 1 2 3 4 5 6 7 8 9 A B C D E F |0123456789ABCDEF|
013F1120 30 78 78 78 78 78 78 78 |........0xxxxxxx|
013F1130 78 78 78 78 78 78 78 78 |xxxxxxxx........|
Exp: 1 Sign: 0
Address 0 1 2 3 4 5 6 7 8 9 A B C D E F |0123456789ABCDEF|
013F1120 31 78 78 78 78 78 78 78 |........1xxxxxxx|
013F1130 78 78 78 78 78 78 78 78 |xxxxxxxx........|
Exp: 0 Sign: 0
Address 0 1 2 3 4 5 6 7 8 9 A B C D E F |0123456789ABCDEF|
013F1120 2D 78 78 78 78 78 78 78 |........-xxxxxxx|
013F1130 78 78 78 78 78 78 78 78 |xxxxxxxx........|
ok
--
VFX Forth 64 for Windows x64
© MicroProcessor Engineering Ltd, 1998-2023
Version: 5.43 [build 4241]
Build date: 22 December 2023
testall
Exp: 1 Sign: 0
0000:0000:01C2:EB00 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
Exp: 1 Sign: 0
0000:0000:01C2:EB00 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 1000000000000000
Exp: 3 Sign: -1
0000:0000:01C2:EB00 49 6E 66 20 20 20 20 20 20 20 20 20 20 20 20 20 Inf
ok
NDP Potential Exception: NDP SW = 0524
4tH preprocessor, ZEN float, Ed's FPout, XDUMP:

p4th -x reprtest.4pp

Exp: 1 Sign: 0

--addr--- 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F chars
0000-0100 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000

Exp: 1 Sign: 0

--addr--- 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F chars
0000-0100 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 1000000000000000
Divide by zero
Executing; Word 566: Unhandled exception

Hans Bezemer
dxf
2024-07-07 03:08:03 UTC
Permalink
...
It's of course no surprise to me that 4tH produces that result. What caught
me unawares was NT/FORTH's correctly rounded output. It's unclear however
whether the author has used it. It's a rare forth that includes end-user
f/p output functions beyond the ANS nominated F. etc. and the latter barely
exercise REPRESENT at all.

Loading...