Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #131683 > unrolled thread

Test REPRESENT corner cases

Started bydxf <dxforth@gmail.com>
First post2024-07-05 00:04 +1000
Last post2024-07-07 13:08 +1000
Articles 3 — 2 participants

Back to article view | Back to comp.lang.forth


Contents

  Test REPRESENT corner cases dxf <dxforth@gmail.com> - 2024-07-05 00:04 +1000
    Re: Test REPRESENT corner cases Hans Bezemer <the.beez.speaks@gmail.com> - 2024-07-06 15:28 +0200
      Re: Test REPRESENT corner cases dxf <dxforth@gmail.com> - 2024-07-07 13:08 +1000

#131683 — Test REPRESENT corner cases

Fromdxf <dxforth@gmail.com>
Date2024-07-05 00:04 +1000
SubjectTest REPRESENT corner cases
Message-ID<6686abec$1@news.ausics.net>
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 

[toc] | [next] | [standalone]


#131691

FromHans Bezemer <the.beez.speaks@gmail.com>
Date2024-07-06 15:28 +0200
Message-ID<nnd$2edd411f$361f8e74@821e6d626dbcbcc7>
In reply to#131683
On 04-07-2024 16:04, dxf wrote:
> 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

[toc] | [prev] | [next] | [standalone]


#131697

Fromdxf <dxforth@gmail.com>
Date2024-07-07 13:08 +1000
Message-ID<668a0693$1@news.ausics.net>
In reply to#131691
On 6/07/2024 11:28 pm, Hans Bezemer wrote:
> ...

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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.forth


csiph-web