"Fossies" - the Fresh Open Source Software Archive

Member "brlcad-7.32.4/doc/notes/rounding.txt" (29 Jul 2021, 1388 Bytes) of package /linux/misc/brlcad-7.32.4.tar.bz2:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 Date:     Wed, 3 Feb 88 23:39:04 EST
    2 From:     Mike Muuss (SECAD) <mike@XXX.XXX>
    3 
    4 This evening I have been working on a program which compares floating
    5 point numbers over the network (part of something much bigger).
    6 
    7 I encountered a rather perplexing phenomenon.  The Cray-2 and XMP
    8 seem to give very slightly different answers for floating point
    9 divisions.  I would have expected them to give the same answers.
   10 
   11 For example, the calculation 196.0 / 112.0 gives "1.75" on both
   12 machines, but differing by one bit, i.e.:
   13 
   14 XMP	4001E00000000000
   15 Cray-2	4001DFFFFFFFFFFF
   16 	^__^
   17 	exp
   18 
   19 It looks like the XMP is rounding UP, and the Cray-2 is rounding DOWN.
   20 
   21 This is easy to check for yourself with this C program:
   22 
   23 main()  {
   24 	double f;
   25 	f = 196.0 / 112.0;
   26 	printf("f = %g, x%x\n", f, f );
   27 }
   28 
   29 Here is the output:
   30 
   31 bob> c
   32 f = 1.75, x4001dfffffffffff
   33 
   34 patton> c
   35 f = 1.75, x4001e00000000000
   36 
   37 ISSUES
   38 
   39 *)  Is this behavior intrinsic to the "hardware" (reciprocal) divide
   40 units, or is the rounding behavior programmable?
   41 
   42 *)  For this particular calculation, the LSB behavior is not significant.
   43 However, for some iterative calculations, the LSB behavior may be
   44 significant.  It would be useful to understand why the two Crays give
   45 differing results.  I can live with a difference, as long as I know
   46 what to expect.  However, if the difference can be resolved, that
   47 would be even better.
   48 
   49 	Best,
   50 	 -Mike