Floating Point 
Author Message
 Floating Point

Category 10,  Topic 8
Message 104       Mon Apr 26, 1993
ELLIOTT.C                    at 17:35 EDT

 -----via Canada Remote Systems  (416)629-7000

 Date: 04-13-93 (00:42)
   To: ALL
 From: MARCEL HENDRIX
 Subj: ANS'S F^

 There is this word  F~  ( -- f  F: a b c -- ) in d-p-ANS's
 Floating-point Extension Wordset.

 F~   "f-proximate"      FLOAT EXT
      ( -- flag ) ( F: r1 r2 r3 -- )
      If r3 is positive, flag is true if the absolute value of
      (r1 minus r2) is less than r3.
      If r3 is zero, flag is true if the implementation-dependent
      encoding of r1 and r2 are exactly identical (positive and
      negative zero are unequal if they have distinct encodings)
      If r3 is negative, flag is true if the absolute value of
      (r1 minus r2) is less than the absolute value of r3 times
      the sum of the absolute values of r1 and r2.

 I am concerned about its behavior when r3 is negative.
 Assume r1 is 1e-42, r2 is 1e-42 and r3 is -1e-3 . The flag will
 be false although r1 and r2 are equal! I'd say the intention
 of using F~ with a negative r3 is to find out if r1 and r2 are
 ``relatively equal'', and being equal is near enough.
 There is also a problem with this exact example if we are using
 single-precision floating-point ( -1e-38 < r < 1e38 ).

 I won't comment on the fact that three fairly useful comparison
 words are being cemented together in F~, resulting in a word slow
 to execute and difficult to memorize -- remember SHIFT .

 Marcel Hendrix, Dutch Forth Workshop

 NET/Mail : FS FORTH Systeme BBS West Germany ++49 7667 556
 ---
  * The GrapeVine/Ferret Face BBS * NLR,ARK * 501-753-8121 DS *
  * PostLink(tm) v1.05  GRAPEVINE (#318) : RelayNet(tm) Hub

-----
This message came from GEnie via willett.  You *cannot* reply to the author
using e-mail.  Please post a follow-up article, or use any instructions
the author may have included (USMail addresses, telephone #, etc.).



Fri, 20 Oct 1995 01:21:39 GMT  
 Floating Point


[...]
|>  F~   "f-proximate"      FLOAT EXT
|>       ( -- flag ) ( F: r1 r2 r3 -- )
[...]
|>       If r3 is negative, flag is true if the absolute value of
|>       (r1 minus r2) is less than the absolute value of r3 times
                                        ^^^^^^^^
|>       the sum of the absolute values of r1 and r2.

This is, in display notation:

|r1 - r2| < |r3| * (|r1| + |r2|)

|>  I am concerned about its behavior when r3 is negative.
|>  Assume r1 is 1e-42, r2 is 1e-42 and r3 is -1e-3 .

| 1e-42 - 1e-42 | < | -1e-3 | * ( 1e-42 + 1e-42 )
        0         <    1e-3   *       2e-42
        0         <         2e-45
                true.

|>  The flag will
|>  be false although r1 and r2 are equal!

false.

You should either read more carefully or the display notation should be added
to the document (it's possible to edit this with WinWord, even if TeX would
give a more pleasent output). There are only positive values left and right
of the inequation. You usually find this inequation in a different form:

        |r1 - r2|
|r3| < -----------
       |r1| + |r2|

and in most books, |r3| is \epsilon and \epsilon > 0 given (and is prooved to
exist).

Objoke (we're not in rec.humor :-) for mathematics: \epsilon < 0 given.
--
Bernd Paysan
"Late answers are wrong answers!"



Fri, 20 Oct 1995 20:43:18 GMT  
 Floating Point

:

: [...]
: |>  F~   "f-proximate"      FLOAT EXT
: |>       ( -- flag ) ( F: r1 r2 r3 -- )
: [...]
: |>       If r3 is negative, flag is true if the absolute value of
: |>       (r1 minus r2) is less than the absolute value of r3 times
:                                         ^^^^^^^^
: |>       the sum of the absolute values of r1 and r2.
:
: This is, in display notation:
:
: |r1 - r2| < |r3| * (|r1| + |r2|)

Shouldn't that be:
 |r1 - r2| <= |r3| * (|r1| + |r2|)
so when one compare 0 with 0 which is obviously approx. equal yields
  0  -  0  <= eps  * ( 0   +  0  )    which is then true ?!

:
: |>  I am concerned about its behavior when r3 is negative.
: |>  Assume r1 is 1e-42, r2 is 1e-42 and r3 is -1e-3 .
:
: | 1e-42 - 1e-42 | < | -1e-3 | * ( 1e-42 + 1e-42 )
:         0         <    1e-3   *       2e-42
:         0         <         2e-45
:                 true.
:
: |>  The flag will
: |>  be false although r1 and r2 are equal!
:
: false.
:
: You should either read more carefully or the display notation should be added
: to the document (it's possible to edit this with WinWord, even if TeX would
: give a more pleasent output). There are only positive values left and right
: of the inequation. You usually find this inequation in a different form:
:
:         |r1 - r2|
: |r3| < -----------
:        |r1| + |r2|

This will crash when r1 = 0 and r2 = 0 !

:
: and in most books, |r3| is \epsilon and \epsilon > 0 given (and is prooved to
: exist).
:
: Objoke (we're not in rec.humor :-) for mathematics: \epsilon < 0 given.
: --
: Bernd Paysan
: "Late answers are wrong answers!"




Sat, 21 Oct 1995 22:15:23 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. An alternative to floating point (was Re: Floating point non-exactness)

2. IBM 370 Floating point to IEEE floating point

3. Getting a floating point number from a float-object

4. vax floating pont to unix floating point

5. fixed point vs floating point

6. code with fixed-point or floating-point

7. fixed point vs floating point

8. fixed point vs floating point

9. Floating Point vs Fixed Point

10. Type/Class Distinction (was: RE: Future floating point directions? [was Re: floating point in 2.0])

11. an if expression comparing a computed floating point value with a floating point constant fails when it shouldn't

12. need floating point conversion method

 

 
Powered by phpBB® Forum Software