ldecNumber

Check-in [3cc84d46a5]
Login

Check-in [3cc84d46a5]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update to decnumber 3.41. Use dectest 2.55.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3cc84d46a53f8dd12b570a4adbc507abb1ab3bc9
User & Date: e@6e5be3b1-1950-f047-a965-c680c9cf6ecc 2007-08-07 22:26:53
Original Comment: Update to decnumber 3.41. Use dectest 2.55.
Context
2011-01-16
03:41
Add a wiki-format version of the library documentation. check-in: ac0742b219 user: e tags: trunk
2007-08-07
22:26
Update to decnumber 3.41. Use dectest 2.55. check-in: 3cc84d46a5 user: e@6e5be3b1-1950-f047-a965-c680c9cf6ecc tags: trunk
2007-06-18
21:32
Make context table weak on keys so threads are GC'd if cache off. Cache is off by default. Add test for thread memory leak. check-in: 55d4fc73d1 user: e@6e5be3b1-1950-f047-a965-c680c9cf6ecc tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to decNumber/decContext.c.

17
18
19
20
21
22
23

24
25







26
27
28
29
30
31
32
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */
/* This module comprises the routines for handling arithmetic         */
/* context structures.                                                */
/* ------------------------------------------------------------------ */

#include <string.h>           // for strcmp

#include "decContext.h"       // context and base types
#include "decNumberLocal.h"   // decNumber local types, etc.








/* ------------------------------------------------------------------ */
/* decContextDefault -- initialize a context structure                */
/*                                                                    */
/*  context is the structure to be initialized                        */
/*  kind selects the required set of default values, one of:          */
/*      DEC_INIT_BASE       -- select ANSI X3-274 defaults            */







>


>
>
>
>
>
>
>







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */
/* This module comprises the routines for handling arithmetic         */
/* context structures.                                                */
/* ------------------------------------------------------------------ */

#include <string.h>           // for strcmp
#include <stdio.h>            // for printf if DECCHECK
#include "decContext.h"       // context and base types
#include "decNumberLocal.h"   // decNumber local types, etc.

#if DECCHECK
/* compile-time endian tester [assumes sizeof(Int)>1] */
static  const  Int mfcone=1;                 // constant 1
static  const  Flag *mfctop=(Flag *)&mfcone; // -> top byte
#define LITEND *mfctop             // named flag; 1=little-endian
#endif

/* ------------------------------------------------------------------ */
/* decContextDefault -- initialize a context structure                */
/*                                                                    */
/*  context is the structure to be initialized                        */
/*  kind selects the required set of default values, one of:          */
/*      DEC_INIT_BASE       -- select ANSI X3-274 defaults            */
87
88
89
90
91
92
93










94
95
96
97
98
99
100
      #endif
      break;

    default:                                 // invalid Kind
      // use defaults, and ..
      decContextSetStatus(context, DEC_Invalid_operation); // trap
    }










  return context;} // decContextDefault

/* ------------------------------------------------------------------ */
/* decContextStatusToString -- convert status flags to a string       */
/*                                                                    */
/*  context is a context with valid status field                      */
/*                                                                    */







>
>
>
>
>
>
>
>
>
>







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
      #endif
      break;

    default:                                 // invalid Kind
      // use defaults, and ..
      decContextSetStatus(context, DEC_Invalid_operation); // trap
    }

  #if DECCHECK
  if (LITEND!=DECLITEND) {
    char *adj;
    if (LITEND) adj="little";
           else adj="big";
    printf("Warning: DECLITEND is set to %d, but this computer appears to be %s-endian\n",
           DECLITEND, adj);
    }
  #endif
  return context;} // decContextDefault

/* ------------------------------------------------------------------ */
/* decContextStatusToString -- convert status flags to a string       */
/*                                                                    */
/*  context is a context with valid status field                      */
/*                                                                    */

Changes to decNumber/decContext.h.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43



44
45
46
47
48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82


83
84
85
86
87
88
89
90
91
92
























93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*                                                                    */
/* Please send comments, suggestions, and corrections to the author:  */
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */
/*                                                                    */
/* Context must always be set correctly:                              */
/*                                                                    */
/*  digits   -- must be in the range 1 through 999999999              */
/*  emax     -- must be in the range 0 through 999999999              */
/*  emin     -- must be in the range 0 through -999999999             */
/*  round    -- must be one of the enumerated rounding modes          */
/*  traps    -- only defined bits may be set                          */
/*  status   -- [any bits may be cleared, but not set, by user]       */
/*  clamp    -- must be either 0 or 1                                 */
/*  extended -- must be either 0 or 1 [present only if DECSUBSET]     */
/*                                                                    */
/* ------------------------------------------------------------------ */

#if !defined(DECCONTEXT)
  #define DECCONTEXT
  #define DECCNAME     "decContext"                     /* Short name */
  #define DECCFULLNAME "Decimal Context Descriptor"   /* Verbose name */
  #define DECCAUTHOR   "Mike Cowlishaw"               /* Who to blame */

  #if !defined(int32_t)
    #include <stdint.h>            // C99 standard integers
  #endif
  #include <signal.h>              // for traps




  /* Conditional code flag -- set this to 0 for best performance */
  #define DECSUBSET 0              // 1=enable subset arithmetic

  /* Context for operations, with associated constants */
  enum rounding {
    DEC_ROUND_CEILING,             // round towards +infinity
    DEC_ROUND_UP,                  // round away from 0
    DEC_ROUND_HALF_UP,             // 0.5 rounds up
    DEC_ROUND_HALF_EVEN,           // 0.5 rounds to nearest even
    DEC_ROUND_HALF_DOWN,           // 0.5 rounds down
    DEC_ROUND_DOWN,                // round towards 0 (truncate)
    DEC_ROUND_FLOOR,               // round towards -infinity

    DEC_ROUND_MAX                  // enum must be less than this
    };

  typedef struct {
    int32_t  digits;               // working precision
    int32_t  emax;                 // maximum positive exponent
    int32_t  emin;                 // minimum negative exponent
    enum     rounding round;       // rounding mode
    uint32_t traps;                // trap-enabler flags
    uint32_t status;               // status flags
    uint8_t  clamp;                // flag: apply IEEE exponent clamp
    #if DECSUBSET
    uint8_t  extended;             // flag: special-values allowed
    #endif
    } decContext;

  /* Maxima and Minima */
  #define DEC_MAX_DIGITS 999999999
  #define DEC_MIN_DIGITS         1
  #define DEC_MAX_EMAX   999999999
  #define DEC_MIN_EMAX           0
  #define DEC_MAX_EMIN           0
  #define DEC_MIN_EMIN  -999999999
  #define DEC_MAX_MATH      999999 // max emax, etc., for math functions

  /* Trap-enabler and Status flags (exceptional conditions), and their names */
  // Top byte is reserved for internal use


  #define DEC_Conversion_syntax    0x00000001
  #define DEC_Division_by_zero     0x00000002
  #define DEC_Division_impossible  0x00000004
  #define DEC_Division_undefined   0x00000008
  #define DEC_Insufficient_storage 0x00000010  // [used if malloc fails]
  #define DEC_Inexact              0x00000020
  #define DEC_Invalid_context      0x00000040
  #define DEC_Invalid_operation    0x00000080
  #if DECSUBSET
  #define DEC_Lost_digits          0x00000100
























  #endif
  #define DEC_Overflow             0x00000200
  #define DEC_Clamped              0x00000400
  #define DEC_Rounded              0x00000800
  #define DEC_Subnormal            0x00001000
  #define DEC_Underflow            0x00002000

  /* IEEE 854 groupings for the flags */
  // [DEC_Clamped, DEC_Lost_digits, DEC_Rounded, and DEC_Subnormal are
  // not in IEEE 854]
  #define DEC_IEEE_854_Division_by_zero  (DEC_Division_by_zero)
  #if DECSUBSET
  #define DEC_IEEE_854_Inexact           (DEC_Inexact | DEC_Lost_digits)
  #else
  #define DEC_IEEE_854_Inexact           (DEC_Inexact)
  #endif
  #define DEC_IEEE_854_Invalid_operation (DEC_Conversion_syntax |     \
                                          DEC_Division_impossible |   \
                                          DEC_Division_undefined |    \
                                          DEC_Insufficient_storage |  \
                                          DEC_Invalid_context |       \
                                          DEC_Invalid_operation)
  #define DEC_IEEE_854_Overflow          (DEC_Overflow)
  #define DEC_IEEE_854_Underflow         (DEC_Underflow)

  // flags which are normally errors (results are qNaN, infinite, or 0)
  #define DEC_Errors (DEC_IEEE_854_Division_by_zero |                 \
                      DEC_IEEE_854_Invalid_operation |                \
                      DEC_IEEE_854_Overflow | DEC_IEEE_854_Underflow)
  // flags which cause a result to become qNaN
  #define DEC_NaNs    DEC_IEEE_854_Invalid_operation

  // flags which are normally for information only (have finite results)
  #if DECSUBSET
  #define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact     \
                          | DEC_Lost_digits)
  #else
  #define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact)
  #endif

  // name strings for the exceptional conditions

  #define DEC_Condition_CS "Conversion syntax"
  #define DEC_Condition_DZ "Division by zero"
  #define DEC_Condition_DI "Division impossible"
  #define DEC_Condition_DU "Division undefined"
  #define DEC_Condition_IE "Inexact"
  #define DEC_Condition_IS "Insufficient storage"
  #define DEC_Condition_IC "Invalid context"
  #define DEC_Condition_IO "Invalid operation"
  #if DECSUBSET
  #define DEC_Condition_LD "Lost digits"
  #endif
  #define DEC_Condition_OV "Overflow"
  #define DEC_Condition_PA "Clamped"
  #define DEC_Condition_RO "Rounded"
  #define DEC_Condition_SU "Subnormal"
  #define DEC_Condition_UN "Underflow"
  #define DEC_Condition_ZE "No status"
  #define DEC_Condition_MU "Multiple status"
  #define DEC_Condition_Length 21  // length of the longest string,
                                   // including terminator

  /* Initialization descriptors, used by decContextDefault */
  #define DEC_INIT_BASE         0
  #define DEC_INIT_DECIMAL32   32
  #define DEC_INIT_DECIMAL64   64
  #define DEC_INIT_DECIMAL128 128

  /* decContext routines */
  decContext * decContextDefault(decContext *, int32_t);
  decContext * decContextSetStatus(decContext *, uint32_t);
  const char * decContextStatusToString(const decContext *);
  decContext * decContextSetStatusFromString(decContext *, const char *);

#endif







|



















|

|

>
>
>
|
|

|

|
|
|
|
|
|
|
>
|



|
|
|
|
|
|
|

|



|






|

|
|
>
>
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

<
<
<
<
<

|
|
|















|



|


|

|





|



















|
|

|





|






13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123





124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*                                                                    */
/* Please send comments, suggestions, and corrections to the author:  */
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */
/*                                                                    */
/* Context variables must always have valid values:                   */
/*                                                                    */
/*  digits   -- must be in the range 1 through 999999999              */
/*  emax     -- must be in the range 0 through 999999999              */
/*  emin     -- must be in the range 0 through -999999999             */
/*  round    -- must be one of the enumerated rounding modes          */
/*  traps    -- only defined bits may be set                          */
/*  status   -- [any bits may be cleared, but not set, by user]       */
/*  clamp    -- must be either 0 or 1                                 */
/*  extended -- must be either 0 or 1 [present only if DECSUBSET]     */
/*                                                                    */
/* ------------------------------------------------------------------ */

#if !defined(DECCONTEXT)
  #define DECCONTEXT
  #define DECCNAME     "decContext"                     /* Short name */
  #define DECCFULLNAME "Decimal Context Descriptor"   /* Verbose name */
  #define DECCAUTHOR   "Mike Cowlishaw"               /* Who to blame */

  #if !defined(int32_t)
    #include <stdint.h>            /* C99 standard integers           */
  #endif
  #include <signal.h>              /* for traps                       */

  /* Extended flags setting -- set this to 0 to use only IEEE flags   */
  #define DECEXTFLAG 1             /* 1=enable extended flags         */

  /* Conditional code flag -- set this to 0 for best performance      */
  #define DECSUBSET  0             /* 1=enable subset arithmetic      */

  /* Context for operations, with associated constants                */
  enum rounding {
    DEC_ROUND_CEILING,             /* round towards +infinity         */
    DEC_ROUND_UP,                  /* round away from 0               */
    DEC_ROUND_HALF_UP,             /* 0.5 rounds up                   */
    DEC_ROUND_HALF_EVEN,           /* 0.5 rounds to nearest even      */
    DEC_ROUND_HALF_DOWN,           /* 0.5 rounds down                 */
    DEC_ROUND_DOWN,                /* round towards 0 (truncate)      */
    DEC_ROUND_FLOOR,               /* round towards -infinity         */
    DEC_ROUND_05UP,                /* round for reround               */
    DEC_ROUND_MAX                  /* enum must be less than this     */
    };

  typedef struct {
    int32_t  digits;               /* working precision               */
    int32_t  emax;                 /* maximum positive exponent       */
    int32_t  emin;                 /* minimum negative exponent       */
    enum     rounding round;       /* rounding mode                   */
    uint32_t traps;                /* trap-enabler flags              */
    uint32_t status;               /* status flags                    */
    uint8_t  clamp;                /* flag: apply IEEE exponent clamp */
    #if DECSUBSET
    uint8_t  extended;             /* flag: special-values allowed    */
    #endif
    } decContext;

  /* Maxima and Minima                                                */
  #define DEC_MAX_DIGITS 999999999
  #define DEC_MIN_DIGITS         1
  #define DEC_MAX_EMAX   999999999
  #define DEC_MIN_EMAX           0
  #define DEC_MAX_EMIN           0
  #define DEC_MIN_EMIN  -999999999
  #define DEC_MAX_MATH      999999 /* max emax, etc., for math funcs. */

  /* Trap-enabler and Status flags (exceptional conditions), and      */
  /* their names.  The top byte is reserved for internal use          */
  #if DECEXTFLAG
    /* Extended flags */
    #define DEC_Conversion_syntax    0x00000001
    #define DEC_Division_by_zero     0x00000002
    #define DEC_Division_impossible  0x00000004
    #define DEC_Division_undefined   0x00000008
    #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails]  */
    #define DEC_Inexact              0x00000020
    #define DEC_Invalid_context      0x00000040
    #define DEC_Invalid_operation    0x00000080
    #if DECSUBSET
    #define DEC_Lost_digits          0x00000100
    #endif
    #define DEC_Overflow             0x00000200
    #define DEC_Clamped              0x00000400
    #define DEC_Rounded              0x00000800
    #define DEC_Subnormal            0x00001000
    #define DEC_Underflow            0x00002000
  #else
    /* IEEE flags only */
    #define DEC_Conversion_syntax    0x00000010
    #define DEC_Division_by_zero     0x00000002
    #define DEC_Division_impossible  0x00000010
    #define DEC_Division_undefined   0x00000010
    #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails]  */
    #define DEC_Inexact              0x00000001
    #define DEC_Invalid_context      0x00000010
    #define DEC_Invalid_operation    0x00000010
    #if DECSUBSET
    #define DEC_Lost_digits          0x00000000
    #endif
    #define DEC_Overflow             0x00000008
    #define DEC_Clamped              0x00000000
    #define DEC_Rounded              0x00000000
    #define DEC_Subnormal            0x00000000
    #define DEC_Underflow            0x00000004
  #endif






  /* IEEE 854 groupings for the flags                                 */
  /* [DEC_Clamped, DEC_Lost_digits, DEC_Rounded, and DEC_Subnormal    */
  /* are not in IEEE 854]                                             */
  #define DEC_IEEE_854_Division_by_zero  (DEC_Division_by_zero)
  #if DECSUBSET
  #define DEC_IEEE_854_Inexact           (DEC_Inexact | DEC_Lost_digits)
  #else
  #define DEC_IEEE_854_Inexact           (DEC_Inexact)
  #endif
  #define DEC_IEEE_854_Invalid_operation (DEC_Conversion_syntax |     \
                                          DEC_Division_impossible |   \
                                          DEC_Division_undefined |    \
                                          DEC_Insufficient_storage |  \
                                          DEC_Invalid_context |       \
                                          DEC_Invalid_operation)
  #define DEC_IEEE_854_Overflow          (DEC_Overflow)
  #define DEC_IEEE_854_Underflow         (DEC_Underflow)

  /* flags which are normally errors (result is qNaN, infinite, or 0) */
  #define DEC_Errors (DEC_IEEE_854_Division_by_zero |                 \
                      DEC_IEEE_854_Invalid_operation |                \
                      DEC_IEEE_854_Overflow | DEC_IEEE_854_Underflow)
  /* flags which cause a result to become qNaN                        */
  #define DEC_NaNs    DEC_IEEE_854_Invalid_operation

  /* flags which are normally for information only (finite results)   */
  #if DECSUBSET
  #define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact    \
                          | DEC_Lost_digits)
  #else
  #define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact)
  #endif

  /* name strings for the exceptional conditions                      */

  #define DEC_Condition_CS "Conversion syntax"
  #define DEC_Condition_DZ "Division by zero"
  #define DEC_Condition_DI "Division impossible"
  #define DEC_Condition_DU "Division undefined"
  #define DEC_Condition_IE "Inexact"
  #define DEC_Condition_IS "Insufficient storage"
  #define DEC_Condition_IC "Invalid context"
  #define DEC_Condition_IO "Invalid operation"
  #if DECSUBSET
  #define DEC_Condition_LD "Lost digits"
  #endif
  #define DEC_Condition_OV "Overflow"
  #define DEC_Condition_PA "Clamped"
  #define DEC_Condition_RO "Rounded"
  #define DEC_Condition_SU "Subnormal"
  #define DEC_Condition_UN "Underflow"
  #define DEC_Condition_ZE "No status"
  #define DEC_Condition_MU "Multiple status"
  #define DEC_Condition_Length 21  /* length of the longest string,   */
                                   /* including terminator            */

  /* Initialization descriptors, used by decContextDefault            */
  #define DEC_INIT_BASE         0
  #define DEC_INIT_DECIMAL32   32
  #define DEC_INIT_DECIMAL64   64
  #define DEC_INIT_DECIMAL128 128

  /* decContext routines                                              */
  decContext * decContextDefault(decContext *, int32_t);
  decContext * decContextSetStatus(decContext *, uint32_t);
  const char * decContextStatusToString(const decContext *);
  decContext * decContextSetStatusFromString(decContext *, const char *);

#endif

Changes to decNumber/decDPD.h.

1
2
3
4
5
6
7
8
9
10
11
12
13

14
15


16
17
18
19
20
21
22

23
24
25
26

27
28
29
30
31
32
33
/* ------------------------------------------------------------------------ */
/* Binary Coded Decimal <--> Densely Packed Decimal lookup tables           */
/* [Automatically generated -- do not edit.  2006.11.09]                    */
/* ------------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2006. All rights reserved.          */
/* ------------------------------------------------------------------------ */
/* For details, see: http://www2.hursley.ibm.com/decimal/DPDecimal.html     */
/*                                                                          */
/* This include file defines conversion tables for DPD, as follows.         */
/*                                                                          */
/*   uint16_t BCD2DPD[2458];     // BCD -> DPD (0x999 => 2457)              */
/*   uint16_t BIN2DPD[1000];     // BIN -> DPD (999 => 2457)                */
/*   uint8_t  BIN2CHAR[4001];    // Bin -> CHAR (999 => '\3' '9' '9' '9')   */

/*   uint16_t DPD2BCD[1024];     // DPD -> BCD (0x3FF => 0x999)             */
/*   uint16_t DPD2BIN[1024];     // DPD -> BIN (0x3FF => 999)               */


/*   uint8_t  DPD2BCD8[4096];    // DPD -> bytes (x3FF => 9 9 9 3)          */
/*                                                                          */
/* In all cases the result (10 bits or 12 bits, or binary) is right-aligned */
/* in the table entry.  BIN2CHAR entries are a single byte length (0 for    */
/* value 0) followed by three digit characters; a trailing terminator is    */
/* included to allow 4-char moves always.  DPD2BCD8 entries are similar     */
/* with the three BCD8 digits followed by a one-byte length.                */

/*                                                                          */
/* To use a table, its name, prefixed with DEC_, must be defined with a     */
/* value of 1 before this header file is included.  For example:            */
/*    #define DEC_BCD2DPD 1                                                 */

/* ------------------------------------------------------------------------ */
 
#if DEC_BCD2DPD==1 && !defined(DECBCD2DPD)
#define DECBCD2DPD
 
const uint16_t BCD2DPD[2458]={    0,    1,    2,    3,    4,    5,    6,    7, 
    8,    9,    0,    0,    0,    0,    0,    0,   16,   17,   18,   19,   20, 

|
|

|



|

|
|
|
>
|
|
>
>
|




|
|
>




>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* ------------------------------------------------------------------------ */
/* Binary Coded Decimal and Densely Packed Decimal conversion lookup tables */
/* [Automatically generated -- do not edit.  2007.04.16]                    */
/* ------------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2007. All rights reserved.          */
/* ------------------------------------------------------------------------ */
/* For details, see: http://www2.hursley.ibm.com/decimal/DPDecimal.html     */
/*                                                                          */
/* This include file defines several DPD and BCD conversion tables:         */
/*                                                                          */
/*   uint16_t BCD2DPD[2458];     -- BCD -> DPD (0x999 => 2457)              */
/*   uint16_t BIN2DPD[1000];     -- Bin -> DPD (999 => 2457)                */
/*   uint8_t  BIN2CHAR[4001];    -- Bin -> CHAR (999 => '\3' '9' '9' '9')   */
/*   uint8_t  BIN2BCD8[4000];    -- Bin -> bytes (999 => 9 9 9 3)           */
/*   uint16_t DPD2BCD[1024];     -- DPD -> BCD (0x3FF => 0x999)             */
/*   uint16_t DPD2BIN[1024];     -- DPD -> BIN (0x3FF => 999)               */
/*   uint32_t DPD2BINK[1024];    -- DPD -> BIN * 1000 (0x3FF => 999000)     */
/*   uint32_t DPD2BINM[1024];    -- DPD -> BIN * 1E+6 (0x3FF => 999000000)  */
/*   uint8_t  DPD2BCD8[4096];    -- DPD -> bytes (x3FF => 9 9 9 3)          */
/*                                                                          */
/* In all cases the result (10 bits or 12 bits, or binary) is right-aligned */
/* in the table entry.  BIN2CHAR entries are a single byte length (0 for    */
/* value 0) followed by three digit characters; a trailing terminator is    */
/* included to allow 4-char moves always.  BIN2BCD8 and DPD2BCD8 entries    */
/* are similar with the three BCD8 digits followed by a one-byte length     */
/* (again, length=0 for value 0).                                           */
/*                                                                          */
/* To use a table, its name, prefixed with DEC_, must be defined with a     */
/* value of 1 before this header file is included.  For example:            */
/*    #define DEC_BCD2DPD 1                                                 */
/* This mechanism allows software to only include tables that are needed.   */
/* ------------------------------------------------------------------------ */
 
#if DEC_BCD2DPD==1 && !defined(DECBCD2DPD)
#define DECBCD2DPD
 
const uint16_t BCD2DPD[2458]={    0,    1,    2,    3,    4,    5,    6,    7, 
    8,    9,    0,    0,    0,    0,    0,    0,   16,   17,   18,   19,   20, 
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
    0,    0,    0,   10,   11,   42,   43,   74,   75,  106,  107,   78,   79, 
    0,    0,    0,    0,    0,    0,   26,   27,   58,   59,   90,   91,  122, 
  123,   94,   95,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,   10,   11,   42,   43,   74, 
   75,  106,  107,   78,   79,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,  128,  129,  130,  131,  132,  133,  134,  135,  136,  137,    0,    0, 
    0,    0,    0,    0,  144,  145,  146,  147,  148,  149,  150,  151,  152, 
  153,    0,    0,    0,    0,    0,    0,  160,  161,  162,  163,  164,  165, 
  166,  167,  168,  169,    0,    0,    0,    0,    0,    0,  176,  177,  178, 
  179,  180,  181,  182,  183,  184,  185,    0,    0,    0,    0,    0,    0, 
  192,  193,  194,  195,  196,  197,  198,  199,  200,  201,    0,    0,    0, 
    0,    0,    0,  208,  209,  210,  211,  212,  213,  214,  215,  216,  217, 
    0,    0,    0,    0,    0,    0,  224,  225,  226,  227,  228,  229,  230, 
  231,  232,  233,    0,    0,    0,    0,    0,    0,  240,  241,  242,  243, 
  244,  245,  246,  247,  248,  249,    0,    0,    0,    0,    0,    0,  138, 
  139,  170,  171,  202,  203,  234,  235,  206,  207,    0,    0,    0,    0, 
    0,    0,  154,  155,  186,  187,  218,  219,  250,  251,  222,  223,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,  138,  139,  170,  171,  202,  203,  234,  235,  206, 
  207,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,  256,  257,  258, 
  259,  260,  261,  262,  263,  264,  265,    0,    0,    0,    0,    0,    0, 
  272,  273,  274,  275,  276,  277,  278,  279,  280,  281,    0,    0,    0, 
    0,    0,    0,  288,  289,  290,  291,  292,  293,  294,  295,  296,  297, 
    0,    0,    0,    0,    0,    0,  304,  305,  306,  307,  308,  309,  310, 
  311,  312,  313,    0,    0,    0,    0,    0,    0,  320,  321,  322,  323, 
  324,  325,  326,  327,  328,  329,    0,    0,    0,    0,    0,    0,  336, 
  337,  338,  339,  340,  341,  342,  343,  344,  345,    0,    0,    0,    0, 
    0,    0,  352,  353,  354,  355,  356,  357,  358,  359,  360,  361,    0, 
    0,    0,    0,    0,    0,  368,  369,  370,  371,  372,  373,  374,  375, 
  376,  377,    0,    0,    0,    0,    0,    0,  266,  267,  298,  299,  330, 
  331,  362,  363,  334,  335,    0,    0,    0,    0,    0,    0,  282,  283, 
  314,  315,  346,  347,  378,  379,  350,  351,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
  266,  267,  298,  299,  330,  331,  362,  363,  334,  335,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,  384,  385,  386,  387,  388,  389,  390, 
  391,  392,  393,    0,    0,    0,    0,    0,    0,  400,  401,  402,  403, 
  404,  405,  406,  407,  408,  409,    0,    0,    0,    0,    0,    0,  416, 
  417,  418,  419,  420,  421,  422,  423,  424,  425,    0,    0,    0,    0, 
    0,    0,  432,  433,  434,  435,  436,  437,  438,  439,  440,  441,    0, 
    0,    0,    0,    0,    0,  448,  449,  450,  451,  452,  453,  454,  455, 
  456,  457,    0,    0,    0,    0,    0,    0,  464,  465,  466,  467,  468, 
  469,  470,  471,  472,  473,    0,    0,    0,    0,    0,    0,  480,  481, 
  482,  483,  484,  485,  486,  487,  488,  489,    0,    0,    0,    0,    0, 
    0,  496,  497,  498,  499,  500,  501,  502,  503,  504,  505,    0,    0, 
    0,    0,    0,    0,  394,  395,  426,  427,  458,  459,  490,  491,  462, 
  463,    0,    0,    0,    0,    0,    0,  410,  411,  442,  443,  474,  475, 
  506,  507,  478,  479,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,  394,  395,  426,  427, 
  458,  459,  490,  491,  462,  463,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,  512,  513,  514,  515,  516,  517,  518,  519,  520,  521,    0, 
    0,    0,    0,    0,    0,  528,  529,  530,  531,  532,  533,  534,  535, 
  536,  537,    0,    0,    0,    0,    0,    0,  544,  545,  546,  547,  548, 
  549,  550,  551,  552,  553,    0,    0,    0,    0,    0,    0,  560,  561, 
  562,  563,  564,  565,  566,  567,  568,  569,    0,    0,    0,    0,    0, 
    0,  576,  577,  578,  579,  580,  581,  582,  583,  584,  585,    0,    0, 
    0,    0,    0,    0,  592,  593,  594,  595,  596,  597,  598,  599,  600, 
  601,    0,    0,    0,    0,    0,    0,  608,  609,  610,  611,  612,  613, 
  614,  615,  616,  617,    0,    0,    0,    0,    0,    0,  624,  625,  626, 
  627,  628,  629,  630,  631,  632,  633,    0,    0,    0,    0,    0,    0, 
  522,  523,  554,  555,  586,  587,  618,  619,  590,  591,    0,    0,    0, 
    0,    0,    0,  538,  539,  570,  571,  602,  603,  634,  635,  606,  607, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,  522,  523,  554,  555,  586,  587,  618,  619, 
  590,  591,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,  640,  641, 
  642,  643,  644,  645,  646,  647,  648,  649,    0,    0,    0,    0,    0, 
    0,  656,  657,  658,  659,  660,  661,  662,  663,  664,  665,    0,    0, 
    0,    0,    0,    0,  672,  673,  674,  675,  676,  677,  678,  679,  680, 
  681,    0,    0,    0,    0,    0,    0,  688,  689,  690,  691,  692,  693, 
  694,  695,  696,  697,    0,    0,    0,    0,    0,    0,  704,  705,  706, 
  707,  708,  709,  710,  711,  712,  713,    0,    0,    0,    0,    0,    0, 
  720,  721,  722,  723,  724,  725,  726,  727,  728,  729,    0,    0,    0, 
    0,    0,    0,  736,  737,  738,  739,  740,  741,  742,  743,  744,  745, 
    0,    0,    0,    0,    0,    0,  752,  753,  754,  755,  756,  757,  758, 
  759,  760,  761,    0,    0,    0,    0,    0,    0,  650,  651,  682,  683, 
  714,  715,  746,  747,  718,  719,    0,    0,    0,    0,    0,    0,  666, 
  667,  698,  699,  730,  731,  762,  763,  734,  735,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,  650,  651,  682,  683,  714,  715,  746,  747,  718,  719,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,  768,  769,  770,  771,  772,  773, 
  774,  775,  776,  777,    0,    0,    0,    0,    0,    0,  784,  785,  786, 
  787,  788,  789,  790,  791,  792,  793,    0,    0,    0,    0,    0,    0, 
  800,  801,  802,  803,  804,  805,  806,  807,  808,  809,    0,    0,    0, 
    0,    0,    0,  816,  817,  818,  819,  820,  821,  822,  823,  824,  825, 
    0,    0,    0,    0,    0,    0,  832,  833,  834,  835,  836,  837,  838, 
  839,  840,  841,    0,    0,    0,    0,    0,    0,  848,  849,  850,  851, 
  852,  853,  854,  855,  856,  857,    0,    0,    0,    0,    0,    0,  864, 
  865,  866,  867,  868,  869,  870,  871,  872,  873,    0,    0,    0,    0, 
    0,    0,  880,  881,  882,  883,  884,  885,  886,  887,  888,  889,    0, 
    0,    0,    0,    0,    0,  778,  779,  810,  811,  842,  843,  874,  875, 
  846,  847,    0,    0,    0,    0,    0,    0,  794,  795,  826,  827,  858, 
  859,  890,  891,  862,  863,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,  778,  779,  810, 
  811,  842,  843,  874,  875,  846,  847,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,  896,  897,  898,  899,  900,  901,  902,  903,  904,  905, 
    0,    0,    0,    0,    0,    0,  912,  913,  914,  915,  916,  917,  918, 
  919,  920,  921,    0,    0,    0,    0,    0,    0,  928,  929,  930,  931, 
  932,  933,  934,  935,  936,  937,    0,    0,    0,    0,    0,    0,  944, 
  945,  946,  947,  948,  949,  950,  951,  952,  953,    0,    0,    0,    0, 
    0,    0,  960,  961,  962,  963,  964,  965,  966,  967,  968,  969,    0, 
    0,    0,    0,    0,    0,  976,  977,  978,  979,  980,  981,  982,  983, 
  984,  985,    0,    0,    0,    0,    0,    0,  992,  993,  994,  995,  996, 
  997,  998,  999, 1000, 1001,    0,    0,    0,    0,    0,    0, 1008, 1009, 
 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,    0,    0,    0,    0,    0, 
    0,  906,  907,  938,  939,  970,  971, 1002, 1003,  974,  975,    0,    0, 
    0,    0,    0,    0,  922,  923,  954,  955,  986,  987, 1018, 1019,  990, 
  991,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,  906,  907,  938,  939,  970,  971, 1002, 
 1003,  974,  975,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,   12, 
   13,  268,  269,  524,  525,  780,  781,   46,   47,    0,    0,    0,    0, 
    0,    0,   28,   29,  284,  285,  540,  541,  796,  797,   62,   63,    0, 
    0,    0,    0,    0,    0,   44,   45,  300,  301,  556,  557,  812,  813, 
  302,  303,    0,    0,    0,    0,    0,    0,   60,   61,  316,  317,  572, 
  573,  828,  829,  318,  319,    0,    0,    0,    0,    0,    0,   76,   77, 
  332,  333,  588,  589,  844,  845,  558,  559,    0,    0,    0,    0,    0, 
    0,   92,   93,  348,  349,  604,  605,  860,  861,  574,  575,    0,    0, 
    0,    0,    0,    0,  108,  109,  364,  365,  620,  621,  876,  877,  814, 
  815,    0,    0,    0,    0,    0,    0,  124,  125,  380,  381,  636,  637, 
  892,  893,  830,  831,    0,    0,    0,    0,    0,    0,   14,   15,  270, 
  271,  526,  527,  782,  783,  110,  111,    0,    0,    0,    0,    0,    0, 
   30,   31,  286,  287,  542,  543,  798,  799,  126,  127,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,   14,   15,  270,  271,  526,  527,  782,  783,  110,  111,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,  140,  141,  396,  397,  652, 
  653,  908,  909,  174,  175,    0,    0,    0,    0,    0,    0,  156,  157, 
  412,  413,  668,  669,  924,  925,  190,  191,    0,    0,    0,    0,    0, 
    0,  172,  173,  428,  429,  684,  685,  940,  941,  430,  431,    0,    0, 
    0,    0,    0,    0,  188,  189,  444,  445,  700,  701,  956,  957,  446, 
  447,    0,    0,    0,    0,    0,    0,  204,  205,  460,  461,  716,  717, 







|
|


















|
|


















|


















|
|


















|
|


















|


















|
|


















|
|


















|







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
    0,    0,    0,   10,   11,   42,   43,   74,   75,  106,  107,   78,   79, 
    0,    0,    0,    0,    0,    0,   26,   27,   58,   59,   90,   91,  122, 
  123,   94,   95,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,  128,  129,  130,  131,  132,  133,  134,  135,  136,  137,    0,    0, 
    0,    0,    0,    0,  144,  145,  146,  147,  148,  149,  150,  151,  152, 
  153,    0,    0,    0,    0,    0,    0,  160,  161,  162,  163,  164,  165, 
  166,  167,  168,  169,    0,    0,    0,    0,    0,    0,  176,  177,  178, 
  179,  180,  181,  182,  183,  184,  185,    0,    0,    0,    0,    0,    0, 
  192,  193,  194,  195,  196,  197,  198,  199,  200,  201,    0,    0,    0, 
    0,    0,    0,  208,  209,  210,  211,  212,  213,  214,  215,  216,  217, 
    0,    0,    0,    0,    0,    0,  224,  225,  226,  227,  228,  229,  230, 
  231,  232,  233,    0,    0,    0,    0,    0,    0,  240,  241,  242,  243, 
  244,  245,  246,  247,  248,  249,    0,    0,    0,    0,    0,    0,  138, 
  139,  170,  171,  202,  203,  234,  235,  206,  207,    0,    0,    0,    0, 
    0,    0,  154,  155,  186,  187,  218,  219,  250,  251,  222,  223,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,  256,  257,  258, 
  259,  260,  261,  262,  263,  264,  265,    0,    0,    0,    0,    0,    0, 
  272,  273,  274,  275,  276,  277,  278,  279,  280,  281,    0,    0,    0, 
    0,    0,    0,  288,  289,  290,  291,  292,  293,  294,  295,  296,  297, 
    0,    0,    0,    0,    0,    0,  304,  305,  306,  307,  308,  309,  310, 
  311,  312,  313,    0,    0,    0,    0,    0,    0,  320,  321,  322,  323, 
  324,  325,  326,  327,  328,  329,    0,    0,    0,    0,    0,    0,  336, 
  337,  338,  339,  340,  341,  342,  343,  344,  345,    0,    0,    0,    0, 
    0,    0,  352,  353,  354,  355,  356,  357,  358,  359,  360,  361,    0, 
    0,    0,    0,    0,    0,  368,  369,  370,  371,  372,  373,  374,  375, 
  376,  377,    0,    0,    0,    0,    0,    0,  266,  267,  298,  299,  330, 
  331,  362,  363,  334,  335,    0,    0,    0,    0,    0,    0,  282,  283, 
  314,  315,  346,  347,  378,  379,  350,  351,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,  384,  385,  386,  387,  388,  389,  390, 
  391,  392,  393,    0,    0,    0,    0,    0,    0,  400,  401,  402,  403, 
  404,  405,  406,  407,  408,  409,    0,    0,    0,    0,    0,    0,  416, 
  417,  418,  419,  420,  421,  422,  423,  424,  425,    0,    0,    0,    0, 
    0,    0,  432,  433,  434,  435,  436,  437,  438,  439,  440,  441,    0, 
    0,    0,    0,    0,    0,  448,  449,  450,  451,  452,  453,  454,  455, 
  456,  457,    0,    0,    0,    0,    0,    0,  464,  465,  466,  467,  468, 
  469,  470,  471,  472,  473,    0,    0,    0,    0,    0,    0,  480,  481, 
  482,  483,  484,  485,  486,  487,  488,  489,    0,    0,    0,    0,    0, 
    0,  496,  497,  498,  499,  500,  501,  502,  503,  504,  505,    0,    0, 
    0,    0,    0,    0,  394,  395,  426,  427,  458,  459,  490,  491,  462, 
  463,    0,    0,    0,    0,    0,    0,  410,  411,  442,  443,  474,  475, 
  506,  507,  478,  479,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,  512,  513,  514,  515,  516,  517,  518,  519,  520,  521,    0, 
    0,    0,    0,    0,    0,  528,  529,  530,  531,  532,  533,  534,  535, 
  536,  537,    0,    0,    0,    0,    0,    0,  544,  545,  546,  547,  548, 
  549,  550,  551,  552,  553,    0,    0,    0,    0,    0,    0,  560,  561, 
  562,  563,  564,  565,  566,  567,  568,  569,    0,    0,    0,    0,    0, 
    0,  576,  577,  578,  579,  580,  581,  582,  583,  584,  585,    0,    0, 
    0,    0,    0,    0,  592,  593,  594,  595,  596,  597,  598,  599,  600, 
  601,    0,    0,    0,    0,    0,    0,  608,  609,  610,  611,  612,  613, 
  614,  615,  616,  617,    0,    0,    0,    0,    0,    0,  624,  625,  626, 
  627,  628,  629,  630,  631,  632,  633,    0,    0,    0,    0,    0,    0, 
  522,  523,  554,  555,  586,  587,  618,  619,  590,  591,    0,    0,    0, 
    0,    0,    0,  538,  539,  570,  571,  602,  603,  634,  635,  606,  607, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,  640,  641, 
  642,  643,  644,  645,  646,  647,  648,  649,    0,    0,    0,    0,    0, 
    0,  656,  657,  658,  659,  660,  661,  662,  663,  664,  665,    0,    0, 
    0,    0,    0,    0,  672,  673,  674,  675,  676,  677,  678,  679,  680, 
  681,    0,    0,    0,    0,    0,    0,  688,  689,  690,  691,  692,  693, 
  694,  695,  696,  697,    0,    0,    0,    0,    0,    0,  704,  705,  706, 
  707,  708,  709,  710,  711,  712,  713,    0,    0,    0,    0,    0,    0, 
  720,  721,  722,  723,  724,  725,  726,  727,  728,  729,    0,    0,    0, 
    0,    0,    0,  736,  737,  738,  739,  740,  741,  742,  743,  744,  745, 
    0,    0,    0,    0,    0,    0,  752,  753,  754,  755,  756,  757,  758, 
  759,  760,  761,    0,    0,    0,    0,    0,    0,  650,  651,  682,  683, 
  714,  715,  746,  747,  718,  719,    0,    0,    0,    0,    0,    0,  666, 
  667,  698,  699,  730,  731,  762,  763,  734,  735,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,  768,  769,  770,  771,  772,  773, 
  774,  775,  776,  777,    0,    0,    0,    0,    0,    0,  784,  785,  786, 
  787,  788,  789,  790,  791,  792,  793,    0,    0,    0,    0,    0,    0, 
  800,  801,  802,  803,  804,  805,  806,  807,  808,  809,    0,    0,    0, 
    0,    0,    0,  816,  817,  818,  819,  820,  821,  822,  823,  824,  825, 
    0,    0,    0,    0,    0,    0,  832,  833,  834,  835,  836,  837,  838, 
  839,  840,  841,    0,    0,    0,    0,    0,    0,  848,  849,  850,  851, 
  852,  853,  854,  855,  856,  857,    0,    0,    0,    0,    0,    0,  864, 
  865,  866,  867,  868,  869,  870,  871,  872,  873,    0,    0,    0,    0, 
    0,    0,  880,  881,  882,  883,  884,  885,  886,  887,  888,  889,    0, 
    0,    0,    0,    0,    0,  778,  779,  810,  811,  842,  843,  874,  875, 
  846,  847,    0,    0,    0,    0,    0,    0,  794,  795,  826,  827,  858, 
  859,  890,  891,  862,  863,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,  896,  897,  898,  899,  900,  901,  902,  903,  904,  905, 
    0,    0,    0,    0,    0,    0,  912,  913,  914,  915,  916,  917,  918, 
  919,  920,  921,    0,    0,    0,    0,    0,    0,  928,  929,  930,  931, 
  932,  933,  934,  935,  936,  937,    0,    0,    0,    0,    0,    0,  944, 
  945,  946,  947,  948,  949,  950,  951,  952,  953,    0,    0,    0,    0, 
    0,    0,  960,  961,  962,  963,  964,  965,  966,  967,  968,  969,    0, 
    0,    0,    0,    0,    0,  976,  977,  978,  979,  980,  981,  982,  983, 
  984,  985,    0,    0,    0,    0,    0,    0,  992,  993,  994,  995,  996, 
  997,  998,  999, 1000, 1001,    0,    0,    0,    0,    0,    0, 1008, 1009, 
 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,    0,    0,    0,    0,    0, 
    0,  906,  907,  938,  939,  970,  971, 1002, 1003,  974,  975,    0,    0, 
    0,    0,    0,    0,  922,  923,  954,  955,  986,  987, 1018, 1019,  990, 
  991,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,   12, 
   13,  268,  269,  524,  525,  780,  781,   46,   47,    0,    0,    0,    0, 
    0,    0,   28,   29,  284,  285,  540,  541,  796,  797,   62,   63,    0, 
    0,    0,    0,    0,    0,   44,   45,  300,  301,  556,  557,  812,  813, 
  302,  303,    0,    0,    0,    0,    0,    0,   60,   61,  316,  317,  572, 
  573,  828,  829,  318,  319,    0,    0,    0,    0,    0,    0,   76,   77, 
  332,  333,  588,  589,  844,  845,  558,  559,    0,    0,    0,    0,    0, 
    0,   92,   93,  348,  349,  604,  605,  860,  861,  574,  575,    0,    0, 
    0,    0,    0,    0,  108,  109,  364,  365,  620,  621,  876,  877,  814, 
  815,    0,    0,    0,    0,    0,    0,  124,  125,  380,  381,  636,  637, 
  892,  893,  830,  831,    0,    0,    0,    0,    0,    0,   14,   15,  270, 
  271,  526,  527,  782,  783,  110,  111,    0,    0,    0,    0,    0,    0, 
   30,   31,  286,  287,  542,  543,  798,  799,  126,  127,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0, 
    0,    0,    0,    0,    0,    0,    0,    0,  140,  141,  396,  397,  652, 
  653,  908,  909,  174,  175,    0,    0,    0,    0,    0,    0,  156,  157, 
  412,  413,  668,  669,  924,  925,  190,  191,    0,    0,    0,    0,    0, 
    0,  172,  173,  428,  429,  684,  685,  940,  941,  430,  431,    0,    0, 
    0,    0,    0,    0,  188,  189,  444,  445,  700,  701,  956,  957,  446, 
  447,    0,    0,    0,    0,    0,    0,  204,  205,  460,  461,  716,  717, 
469
470
471
472
473
474
475




































































































































































































































































476
477
478
479
480
481
482
  937,  978,  979,  740,  741,  742,  743,  744,  745,  746,  747,  748,  749, 
  784,  785,  946,  947,  788,  789,  750,  751,  752,  753,  754,  755,  756, 
  757,  758,  759,  794,  795,  956,  957,  798,  799,  760,  761,  762,  763, 
  764,  765,  766,  767,  768,  769,  786,  787,  966,  967,  988,  989,  770, 
  771,  772,  773,  774,  775,  776,  777,  778,  779,  796,  797,  976,  977, 
  998,  999};
#endif




































































































































































































































































 
#if DEC_BIN2CHAR==1 && !defined(DECBIN2CHAR)
#define DECBIN2CHAR
 
const uint8_t BIN2CHAR[4001]={
 '\0','0','0','0', '\1','0','0','1', '\1','0','0','2', '\1','0','0','3', '\1','0','0','4', 
 '\1','0','0','5', '\1','0','0','6', '\1','0','0','7', '\1','0','0','8', '\1','0','0','9', 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
  937,  978,  979,  740,  741,  742,  743,  744,  745,  746,  747,  748,  749, 
  784,  785,  946,  947,  788,  789,  750,  751,  752,  753,  754,  755,  756, 
  757,  758,  759,  794,  795,  956,  957,  798,  799,  760,  761,  762,  763, 
  764,  765,  766,  767,  768,  769,  786,  787,  966,  967,  988,  989,  770, 
  771,  772,  773,  774,  775,  776,  777,  778,  779,  796,  797,  976,  977, 
  998,  999};
#endif
 
#if DEC_DPD2BINK==1 && !defined(DECDPD2BINK)
#define DECDPD2BINK
 
const uint32_t DPD2BINK[1024]={       0,   1000,   2000,   3000,   4000,   5000, 
   6000,   7000,   8000,   9000,  80000,  81000, 800000, 801000, 880000, 881000, 
  10000,  11000,  12000,  13000,  14000,  15000,  16000,  17000,  18000,  19000, 
  90000,  91000, 810000, 811000, 890000, 891000,  20000,  21000,  22000,  23000, 
  24000,  25000,  26000,  27000,  28000,  29000,  82000,  83000, 820000, 821000, 
 808000, 809000,  30000,  31000,  32000,  33000,  34000,  35000,  36000,  37000, 
  38000,  39000,  92000,  93000, 830000, 831000, 818000, 819000,  40000,  41000, 
  42000,  43000,  44000,  45000,  46000,  47000,  48000,  49000,  84000,  85000, 
 840000, 841000,  88000,  89000,  50000,  51000,  52000,  53000,  54000,  55000, 
  56000,  57000,  58000,  59000,  94000,  95000, 850000, 851000,  98000,  99000, 
  60000,  61000,  62000,  63000,  64000,  65000,  66000,  67000,  68000,  69000, 
  86000,  87000, 860000, 861000, 888000, 889000,  70000,  71000,  72000,  73000, 
  74000,  75000,  76000,  77000,  78000,  79000,  96000,  97000, 870000, 871000, 
 898000, 899000, 100000, 101000, 102000, 103000, 104000, 105000, 106000, 107000, 
 108000, 109000, 180000, 181000, 900000, 901000, 980000, 981000, 110000, 111000, 
 112000, 113000, 114000, 115000, 116000, 117000, 118000, 119000, 190000, 191000, 
 910000, 911000, 990000, 991000, 120000, 121000, 122000, 123000, 124000, 125000, 
 126000, 127000, 128000, 129000, 182000, 183000, 920000, 921000, 908000, 909000, 
 130000, 131000, 132000, 133000, 134000, 135000, 136000, 137000, 138000, 139000, 
 192000, 193000, 930000, 931000, 918000, 919000, 140000, 141000, 142000, 143000, 
 144000, 145000, 146000, 147000, 148000, 149000, 184000, 185000, 940000, 941000, 
 188000, 189000, 150000, 151000, 152000, 153000, 154000, 155000, 156000, 157000, 
 158000, 159000, 194000, 195000, 950000, 951000, 198000, 199000, 160000, 161000, 
 162000, 163000, 164000, 165000, 166000, 167000, 168000, 169000, 186000, 187000, 
 960000, 961000, 988000, 989000, 170000, 171000, 172000, 173000, 174000, 175000, 
 176000, 177000, 178000, 179000, 196000, 197000, 970000, 971000, 998000, 999000, 
 200000, 201000, 202000, 203000, 204000, 205000, 206000, 207000, 208000, 209000, 
 280000, 281000, 802000, 803000, 882000, 883000, 210000, 211000, 212000, 213000, 
 214000, 215000, 216000, 217000, 218000, 219000, 290000, 291000, 812000, 813000, 
 892000, 893000, 220000, 221000, 222000, 223000, 224000, 225000, 226000, 227000, 
 228000, 229000, 282000, 283000, 822000, 823000, 828000, 829000, 230000, 231000, 
 232000, 233000, 234000, 235000, 236000, 237000, 238000, 239000, 292000, 293000, 
 832000, 833000, 838000, 839000, 240000, 241000, 242000, 243000, 244000, 245000, 
 246000, 247000, 248000, 249000, 284000, 285000, 842000, 843000, 288000, 289000, 
 250000, 251000, 252000, 253000, 254000, 255000, 256000, 257000, 258000, 259000, 
 294000, 295000, 852000, 853000, 298000, 299000, 260000, 261000, 262000, 263000, 
 264000, 265000, 266000, 267000, 268000, 269000, 286000, 287000, 862000, 863000, 
 888000, 889000, 270000, 271000, 272000, 273000, 274000, 275000, 276000, 277000, 
 278000, 279000, 296000, 297000, 872000, 873000, 898000, 899000, 300000, 301000, 
 302000, 303000, 304000, 305000, 306000, 307000, 308000, 309000, 380000, 381000, 
 902000, 903000, 982000, 983000, 310000, 311000, 312000, 313000, 314000, 315000, 
 316000, 317000, 318000, 319000, 390000, 391000, 912000, 913000, 992000, 993000, 
 320000, 321000, 322000, 323000, 324000, 325000, 326000, 327000, 328000, 329000, 
 382000, 383000, 922000, 923000, 928000, 929000, 330000, 331000, 332000, 333000, 
 334000, 335000, 336000, 337000, 338000, 339000, 392000, 393000, 932000, 933000, 
 938000, 939000, 340000, 341000, 342000, 343000, 344000, 345000, 346000, 347000, 
 348000, 349000, 384000, 385000, 942000, 943000, 388000, 389000, 350000, 351000, 
 352000, 353000, 354000, 355000, 356000, 357000, 358000, 359000, 394000, 395000, 
 952000, 953000, 398000, 399000, 360000, 361000, 362000, 363000, 364000, 365000, 
 366000, 367000, 368000, 369000, 386000, 387000, 962000, 963000, 988000, 989000, 
 370000, 371000, 372000, 373000, 374000, 375000, 376000, 377000, 378000, 379000, 
 396000, 397000, 972000, 973000, 998000, 999000, 400000, 401000, 402000, 403000, 
 404000, 405000, 406000, 407000, 408000, 409000, 480000, 481000, 804000, 805000, 
 884000, 885000, 410000, 411000, 412000, 413000, 414000, 415000, 416000, 417000, 
 418000, 419000, 490000, 491000, 814000, 815000, 894000, 895000, 420000, 421000, 
 422000, 423000, 424000, 425000, 426000, 427000, 428000, 429000, 482000, 483000, 
 824000, 825000, 848000, 849000, 430000, 431000, 432000, 433000, 434000, 435000, 
 436000, 437000, 438000, 439000, 492000, 493000, 834000, 835000, 858000, 859000, 
 440000, 441000, 442000, 443000, 444000, 445000, 446000, 447000, 448000, 449000, 
 484000, 485000, 844000, 845000, 488000, 489000, 450000, 451000, 452000, 453000, 
 454000, 455000, 456000, 457000, 458000, 459000, 494000, 495000, 854000, 855000, 
 498000, 499000, 460000, 461000, 462000, 463000, 464000, 465000, 466000, 467000, 
 468000, 469000, 486000, 487000, 864000, 865000, 888000, 889000, 470000, 471000, 
 472000, 473000, 474000, 475000, 476000, 477000, 478000, 479000, 496000, 497000, 
 874000, 875000, 898000, 899000, 500000, 501000, 502000, 503000, 504000, 505000, 
 506000, 507000, 508000, 509000, 580000, 581000, 904000, 905000, 984000, 985000, 
 510000, 511000, 512000, 513000, 514000, 515000, 516000, 517000, 518000, 519000, 
 590000, 591000, 914000, 915000, 994000, 995000, 520000, 521000, 522000, 523000, 
 524000, 525000, 526000, 527000, 528000, 529000, 582000, 583000, 924000, 925000, 
 948000, 949000, 530000, 531000, 532000, 533000, 534000, 535000, 536000, 537000, 
 538000, 539000, 592000, 593000, 934000, 935000, 958000, 959000, 540000, 541000, 
 542000, 543000, 544000, 545000, 546000, 547000, 548000, 549000, 584000, 585000, 
 944000, 945000, 588000, 589000, 550000, 551000, 552000, 553000, 554000, 555000, 
 556000, 557000, 558000, 559000, 594000, 595000, 954000, 955000, 598000, 599000, 
 560000, 561000, 562000, 563000, 564000, 565000, 566000, 567000, 568000, 569000, 
 586000, 587000, 964000, 965000, 988000, 989000, 570000, 571000, 572000, 573000, 
 574000, 575000, 576000, 577000, 578000, 579000, 596000, 597000, 974000, 975000, 
 998000, 999000, 600000, 601000, 602000, 603000, 604000, 605000, 606000, 607000, 
 608000, 609000, 680000, 681000, 806000, 807000, 886000, 887000, 610000, 611000, 
 612000, 613000, 614000, 615000, 616000, 617000, 618000, 619000, 690000, 691000, 
 816000, 817000, 896000, 897000, 620000, 621000, 622000, 623000, 624000, 625000, 
 626000, 627000, 628000, 629000, 682000, 683000, 826000, 827000, 868000, 869000, 
 630000, 631000, 632000, 633000, 634000, 635000, 636000, 637000, 638000, 639000, 
 692000, 693000, 836000, 837000, 878000, 879000, 640000, 641000, 642000, 643000, 
 644000, 645000, 646000, 647000, 648000, 649000, 684000, 685000, 846000, 847000, 
 688000, 689000, 650000, 651000, 652000, 653000, 654000, 655000, 656000, 657000, 
 658000, 659000, 694000, 695000, 856000, 857000, 698000, 699000, 660000, 661000, 
 662000, 663000, 664000, 665000, 666000, 667000, 668000, 669000, 686000, 687000, 
 866000, 867000, 888000, 889000, 670000, 671000, 672000, 673000, 674000, 675000, 
 676000, 677000, 678000, 679000, 696000, 697000, 876000, 877000, 898000, 899000, 
 700000, 701000, 702000, 703000, 704000, 705000, 706000, 707000, 708000, 709000, 
 780000, 781000, 906000, 907000, 986000, 987000, 710000, 711000, 712000, 713000, 
 714000, 715000, 716000, 717000, 718000, 719000, 790000, 791000, 916000, 917000, 
 996000, 997000, 720000, 721000, 722000, 723000, 724000, 725000, 726000, 727000, 
 728000, 729000, 782000, 783000, 926000, 927000, 968000, 969000, 730000, 731000, 
 732000, 733000, 734000, 735000, 736000, 737000, 738000, 739000, 792000, 793000, 
 936000, 937000, 978000, 979000, 740000, 741000, 742000, 743000, 744000, 745000, 
 746000, 747000, 748000, 749000, 784000, 785000, 946000, 947000, 788000, 789000, 
 750000, 751000, 752000, 753000, 754000, 755000, 756000, 757000, 758000, 759000, 
 794000, 795000, 956000, 957000, 798000, 799000, 760000, 761000, 762000, 763000, 
 764000, 765000, 766000, 767000, 768000, 769000, 786000, 787000, 966000, 967000, 
 988000, 989000, 770000, 771000, 772000, 773000, 774000, 775000, 776000, 777000, 
 778000, 779000, 796000, 797000, 976000, 977000, 998000, 999000};
#endif
 
#if DEC_DPD2BINM==1 && !defined(DECDPD2BINM)
#define DECDPD2BINM
 
const uint32_t DPD2BINM[1024]={0,   1000000,   2000000,   3000000,   4000000, 
   5000000,   6000000,   7000000,   8000000,   9000000,  80000000,  81000000, 
 800000000, 801000000, 880000000, 881000000,  10000000,  11000000,  12000000, 
  13000000,  14000000,  15000000,  16000000,  17000000,  18000000,  19000000, 
  90000000,  91000000, 810000000, 811000000, 890000000, 891000000,  20000000, 
  21000000,  22000000,  23000000,  24000000,  25000000,  26000000,  27000000, 
  28000000,  29000000,  82000000,  83000000, 820000000, 821000000, 808000000, 
 809000000,  30000000,  31000000,  32000000,  33000000,  34000000,  35000000, 
  36000000,  37000000,  38000000,  39000000,  92000000,  93000000, 830000000, 
 831000000, 818000000, 819000000,  40000000,  41000000,  42000000,  43000000, 
  44000000,  45000000,  46000000,  47000000,  48000000,  49000000,  84000000, 
  85000000, 840000000, 841000000,  88000000,  89000000,  50000000,  51000000, 
  52000000,  53000000,  54000000,  55000000,  56000000,  57000000,  58000000, 
  59000000,  94000000,  95000000, 850000000, 851000000,  98000000,  99000000, 
  60000000,  61000000,  62000000,  63000000,  64000000,  65000000,  66000000, 
  67000000,  68000000,  69000000,  86000000,  87000000, 860000000, 861000000, 
 888000000, 889000000,  70000000,  71000000,  72000000,  73000000,  74000000, 
  75000000,  76000000,  77000000,  78000000,  79000000,  96000000,  97000000, 
 870000000, 871000000, 898000000, 899000000, 100000000, 101000000, 102000000, 
 103000000, 104000000, 105000000, 106000000, 107000000, 108000000, 109000000, 
 180000000, 181000000, 900000000, 901000000, 980000000, 981000000, 110000000, 
 111000000, 112000000, 113000000, 114000000, 115000000, 116000000, 117000000, 
 118000000, 119000000, 190000000, 191000000, 910000000, 911000000, 990000000, 
 991000000, 120000000, 121000000, 122000000, 123000000, 124000000, 125000000, 
 126000000, 127000000, 128000000, 129000000, 182000000, 183000000, 920000000, 
 921000000, 908000000, 909000000, 130000000, 131000000, 132000000, 133000000, 
 134000000, 135000000, 136000000, 137000000, 138000000, 139000000, 192000000, 
 193000000, 930000000, 931000000, 918000000, 919000000, 140000000, 141000000, 
 142000000, 143000000, 144000000, 145000000, 146000000, 147000000, 148000000, 
 149000000, 184000000, 185000000, 940000000, 941000000, 188000000, 189000000, 
 150000000, 151000000, 152000000, 153000000, 154000000, 155000000, 156000000, 
 157000000, 158000000, 159000000, 194000000, 195000000, 950000000, 951000000, 
 198000000, 199000000, 160000000, 161000000, 162000000, 163000000, 164000000, 
 165000000, 166000000, 167000000, 168000000, 169000000, 186000000, 187000000, 
 960000000, 961000000, 988000000, 989000000, 170000000, 171000000, 172000000, 
 173000000, 174000000, 175000000, 176000000, 177000000, 178000000, 179000000, 
 196000000, 197000000, 970000000, 971000000, 998000000, 999000000, 200000000, 
 201000000, 202000000, 203000000, 204000000, 205000000, 206000000, 207000000, 
 208000000, 209000000, 280000000, 281000000, 802000000, 803000000, 882000000, 
 883000000, 210000000, 211000000, 212000000, 213000000, 214000000, 215000000, 
 216000000, 217000000, 218000000, 219000000, 290000000, 291000000, 812000000, 
 813000000, 892000000, 893000000, 220000000, 221000000, 222000000, 223000000, 
 224000000, 225000000, 226000000, 227000000, 228000000, 229000000, 282000000, 
 283000000, 822000000, 823000000, 828000000, 829000000, 230000000, 231000000, 
 232000000, 233000000, 234000000, 235000000, 236000000, 237000000, 238000000, 
 239000000, 292000000, 293000000, 832000000, 833000000, 838000000, 839000000, 
 240000000, 241000000, 242000000, 243000000, 244000000, 245000000, 246000000, 
 247000000, 248000000, 249000000, 284000000, 285000000, 842000000, 843000000, 
 288000000, 289000000, 250000000, 251000000, 252000000, 253000000, 254000000, 
 255000000, 256000000, 257000000, 258000000, 259000000, 294000000, 295000000, 
 852000000, 853000000, 298000000, 299000000, 260000000, 261000000, 262000000, 
 263000000, 264000000, 265000000, 266000000, 267000000, 268000000, 269000000, 
 286000000, 287000000, 862000000, 863000000, 888000000, 889000000, 270000000, 
 271000000, 272000000, 273000000, 274000000, 275000000, 276000000, 277000000, 
 278000000, 279000000, 296000000, 297000000, 872000000, 873000000, 898000000, 
 899000000, 300000000, 301000000, 302000000, 303000000, 304000000, 305000000, 
 306000000, 307000000, 308000000, 309000000, 380000000, 381000000, 902000000, 
 903000000, 982000000, 983000000, 310000000, 311000000, 312000000, 313000000, 
 314000000, 315000000, 316000000, 317000000, 318000000, 319000000, 390000000, 
 391000000, 912000000, 913000000, 992000000, 993000000, 320000000, 321000000, 
 322000000, 323000000, 324000000, 325000000, 326000000, 327000000, 328000000, 
 329000000, 382000000, 383000000, 922000000, 923000000, 928000000, 929000000, 
 330000000, 331000000, 332000000, 333000000, 334000000, 335000000, 336000000, 
 337000000, 338000000, 339000000, 392000000, 393000000, 932000000, 933000000, 
 938000000, 939000000, 340000000, 341000000, 342000000, 343000000, 344000000, 
 345000000, 346000000, 347000000, 348000000, 349000000, 384000000, 385000000, 
 942000000, 943000000, 388000000, 389000000, 350000000, 351000000, 352000000, 
 353000000, 354000000, 355000000, 356000000, 357000000, 358000000, 359000000, 
 394000000, 395000000, 952000000, 953000000, 398000000, 399000000, 360000000, 
 361000000, 362000000, 363000000, 364000000, 365000000, 366000000, 367000000, 
 368000000, 369000000, 386000000, 387000000, 962000000, 963000000, 988000000, 
 989000000, 370000000, 371000000, 372000000, 373000000, 374000000, 375000000, 
 376000000, 377000000, 378000000, 379000000, 396000000, 397000000, 972000000, 
 973000000, 998000000, 999000000, 400000000, 401000000, 402000000, 403000000, 
 404000000, 405000000, 406000000, 407000000, 408000000, 409000000, 480000000, 
 481000000, 804000000, 805000000, 884000000, 885000000, 410000000, 411000000, 
 412000000, 413000000, 414000000, 415000000, 416000000, 417000000, 418000000, 
 419000000, 490000000, 491000000, 814000000, 815000000, 894000000, 895000000, 
 420000000, 421000000, 422000000, 423000000, 424000000, 425000000, 426000000, 
 427000000, 428000000, 429000000, 482000000, 483000000, 824000000, 825000000, 
 848000000, 849000000, 430000000, 431000000, 432000000, 433000000, 434000000, 
 435000000, 436000000, 437000000, 438000000, 439000000, 492000000, 493000000, 
 834000000, 835000000, 858000000, 859000000, 440000000, 441000000, 442000000, 
 443000000, 444000000, 445000000, 446000000, 447000000, 448000000, 449000000, 
 484000000, 485000000, 844000000, 845000000, 488000000, 489000000, 450000000, 
 451000000, 452000000, 453000000, 454000000, 455000000, 456000000, 457000000, 
 458000000, 459000000, 494000000, 495000000, 854000000, 855000000, 498000000, 
 499000000, 460000000, 461000000, 462000000, 463000000, 464000000, 465000000, 
 466000000, 467000000, 468000000, 469000000, 486000000, 487000000, 864000000, 
 865000000, 888000000, 889000000, 470000000, 471000000, 472000000, 473000000, 
 474000000, 475000000, 476000000, 477000000, 478000000, 479000000, 496000000, 
 497000000, 874000000, 875000000, 898000000, 899000000, 500000000, 501000000, 
 502000000, 503000000, 504000000, 505000000, 506000000, 507000000, 508000000, 
 509000000, 580000000, 581000000, 904000000, 905000000, 984000000, 985000000, 
 510000000, 511000000, 512000000, 513000000, 514000000, 515000000, 516000000, 
 517000000, 518000000, 519000000, 590000000, 591000000, 914000000, 915000000, 
 994000000, 995000000, 520000000, 521000000, 522000000, 523000000, 524000000, 
 525000000, 526000000, 527000000, 528000000, 529000000, 582000000, 583000000, 
 924000000, 925000000, 948000000, 949000000, 530000000, 531000000, 532000000, 
 533000000, 534000000, 535000000, 536000000, 537000000, 538000000, 539000000, 
 592000000, 593000000, 934000000, 935000000, 958000000, 959000000, 540000000, 
 541000000, 542000000, 543000000, 544000000, 545000000, 546000000, 547000000, 
 548000000, 549000000, 584000000, 585000000, 944000000, 945000000, 588000000, 
 589000000, 550000000, 551000000, 552000000, 553000000, 554000000, 555000000, 
 556000000, 557000000, 558000000, 559000000, 594000000, 595000000, 954000000, 
 955000000, 598000000, 599000000, 560000000, 561000000, 562000000, 563000000, 
 564000000, 565000000, 566000000, 567000000, 568000000, 569000000, 586000000, 
 587000000, 964000000, 965000000, 988000000, 989000000, 570000000, 571000000, 
 572000000, 573000000, 574000000, 575000000, 576000000, 577000000, 578000000, 
 579000000, 596000000, 597000000, 974000000, 975000000, 998000000, 999000000, 
 600000000, 601000000, 602000000, 603000000, 604000000, 605000000, 606000000, 
 607000000, 608000000, 609000000, 680000000, 681000000, 806000000, 807000000, 
 886000000, 887000000, 610000000, 611000000, 612000000, 613000000, 614000000, 
 615000000, 616000000, 617000000, 618000000, 619000000, 690000000, 691000000, 
 816000000, 817000000, 896000000, 897000000, 620000000, 621000000, 622000000, 
 623000000, 624000000, 625000000, 626000000, 627000000, 628000000, 629000000, 
 682000000, 683000000, 826000000, 827000000, 868000000, 869000000, 630000000, 
 631000000, 632000000, 633000000, 634000000, 635000000, 636000000, 637000000, 
 638000000, 639000000, 692000000, 693000000, 836000000, 837000000, 878000000, 
 879000000, 640000000, 641000000, 642000000, 643000000, 644000000, 645000000, 
 646000000, 647000000, 648000000, 649000000, 684000000, 685000000, 846000000, 
 847000000, 688000000, 689000000, 650000000, 651000000, 652000000, 653000000, 
 654000000, 655000000, 656000000, 657000000, 658000000, 659000000, 694000000, 
 695000000, 856000000, 857000000, 698000000, 699000000, 660000000, 661000000, 
 662000000, 663000000, 664000000, 665000000, 666000000, 667000000, 668000000, 
 669000000, 686000000, 687000000, 866000000, 867000000, 888000000, 889000000, 
 670000000, 671000000, 672000000, 673000000, 674000000, 675000000, 676000000, 
 677000000, 678000000, 679000000, 696000000, 697000000, 876000000, 877000000, 
 898000000, 899000000, 700000000, 701000000, 702000000, 703000000, 704000000, 
 705000000, 706000000, 707000000, 708000000, 709000000, 780000000, 781000000, 
 906000000, 907000000, 986000000, 987000000, 710000000, 711000000, 712000000, 
 713000000, 714000000, 715000000, 716000000, 717000000, 718000000, 719000000, 
 790000000, 791000000, 916000000, 917000000, 996000000, 997000000, 720000000, 
 721000000, 722000000, 723000000, 724000000, 725000000, 726000000, 727000000, 
 728000000, 729000000, 782000000, 783000000, 926000000, 927000000, 968000000, 
 969000000, 730000000, 731000000, 732000000, 733000000, 734000000, 735000000, 
 736000000, 737000000, 738000000, 739000000, 792000000, 793000000, 936000000, 
 937000000, 978000000, 979000000, 740000000, 741000000, 742000000, 743000000, 
 744000000, 745000000, 746000000, 747000000, 748000000, 749000000, 784000000, 
 785000000, 946000000, 947000000, 788000000, 789000000, 750000000, 751000000, 
 752000000, 753000000, 754000000, 755000000, 756000000, 757000000, 758000000, 
 759000000, 794000000, 795000000, 956000000, 957000000, 798000000, 799000000, 
 760000000, 761000000, 762000000, 763000000, 764000000, 765000000, 766000000, 
 767000000, 768000000, 769000000, 786000000, 787000000, 966000000, 967000000, 
 988000000, 989000000, 770000000, 771000000, 772000000, 773000000, 774000000, 
 775000000, 776000000, 777000000, 778000000, 779000000, 796000000, 797000000, 
 976000000, 977000000, 998000000, 999000000};
#endif
 
#if DEC_BIN2CHAR==1 && !defined(DECBIN2CHAR)
#define DECBIN2CHAR
 
const uint8_t BIN2CHAR[4001]={
 '\0','0','0','0', '\1','0','0','1', '\1','0','0','2', '\1','0','0','3', '\1','0','0','4', 
 '\1','0','0','5', '\1','0','0','6', '\1','0','0','7', '\1','0','0','8', '\1','0','0','9', 
795
796
797
798
799
800
801
802






















































































































 9,4,6,3, 9,4,7,3, 7,8,8,3, 7,8,9,3, 7,5,0,3, 7,5,1,3, 7,5,2,3, 7,5,3,3, 7,5,4,3, 
 7,5,5,3, 7,5,6,3, 7,5,7,3, 7,5,8,3, 7,5,9,3, 7,9,4,3, 7,9,5,3, 9,5,6,3, 9,5,7,3, 
 7,9,8,3, 7,9,9,3, 7,6,0,3, 7,6,1,3, 7,6,2,3, 7,6,3,3, 7,6,4,3, 7,6,5,3, 7,6,6,3, 
 7,6,7,3, 7,6,8,3, 7,6,9,3, 7,8,6,3, 7,8,7,3, 9,6,6,3, 9,6,7,3, 9,8,8,3, 9,8,9,3, 
 7,7,0,3, 7,7,1,3, 7,7,2,3, 7,7,3,3, 7,7,4,3, 7,7,5,3, 7,7,6,3, 7,7,7,3, 7,7,8,3, 
 7,7,9,3, 7,9,6,3, 7,9,7,3, 9,7,6,3, 9,7,7,3, 9,9,8,3, 9,9,9,3};
#endif
 






























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
 9,4,6,3, 9,4,7,3, 7,8,8,3, 7,8,9,3, 7,5,0,3, 7,5,1,3, 7,5,2,3, 7,5,3,3, 7,5,4,3, 
 7,5,5,3, 7,5,6,3, 7,5,7,3, 7,5,8,3, 7,5,9,3, 7,9,4,3, 7,9,5,3, 9,5,6,3, 9,5,7,3, 
 7,9,8,3, 7,9,9,3, 7,6,0,3, 7,6,1,3, 7,6,2,3, 7,6,3,3, 7,6,4,3, 7,6,5,3, 7,6,6,3, 
 7,6,7,3, 7,6,8,3, 7,6,9,3, 7,8,6,3, 7,8,7,3, 9,6,6,3, 9,6,7,3, 9,8,8,3, 9,8,9,3, 
 7,7,0,3, 7,7,1,3, 7,7,2,3, 7,7,3,3, 7,7,4,3, 7,7,5,3, 7,7,6,3, 7,7,7,3, 7,7,8,3, 
 7,7,9,3, 7,9,6,3, 7,9,7,3, 9,7,6,3, 9,7,7,3, 9,9,8,3, 9,9,9,3};
#endif
 
#if DEC_BIN2BCD8==1 && !defined(DECBIN2BCD8)
#define DECBIN2BCD8
 
const uint8_t BIN2BCD8[4000]={
 0,0,0,0, 0,0,1,1, 0,0,2,1, 0,0,3,1, 0,0,4,1, 0,0,5,1, 0,0,6,1, 0,0,7,1, 0,0,8,1, 
 0,0,9,1, 0,1,0,2, 0,1,1,2, 0,1,2,2, 0,1,3,2, 0,1,4,2, 0,1,5,2, 0,1,6,2, 0,1,7,2, 
 0,1,8,2, 0,1,9,2, 0,2,0,2, 0,2,1,2, 0,2,2,2, 0,2,3,2, 0,2,4,2, 0,2,5,2, 0,2,6,2, 
 0,2,7,2, 0,2,8,2, 0,2,9,2, 0,3,0,2, 0,3,1,2, 0,3,2,2, 0,3,3,2, 0,3,4,2, 0,3,5,2, 
 0,3,6,2, 0,3,7,2, 0,3,8,2, 0,3,9,2, 0,4,0,2, 0,4,1,2, 0,4,2,2, 0,4,3,2, 0,4,4,2, 
 0,4,5,2, 0,4,6,2, 0,4,7,2, 0,4,8,2, 0,4,9,2, 0,5,0,2, 0,5,1,2, 0,5,2,2, 0,5,3,2, 
 0,5,4,2, 0,5,5,2, 0,5,6,2, 0,5,7,2, 0,5,8,2, 0,5,9,2, 0,6,0,2, 0,6,1,2, 0,6,2,2, 
 0,6,3,2, 0,6,4,2, 0,6,5,2, 0,6,6,2, 0,6,7,2, 0,6,8,2, 0,6,9,2, 0,7,0,2, 0,7,1,2, 
 0,7,2,2, 0,7,3,2, 0,7,4,2, 0,7,5,2, 0,7,6,2, 0,7,7,2, 0,7,8,2, 0,7,9,2, 0,8,0,2, 
 0,8,1,2, 0,8,2,2, 0,8,3,2, 0,8,4,2, 0,8,5,2, 0,8,6,2, 0,8,7,2, 0,8,8,2, 0,8,9,2, 
 0,9,0,2, 0,9,1,2, 0,9,2,2, 0,9,3,2, 0,9,4,2, 0,9,5,2, 0,9,6,2, 0,9,7,2, 0,9,8,2, 
 0,9,9,2, 1,0,0,3, 1,0,1,3, 1,0,2,3, 1,0,3,3, 1,0,4,3, 1,0,5,3, 1,0,6,3, 1,0,7,3, 
 1,0,8,3, 1,0,9,3, 1,1,0,3, 1,1,1,3, 1,1,2,3, 1,1,3,3, 1,1,4,3, 1,1,5,3, 1,1,6,3, 
 1,1,7,3, 1,1,8,3, 1,1,9,3, 1,2,0,3, 1,2,1,3, 1,2,2,3, 1,2,3,3, 1,2,4,3, 1,2,5,3, 
 1,2,6,3, 1,2,7,3, 1,2,8,3, 1,2,9,3, 1,3,0,3, 1,3,1,3, 1,3,2,3, 1,3,3,3, 1,3,4,3, 
 1,3,5,3, 1,3,6,3, 1,3,7,3, 1,3,8,3, 1,3,9,3, 1,4,0,3, 1,4,1,3, 1,4,2,3, 1,4,3,3, 
 1,4,4,3, 1,4,5,3, 1,4,6,3, 1,4,7,3, 1,4,8,3, 1,4,9,3, 1,5,0,3, 1,5,1,3, 1,5,2,3, 
 1,5,3,3, 1,5,4,3, 1,5,5,3, 1,5,6,3, 1,5,7,3, 1,5,8,3, 1,5,9,3, 1,6,0,3, 1,6,1,3, 
 1,6,2,3, 1,6,3,3, 1,6,4,3, 1,6,5,3, 1,6,6,3, 1,6,7,3, 1,6,8,3, 1,6,9,3, 1,7,0,3, 
 1,7,1,3, 1,7,2,3, 1,7,3,3, 1,7,4,3, 1,7,5,3, 1,7,6,3, 1,7,7,3, 1,7,8,3, 1,7,9,3, 
 1,8,0,3, 1,8,1,3, 1,8,2,3, 1,8,3,3, 1,8,4,3, 1,8,5,3, 1,8,6,3, 1,8,7,3, 1,8,8,3, 
 1,8,9,3, 1,9,0,3, 1,9,1,3, 1,9,2,3, 1,9,3,3, 1,9,4,3, 1,9,5,3, 1,9,6,3, 1,9,7,3, 
 1,9,8,3, 1,9,9,3, 2,0,0,3, 2,0,1,3, 2,0,2,3, 2,0,3,3, 2,0,4,3, 2,0,5,3, 2,0,6,3, 
 2,0,7,3, 2,0,8,3, 2,0,9,3, 2,1,0,3, 2,1,1,3, 2,1,2,3, 2,1,3,3, 2,1,4,3, 2,1,5,3, 
 2,1,6,3, 2,1,7,3, 2,1,8,3, 2,1,9,3, 2,2,0,3, 2,2,1,3, 2,2,2,3, 2,2,3,3, 2,2,4,3, 
 2,2,5,3, 2,2,6,3, 2,2,7,3, 2,2,8,3, 2,2,9,3, 2,3,0,3, 2,3,1,3, 2,3,2,3, 2,3,3,3, 
 2,3,4,3, 2,3,5,3, 2,3,6,3, 2,3,7,3, 2,3,8,3, 2,3,9,3, 2,4,0,3, 2,4,1,3, 2,4,2,3, 
 2,4,3,3, 2,4,4,3, 2,4,5,3, 2,4,6,3, 2,4,7,3, 2,4,8,3, 2,4,9,3, 2,5,0,3, 2,5,1,3, 
 2,5,2,3, 2,5,3,3, 2,5,4,3, 2,5,5,3, 2,5,6,3, 2,5,7,3, 2,5,8,3, 2,5,9,3, 2,6,0,3, 
 2,6,1,3, 2,6,2,3, 2,6,3,3, 2,6,4,3, 2,6,5,3, 2,6,6,3, 2,6,7,3, 2,6,8,3, 2,6,9,3, 
 2,7,0,3, 2,7,1,3, 2,7,2,3, 2,7,3,3, 2,7,4,3, 2,7,5,3, 2,7,6,3, 2,7,7,3, 2,7,8,3, 
 2,7,9,3, 2,8,0,3, 2,8,1,3, 2,8,2,3, 2,8,3,3, 2,8,4,3, 2,8,5,3, 2,8,6,3, 2,8,7,3, 
 2,8,8,3, 2,8,9,3, 2,9,0,3, 2,9,1,3, 2,9,2,3, 2,9,3,3, 2,9,4,3, 2,9,5,3, 2,9,6,3, 
 2,9,7,3, 2,9,8,3, 2,9,9,3, 3,0,0,3, 3,0,1,3, 3,0,2,3, 3,0,3,3, 3,0,4,3, 3,0,5,3, 
 3,0,6,3, 3,0,7,3, 3,0,8,3, 3,0,9,3, 3,1,0,3, 3,1,1,3, 3,1,2,3, 3,1,3,3, 3,1,4,3, 
 3,1,5,3, 3,1,6,3, 3,1,7,3, 3,1,8,3, 3,1,9,3, 3,2,0,3, 3,2,1,3, 3,2,2,3, 3,2,3,3, 
 3,2,4,3, 3,2,5,3, 3,2,6,3, 3,2,7,3, 3,2,8,3, 3,2,9,3, 3,3,0,3, 3,3,1,3, 3,3,2,3, 
 3,3,3,3, 3,3,4,3, 3,3,5,3, 3,3,6,3, 3,3,7,3, 3,3,8,3, 3,3,9,3, 3,4,0,3, 3,4,1,3, 
 3,4,2,3, 3,4,3,3, 3,4,4,3, 3,4,5,3, 3,4,6,3, 3,4,7,3, 3,4,8,3, 3,4,9,3, 3,5,0,3, 
 3,5,1,3, 3,5,2,3, 3,5,3,3, 3,5,4,3, 3,5,5,3, 3,5,6,3, 3,5,7,3, 3,5,8,3, 3,5,9,3, 
 3,6,0,3, 3,6,1,3, 3,6,2,3, 3,6,3,3, 3,6,4,3, 3,6,5,3, 3,6,6,3, 3,6,7,3, 3,6,8,3, 
 3,6,9,3, 3,7,0,3, 3,7,1,3, 3,7,2,3, 3,7,3,3, 3,7,4,3, 3,7,5,3, 3,7,6,3, 3,7,7,3, 
 3,7,8,3, 3,7,9,3, 3,8,0,3, 3,8,1,3, 3,8,2,3, 3,8,3,3, 3,8,4,3, 3,8,5,3, 3,8,6,3, 
 3,8,7,3, 3,8,8,3, 3,8,9,3, 3,9,0,3, 3,9,1,3, 3,9,2,3, 3,9,3,3, 3,9,4,3, 3,9,5,3, 
 3,9,6,3, 3,9,7,3, 3,9,8,3, 3,9,9,3, 4,0,0,3, 4,0,1,3, 4,0,2,3, 4,0,3,3, 4,0,4,3, 
 4,0,5,3, 4,0,6,3, 4,0,7,3, 4,0,8,3, 4,0,9,3, 4,1,0,3, 4,1,1,3, 4,1,2,3, 4,1,3,3, 
 4,1,4,3, 4,1,5,3, 4,1,6,3, 4,1,7,3, 4,1,8,3, 4,1,9,3, 4,2,0,3, 4,2,1,3, 4,2,2,3, 
 4,2,3,3, 4,2,4,3, 4,2,5,3, 4,2,6,3, 4,2,7,3, 4,2,8,3, 4,2,9,3, 4,3,0,3, 4,3,1,3, 
 4,3,2,3, 4,3,3,3, 4,3,4,3, 4,3,5,3, 4,3,6,3, 4,3,7,3, 4,3,8,3, 4,3,9,3, 4,4,0,3, 
 4,4,1,3, 4,4,2,3, 4,4,3,3, 4,4,4,3, 4,4,5,3, 4,4,6,3, 4,4,7,3, 4,4,8,3, 4,4,9,3, 
 4,5,0,3, 4,5,1,3, 4,5,2,3, 4,5,3,3, 4,5,4,3, 4,5,5,3, 4,5,6,3, 4,5,7,3, 4,5,8,3, 
 4,5,9,3, 4,6,0,3, 4,6,1,3, 4,6,2,3, 4,6,3,3, 4,6,4,3, 4,6,5,3, 4,6,6,3, 4,6,7,3, 
 4,6,8,3, 4,6,9,3, 4,7,0,3, 4,7,1,3, 4,7,2,3, 4,7,3,3, 4,7,4,3, 4,7,5,3, 4,7,6,3, 
 4,7,7,3, 4,7,8,3, 4,7,9,3, 4,8,0,3, 4,8,1,3, 4,8,2,3, 4,8,3,3, 4,8,4,3, 4,8,5,3, 
 4,8,6,3, 4,8,7,3, 4,8,8,3, 4,8,9,3, 4,9,0,3, 4,9,1,3, 4,9,2,3, 4,9,3,3, 4,9,4,3, 
 4,9,5,3, 4,9,6,3, 4,9,7,3, 4,9,8,3, 4,9,9,3, 5,0,0,3, 5,0,1,3, 5,0,2,3, 5,0,3,3, 
 5,0,4,3, 5,0,5,3, 5,0,6,3, 5,0,7,3, 5,0,8,3, 5,0,9,3, 5,1,0,3, 5,1,1,3, 5,1,2,3, 
 5,1,3,3, 5,1,4,3, 5,1,5,3, 5,1,6,3, 5,1,7,3, 5,1,8,3, 5,1,9,3, 5,2,0,3, 5,2,1,3, 
 5,2,2,3, 5,2,3,3, 5,2,4,3, 5,2,5,3, 5,2,6,3, 5,2,7,3, 5,2,8,3, 5,2,9,3, 5,3,0,3, 
 5,3,1,3, 5,3,2,3, 5,3,3,3, 5,3,4,3, 5,3,5,3, 5,3,6,3, 5,3,7,3, 5,3,8,3, 5,3,9,3, 
 5,4,0,3, 5,4,1,3, 5,4,2,3, 5,4,3,3, 5,4,4,3, 5,4,5,3, 5,4,6,3, 5,4,7,3, 5,4,8,3, 
 5,4,9,3, 5,5,0,3, 5,5,1,3, 5,5,2,3, 5,5,3,3, 5,5,4,3, 5,5,5,3, 5,5,6,3, 5,5,7,3, 
 5,5,8,3, 5,5,9,3, 5,6,0,3, 5,6,1,3, 5,6,2,3, 5,6,3,3, 5,6,4,3, 5,6,5,3, 5,6,6,3, 
 5,6,7,3, 5,6,8,3, 5,6,9,3, 5,7,0,3, 5,7,1,3, 5,7,2,3, 5,7,3,3, 5,7,4,3, 5,7,5,3, 
 5,7,6,3, 5,7,7,3, 5,7,8,3, 5,7,9,3, 5,8,0,3, 5,8,1,3, 5,8,2,3, 5,8,3,3, 5,8,4,3, 
 5,8,5,3, 5,8,6,3, 5,8,7,3, 5,8,8,3, 5,8,9,3, 5,9,0,3, 5,9,1,3, 5,9,2,3, 5,9,3,3, 
 5,9,4,3, 5,9,5,3, 5,9,6,3, 5,9,7,3, 5,9,8,3, 5,9,9,3, 6,0,0,3, 6,0,1,3, 6,0,2,3, 
 6,0,3,3, 6,0,4,3, 6,0,5,3, 6,0,6,3, 6,0,7,3, 6,0,8,3, 6,0,9,3, 6,1,0,3, 6,1,1,3, 
 6,1,2,3, 6,1,3,3, 6,1,4,3, 6,1,5,3, 6,1,6,3, 6,1,7,3, 6,1,8,3, 6,1,9,3, 6,2,0,3, 
 6,2,1,3, 6,2,2,3, 6,2,3,3, 6,2,4,3, 6,2,5,3, 6,2,6,3, 6,2,7,3, 6,2,8,3, 6,2,9,3, 
 6,3,0,3, 6,3,1,3, 6,3,2,3, 6,3,3,3, 6,3,4,3, 6,3,5,3, 6,3,6,3, 6,3,7,3, 6,3,8,3, 
 6,3,9,3, 6,4,0,3, 6,4,1,3, 6,4,2,3, 6,4,3,3, 6,4,4,3, 6,4,5,3, 6,4,6,3, 6,4,7,3, 
 6,4,8,3, 6,4,9,3, 6,5,0,3, 6,5,1,3, 6,5,2,3, 6,5,3,3, 6,5,4,3, 6,5,5,3, 6,5,6,3, 
 6,5,7,3, 6,5,8,3, 6,5,9,3, 6,6,0,3, 6,6,1,3, 6,6,2,3, 6,6,3,3, 6,6,4,3, 6,6,5,3, 
 6,6,6,3, 6,6,7,3, 6,6,8,3, 6,6,9,3, 6,7,0,3, 6,7,1,3, 6,7,2,3, 6,7,3,3, 6,7,4,3, 
 6,7,5,3, 6,7,6,3, 6,7,7,3, 6,7,8,3, 6,7,9,3, 6,8,0,3, 6,8,1,3, 6,8,2,3, 6,8,3,3, 
 6,8,4,3, 6,8,5,3, 6,8,6,3, 6,8,7,3, 6,8,8,3, 6,8,9,3, 6,9,0,3, 6,9,1,3, 6,9,2,3, 
 6,9,3,3, 6,9,4,3, 6,9,5,3, 6,9,6,3, 6,9,7,3, 6,9,8,3, 6,9,9,3, 7,0,0,3, 7,0,1,3, 
 7,0,2,3, 7,0,3,3, 7,0,4,3, 7,0,5,3, 7,0,6,3, 7,0,7,3, 7,0,8,3, 7,0,9,3, 7,1,0,3, 
 7,1,1,3, 7,1,2,3, 7,1,3,3, 7,1,4,3, 7,1,5,3, 7,1,6,3, 7,1,7,3, 7,1,8,3, 7,1,9,3, 
 7,2,0,3, 7,2,1,3, 7,2,2,3, 7,2,3,3, 7,2,4,3, 7,2,5,3, 7,2,6,3, 7,2,7,3, 7,2,8,3, 
 7,2,9,3, 7,3,0,3, 7,3,1,3, 7,3,2,3, 7,3,3,3, 7,3,4,3, 7,3,5,3, 7,3,6,3, 7,3,7,3, 
 7,3,8,3, 7,3,9,3, 7,4,0,3, 7,4,1,3, 7,4,2,3, 7,4,3,3, 7,4,4,3, 7,4,5,3, 7,4,6,3, 
 7,4,7,3, 7,4,8,3, 7,4,9,3, 7,5,0,3, 7,5,1,3, 7,5,2,3, 7,5,3,3, 7,5,4,3, 7,5,5,3, 
 7,5,6,3, 7,5,7,3, 7,5,8,3, 7,5,9,3, 7,6,0,3, 7,6,1,3, 7,6,2,3, 7,6,3,3, 7,6,4,3, 
 7,6,5,3, 7,6,6,3, 7,6,7,3, 7,6,8,3, 7,6,9,3, 7,7,0,3, 7,7,1,3, 7,7,2,3, 7,7,3,3, 
 7,7,4,3, 7,7,5,3, 7,7,6,3, 7,7,7,3, 7,7,8,3, 7,7,9,3, 7,8,0,3, 7,8,1,3, 7,8,2,3, 
 7,8,3,3, 7,8,4,3, 7,8,5,3, 7,8,6,3, 7,8,7,3, 7,8,8,3, 7,8,9,3, 7,9,0,3, 7,9,1,3, 
 7,9,2,3, 7,9,3,3, 7,9,4,3, 7,9,5,3, 7,9,6,3, 7,9,7,3, 7,9,8,3, 7,9,9,3, 8,0,0,3, 
 8,0,1,3, 8,0,2,3, 8,0,3,3, 8,0,4,3, 8,0,5,3, 8,0,6,3, 8,0,7,3, 8,0,8,3, 8,0,9,3, 
 8,1,0,3, 8,1,1,3, 8,1,2,3, 8,1,3,3, 8,1,4,3, 8,1,5,3, 8,1,6,3, 8,1,7,3, 8,1,8,3, 
 8,1,9,3, 8,2,0,3, 8,2,1,3, 8,2,2,3, 8,2,3,3, 8,2,4,3, 8,2,5,3, 8,2,6,3, 8,2,7,3, 
 8,2,8,3, 8,2,9,3, 8,3,0,3, 8,3,1,3, 8,3,2,3, 8,3,3,3, 8,3,4,3, 8,3,5,3, 8,3,6,3, 
 8,3,7,3, 8,3,8,3, 8,3,9,3, 8,4,0,3, 8,4,1,3, 8,4,2,3, 8,4,3,3, 8,4,4,3, 8,4,5,3, 
 8,4,6,3, 8,4,7,3, 8,4,8,3, 8,4,9,3, 8,5,0,3, 8,5,1,3, 8,5,2,3, 8,5,3,3, 8,5,4,3, 
 8,5,5,3, 8,5,6,3, 8,5,7,3, 8,5,8,3, 8,5,9,3, 8,6,0,3, 8,6,1,3, 8,6,2,3, 8,6,3,3, 
 8,6,4,3, 8,6,5,3, 8,6,6,3, 8,6,7,3, 8,6,8,3, 8,6,9,3, 8,7,0,3, 8,7,1,3, 8,7,2,3, 
 8,7,3,3, 8,7,4,3, 8,7,5,3, 8,7,6,3, 8,7,7,3, 8,7,8,3, 8,7,9,3, 8,8,0,3, 8,8,1,3, 
 8,8,2,3, 8,8,3,3, 8,8,4,3, 8,8,5,3, 8,8,6,3, 8,8,7,3, 8,8,8,3, 8,8,9,3, 8,9,0,3, 
 8,9,1,3, 8,9,2,3, 8,9,3,3, 8,9,4,3, 8,9,5,3, 8,9,6,3, 8,9,7,3, 8,9,8,3, 8,9,9,3, 
 9,0,0,3, 9,0,1,3, 9,0,2,3, 9,0,3,3, 9,0,4,3, 9,0,5,3, 9,0,6,3, 9,0,7,3, 9,0,8,3, 
 9,0,9,3, 9,1,0,3, 9,1,1,3, 9,1,2,3, 9,1,3,3, 9,1,4,3, 9,1,5,3, 9,1,6,3, 9,1,7,3, 
 9,1,8,3, 9,1,9,3, 9,2,0,3, 9,2,1,3, 9,2,2,3, 9,2,3,3, 9,2,4,3, 9,2,5,3, 9,2,6,3, 
 9,2,7,3, 9,2,8,3, 9,2,9,3, 9,3,0,3, 9,3,1,3, 9,3,2,3, 9,3,3,3, 9,3,4,3, 9,3,5,3, 
 9,3,6,3, 9,3,7,3, 9,3,8,3, 9,3,9,3, 9,4,0,3, 9,4,1,3, 9,4,2,3, 9,4,3,3, 9,4,4,3, 
 9,4,5,3, 9,4,6,3, 9,4,7,3, 9,4,8,3, 9,4,9,3, 9,5,0,3, 9,5,1,3, 9,5,2,3, 9,5,3,3, 
 9,5,4,3, 9,5,5,3, 9,5,6,3, 9,5,7,3, 9,5,8,3, 9,5,9,3, 9,6,0,3, 9,6,1,3, 9,6,2,3, 
 9,6,3,3, 9,6,4,3, 9,6,5,3, 9,6,6,3, 9,6,7,3, 9,6,8,3, 9,6,9,3, 9,7,0,3, 9,7,1,3, 
 9,7,2,3, 9,7,3,3, 9,7,4,3, 9,7,5,3, 9,7,6,3, 9,7,7,3, 9,7,8,3, 9,7,9,3, 9,8,0,3, 
 9,8,1,3, 9,8,2,3, 9,8,3,3, 9,8,4,3, 9,8,5,3, 9,8,6,3, 9,8,7,3, 9,8,8,3, 9,8,9,3, 
 9,9,0,3, 9,9,1,3, 9,9,2,3, 9,9,3,3, 9,9,4,3, 9,9,5,3, 9,9,6,3, 9,9,7,3, 9,9,8,3, 
 9,9,9,3};
#endif
 

Changes to decNumber/decNumber.c.

1
2
3
4
5
6
7
8
9
10
11
/* ------------------------------------------------------------------ */
/* Decimal Number arithmetic module                                   */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2006.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is called decNumber.pdf.  This document is           */
/* available, together with arithmetic and format specifications,     */



|







1
2
3
4
5
6
7
8
9
10
11
/* ------------------------------------------------------------------ */
/* Decimal Number arithmetic module                                   */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is called decNumber.pdf.  This document is           */
/* available, together with arithmetic and format specifications,     */
46
47
48
49
50
51
52





53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*    range (Emax in the range 0 through 999,999,999 and Emin in the  */
/*    range -999,999,999 through 0).  Mathematical functions (for     */
/*    example decNumberExp) as identified below are restricted more   */
/*    tightly: digits, emax, and -emin in the context must be <=      */
/*    DEC_MAX_MATH (999999), and their operand(s) must be within      */
/*    these bounds.                                                   */
/*                                                                    */





/* 3. Operands to operator functions are never modified unless they   */
/*    are also specified to be the result number (which is always     */
/*    permitted).  Other than that case, operands must not overlap.   */
/*                                                                    */
/* 4. Error handling: the type of the error is ORed into the status   */
/*    flags in the current context (decContext structure).  The       */
/*    SIGFPE signal is then raised if the corresponding trap-enabler  */
/*    flag in the decContext is set (is 1).                           */
/*                                                                    */
/*    It is the responsibility of the caller to clear the status      */
/*    flags as required.                                              */
/*                                                                    */
/*    The result of any routine which returns a number will always    */
/*    be a valid number (which may be a special value, such as an     */
/*    Infinity or NaN).                                               */
/*                                                                    */
/* 5. The decNumber format is not an exchangeable concrete            */
/*    representation as it comprises fields which may be machine-     */
/*    dependent (packed or unpacked, or special length, for example). */
/*    Canonical conversions to and from strings are provided; other   */
/*    conversions are available in separate modules.                  */
/*                                                                    */
/* 6. Normally, input operands are assumed to be valid.  Set DECCHECK */
/*    to 1 for extended operand checking (including NULL operands).   */
/*    Results are undefined if a badly-formed structure (or a NULL    */
/*    pointer to a structure) is provided, though with DECCHECK       */
/*    enabled the operator routines are protected against exceptions. */
/*    (Except if the result pointer is NULL, which is unrecoverable.) */
/*                                                                    */
/*    However, the routines will never cause exceptions if they are   */
/*    given well-formed operands, even if the value of the operands   */
/*    is inappropriate for the operation and DECCHECK is not set.     */
/*    (Except for SIGFPE, as and where documented.)                   */
/*                                                                    */
/* 7. Subset arithmetic is available only if DECSUBSET is set to 1.   */
/* ------------------------------------------------------------------ */
/* Implementation notes for maintenance of this module:               */
/*                                                                    */
/* 1. Storage leak protection:  Routines which use malloc are not     */
/*    permitted to use return for fastpath or error exits (i.e.,      */
/*    they follow strict structured programming conventions).         */
/*    Instead they have a do{}while(0); construct surrounding the     */







>
>
>
>
>
|



|











|





|











|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*    range (Emax in the range 0 through 999,999,999 and Emin in the  */
/*    range -999,999,999 through 0).  Mathematical functions (for     */
/*    example decNumberExp) as identified below are restricted more   */
/*    tightly: digits, emax, and -emin in the context must be <=      */
/*    DEC_MAX_MATH (999999), and their operand(s) must be within      */
/*    these bounds.                                                   */
/*                                                                    */
/* 3. Logical functions are further restricted; their operands must   */
/*    be finite, positive, have an exponent of zero, and all digits   */
/*    must be either 0 or 1.  The result will only contain digits     */
/*    which are 0 or 1 (and will have exponent=0 and a sign of 0).    */
/*                                                                    */
/* 4. Operands to operator functions are never modified unless they   */
/*    are also specified to be the result number (which is always     */
/*    permitted).  Other than that case, operands must not overlap.   */
/*                                                                    */
/* 5. Error handling: the type of the error is ORed into the status   */
/*    flags in the current context (decContext structure).  The       */
/*    SIGFPE signal is then raised if the corresponding trap-enabler  */
/*    flag in the decContext is set (is 1).                           */
/*                                                                    */
/*    It is the responsibility of the caller to clear the status      */
/*    flags as required.                                              */
/*                                                                    */
/*    The result of any routine which returns a number will always    */
/*    be a valid number (which may be a special value, such as an     */
/*    Infinity or NaN).                                               */
/*                                                                    */
/* 6. The decNumber format is not an exchangeable concrete            */
/*    representation as it comprises fields which may be machine-     */
/*    dependent (packed or unpacked, or special length, for example). */
/*    Canonical conversions to and from strings are provided; other   */
/*    conversions are available in separate modules.                  */
/*                                                                    */
/* 7. Normally, input operands are assumed to be valid.  Set DECCHECK */
/*    to 1 for extended operand checking (including NULL operands).   */
/*    Results are undefined if a badly-formed structure (or a NULL    */
/*    pointer to a structure) is provided, though with DECCHECK       */
/*    enabled the operator routines are protected against exceptions. */
/*    (Except if the result pointer is NULL, which is unrecoverable.) */
/*                                                                    */
/*    However, the routines will never cause exceptions if they are   */
/*    given well-formed operands, even if the value of the operands   */
/*    is inappropriate for the operation and DECCHECK is not set.     */
/*    (Except for SIGFPE, as and where documented.)                   */
/*                                                                    */
/* 8. Subset arithmetic is available only if DECSUBSET is set to 1.   */
/* ------------------------------------------------------------------ */
/* Implementation notes for maintenance of this module:               */
/*                                                                    */
/* 1. Storage leak protection:  Routines which use malloc are not     */
/*    permitted to use return for fastpath or error exits (i.e.,      */
/*    they follow strict structured programming conventions).         */
/*    Instead they have a do{}while(0); construct surrounding the     */
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180



181
182
183
184
185
186


187
188
189
190
191
192
193
// Public constant array: powers of ten (powers[n]==10**n, 0<=n<=9)
const uInt powers[10]={1, 10, 100, 1000, 10000, 100000, 1000000,
                       10000000, 100000000, 1000000000};
// Public lookup table used by the D2U macro
const uByte d2utable[DECMAXD2U+1]=D2UTABLE;

// Local constants
#define DIVIDE    0x80             // Divide operators
#define REMAINDER 0x40             // ..
#define DIVIDEINT 0x20             // ..
#define REMNEAR   0x10             // ..
#define COMPARE   0x01             // Compare operators
#define COMPMAX   0x02             // ..
#define COMPMIN   0x03             // ..
#define COMPTOTAL 0x04             // ..
#define COMPNAN   0x05             // .. [NaN processing]




#define DEC_sNaN     0x40000000    // local status: sNaN signal
#define BADINT  (Int)0x80000000    // most-negative Int; error indicator
// Next two indicate an integer >= 10**6, and its parity (bottom bit)
#define BIGEVEN (Int)0x80000002
#define BIGODD  (Int)0x80000003



static Unit uarrone[1]={1};   // Unit array of 1, used for incrementing

/* Granularity-dependent code */
#if DECDPUN<=4
  #define eInt  Int           // extended integer
  #define ueInt uInt          // unsigned extended integer







|
|
|
|
|
|
|
|
|
>
>
>






>
>







170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// Public constant array: powers of ten (powers[n]==10**n, 0<=n<=9)
const uInt powers[10]={1, 10, 100, 1000, 10000, 100000, 1000000,
                       10000000, 100000000, 1000000000};
// Public lookup table used by the D2U macro
const uByte d2utable[DECMAXD2U+1]=D2UTABLE;

// Local constants
#define DIVIDE      0x80           // Divide operators
#define REMAINDER   0x40           // ..
#define DIVIDEINT   0x20           // ..
#define REMNEAR     0x10           // ..
#define COMPARE     0x01           // Compare operators
#define COMPMAX     0x02           // ..
#define COMPMIN     0x03           // ..
#define COMPTOTAL   0x04           // ..
#define COMPNAN     0x05           // .. [NaN processing]
#define COMPSIG     0x06           // .. [signaling COMPARE]
#define COMPMAXMAG  0x07           // ..
#define COMPMINMAG  0x08           // ..

#define DEC_sNaN     0x40000000    // local status: sNaN signal
#define BADINT  (Int)0x80000000    // most-negative Int; error indicator
// Next two indicate an integer >= 10**6, and its parity (bottom bit)
#define BIGEVEN (Int)0x80000002
#define BIGODD  (Int)0x80000003

#define DECVERB     1              // set to 1 for verbose DECCHECK

static Unit uarrone[1]={1};   // Unit array of 1, used for incrementing

/* Granularity-dependent code */
#if DECDPUN<=4
  #define eInt  Int           // extended integer
  #define ueInt uInt          // unsigned extended integer
214
215
216
217
218
219
220

221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238

239
240

241
242
243
244
245
246
247
248
249
250
251
252
253
254
static void        decApplyRound(decNumber *, decContext *, Int, uInt *);
static Int         decCompare(const decNumber *lhs, const decNumber *rhs, Flag);
static decNumber * decCompareOp(decNumber *, const decNumber *,
                              const decNumber *, decContext *,
                              Flag, uInt *);
static void        decCopyFit(decNumber *, const decNumber *, decContext *,
                              Int *, uInt *);

static decNumber * decDivideOp(decNumber *, const decNumber *,
                              const decNumber *, decContext *, Flag, uInt *);
static decNumber * decExpOp(decNumber *, const decNumber *,
                              decContext *, uInt *);
static void        decFinalize(decNumber *, decContext *, Int *, uInt *);
static Int         decGetDigits(Unit *, Int);
static Int         decGetInt(const decNumber *);
static decNumber * decLnOp(decNumber *, const decNumber *,
                              decContext *, uInt *);
static decNumber * decMultiplyOp(decNumber *, const decNumber *,
                              const decNumber *, decContext *,
                              uInt *);
static decNumber * decNaNs(decNumber *, const decNumber *,
                              const decNumber *, uInt *);
static decNumber * decPutInt(decNumber *, Int);
static decNumber * decQuantizeOp(decNumber *, const decNumber *,
                              const decNumber *, decContext *, Flag,
                              uInt *);

static void        decSetCoeff(decNumber *, decContext *, const Unit *,
                              Int, Int *, uInt *);

static void        decSetOverflow(decNumber *, decContext *, uInt *);
static void        decSetSubnormal(decNumber *, decContext *, Int *, uInt *);
static Int         decShiftToLeast(Unit *, Int, Int);
static Int         decShiftToMost(Unit *, Int, Int);
static void        decStatus(decNumber *, uInt, decContext *);
static void        decToString(const decNumber *, char[], Flag);
static decNumber * decTrim(decNumber *, Flag, Int *);
static Int         decUnitAddSub(const Unit *, Int, const Unit *, Int, Int,
                              Unit *, Int);
static Int         decUnitCompare(const Unit *, Int, const Unit *, Int, Int);

#if !DECSUBSET
/* decFinish == decFinalize when no subset arithmetic needed */
#define decFinish(a,b,c,d) decFinalize(a,b,c,d)







>













|
<



>


>






|







224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245

246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
static void        decApplyRound(decNumber *, decContext *, Int, uInt *);
static Int         decCompare(const decNumber *lhs, const decNumber *rhs, Flag);
static decNumber * decCompareOp(decNumber *, const decNumber *,
                              const decNumber *, decContext *,
                              Flag, uInt *);
static void        decCopyFit(decNumber *, const decNumber *, decContext *,
                              Int *, uInt *);
static decNumber * decDecap(decNumber *, Int);
static decNumber * decDivideOp(decNumber *, const decNumber *,
                              const decNumber *, decContext *, Flag, uInt *);
static decNumber * decExpOp(decNumber *, const decNumber *,
                              decContext *, uInt *);
static void        decFinalize(decNumber *, decContext *, Int *, uInt *);
static Int         decGetDigits(Unit *, Int);
static Int         decGetInt(const decNumber *);
static decNumber * decLnOp(decNumber *, const decNumber *,
                              decContext *, uInt *);
static decNumber * decMultiplyOp(decNumber *, const decNumber *,
                              const decNumber *, decContext *,
                              uInt *);
static decNumber * decNaNs(decNumber *, const decNumber *,
                              const decNumber *, decContext *, uInt *);

static decNumber * decQuantizeOp(decNumber *, const decNumber *,
                              const decNumber *, decContext *, Flag,
                              uInt *);
static void        decReverse(Unit *, Unit *);
static void        decSetCoeff(decNumber *, decContext *, const Unit *,
                              Int, Int *, uInt *);
static void        decSetMaxValue(decNumber *, decContext *);
static void        decSetOverflow(decNumber *, decContext *, uInt *);
static void        decSetSubnormal(decNumber *, decContext *, Int *, uInt *);
static Int         decShiftToLeast(Unit *, Int, Int);
static Int         decShiftToMost(Unit *, Int, Int);
static void        decStatus(decNumber *, uInt, decContext *);
static void        decToString(const decNumber *, char[], Flag);
static decNumber * decTrim(decNumber *, decContext *, Flag, Int *);
static Int         decUnitAddSub(const Unit *, Int, const Unit *, Int, Int,
                              Unit *, Int);
static Int         decUnitCompare(const Unit *, Int, const Unit *, Int, Int);

#if !DECSUBSET
/* decFinish == decFinalize when no subset arithmetic needed */
#define decFinish(a,b,c,d) decFinalize(a,b,c,d)
302
303
304
305
306
307
308













































































































309
310
311
312
313
314
315
void decNumberShow(const decNumber *);  // displays the components of a number
static void decDumpAr(char, const Unit *, Int);
#endif

/* ================================================================== */
/* Conversions                                                        */
/* ================================================================== */














































































































/* ------------------------------------------------------------------ */
/* to-scientific-string -- conversion to numeric string               */
/* to-engineering-string -- conversion to numeric string              */
/*                                                                    */
/*   decNumberToString(dn, string);                                   */
/*   decNumberToEngString(dn, string);                                */







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
void decNumberShow(const decNumber *);  // displays the components of a number
static void decDumpAr(char, const Unit *, Int);
#endif

/* ================================================================== */
/* Conversions                                                        */
/* ================================================================== */

/* ------------------------------------------------------------------ */
/* from-int32 -- conversion from Int or uInt                          */
/*                                                                    */
/*  dn is the decNumber to receive the integer                        */
/*  in or uin is the integer to be converted                          */
/*  returns dn                                                        */
/*                                                                    */
/* No error is possible.                                              */
/* ------------------------------------------------------------------ */
decNumber * decNumberFromInt32(decNumber *dn, Int in) {
  uInt unsig;
  if (in>=0) unsig=in;
   else {                               // negative (possibly BADINT)
    if (in==BADINT) unsig=(uInt)1073741824*2; // special case
     else unsig=-in;                    // invert
    }
  // in is now positive
  decNumberFromUInt32(dn, unsig);
  if (in<0) dn->bits=DECNEG;            // sign needed
  return dn;
  } // decNumberFromInt32

decNumber * decNumberFromUInt32(decNumber *dn, uInt uin) {
  Unit *up;                             // work pointer
  decNumberZero(dn);                    // clean
  if (uin==0) return dn;                // [or decGetDigits bad call]
  for (up=dn->lsu; uin>0; up++) {
    *up=(Unit)(uin%(DECDPUNMAX+1));
    uin=uin/(DECDPUNMAX+1);
    }
  dn->digits=decGetDigits(dn->lsu, up-dn->lsu);
  return dn;
  } // decNumberFromUInt32

/* ------------------------------------------------------------------ */
/* to-int32 -- conversion to Int or uInt                              */
/*                                                                    */
/*  dn is the decNumber to convert                                    */
/*  set is the context for reporting errors                           */
/*  returns the converted decNumber, or 0 if Invalid is set           */
/*                                                                    */
/* Invalid is set if the decNumber does not have exponent==0 or if    */
/* it is a NaN, Infinite, or out-of-range.                            */
/* ------------------------------------------------------------------ */
Int decNumberToInt32(const decNumber *dn, decContext *set) {
  #if DECCHECK
  if (decCheckOperands(DECUNUSED, DECUNUSED, dn, set)) return 0;
  #endif

  // special or too many digits, or bad exponent
  if (dn->bits&DECSPECIAL || dn->digits>10 || dn->exponent!=0) ; // bad
   else { // is a finite integer with 10 or fewer digits
    Int d;                         // work
    const Unit *up;                // ..
    uInt hi=0, lo;                 // ..
    up=dn->lsu;                    // -> lsu
    lo=*up;                        // get 1 to 9 digits
    #if DECDPUN>1                  // split to higher
      hi=lo/10;
      lo=lo%10;
    #endif
    up++;
    // collect remaining Units, if any, into hi
    for (d=DECDPUN; d<dn->digits; up++, d+=DECDPUN) hi+=*up*powers[d-1];
    // now low has the lsd, hi the remainder
    if (hi>214748364 || (hi==214748364 && lo>7)) { // out of range?
      // most-negative is a reprieve
      if (dn->bits&DECNEG && hi==214748364 && lo==8) return 0x80000000;
      // bad -- drop through
      }
     else { // in-range always
      Int i=X10(hi)+lo;
      if (dn->bits&DECNEG) return -i;
      return i;
      }
    } // integer
  decContextSetStatus(set, DEC_Invalid_operation); // [may not return]
  return 0;
  } // decNumberToInt32

uInt decNumberToUInt32(const decNumber *dn, decContext *set) {
  #if DECCHECK
  if (decCheckOperands(DECUNUSED, DECUNUSED, dn, set)) return 0;
  #endif
  // special or too many digits, or bad exponent, or negative (<0)
  if (dn->bits&DECSPECIAL || dn->digits>10 || dn->exponent!=0
    || (dn->bits&DECNEG && !ISZERO(dn)));                   // bad
   else { // is a finite integer with 10 or fewer digits
    Int d;                         // work
    const Unit *up;                // ..
    uInt hi=0, lo;                 // ..
    up=dn->lsu;                    // -> lsu
    lo=*up;                        // get 1 to 9 digits
    #if DECDPUN>1                  // split to higher
      hi=lo/10;
      lo=lo%10;
    #endif
    up++;
    // collect remaining Units, if any, into hi
    for (d=DECDPUN; d<dn->digits; up++, d+=DECDPUN) hi+=*up*powers[d-1];

    // now low has the lsd, hi the remainder
    if (hi>429496729 || (hi==429496729 && lo>5)) ; // no reprieve possible
     else return X10(hi)+lo;
    } // integer
  decContextSetStatus(set, DEC_Invalid_operation); // [may not return]
  return 0;
  } // decNumberToUInt32

/* ------------------------------------------------------------------ */
/* to-scientific-string -- conversion to numeric string               */
/* to-engineering-string -- conversion to numeric string              */
/*                                                                    */
/*   decNumberToString(dn, string);                                   */
/*   decNumberToEngString(dn, string);                                */
352
353
354
355
356
357
358
359

360
361
362
363
364
365
366
/* If bad syntax is detected, the result will be a quiet NaN.         */
/* ------------------------------------------------------------------ */
decNumber * decNumberFromString(decNumber *dn, const char chars[],
                                decContext *set) {
  Int   exponent=0;                // working exponent [assume 0]
  uByte bits=0;                    // working flags [assume +ve]
  Unit  *res;                      // where result will be built
  Unit  resbuff[SD2U(DECBUFFER+1)];// local buffer in case need temporary

  Unit  *allocres=NULL;            // -> allocated result, iff allocated
  Int   d=0;                       // count of digits found in decimal part
  const char *dotchar=NULL;        // where dot was found
  const char *cfirst=chars;        // -> first character of decimal part
  const char *last=NULL;           // -> last digit of decimal part
  const char *c;                   // work
  Unit  *up;                       // ..







|
>







473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
/* If bad syntax is detected, the result will be a quiet NaN.         */
/* ------------------------------------------------------------------ */
decNumber * decNumberFromString(decNumber *dn, const char chars[],
                                decContext *set) {
  Int   exponent=0;                // working exponent [assume 0]
  uByte bits=0;                    // working flags [assume +ve]
  Unit  *res;                      // where result will be built
  Unit  resbuff[SD2U(DECBUFFER+9)];// local buffer in case need temporary
                                   // [+9 allows for ln() constants]
  Unit  *allocres=NULL;            // -> allocated result, iff allocated
  Int   d=0;                       // count of digits found in decimal part
  const char *dotchar=NULL;        // where dot was found
  const char *cfirst=chars;        // -> first character of decimal part
  const char *last=NULL;           // -> last digit of decimal part
  const char *c;                   // work
  Unit  *up;                       // ..
589
590
591
592
593
594
595

596
597
598
599
600
601
602
/*                                                                    */
/*   This computes C = abs(A)                                         */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
/*   rhs is A                                                         */
/*   set is the context                                               */
/*                                                                    */

/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
/* This has the same effect as decNumberPlus unless A is negative,    */
/* in which case it has the same effect as decNumberMinus.            */
/* ------------------------------------------------------------------ */
decNumber * decNumberAbs(decNumber *res, const decNumber *rhs,
                         decContext *set) {







>







711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
/*                                                                    */
/*   This computes C = abs(A)                                         */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
/*   rhs is A                                                         */
/*   set is the context                                               */
/*                                                                    */
/* See also decNumberCopyAbs for a quiet bitwise version of this.     */
/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
/* This has the same effect as decNumberPlus unless A is negative,    */
/* in which case it has the same effect as decNumberMinus.            */
/* ------------------------------------------------------------------ */
decNumber * decNumberAbs(decNumber *res, const decNumber *rhs,
                         decContext *set) {
636
637
638
639
640
641
642







































































643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662




















663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683


































































684
685
686
687
688
689
690
  decAddOp(res, lhs, rhs, set, 0, &status);
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberAdd








































































/* ------------------------------------------------------------------ */
/* decNumberCompare -- compare two Numbers                            */
/*                                                                    */
/*   This computes C = A ? B                                          */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for one digit (or NaN).                          */
/* ------------------------------------------------------------------ */
decNumber * decNumberCompare(decNumber *res, const decNumber *lhs,
                             const decNumber *rhs, decContext *set) {
  uInt status=0;                        // accumulator
  decCompareOp(res, lhs, rhs, set, COMPARE, &status);
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberCompare





















/* ------------------------------------------------------------------ */
/* decNumberCompareTotal -- compare two Numbers, using total ordering */
/*                                                                    */
/*   This computes C = A ? B, under total ordering                    */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for one digit; the result will always be one of  */
/* -1, 0, or 1.                                                       */
/* ------------------------------------------------------------------ */
decNumber * decNumberCompareTotal(decNumber *res, const decNumber *lhs,
                             const decNumber *rhs, decContext *set) {
  uInt status=0;                        // accumulator
  decCompareOp(res, lhs, rhs, set, COMPTOTAL, &status);
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberCompareTotal



































































/* ------------------------------------------------------------------ */
/* decNumberDivide -- divide one number by another                    */
/*                                                                    */
/*   This computes C = A / B                                          */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X/X)         */







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>















|





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
  decAddOp(res, lhs, rhs, set, 0, &status);
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberAdd

/* ------------------------------------------------------------------ */
/* decNumberAnd -- AND two Numbers, digitwise                         */
/*                                                                    */
/*   This computes C = A & B                                          */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X&X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context (used for result length and error report)     */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/*                                                                    */
/* Logical function restrictions apply (see above); a NaN is          */
/* returned with Invalid_operation if a restriction is violated.      */
/* ------------------------------------------------------------------ */
decNumber * decNumberAnd(decNumber *res, const decNumber *lhs,
                         const decNumber *rhs, decContext *set) {
  const Unit *ua, *ub;                  // -> operands
  const Unit *msua, *msub;              // -> operand msus
  Unit *uc,  *msuc;                     // -> result and its msu
  Int   msudigs;                        // digits in res msu
  #if DECCHECK
  if (decCheckOperands(res, lhs, rhs, set)) return res;
  #endif

  if (lhs->exponent!=0 || decNumberIsSpecial(lhs) || decNumberIsNegative(lhs)
   || rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) {
    decStatus(res, DEC_Invalid_operation, set);
    return res;
    }

  // operands are valid
  ua=lhs->lsu;                          // bottom-up
  ub=rhs->lsu;                          // ..
  uc=res->lsu;                          // ..
  msua=ua+D2U(lhs->digits)-1;           // -> msu of lhs
  msub=ub+D2U(rhs->digits)-1;           // -> msu of rhs
  msuc=uc+D2U(set->digits)-1;           // -> msu of result
  msudigs=MSUDIGITS(set->digits);       // [faster than remainder]
  for (; uc<=msuc; ua++, ub++, uc++) {  // Unit loop
    Unit a, b;                          // extract units
    if (ua>msua) a=0;
     else a=*ua;
    if (ub>msub) b=0;
     else b=*ub;
    *uc=0;                              // can now write back
    if (a|b) {                          // maybe 1 bits to examine
      Int i, j;
      *uc=0;                            // can now write back
      // This loop could be unrolled and/or use BIN2BCD tables
      for (i=0; i<DECDPUN; i++) {
        if (a&b&1) *uc=*uc+(Unit)powers[i];  // effect AND
        j=a%10;
        a=a/10;
        j|=b%10;
        b=b/10;
        if (j>1) {
          decStatus(res, DEC_Invalid_operation, set);
          return res;
          }
        if (uc==msuc && i==msudigs-1) break; // just did final digit
        } // each digit
      } // both OK
    } // each unit
  // [here uc-1 is the msu of the result]
  res->digits=decGetDigits(res->lsu, uc-res->lsu);
  res->exponent=0;                      // integer
  res->bits=0;                          // sign=0
  return res;  // [no status to set]
  } // decNumberAnd

/* ------------------------------------------------------------------ */
/* decNumberCompare -- compare two Numbers                            */
/*                                                                    */
/*   This computes C = A ? B                                          */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for one digit (or NaN).                          */
/* ------------------------------------------------------------------ */
decNumber * decNumberCompare(decNumber *res, const decNumber *lhs,
                             const decNumber *rhs, decContext *set) {
  uInt status=0;                        // accumulator
  decCompareOp(res, lhs, rhs, set, COMPARE, &status);
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberCompare

/* ------------------------------------------------------------------ */
/* decNumberCompareSignal -- compare, signalling on all NaNs          */
/*                                                                    */
/*   This computes C = A ? B                                          */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for one digit (or NaN).                          */
/* ------------------------------------------------------------------ */
decNumber * decNumberCompareSignal(decNumber *res, const decNumber *lhs,
                                   const decNumber *rhs, decContext *set) {
  uInt status=0;                        // accumulator
  decCompareOp(res, lhs, rhs, set, COMPSIG, &status);
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberCompareSignal

/* ------------------------------------------------------------------ */
/* decNumberCompareTotal -- compare two Numbers, using total ordering */
/*                                                                    */
/*   This computes C = A ? B, under total ordering                    */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for one digit; the result will always be one of  */
/* -1, 0, or 1.                                                       */
/* ------------------------------------------------------------------ */
decNumber * decNumberCompareTotal(decNumber *res, const decNumber *lhs,
                                  const decNumber *rhs, decContext *set) {
  uInt status=0;                        // accumulator
  decCompareOp(res, lhs, rhs, set, COMPTOTAL, &status);
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberCompareTotal

/* ------------------------------------------------------------------ */
/* decNumberCompareTotalMag -- compare, total ordering of magnitudes  */
/*                                                                    */
/*   This computes C = |A| ? |B|, under total ordering                */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for one digit; the result will always be one of  */
/* -1, 0, or 1.                                                       */
/* ------------------------------------------------------------------ */
decNumber * decNumberCompareTotalMag(decNumber *res, const decNumber *lhs,
                                     const decNumber *rhs, decContext *set) {
  uInt status=0;                   // accumulator
  uInt needbytes;                  // for space calculations
  decNumber bufa[D2N(DECBUFFER+1)];// +1 in case DECBUFFER=0
  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated
  decNumber bufb[D2N(DECBUFFER+1)];
  decNumber *allocbufb=NULL;       // -> allocated bufb, iff allocated
  decNumber *a, *b;                // temporary pointers

  #if DECCHECK
  if (decCheckOperands(res, lhs, rhs, set)) return res;
  #endif

  do {                                  // protect allocated storage
    // if either is negative, take a copy and absolute
    if (decNumberIsNegative(lhs)) {     // lhs<0
      a=bufa;
      needbytes=sizeof(decNumber)+(D2U(lhs->digits)-1)*sizeof(Unit);
      if (needbytes>sizeof(bufa)) {     // need malloc space
        allocbufa=(decNumber *)malloc(needbytes);
        if (allocbufa==NULL) {          // hopeless -- abandon
          status|=DEC_Insufficient_storage;
          break;}
        a=allocbufa;                    // use the allocated space
        }
      decNumberCopy(a, lhs);            // copy content
      a->bits&=~DECNEG;                 // .. and clear the sign
      lhs=a;                            // use copy from here on
      }
    if (decNumberIsNegative(rhs)) {     // rhs<0
      b=bufb;
      needbytes=sizeof(decNumber)+(D2U(rhs->digits)-1)*sizeof(Unit);
      if (needbytes>sizeof(bufb)) {     // need malloc space
        allocbufb=(decNumber *)malloc(needbytes);
        if (allocbufb==NULL) {          // hopeless -- abandon
          status|=DEC_Insufficient_storage;
          break;}
        b=allocbufb;                    // use the allocated space
        }
      decNumberCopy(b, rhs);            // copy content
      b->bits&=~DECNEG;                 // .. and clear the sign
      rhs=b;                            // use copy from here on
      }
    decCompareOp(res, lhs, rhs, set, COMPTOTAL, &status);
    } while(0);                         // end protected

  if (allocbufa!=NULL) free(allocbufa); // drop any storage used
  if (allocbufb!=NULL) free(allocbufb); // ..
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberCompareTotalMag

/* ------------------------------------------------------------------ */
/* decNumberDivide -- divide one number by another                    */
/*                                                                    */
/*   This computes C = A / B                                          */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X/X)         */
785
786
787
788
789
790
791
























































































































































792
793
794
795
796
797
798
  // apply significant status
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberExp

























































































































































/* ------------------------------------------------------------------ */
/* decNumberLn -- natural logarithm                                   */
/*                                                                    */
/*   This computes C = ln(A)                                          */
/*                                                                    */
/*   res is C, the result.  C may be A                                */







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
  // apply significant status
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberExp

/* ------------------------------------------------------------------ */
/* decNumberFMA -- fused multiply add                                 */
/*                                                                    */
/*   This computes D = (A * B) + C with only one rounding             */
/*                                                                    */
/*   res is D, the result.  D may be A or B or C (e.g., X=FMA(X,X,X)) */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   fhs is C [far hand side]                                         */
/*   set is the context                                               */
/*                                                                    */
/* Mathematical function restrictions apply (see above); a NaN is     */
/* returned with Invalid_operation if a restriction is violated.      */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
decNumber * decNumberFMA(decNumber *res, const decNumber *lhs,
                         const decNumber *rhs, const decNumber *fhs,
                         decContext *set) {
  uInt status=0;                   // accumulator
  decContext dcmul;                // context for the multiplication
  uInt needbytes;                  // for space calculations
  decNumber bufa[D2N(DECBUFFER*2+1)];
  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated
  decNumber *acc;                  // accumulator pointer
  decNumber dzero;                 // work

  #if DECCHECK
  if (decCheckOperands(res, lhs, rhs, set)) return res;
  if (decCheckOperands(res, fhs, DECUNUSED, set)) return res;
  #endif

  do {                                  // protect allocated storage
    #if DECSUBSET
    if (!set->extended) {               // [undefined if subset]
      status|=DEC_Invalid_operation;
      break;}
    #endif
    // Check math restrictions [these ensure no overflow or underflow]
    if ((!decNumberIsSpecial(lhs) && decCheckMath(lhs, set, &status))
     || (!decNumberIsSpecial(rhs) && decCheckMath(rhs, set, &status))
     || (!decNumberIsSpecial(fhs) && decCheckMath(fhs, set, &status))) break;
    // set up context for multiply
    dcmul=*set;
    dcmul.digits=lhs->digits+rhs->digits; // just enough
    // [The above may be an over-estimate for subset arithmetic, but that's OK]
    dcmul.emax=DEC_MAX_EMAX;            // effectively unbounded ..
    dcmul.emin=DEC_MIN_EMIN;            // [thanks to Math restrictions]
    // set up decNumber space to receive the result of the multiply
    acc=bufa;                           // may fit
    needbytes=sizeof(decNumber)+(D2U(dcmul.digits)-1)*sizeof(Unit);
    if (needbytes>sizeof(bufa)) {       // need malloc space
      allocbufa=(decNumber *)malloc(needbytes);
      if (allocbufa==NULL) {            // hopeless -- abandon
        status|=DEC_Insufficient_storage;
        break;}
      acc=allocbufa;                    // use the allocated space
      }
    // multiply with extended range and necessary precision
    //printf("emin=%ld\n", dcmul.emin);
    decMultiplyOp(acc, lhs, rhs, &dcmul, &status);
    // Only Invalid operation (from sNaN or Inf * 0) is possible in
    // status; if either is seen than ignore fhs (in case it is
    // another sNaN) and set acc to NaN unless we had an sNaN
    // [decMultiplyOp leaves that to caller]
    // Note sNaN has to go through addOp to shorten payload if
    // necessary
    if ((status&DEC_Invalid_operation)!=0) {
      if (!(status&DEC_sNaN)) {         // but be true invalid
        decNumberZero(res);             // acc not yet set
        res->bits=DECNAN;
        break;
        }
      decNumberZero(&dzero);            // make 0 (any non-NaN would do)
      fhs=&dzero;                       // use that
      }
    #if DECCHECK
     else { // multiply was OK
      if (status!=0) printf("Status=%08lx after FMA multiply\n", status);
      }
    #endif
    // add the third operand and result -> res, and all is done
    decAddOp(res, acc, fhs, set, 0, &status);
    } while(0);                         // end protected

  if (allocbufa!=NULL) free(allocbufa); // drop any storage used
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberFMA

/* ------------------------------------------------------------------ */
/* decNumberInvert -- invert a Number, digitwise                      */
/*                                                                    */
/*   This computes C = ~A                                             */
/*                                                                    */
/*   res is C, the result.  C may be A (e.g., X=~X)                   */
/*   rhs is A                                                         */
/*   set is the context (used for result length and error report)     */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/*                                                                    */
/* Logical function restrictions apply (see above); a NaN is          */
/* returned with Invalid_operation if a restriction is violated.      */
/* ------------------------------------------------------------------ */
decNumber * decNumberInvert(decNumber *res, const decNumber *rhs,
                            decContext *set) {
  const Unit *ua, *msua;                // -> operand and its msu
  Unit  *uc, *msuc;                     // -> result and its msu
  Int   msudigs;                        // digits in res msu
  #if DECCHECK
  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
  #endif

  if (rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) {
    decStatus(res, DEC_Invalid_operation, set);
    return res;
    }
  // operand is valid
  ua=rhs->lsu;                          // bottom-up
  uc=res->lsu;                          // ..
  msua=ua+D2U(rhs->digits)-1;           // -> msu of rhs
  msuc=uc+D2U(set->digits)-1;           // -> msu of result
  msudigs=MSUDIGITS(set->digits);       // [faster than remainder]
  for (; uc<=msuc; ua++, uc++) {        // Unit loop
    Unit a;                             // extract unit
    Int  i, j;                          // work
    if (ua>msua) a=0;
     else a=*ua;
    *uc=0;                              // can now write back
    // always need to examine all bits in rhs
    // This loop could be unrolled and/or use BIN2BCD tables
    for (i=0; i<DECDPUN; i++) {
      if ((~a)&1) *uc=*uc+(Unit)powers[i];   // effect INVERT
      j=a%10;
      a=a/10;
      if (j>1) {
        decStatus(res, DEC_Invalid_operation, set);
        return res;
        }
      if (uc==msuc && i==msudigs-1) break;   // just did final digit
      } // each digit
    } // each unit
  // [here uc-1 is the msu of the result]
  res->digits=decGetDigits(res->lsu, uc-res->lsu);
  res->exponent=0;                      // integer
  res->bits=0;                          // sign=0
  return res;  // [no status to set]
  } // decNumberInvert

/* ------------------------------------------------------------------ */
/* decNumberLn -- natural logarithm                                   */
/*                                                                    */
/*   This computes C = ln(A)                                          */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
855
856
857
858
859
860
861

















































862
863
864
865
866
867
868
  // apply significant status
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberLn


















































/* ------------------------------------------------------------------ */
/* decNumberLog10 -- logarithm in base 10                             */
/*                                                                    */
/*   This computes C = log10(A)                                       */
/*                                                                    */
/*   res is C, the result.  C may be A                                */







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
  // apply significant status
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberLn

/* ------------------------------------------------------------------ */
/* decNumberLogB - get adjusted exponent, by 754r rules               */
/*                                                                    */
/*   This computes C = adjustedexponent(A)                            */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
/*   rhs is A                                                         */
/*   set is the context, used only for digits and status              */
/*                                                                    */
/* C must have space for 10 digits (A might have 10**9 digits and     */
/* an exponent of +999999999, or one digit and an exponent of         */
/* -1999999999).                                                      */
/*                                                                    */
/* This returns the adjusted exponent of A after (in theory) padding  */
/* with zeros on the right to set->digits digits while keeping the    */
/* same value.  The exponent is not limited by emin/emax.             */
/*                                                                    */
/* Notable cases:                                                     */
/*   A<0 -> Use |A|                                                   */
/*   A=0 -> -Infinity (Division by zero)                              */
/*   A=Infinite -> +Infinity (Exact)                                  */
/*   A=1 exactly -> 0 (Exact)                                         */
/*   NaNs are propagated as usual                                     */
/* ------------------------------------------------------------------ */
decNumber * decNumberLogB(decNumber *res, const decNumber *rhs,
                          decContext *set) {
  uInt status=0;                   // accumulator

  #if DECCHECK
  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
  #endif

  // NaNs as usual; Infinities return +Infinity; 0->oops
  if (decNumberIsNaN(rhs)) decNaNs(res, rhs, NULL, set, &status);
   else if (decNumberIsInfinite(rhs)) decNumberCopyAbs(res, rhs);
   else if (decNumberIsZero(rhs)) {
    decNumberZero(res);                 // prepare for Infinity
    res->bits=DECNEG|DECINF;            // -Infinity
    status|=DEC_Division_by_zero;       // as per 754r
    }
   else { // finite non-zero
    Int ae=rhs->exponent+rhs->digits-1; // adjusted exponent
    decNumberFromInt32(res, ae);        // lay it out
    }

  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberLogB

/* ------------------------------------------------------------------ */
/* decNumberLog10 -- logarithm in base 10                             */
/*                                                                    */
/*   This computes C = log10(A)                                       */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914

  // buffers for a and b working decimals
  // (adjustment calculator, same size)
  decNumber bufa[D2N(DECBUFFER+2)];
  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated
  decNumber *a=bufa;               // temporary a
  decNumber bufb[D2N(DECBUFFER+2)];
  decNumber *allocbufb=NULL;       // -> allocated bufa, iff allocated
  decNumber *b=bufb;               // temporary b
  decNumber bufw[D2N(10)];         // working 2-10 digit number
  decNumber *w=bufw;               // ..
  #if DECSUBSET
  decNumber *allocrhs=NULL;        // non-NULL if rounded rhs allocated
  #endif








|







1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395

  // buffers for a and b working decimals
  // (adjustment calculator, same size)
  decNumber bufa[D2N(DECBUFFER+2)];
  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated
  decNumber *a=bufa;               // temporary a
  decNumber bufb[D2N(DECBUFFER+2)];
  decNumber *allocbufb=NULL;       // -> allocated bufb, iff allocated
  decNumber *b=bufb;               // temporary b
  decNumber bufw[D2N(10)];         // working 2-10 digit number
  decNumber *w=bufw;               // ..
  #if DECSUBSET
  decNumber *allocrhs=NULL;        // non-NULL if rounded rhs allocated
  #endif

948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
      decCopyFit(w, rhs, &aset, &residue, &copystat); // copy & shorten
      // if exact and the digit is 1, rhs is a power of 10
      if (!(copystat&DEC_Inexact) && w->lsu[0]==1) {
        // the exponent, conveniently, is the power of 10; making
        // this the result needs a little care as it might not fit,
        // so first convert it into the working number, and then move
        // to res
        decPutInt(w, w->exponent);
        residue=0;
        decCopyFit(res, w, set, &residue, &status); // copy & round
        decFinish(res, set, &residue, &status);     // cleanup/set flags
        break;
        } // not a power of 10
      } // not a candidate for exact








|







1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
      decCopyFit(w, rhs, &aset, &residue, &copystat); // copy & shorten
      // if exact and the digit is 1, rhs is a power of 10
      if (!(copystat&DEC_Inexact) && w->lsu[0]==1) {
        // the exponent, conveniently, is the power of 10; making
        // this the result needs a little care as it might not fit,
        // so first convert it into the working number, and then move
        // to res
        decNumberFromInt32(w, w->exponent);
        residue=0;
        decCopyFit(res, w, set, &residue, &status); // copy & round
        decFinish(res, set, &residue, &status);     // cleanup/set flags
        break;
        } // not a power of 10
      } // not a candidate for exact

1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051























1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074























1075
1076
1077
1078
1079
1080
1081
1082
1083
1084

1085
1086
1087
1088
1089
1090
1091
  #endif
  return res;
  } // decNumberLog10

/* ------------------------------------------------------------------ */
/* decNumberMax -- compare two Numbers and return the maximum         */
/*                                                                    */
/*   This computes C = A ? B, returning the maximum or A if equal     */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
decNumber * decNumberMax(decNumber *res, const decNumber *lhs,
                         const decNumber *rhs, decContext *set) {
  uInt status=0;                        // accumulator
  decCompareOp(res, lhs, rhs, set, COMPMAX, &status);
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberMax
























/* ------------------------------------------------------------------ */
/* decNumberMin -- compare two Numbers and return the minimum         */
/*                                                                    */
/*   This computes C = A ? B, returning the minimum or A if equal     */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
decNumber * decNumberMin(decNumber *res, const decNumber *lhs,
                         const decNumber *rhs, decContext *set) {
  uInt status=0;                        // accumulator
  decCompareOp(res, lhs, rhs, set, COMPMIN, &status);
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberMin
























/* ------------------------------------------------------------------ */
/* decNumberMinus -- prefix minus operator                            */
/*                                                                    */
/*   This computes C = 0 - A                                          */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
/*   rhs is A                                                         */
/*   set is the context                                               */
/*                                                                    */

/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
/* Simply use AddOp for the subtract, which will do the necessary.    */
/* ------------------------------------------------------------------ */
decNumber * decNumberMinus(decNumber *res, const decNumber *rhs,
                           decContext *set) {
  decNumber dzero;







|


















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




|


















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










>







1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
  #endif
  return res;
  } // decNumberLog10

/* ------------------------------------------------------------------ */
/* decNumberMax -- compare two Numbers and return the maximum         */
/*                                                                    */
/*   This computes C = A ? B, returning the maximum by 754R rules     */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
decNumber * decNumberMax(decNumber *res, const decNumber *lhs,
                         const decNumber *rhs, decContext *set) {
  uInt status=0;                        // accumulator
  decCompareOp(res, lhs, rhs, set, COMPMAX, &status);
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberMax

/* ------------------------------------------------------------------ */
/* decNumberMaxMag -- compare and return the maximum by magnitude     */
/*                                                                    */
/*   This computes C = A ? B, returning the maximum by 754R rules     */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
decNumber * decNumberMaxMag(decNumber *res, const decNumber *lhs,
                         const decNumber *rhs, decContext *set) {
  uInt status=0;                        // accumulator
  decCompareOp(res, lhs, rhs, set, COMPMAXMAG, &status);
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberMaxMag

/* ------------------------------------------------------------------ */
/* decNumberMin -- compare two Numbers and return the minimum         */
/*                                                                    */
/*   This computes C = A ? B, returning the minimum by 754R rules     */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
decNumber * decNumberMin(decNumber *res, const decNumber *lhs,
                         const decNumber *rhs, decContext *set) {
  uInt status=0;                        // accumulator
  decCompareOp(res, lhs, rhs, set, COMPMIN, &status);
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberMin

/* ------------------------------------------------------------------ */
/* decNumberMinMag -- compare and return the minimum by magnitude     */
/*                                                                    */
/*   This computes C = A ? B, returning the minimum by 754R rules     */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
decNumber * decNumberMinMag(decNumber *res, const decNumber *lhs,
                         const decNumber *rhs, decContext *set) {
  uInt status=0;                        // accumulator
  decCompareOp(res, lhs, rhs, set, COMPMINMAG, &status);
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberMinMag

/* ------------------------------------------------------------------ */
/* decNumberMinus -- prefix minus operator                            */
/*                                                                    */
/*   This computes C = 0 - A                                          */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
/*   rhs is A                                                         */
/*   set is the context                                               */
/*                                                                    */
/* See also decNumberCopyNegate for a quiet bitwise version of this.  */
/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
/* Simply use AddOp for the subtract, which will do the necessary.    */
/* ------------------------------------------------------------------ */
decNumber * decNumberMinus(decNumber *res, const decNumber *rhs,
                           decContext *set) {
  decNumber dzero;
1100
1101
1102
1103
1104
1105
1106
















































































































































































































1107
1108
1109
1110
1111
1112
1113
1114
1115
1116

1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
  decAddOp(res, &dzero, rhs, set, DECNEG, &status);
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberMinus

















































































































































































































/* ------------------------------------------------------------------ */
/* decNumberPlus -- prefix plus operator                              */
/*                                                                    */
/*   This computes C = 0 + A                                          */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
/*   rhs is A                                                         */
/*   set is the context                                               */
/*                                                                    */

/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
/* This simply uses AddOp; Add will take fast path after preparing A. */
/* Performance is a concern here, as this routine is often used to    */
/* check operands and apply rounding and overflow/underflow testing.  */
/* ------------------------------------------------------------------ */
decNumber * decNumberPlus(decNumber *res, const decNumber *rhs,
                          decContext *set) {
  decNumber dzero;
  uInt status=0;                        // accumulator

  #if DECCHECK
  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
  #endif

  decNumberZero(&dzero);                // make 0
  dzero.exponent=rhs->exponent;         // [no coefficient expansion]
  decAddOp(res, &dzero, rhs, set, 0, &status);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










>










<







1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863

1864
1865
1866
1867
1868
1869
1870
  decAddOp(res, &dzero, rhs, set, DECNEG, &status);
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberMinus

/* ------------------------------------------------------------------ */
/* decNumberNextMinus -- next towards -Infinity                       */
/*                                                                    */
/*   This computes C = A - infinitesimal, rounded towards -Infinity   */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
/*   rhs is A                                                         */
/*   set is the context                                               */
/*                                                                    */
/* This is a generalization of 754r NextDown.                         */
/* ------------------------------------------------------------------ */
decNumber * decNumberNextMinus(decNumber *res, const decNumber *rhs,
                               decContext *set) {
  decNumber dtiny;                           // constant
  decContext workset=*set;                   // work
  uInt status=0;                             // accumulator
  #if DECCHECK
  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
  #endif

  // +Infinity is the special case
  if ((rhs->bits&(DECINF|DECNEG))==DECINF) {
    decSetMaxValue(res, set);                // is +ve
    // there is no status to set
    return res;
    }
  decNumberZero(&dtiny);                     // start with 0
  dtiny.lsu[0]=1;                            // make number that is ..
  dtiny.exponent=DEC_MIN_EMIN-1;             // .. smaller than tiniest
  workset.round=DEC_ROUND_FLOOR;
  decAddOp(res, rhs, &dtiny, &workset, DECNEG, &status);
  status&=DEC_Invalid_operation|DEC_sNaN;    // only sNaN Invalid please
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberNextMinus

/* ------------------------------------------------------------------ */
/* decNumberNextPlus -- next towards +Infinity                        */
/*                                                                    */
/*   This computes C = A + infinitesimal, rounded towards +Infinity   */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
/*   rhs is A                                                         */
/*   set is the context                                               */
/*                                                                    */
/* This is a generalization of 754r NextUp.                           */
/* ------------------------------------------------------------------ */
decNumber * decNumberNextPlus(decNumber *res, const decNumber *rhs,
                              decContext *set) {
  decNumber dtiny;                           // constant
  decContext workset=*set;                   // work
  uInt status=0;                             // accumulator
  #if DECCHECK
  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
  #endif

  // -Infinity is the special case
  if ((rhs->bits&(DECINF|DECNEG))==(DECINF|DECNEG)) {
    decSetMaxValue(res, set);
    res->bits=DECNEG;                        // negative
    // there is no status to set
    return res;
    }
  decNumberZero(&dtiny);                     // start with 0
  dtiny.lsu[0]=1;                            // make number that is ..
  dtiny.exponent=DEC_MIN_EMIN-1;             // .. smaller than tiniest
  workset.round=DEC_ROUND_CEILING;
  decAddOp(res, rhs, &dtiny, &workset, 0, &status);
  status&=DEC_Invalid_operation|DEC_sNaN;    // only sNaN Invalid please
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberNextPlus

/* ------------------------------------------------------------------ */
/* decNumberNextToward -- next towards rhs                            */
/*                                                                    */
/*   This computes C = A +/- infinitesimal, rounded towards           */
/*   +/-Infinity in the direction of B, as per 754r nextafter rules   */
/*                                                                    */
/*   res is C, the result.  C may be A or B.                          */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*                                                                    */
/* This is a generalization of 754r NextAfter.                        */
/* ------------------------------------------------------------------ */
decNumber * decNumberNextToward(decNumber *res, const decNumber *lhs,
                                const decNumber *rhs, decContext *set) {
  decNumber dtiny;                           // constant
  decContext workset=*set;                   // work
  Int result;                                // ..
  uInt status=0;                             // accumulator
  #if DECCHECK
  if (decCheckOperands(res, lhs, rhs, set)) return res;
  #endif

  if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs)) {
    decNaNs(res, lhs, rhs, set, &status);
    }
   else { // Is numeric, so no chance of sNaN Invalid, etc.
    result=decCompare(lhs, rhs, 0);     // sign matters
    if (result==BADINT) status|=DEC_Insufficient_storage; // rare
     else { // valid compare
      if (result==0) decNumberCopySign(res, lhs, rhs); // easy
       else { // differ: need NextPlus or NextMinus
        uByte sub;                      // add or subtract
        if (result<0) {                 // lhs<rhs, do nextplus
          // -Infinity is the special case
          if ((lhs->bits&(DECINF|DECNEG))==(DECINF|DECNEG)) {
            decSetMaxValue(res, set);
            res->bits=DECNEG;           // negative
            return res;                 // there is no status to set
            }
          workset.round=DEC_ROUND_CEILING;
          sub=0;                        // add, please
          } // plus
         else {                         // lhs>rhs, do nextminus
          // +Infinity is the special case
          if ((lhs->bits&(DECINF|DECNEG))==DECINF) {
            decSetMaxValue(res, set);
            return res;                 // there is no status to set
            }
          workset.round=DEC_ROUND_FLOOR;
          sub=DECNEG;                   // subtract, please
          } // minus
        decNumberZero(&dtiny);          // start with 0
        dtiny.lsu[0]=1;                 // make number that is ..
        dtiny.exponent=DEC_MIN_EMIN-1;  // .. smaller than tiniest
        decAddOp(res, lhs, &dtiny, &workset, sub, &status); // + or -
        // turn off exceptions if the result is a normal number
        // (including Nmin), otherwise let all status through
        if (decNumberIsNormal(res, set)) status=0;
        } // unequal
      } // compare OK
    } // numeric
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberNextToward

/* ------------------------------------------------------------------ */
/* decNumberOr -- OR two Numbers, digitwise                           */
/*                                                                    */
/*   This computes C = A | B                                          */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X|X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context (used for result length and error report)     */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/*                                                                    */
/* Logical function restrictions apply (see above); a NaN is          */
/* returned with Invalid_operation if a restriction is violated.      */
/* ------------------------------------------------------------------ */
decNumber * decNumberOr(decNumber *res, const decNumber *lhs,
                        const decNumber *rhs, decContext *set) {
  const Unit *ua, *ub;                  // -> operands
  const Unit *msua, *msub;              // -> operand msus
  Unit  *uc, *msuc;                     // -> result and its msu
  Int   msudigs;                        // digits in res msu
  #if DECCHECK
  if (decCheckOperands(res, lhs, rhs, set)) return res;
  #endif

  if (lhs->exponent!=0 || decNumberIsSpecial(lhs) || decNumberIsNegative(lhs)
   || rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) {
    decStatus(res, DEC_Invalid_operation, set);
    return res;
    }
  // operands are valid
  ua=lhs->lsu;                          // bottom-up
  ub=rhs->lsu;                          // ..
  uc=res->lsu;                          // ..
  msua=ua+D2U(lhs->digits)-1;           // -> msu of lhs
  msub=ub+D2U(rhs->digits)-1;           // -> msu of rhs
  msuc=uc+D2U(set->digits)-1;           // -> msu of result
  msudigs=MSUDIGITS(set->digits);       // [faster than remainder]
  for (; uc<=msuc; ua++, ub++, uc++) {  // Unit loop
    Unit a, b;                          // extract units
    if (ua>msua) a=0;
     else a=*ua;
    if (ub>msub) b=0;
     else b=*ub;
    *uc=0;                              // can now write back
    if (a|b) {                          // maybe 1 bits to examine
      Int i, j;
      // This loop could be unrolled and/or use BIN2BCD tables
      for (i=0; i<DECDPUN; i++) {
        if ((a|b)&1) *uc=*uc+(Unit)powers[i];     // effect OR
        j=a%10;
        a=a/10;
        j|=b%10;
        b=b/10;
        if (j>1) {
          decStatus(res, DEC_Invalid_operation, set);
          return res;
          }
        if (uc==msuc && i==msudigs-1) break;      // just did final digit
        } // each digit
      } // non-zero
    } // each unit
  // [here uc-1 is the msu of the result]
  res->digits=decGetDigits(res->lsu, uc-res->lsu);
  res->exponent=0;                      // integer
  res->bits=0;                          // sign=0
  return res;  // [no status to set]
  } // decNumberOr

/* ------------------------------------------------------------------ */
/* decNumberPlus -- prefix plus operator                              */
/*                                                                    */
/*   This computes C = 0 + A                                          */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
/*   rhs is A                                                         */
/*   set is the context                                               */
/*                                                                    */
/* See also decNumberCopy for a quiet bitwise version of this.        */
/* C must have space for set->digits digits.                          */
/* ------------------------------------------------------------------ */
/* This simply uses AddOp; Add will take fast path after preparing A. */
/* Performance is a concern here, as this routine is often used to    */
/* check operands and apply rounding and overflow/underflow testing.  */
/* ------------------------------------------------------------------ */
decNumber * decNumberPlus(decNumber *res, const decNumber *rhs,
                          decContext *set) {
  decNumber dzero;
  uInt status=0;                        // accumulator

  #if DECCHECK
  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
  #endif

  decNumberZero(&dzero);                // make 0
  dzero.exponent=rhs->exponent;         // [no coefficient expansion]
  decAddOp(res, &dzero, rhs, set, 0, &status);
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
        if (allocrhs==NULL) break;
        rhs=allocrhs;
        }
      }
    #endif
    // [following code does not require input rounding]

    // specials copy through, except NaNs need care
    if (decNumberIsNaN(rhs)) {
      decNaNs(res, rhs, NULL, &status);
      break;
      }

    // reduce result to the requested length and copy to result
    decCopyFit(res, rhs, set, &residue, &status); // copy & round
    decFinish(res, set, &residue, &status);       // cleanup/set flags
    decTrim(res, 1, &dropped);               // normalize in place
    } while(0);                              // end protected

  #if DECSUBSET
  if (allocrhs !=NULL) free(allocrhs);       // ..
  #endif
  if (status!=0) decStatus(res, status, set);// then report status
  return res;







|

|






|







1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
        if (allocrhs==NULL) break;
        rhs=allocrhs;
        }
      }
    #endif
    // [following code does not require input rounding]

    // Infinities copy through; NaNs need usual treatment
    if (decNumberIsNaN(rhs)) {
      decNaNs(res, rhs, NULL, set, &status);
      break;
      }

    // reduce result to the requested length and copy to result
    decCopyFit(res, rhs, set, &residue, &status); // copy & round
    decFinish(res, set, &residue, &status);       // cleanup/set flags
    decTrim(res, set, 1, &dropped);               // normalize in place
    } while(0);                              // end protected

  #if DECSUBSET
  if (allocrhs !=NULL) free(allocrhs);       // ..
  #endif
  if (status!=0) decStatus(res, status, set);// then report status
  return res;
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
      }
    #endif
    // [following code does not require input rounding]

    // handle NaNs and rhs Infinity (lhs infinity is harder)
    if (SPECIALARGS) {
      if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs)) { // NaNs
        decNaNs(res, lhs, rhs, &status);
        break;}
      if (decNumberIsInfinite(rhs)) {   // rhs Infinity
        Flag rhsneg=rhs->bits&DECNEG;   // save rhs sign
        if (decNumberIsNegative(lhs)    // lhs<0
         && !decNumberIsZero(lhs))      // ..
          status|=DEC_Invalid_operation;
         else {                         // lhs >=0







|







2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
      }
    #endif
    // [following code does not require input rounding]

    // handle NaNs and rhs Infinity (lhs infinity is harder)
    if (SPECIALARGS) {
      if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs)) { // NaNs
        decNaNs(res, lhs, rhs, set, &status);
        break;}
      if (decNumberIsInfinite(rhs)) {   // rhs Infinity
        Flag rhsneg=rhs->bits&DECNEG;   // save rhs sign
        if (decNumberIsNegative(lhs)    // lhs<0
         && !decNumberIsZero(lhs))      // ..
          status|=DEC_Invalid_operation;
         else {                         // lhs >=0
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
          }
        if (i==31) break;          // that was the last bit
        if (!seenbit) continue;    // no need to square 1
        decMultiplyOp(dac, dac, dac, &aset, &status); // dac=dac*dac [square]
        } /*i*/ // 32 bits

      // complete internal overflow or underflow processing
      if (status & (DEC_Overflow|DEC_Subnormal)) {
        #if DECSUBSET
        // If subset, and power was negative, reverse the kind of -erflow
        // [1/x not yet done]
        if (!set->extended && decNumberIsNegative(rhs)) {
          if (status & DEC_Overflow)
            status^=DEC_Overflow | DEC_Underflow | DEC_Subnormal;
           else { // trickier -- Underflow may or may not be set







|







2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
          }
        if (i==31) break;          // that was the last bit
        if (!seenbit) continue;    // no need to square 1
        decMultiplyOp(dac, dac, dac, &aset, &status); // dac=dac*dac [square]
        } /*i*/ // 32 bits

      // complete internal overflow or underflow processing
      if (status & (DEC_Overflow|DEC_Underflow)) {
        #if DECSUBSET
        // If subset, and power was negative, reverse the kind of -erflow
        // [1/x not yet done]
        if (!set->extended && decNumberIsNegative(rhs)) {
          if (status & DEC_Overflow)
            status^=DEC_Overflow | DEC_Underflow | DEC_Subnormal;
           else { // trickier -- Underflow may or may not be set
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
      #endif
      } // rhs integer path

    // reduce result to the requested length and copy to result
    decCopyFit(res, dac, set, &residue, &status);
    decFinish(res, set, &residue, &status);  // final cleanup
    #if DECSUBSET
    if (!set->extended) decTrim(res, 0, &dropped); // trailing zeros
    #endif
    } while(0);                         // end protected

  if (allocdac!=NULL) free(allocdac);   // drop any storage used
  if (allocinv!=NULL) free(allocinv);   // ..
  #if DECSUBSET
  if (alloclhs!=NULL) free(alloclhs);   // ..







|







2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
      #endif
      } // rhs integer path

    // reduce result to the requested length and copy to result
    decCopyFit(res, dac, set, &residue, &status);
    decFinish(res, set, &residue, &status);  // final cleanup
    #if DECSUBSET
    if (!set->extended) decTrim(res, set, 0, &dropped); // trailing zeros
    #endif
    } while(0);                         // end protected

  if (allocdac!=NULL) free(allocdac);   // drop any storage used
  if (allocinv!=NULL) free(allocinv);   // ..
  #if DECSUBSET
  if (alloclhs!=NULL) free(alloclhs);   // ..
1664
1665
1666
1667
1668
1669
1670









































































































































1671
1672
1673
1674
1675
1676
1677
  decDivideOp(res, lhs, rhs, set, REMNEAR, &status);
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberRemainderNear










































































































































/* ------------------------------------------------------------------ */
/* decNumberSameQuantum -- test for equal exponents                   */
/*                                                                    */
/*   res is the result number, which will contain either 0 or 1       */
/*   lhs is a number to test                                          */
/*   rhs is the second (usually a pattern)                            */







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
  decDivideOp(res, lhs, rhs, set, REMNEAR, &status);
  if (status!=0) decStatus(res, status, set);
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberRemainderNear

/* ------------------------------------------------------------------ */
/* decNumberRotate -- rotate the coefficient of a Number left/right   */
/*                                                                    */
/*   This computes C = A rot B  (in base ten and rotating set->digits */
/*   digits).                                                         */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=XrotX)       */
/*   lhs is A                                                         */
/*   rhs is B, the number of digits to rotate (-ve to right)          */
/*   set is the context                                               */
/*                                                                    */
/* The digits of the coefficient of A are rotated to the left (if B   */
/* is positive) or to the right (if B is negative) without adjusting  */
/* the exponent or the sign of A.  If lhs->digits is less than        */
/* set->digits the coefficient is padded with zeros on the left       */
/* before the rotate.  Any leading zeros in the result are removed    */
/* as usual.                                                          */
/*                                                                    */
/* B must be an integer (q=0) and in the range -set->digits through   */
/* +set->digits.                                                      */
/* C must have space for set->digits digits.                          */
/* NaNs are propagated as usual.  Infinities are unaffected (but      */
/* B must be valid).  No status is set unless B is invalid or an      */
/* operand is an sNaN.                                                */
/* ------------------------------------------------------------------ */
decNumber * decNumberRotate(decNumber *res, const decNumber *lhs,
                           const decNumber *rhs, decContext *set) {
  uInt status=0;              // accumulator
  Int  rotate;                // rhs as an Int

  #if DECCHECK
  if (decCheckOperands(res, lhs, rhs, set)) return res;
  #endif

  // NaNs propagate as normal
  if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs))
    decNaNs(res, lhs, rhs, set, &status);
   // rhs must be an integer
   else if (decNumberIsInfinite(rhs) || rhs->exponent!=0)
    status=DEC_Invalid_operation;
   else { // both numeric, rhs is an integer
    rotate=decGetInt(rhs);                   // [cannot fail]
    if (rotate==BADINT                       // something bad ..
     || rotate==BIGODD || rotate==BIGEVEN    // .. very big ..
     || abs(rotate)>set->digits)             // .. or out of range
      status=DEC_Invalid_operation;
     else {                                  // rhs is OK
      decNumberCopy(res, lhs);
      // convert -ve rotate to equivalent positive rotation
      if (rotate<0) rotate=set->digits+rotate;
      if (rotate!=0 && rotate!=set->digits   // zero or full rotation
       && !decNumberIsInfinite(res)) {       // lhs was infinite
        // left-rotate to do; 0 < rotate < set->digits
        uInt units, shift;                   // work
        uInt msudigits;                      // digits in result msu
        Unit *msu=res->lsu+D2U(res->digits)-1;    // current msu
        Unit *msumax=res->lsu+D2U(set->digits)-1; // rotation msu
        for (msu++; msu<=msumax; msu++) *msu=0;   // ensure high units=0
        res->digits=set->digits;                  // now full-length
        msudigits=MSUDIGITS(res->digits);         // actual digits in msu

        // rotation here is done in-place, in three steps
        // 1. shift all to least up to one unit to unit-align final
        //    lsd [any digits shifted out are rotated to the left,
        //    abutted to the original msd (which may require split)]
        //
        //    [if there are no whole units left to rotate, the
        //    rotation is now complete]
        //
        // 2. shift to least, from below the split point only, so that
        //    the final msd is in the right place in its Unit [any
        //    digits shifted out will fit exactly in the current msu,
        //    left aligned, no split required]
        //
        // 3. rotate all the units by reversing left part, right
        //    part, and then whole
        //
        // example: rotate right 8 digits (2 units + 2), DECDPUN=3.
        //
        //   start: 00a bcd efg hij klm npq
        //
        //      1a  000 0ab cde fgh|ijk lmn [pq saved]
        //      1b  00p qab cde fgh|ijk lmn
        //
        //      2a  00p qab cde fgh|00i jkl [mn saved]
        //      2b  mnp qab cde fgh|00i jkl
        //
        //      3a  fgh cde qab mnp|00i jkl
        //      3b  fgh cde qab mnp|jkl 00i
        //      3c  00i jkl mnp qab cde fgh

        // Step 1: amount to shift is the partial right-rotate count
        rotate=set->digits-rotate;      // make it right-rotate
        units=rotate/DECDPUN;           // whole units to rotate
        shift=rotate%DECDPUN;           // left-over digits count
        if (shift>0) {                  // not an exact number of units
          uInt save=res->lsu[0]%powers[shift];    // save low digit(s)
          decShiftToLeast(res->lsu, D2U(res->digits), shift);
          if (shift>msudigits) {        // msumax-1 needs >0 digits
            uInt rem=save%powers[shift-msudigits];// split save
            *msumax=(Unit)(save/powers[shift-msudigits]); // and insert
            *(msumax-1)=*(msumax-1)
                       +(Unit)(rem*powers[DECDPUN-(shift-msudigits)]); // ..
            }
           else { // all fits in msumax
            *msumax=*msumax+(Unit)(save*powers[msudigits-shift]); // [maybe *1]
            }
          } // digits shift needed

        // If whole units to rotate...
        if (units>0) {                  // some to do
          // Step 2: the units to touch are the whole ones in rotate,
          //   if any, and the shift is DECDPUN-msudigits (which may be
          //   0, again)
          shift=DECDPUN-msudigits;
          if (shift>0) {                // not an exact number of units
            uInt save=res->lsu[0]%powers[shift];  // save low digit(s)
            decShiftToLeast(res->lsu, units, shift);
            *msumax=*msumax+(Unit)(save*powers[msudigits]);
            } // partial shift needed

          // Step 3: rotate the units array using triple reverse
          // (reversing is easy and fast)
          decReverse(res->lsu+units, msumax);     // left part
          decReverse(res->lsu, res->lsu+units-1); // right part
          decReverse(res->lsu, msumax);           // whole
          } // whole units to rotate
        // the rotation may have left an undetermined number of zeros
        // on the left, so true length needs to be calculated
        res->digits=decGetDigits(res->lsu, msumax-res->lsu+1);
        } // rotate needed
      } // rhs OK
    } // numerics
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberRotate

/* ------------------------------------------------------------------ */
/* decNumberSameQuantum -- test for equal exponents                   */
/*                                                                    */
/*   res is the result number, which will contain either 0 or 1       */
/*   lhs is a number to test                                          */
/*   rhs is the second (usually a pattern)                            */
1693
1694
1695
1696
1697
1698
1699

































































































































1700
1701
1702
1703
1704
1705
1706
    }
   else if (lhs->exponent==rhs->exponent) ret=1;

  decNumberZero(res);              // OK to overwrite an operand now
  *res->lsu=ret;
  return res;
  } // decNumberSameQuantum


































































































































/* ------------------------------------------------------------------ */
/* decNumberSquareRoot -- square root operator                        */
/*                                                                    */
/*   This computes C = squareroot(A)                                  */
/*                                                                    */
/*   res is C, the result.  C may be A                                */







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
    }
   else if (lhs->exponent==rhs->exponent) ret=1;

  decNumberZero(res);              // OK to overwrite an operand now
  *res->lsu=ret;
  return res;
  } // decNumberSameQuantum

/* ------------------------------------------------------------------ */
/* decNumberScaleB -- multiply by a power of 10                       */
/*                                                                    */
/* This computes C = A x 10**B where B is an integer (q=0) with       */
/* maximum magnitude 2*(emax+digits)                                  */
/*                                                                    */
/*   res is C, the result.  C may be A or B                           */
/*   lhs is A, the number to adjust                                   */
/*   rhs is B, the requested power of ten to use                      */
/*   set is the context                                               */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/*                                                                    */
/* The result may underflow or overflow.                              */
/* ------------------------------------------------------------------ */
decNumber * decNumberScaleB(decNumber *res, const decNumber *lhs,
                            const decNumber *rhs, decContext *set) {
  Int  reqexp;                // requested exponent change [B]
  uInt status=0;              // accumulator
  Int  residue;               // work

  #if DECCHECK
  if (decCheckOperands(res, lhs, rhs, set)) return res;
  #endif

  // Handle special values except lhs infinite
  if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs))
    decNaNs(res, lhs, rhs, set, &status);
    // rhs must be an integer
   else if (decNumberIsInfinite(rhs) || rhs->exponent!=0)
    status=DEC_Invalid_operation;
   else {
    // lhs is a number; rhs is a finite with q==0
    reqexp=decGetInt(rhs);                   // [cannot fail]
    if (reqexp==BADINT                       // something bad ..
     || reqexp==BIGODD || reqexp==BIGEVEN    // .. very big ..
     || abs(reqexp)>(2*(set->digits+set->emax))) // .. or out of range
      status=DEC_Invalid_operation;
     else {                                  // rhs is OK
      decNumberCopy(res, lhs);               // all done if infinite lhs
      if (!decNumberIsInfinite(res)) {       // prepare to scale
        res->exponent+=reqexp;               // adjust the exponent
        residue=0;
        decFinalize(res, set, &residue, &status); // .. and check
        } // finite LHS
      } // rhs OK
    } // rhs finite
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberScaleB

/* ------------------------------------------------------------------ */
/* decNumberShift -- shift the coefficient of a Number left or right  */
/*                                                                    */
/*   This computes C = A << B or C = A >> -B  (in base ten).          */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X<<X)        */
/*   lhs is A                                                         */
/*   rhs is B, the number of digits to shift (-ve to right)           */
/*   set is the context                                               */
/*                                                                    */
/* The digits of the coefficient of A are shifted to the left (if B   */
/* is positive) or to the right (if B is negative) without adjusting  */
/* the exponent or the sign of A.                                     */
/*                                                                    */
/* B must be an integer (q=0) and in the range -set->digits through   */
/* +set->digits.                                                      */
/* C must have space for set->digits digits.                          */
/* NaNs are propagated as usual.  Infinities are unaffected (but      */
/* B must be valid).  No status is set unless B is invalid or an      */
/* operand is an sNaN.                                                */
/* ------------------------------------------------------------------ */
decNumber * decNumberShift(decNumber *res, const decNumber *lhs,
                           const decNumber *rhs, decContext *set) {
  uInt status=0;              // accumulator
  Int  shift;                 // rhs as an Int

  #if DECCHECK
  if (decCheckOperands(res, lhs, rhs, set)) return res;
  #endif

  // NaNs propagate as normal
  if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs))
    decNaNs(res, lhs, rhs, set, &status);
   // rhs must be an integer
   else if (decNumberIsInfinite(rhs) || rhs->exponent!=0)
    status=DEC_Invalid_operation;
   else { // both numeric, rhs is an integer
    shift=decGetInt(rhs);                    // [cannot fail]
    if (shift==BADINT                        // something bad ..
     || shift==BIGODD || shift==BIGEVEN      // .. very big ..
     || abs(shift)>set->digits)              // .. or out of range
      status=DEC_Invalid_operation;
     else {                                  // rhs is OK
      decNumberCopy(res, lhs);
      if (shift!=0 && !decNumberIsInfinite(res)) { // something to do
        if (shift>0) {                       // to left
          if (shift==set->digits) {          // removing all
            *res->lsu=0;                     // so place 0
            res->digits=1;                   // ..
            }
           else {                            //
            // first remove leading digits if necessary
            if (res->digits+shift>set->digits) {
              decDecap(res, res->digits+shift-set->digits);
              // that updated res->digits; may have gone to 1 (for a
              // single digit or for zero
              }
            if (res->digits>1 || *res->lsu)  // if non-zero..
              res->digits=decShiftToMost(res->lsu, res->digits, shift);
            } // partial left
          } // left
         else { // to right
          if (-shift>=res->digits) {         // discarding all
            *res->lsu=0;                     // so place 0
            res->digits=1;                   // ..
            }
           else {
            decShiftToLeast(res->lsu, D2U(res->digits), -shift);
            res->digits-=(-shift);
            }
          } // to right
        } // non-0 non-Inf shift
      } // rhs OK
    } // numerics
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberShift

/* ------------------------------------------------------------------ */
/* decNumberSquareRoot -- square root operator                        */
/*                                                                    */
/*   This computes C = squareroot(A)                                  */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836

    // handle infinities and NaNs
    if (SPECIALARG) {
      if (decNumberIsInfinite(rhs)) {         // an infinity
        if (decNumberIsNegative(rhs)) status|=DEC_Invalid_operation;
         else decNumberCopy(res, rhs);        // +Infinity
        }
       else decNaNs(res, rhs, NULL, &status); // a NaN
      break;
      }

    // calculate the ideal (preferred) exponent [floor(exp/2)]
    // [We would like to write: ideal=rhs->exponent>>1, but this
    // generates a compiler warning.  Generated code is the same.]
    ideal=(rhs->exponent&~1)/2;         // target







|







2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838

    // handle infinities and NaNs
    if (SPECIALARG) {
      if (decNumberIsInfinite(rhs)) {         // an infinity
        if (decNumberIsNegative(rhs)) status|=DEC_Invalid_operation;
         else decNumberCopy(res, rhs);        // +Infinity
        }
       else decNaNs(res, rhs, NULL, set, &status); // a NaN
      break;
      }

    // calculate the ideal (preferred) exponent [floor(exp/2)]
    // [We would like to write: ideal=rhs->exponent>>1, but this
    // generates a compiler warning.  Generated code is the same.]
    ideal=(rhs->exponent&~1)/2;         // target
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004

    // Process Subnormals
    decFinalize(a, set, &residue, &status);

    // count droppable zeros [after any subnormal rounding] by
    // trimming a copy
    decNumberCopy(b, a);
    decTrim(b, 1, &dropped);                 // [drops trailing zeros]

    // Finally set Inexact and Rounded.  The answer can only be exact if
    // it is short enough so that squaring it could fit in set->digits,
    // so this is the only (relatively rare) time a careful check is
    // needed
    if (b->digits*2-1 > set->digits) {       // cannot fit
      status|=DEC_Inexact|DEC_Rounded;







|







2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006

    // Process Subnormals
    decFinalize(a, set, &residue, &status);

    // count droppable zeros [after any subnormal rounding] by
    // trimming a copy
    decNumberCopy(b, a);
    decTrim(b, set, 1, &dropped);            // [drops trailing zeros]

    // Finally set Inexact and Rounded.  The answer can only be exact if
    // it is short enough so that squaring it could fit in set->digits,
    // so this is the only (relatively rare) time a careful check is
    // needed
    if (b->digits*2-1 > set->digits) {       // cannot fit
      status|=DEC_Inexact|DEC_Rounded;
2032
2033
2034
2035
2036
2037
2038
2039

2040
2041
2042
2043
2044
2045
2046
            }
          }
        }
      }

    // make sure there is a full complement of digits for normal
    // inexact results
    if ((status & (DEC_Inexact|DEC_Subnormal))==DEC_Inexact) {

      Int shift=set->digits-a->digits;
      if (shift>0) {
        a->digits=decShiftToMost(a->lsu, a->digits, shift);
        a->exponent-=shift;                  // adjust the exponent.
        }
      }
    decNumberCopy(res, a);                   // a is now the result







|
>







3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
            }
          }
        }
      }

    // make sure there is a full complement of digits for normal
    // inexact results
    if ((status & DEC_Inexact)
     && (a->exponent+a->digits-1>=set->emin)) {
      Int shift=set->digits-a->digits;
      if (shift>0) {
        a->digits=decShiftToMost(a->lsu, a->digits, shift);
        a->exponent-=shift;                  // adjust the exponent.
        }
      }
    decNumberCopy(res, a);                   // a is now the result
2080
2081
2082
2083
2084
2085
2086

2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098

2099
2100


2101
2102
2103
2104
2105
2106

2107
2108
2109
2110
2111
2112
2113
2114
2115
2116












2117










































2118
2119



























2120
2121
2122
2123
2124

2125



2126
2127
2128
2129

2130
2131
2132
2133
















































2134
2135
2136
2137
2138
2139
2140
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberSubtract

/* ------------------------------------------------------------------ */

/* decNumberToIntegralValue -- round-to-integral-value                */
/*                                                                    */
/*   res is the result                                                */
/*   rhs is input number                                              */
/*   set is the context                                               */
/*                                                                    */
/* res must have space for any value of rhs.                          */
/*                                                                    */
/* This implements the IEEE special operator and therefore treats     */
/* special values as valid, and also never sets Inexact.  For finite  */
/* numbers it returns rescale(rhs, 0) if rhs->exponent is <0.         */
/* Otherwise the result is rhs (so no error is possible).             */

/*                                                                    */
/* The context is used for rounding mode and status after sNaN, but   */


/* the digits setting is ignored.                                     */
/* ------------------------------------------------------------------ */
decNumber * decNumberToIntegralValue(decNumber *res, const decNumber *rhs,
                                     decContext *set) {
  decNumber dn;
  decContext workset;              // working context


  #if DECCHECK
  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
  #endif

  // handle infinities and NaNs
  if (SPECIALARG) {
    uInt status=0;
    if (decNumberIsInfinite(rhs)) decNumberCopy(res, rhs); // an Infinity
     else decNaNs(res, rhs, NULL, &status); // a NaN












    if (status!=0) decStatus(res, status, set);










































    return res;
    }




























  // have a finite number; no error possible (res must be big enough)
  if (rhs->exponent>=0) return decNumberCopy(res, rhs);
  // that was easy, but if negative exponent there is work to do...
  workset=*set;                    // clone rounding, etc.

  workset.digits=rhs->digits;      // no length rounding



  workset.traps=0;                 // no traps
  decNumberZero(&dn);              // make a number with exponent 0
  return decNumberQuantize(res, rhs, &dn, &workset);
  } // decNumberToIntegralValue


/* ================================================================== */
/* Utility routines                                                   */
/* ================================================================== */

















































/* ------------------------------------------------------------------ */
/* decNumberCopy -- copy a number                                     */
/*                                                                    */
/*   dest is the target decNumber                                     */
/*   src  is the source decNumber                                     */
/*   returns dest                                                     */







>








|
|
|
|
>


>
>
|

|



>







<

|
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
<
<
|
>
|
>
>
>
|
|
|
|
>




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121

3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208



3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
  #if DECCHECK
  decCheckInexact(res, set);
  #endif
  return res;
  } // decNumberSubtract

/* ------------------------------------------------------------------ */
/* decNumberToIntegralExact -- round-to-integral-value with InExact   */
/* decNumberToIntegralValue -- round-to-integral-value                */
/*                                                                    */
/*   res is the result                                                */
/*   rhs is input number                                              */
/*   set is the context                                               */
/*                                                                    */
/* res must have space for any value of rhs.                          */
/*                                                                    */
/* This implements the IEEE special operators and therefore treats    */
/* special values as valid.  For finite numbers it returns            */
/* rescale(rhs, 0) if rhs->exponent is <0.                            */
/* Otherwise the result is rhs (so no error is possible, except for   */
/* sNaN).                                                             */
/*                                                                    */
/* The context is used for rounding mode and status after sNaN, but   */
/* the digits setting is ignored.  The Exact version will signal      */
/* Inexact if the result differs numerically from rhs; the other      */
/* never signals Inexact.                                             */
/* ------------------------------------------------------------------ */
decNumber * decNumberToIntegralExact(decNumber *res, const decNumber *rhs,
                                     decContext *set) {
  decNumber dn;
  decContext workset;              // working context
  uInt status=0;                   // accumulator

  #if DECCHECK
  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
  #endif

  // handle infinities and NaNs
  if (SPECIALARG) {

    if (decNumberIsInfinite(rhs)) decNumberCopy(res, rhs); // an Infinity
     else decNaNs(res, rhs, NULL, set, &status); // a NaN
    }
   else { // finite
    // have a finite number; no error possible (res must be big enough)
    if (rhs->exponent>=0) return decNumberCopy(res, rhs);
    // that was easy, but if negative exponent there is work to do...
    workset=*set;                  // clone rounding, etc.
    workset.digits=rhs->digits;    // no length rounding
    workset.traps=0;               // no traps
    decNumberZero(&dn);            // make a number with exponent 0
    decNumberQuantize(res, rhs, &dn, &workset);
    status|=workset.status;
    }
  if (status!=0) decStatus(res, status, set);
  return res;
  } // decNumberToIntegralExact

decNumber * decNumberToIntegralValue(decNumber *res, const decNumber *rhs,
                                     decContext *set) {
  decContext workset=*set;         // working context
  workset.traps=0;                 // no traps
  decNumberToIntegralExact(res, rhs, &workset);
  // this never affects set, except for sNaNs; NaN will have been set
  // or propagated already, so no need to call decStatus
  set->status|=workset.status&DEC_Invalid_operation;
  return res;
  } // decNumberToIntegralValue

/* ------------------------------------------------------------------ */
/* decNumberXor -- XOR two Numbers, digitwise                         */
/*                                                                    */
/*   This computes C = A ^ B                                          */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X^X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context (used for result length and error report)     */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/*                                                                    */
/* Logical function restrictions apply (see above); a NaN is          */
/* returned with Invalid_operation if a restriction is violated.      */
/* ------------------------------------------------------------------ */
decNumber * decNumberXor(decNumber *res, const decNumber *lhs,
                         const decNumber *rhs, decContext *set) {
  const Unit *ua, *ub;                  // -> operands
  const Unit *msua, *msub;              // -> operand msus
  Unit  *uc, *msuc;                     // -> result and its msu
  Int   msudigs;                        // digits in res msu
  #if DECCHECK
  if (decCheckOperands(res, lhs, rhs, set)) return res;
  #endif

  if (lhs->exponent!=0 || decNumberIsSpecial(lhs) || decNumberIsNegative(lhs)
   || rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) {
    decStatus(res, DEC_Invalid_operation, set);
    return res;
    }
  // operands are valid
  ua=lhs->lsu;                          // bottom-up
  ub=rhs->lsu;                          // ..
  uc=res->lsu;                          // ..
  msua=ua+D2U(lhs->digits)-1;           // -> msu of lhs
  msub=ub+D2U(rhs->digits)-1;           // -> msu of rhs
  msuc=uc+D2U(set->digits)-1;           // -> msu of result
  msudigs=MSUDIGITS(set->digits);       // [faster than remainder]
  for (; uc<=msuc; ua++, ub++, uc++) {  // Unit loop
    Unit a, b;                          // extract units
    if (ua>msua) a=0;
     else a=*ua;
    if (ub>msub) b=0;
     else b=*ub;
    *uc=0;                              // can now write back
    if (a|b) {                          // maybe 1 bits to examine
      Int i, j;
      // This loop could be unrolled and/or use BIN2BCD tables
      for (i=0; i<DECDPUN; i++) {
        if ((a^b)&1) *uc=*uc+(Unit)powers[i];     // effect XOR
        j=a%10;
        a=a/10;
        j|=b%10;
        b=b/10;
        if (j>1) {
          decStatus(res, DEC_Invalid_operation, set);
          return res;
          }



        if (uc==msuc && i==msudigs-1) break;      // just did final digit
        } // each digit
      } // non-zero
    } // each unit
  // [here uc-1 is the msu of the result]
  res->digits=decGetDigits(res->lsu, uc-res->lsu);
  res->exponent=0;                      // integer
  res->bits=0;                          // sign=0
  return res;  // [no status to set]
  } // decNumberXor


/* ================================================================== */
/* Utility routines                                                   */
/* ================================================================== */

/* ------------------------------------------------------------------ */
/* decNumberClass -- return the decClass of a decNumber               */
/*   dn -- the decNumber to test                                      */
/*   set -- the context to use for Emin                               */
/*   returns the decClass enum                                        */
/* ------------------------------------------------------------------ */
enum decClass decNumberClass(const decNumber *dn, decContext *set) {
  if (decNumberIsSpecial(dn)) {
    if (decNumberIsQNaN(dn)) return DEC_CLASS_QNAN;
    if (decNumberIsSNaN(dn)) return DEC_CLASS_SNAN;
    // must be an infinity
    if (decNumberIsNegative(dn)) return DEC_CLASS_NEG_INF;
    return DEC_CLASS_POS_INF;
    }
  // is finite
  if (decNumberIsNormal(dn, set)) { // most common
    if (decNumberIsNegative(dn)) return DEC_CLASS_NEG_NORMAL;
    return DEC_CLASS_POS_NORMAL;
    }
  // is subnormal or zero
  if (decNumberIsZero(dn)) {    // most common
    if (decNumberIsNegative(dn)) return DEC_CLASS_NEG_ZERO;
    return DEC_CLASS_POS_ZERO;
    }
  if (decNumberIsNegative(dn)) return DEC_CLASS_NEG_SUBNORMAL;
  return DEC_CLASS_POS_SUBNORMAL;
  } // decNumberClass

/* ------------------------------------------------------------------ */
/* decNumberClassToString -- convert decClass to a string             */
/*                                                                    */
/*  eclass is a valid decClass                                        */
/*  returns a constant string describing the class (max 13+1 chars)   */
/* ------------------------------------------------------------------ */
const char *decNumberClassToString(enum decClass eclass) {
  if (eclass==DEC_CLASS_POS_NORMAL)    return DEC_ClassString_PN;
  if (eclass==DEC_CLASS_NEG_NORMAL)    return DEC_ClassString_NN;
  if (eclass==DEC_CLASS_POS_ZERO)      return DEC_ClassString_PZ;
  if (eclass==DEC_CLASS_NEG_ZERO)      return DEC_ClassString_NZ;
  if (eclass==DEC_CLASS_POS_SUBNORMAL) return DEC_ClassString_PS;
  if (eclass==DEC_CLASS_NEG_SUBNORMAL) return DEC_ClassString_NS;
  if (eclass==DEC_CLASS_POS_INF)       return DEC_ClassString_PI;
  if (eclass==DEC_CLASS_NEG_INF)       return DEC_ClassString_NI;
  if (eclass==DEC_CLASS_QNAN)          return DEC_ClassString_QN;
  if (eclass==DEC_CLASS_SNAN)          return DEC_ClassString_SN;
  return DEC_ClassString_UN;           // Unknown
  } // decNumberClassToString

/* ------------------------------------------------------------------ */
/* decNumberCopy -- copy a number                                     */
/*                                                                    */
/*   dest is the target decNumber                                     */
/*   src  is the source decNumber                                     */
/*   returns dest                                                     */
2166
2167
2168
2169
2170
2171
2172










































































































































































2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184





2185
2186
2187
2188
2189
2190
2191
2192
    // overlap.  However, this explicit loop is faster in short cases.
    d=dest->lsu+1;                           // -> first destination
    smsup=src->lsu+D2U(src->digits);         // -> source msu+1
    for (s=src->lsu+1; s<smsup; s++, d++) *d=*s;
    }
  return dest;
  } // decNumberCopy











































































































































































/* ------------------------------------------------------------------ */
/* decNumberTrim -- remove insignificant zeros                        */
/*                                                                    */
/*   dn is the number to trim                                         */
/*   returns dn                                                       */
/*                                                                    */
/* All fields are updated as required.  This is a utility operation,  */
/* so special values are unchanged and no error is possible.          */
/* ------------------------------------------------------------------ */
decNumber * decNumberTrim(decNumber *dn) {
  Int  dropped;                    // work





  return decTrim(dn, 0, &dropped);
  } // decNumberTrim

/* ------------------------------------------------------------------ */
/* decNumberVersion -- return the name and version of this module     */
/*                                                                    */
/* No error is possible.                                              */
/* ------------------------------------------------------------------ */







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>












>
>
>
>
>
|







3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
    // overlap.  However, this explicit loop is faster in short cases.
    d=dest->lsu+1;                           // -> first destination
    smsup=src->lsu+D2U(src->digits);         // -> source msu+1
    for (s=src->lsu+1; s<smsup; s++, d++) *d=*s;
    }
  return dest;
  } // decNumberCopy

/* ------------------------------------------------------------------ */
/* decNumberCopyAbs -- quiet absolute value operator                  */
/*                                                                    */
/*   This sets C = abs(A)                                             */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
/*   rhs is A                                                         */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/* No exception or error can occur; this is a quiet bitwise operation.*/
/* See also decNumberAbs for a checking version of this.              */
/* ------------------------------------------------------------------ */
decNumber * decNumberCopyAbs(decNumber *res, const decNumber *rhs) {
  #if DECCHECK
  if (decCheckOperands(res, DECUNUSED, rhs, DECUNUSED)) return res;
  #endif
  decNumberCopy(res, rhs);
  res->bits&=~DECNEG;                   // turn off sign
  return res;
  } // decNumberCopyAbs

/* ------------------------------------------------------------------ */
/* decNumberCopyNegate -- quiet negate value operator                 */
/*                                                                    */
/*   This sets C = negate(A)                                          */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
/*   rhs is A                                                         */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/* No exception or error can occur; this is a quiet bitwise operation.*/
/* See also decNumberMinus for a checking version of this.            */
/* ------------------------------------------------------------------ */
decNumber * decNumberCopyNegate(decNumber *res, const decNumber *rhs) {
  #if DECCHECK
  if (decCheckOperands(res, DECUNUSED, rhs, DECUNUSED)) return res;
  #endif
  decNumberCopy(res, rhs);
  res->bits^=DECNEG;                    // invert the sign
  return res;
  } // decNumberCopyNegate

/* ------------------------------------------------------------------ */
/* decNumberCopySign -- quiet copy and set sign operator              */
/*                                                                    */
/*   This sets C = A with the sign of B                               */
/*                                                                    */
/*   res is C, the result.  C may be A                                */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/* No exception or error can occur; this is a quiet bitwise operation.*/
/* ------------------------------------------------------------------ */
decNumber * decNumberCopySign(decNumber *res, const decNumber *lhs,
                              const decNumber *rhs) {
  uByte sign;                           // rhs sign
  #if DECCHECK
  if (decCheckOperands(res, DECUNUSED, rhs, DECUNUSED)) return res;
  #endif
  sign=rhs->bits & DECNEG;              // save sign bit
  decNumberCopy(res, lhs);
  res->bits&=~DECNEG;                   // clear the sign
  res->bits|=sign;                      // set from rhs
  return res;
  } // decNumberCopySign

/* ------------------------------------------------------------------ */
/* decNumberGetBCD -- get the coefficient in BCD8                     */
/*   dn is the source decNumber                                       */
/*   bcd is the uInt array that will receive dn->digits BCD bytes,    */
/*     most-significant at offset 0                                   */
/*   returns bcd                                                      */
/*                                                                    */
/* bcd must have at least dn->digits bytes.  No error is possible; if */
/* dn is a NaN or Infinite, digits must be 1 and the coefficient 0.   */
/* ------------------------------------------------------------------ */
uByte * decNumberGetBCD(const decNumber *dn, uint8_t *bcd) {
  uByte *ub=bcd+dn->digits-1;      // -> lsd
  const Unit *up=dn->lsu;          // Unit pointer, -> lsu

  #if DECDPUN==1                   // trivial simple copy
    for (; ub>=bcd; ub--, up++) *ub=*up;
  #else                            // chopping needed
    uInt u=*up;                    // work
    uInt cut=DECDPUN;              // downcounter through unit
    for (; ub>=bcd; ub--) {
      *ub=(uByte)(u%10);           // [*6554 trick inhibits, here]
      u=u/10;
      cut--;
      if (cut>0) continue;         // more in this unit
      up++;
      u=*up;
      cut=DECDPUN;
      }
  #endif
  return bcd;
  } // decNumberGetBCD

/* ------------------------------------------------------------------ */
/* decNumberSetBCD -- set (replace) the coefficient from BCD8         */
/*   dn is the target decNumber                                       */
/*   bcd is the uInt array that will source n BCD bytes, most-        */
/*     significant at offset 0                                        */
/*   n is the number of digits in the source BCD array (bcd)          */
/*   returns dn                                                       */
/*                                                                    */
/* dn must have space for at least n digits.  No error is possible;   */
/* if dn is a NaN, or Infinite, or is to become a zero, n must be 1   */
/* and bcd[0] zero.                                                   */
/* ------------------------------------------------------------------ */
decNumber * decNumberSetBCD(decNumber *dn, const uByte *bcd, uInt n) {
  Unit *up=dn->lsu+D2U(dn->digits)-1;   // -> msu [target pointer]
  const uByte *ub=bcd;                  // -> source msd

  #if DECDPUN==1                        // trivial simple copy
    for (; ub<bcd+n; ub++, up--) *up=*ub;
  #else                                 // some assembly needed
    // calculate how many digits in msu, and hence first cut
    Int cut=MSUDIGITS(n);               // [faster than remainder]
    for (;up>=dn->lsu; up--) {          // each Unit from msu
      *up=0;                            // will take <=DECDPUN digits
      for (; cut>0; ub++, cut--) *up=X10(*up)+*ub;
      cut=DECDPUN;                      // next Unit has all digits
      }
  #endif
  dn->digits=n;                         // set digit count
  return dn;
  } // decNumberSetBCD

/* ------------------------------------------------------------------ */
/* decNumberIsNormal -- test normality of a decNumber                 */
/*   dn is the decNumber to test                                      */
/*   set is the context to use for Emin                               */
/*   returns 1 if |dn| is finite and >=Nmin, 0 otherwise              */
/* ------------------------------------------------------------------ */
Int decNumberIsNormal(const decNumber *dn, decContext *set) {
  Int ae;                               // adjusted exponent
  #if DECCHECK
  if (decCheckOperands(DECUNUSED, DECUNUSED, dn, set)) return 0;
  #endif

  if (decNumberIsSpecial(dn)) return 0; // not finite
  if (decNumberIsZero(dn)) return 0;    // not non-zero

  ae=dn->exponent+dn->digits-1;         // adjusted exponent
  if (ae<set->emin) return 0;           // is subnormal
  return 1;
  } // decNumberIsNormal

/* ------------------------------------------------------------------ */
/* decNumberIsSubnormal -- test subnormality of a decNumber           */
/*   dn is the decNumber to test                                      */
/*   set is the context to use for Emin                               */
/*   returns 1 if |dn| is finite, non-zero, and <Nmin, 0 otherwise    */
/* ------------------------------------------------------------------ */
Int decNumberIsSubnormal(const decNumber *dn, decContext *set) {
  Int ae;                               // adjusted exponent
  #if DECCHECK
  if (decCheckOperands(DECUNUSED, DECUNUSED, dn, set)) return 0;
  #endif

  if (decNumberIsSpecial(dn)) return 0; // not finite
  if (decNumberIsZero(dn)) return 0;    // not non-zero

  ae=dn->exponent+dn->digits-1;         // adjusted exponent
  if (ae<set->emin) return 1;           // is subnormal
  return 0;
  } // decNumberIsSubnormal

/* ------------------------------------------------------------------ */
/* decNumberTrim -- remove insignificant zeros                        */
/*                                                                    */
/*   dn is the number to trim                                         */
/*   returns dn                                                       */
/*                                                                    */
/* All fields are updated as required.  This is a utility operation,  */
/* so special values are unchanged and no error is possible.          */
/* ------------------------------------------------------------------ */
decNumber * decNumberTrim(decNumber *dn) {
  Int  dropped;                    // work
  decContext set;                  // ..
  #if DECCHECK
  if (decCheckOperands(DECUNUSED, DECUNUSED, dn, DECUNUSED)) return dn;
  #endif
  decContextDefault(&set, DEC_INIT_BASE);    // clamp=0
  return decTrim(dn, &set, 0, &dropped);
  } // decNumberTrim

/* ------------------------------------------------------------------ */
/* decNumberVersion -- return the name and version of this module     */
/*                                                                    */
/* No error is possible.                                              */
/* ------------------------------------------------------------------ */
2391
2392
2393
2394
2395
2396
2397

2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415


2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*   negate is DECNEG if rhs should be negated, or 0 otherwise        */
/*   status accumulates status for the caller                         */
/*                                                                    */
/* C must have space for set->digits digits.                          */

/* ------------------------------------------------------------------ */
/* If possible, the coefficient is calculated directly into C.        */
/* However, if:                                                       */
/*   -- a digits+1 calculation is needed because the numbers are      */
/*      unaligned and span more than set->digits digits               */
/*   -- a carry to digits+1 digits looks possible                     */
/*   -- C is the same as A or B, and the result would destructively   */
/*      overlap the A or B coefficient                                */
/* then the result must be calculated into a temporary buffer.  In    */
/* this case a local (stack) buffer is used if possible, and only if  */
/* too long for that does malloc become the last resort.              */
/*                                                                    */
/* Misalignment is handled as follows:                                */
/*   Apad: (AExp>BExp) Swap operands and proceed as for BExp>AExp.    */
/*   BPad: Apply the padding by a combination of shifting (whole      */
/*         units) and multiplication (part units).                    */
/*                                                                    */
/* Addition, especially x=x+1, is speed-critical.                     */


/* ------------------------------------------------------------------ */
static decNumber * decAddOp(decNumber *res, const decNumber *lhs,
                            const decNumber *rhs, decContext *set,
                            uByte negate, uInt *status) {
  #if DECSUBSET
  decNumber *alloclhs=NULL;        // non-NULL if rounded lhs allocated
  decNumber *allocrhs=NULL;        // .., rhs
  #endif
  Int   rhsshift;                  // working shift (in Units)
  Int   maxdigits;                 // longest logical length
  Int   mult;                      // multiplier
  Int   residue;                   // rounding accumulator
  uByte bits;                      // result bits
  Flag  diffsign;                  // non-0 if arguments have different sign
  Unit  *acc;                      // accumulator for result
  Unit  accbuff[SD2U(DECBUFFER+20)]; // local buffer [+20 reduces many
                                   // allocations when called from
                                   // other operations]
  Unit  *allocacc=NULL;            // -> allocated acc buffer, iff allocated
  Int   reqdigits=set->digits;     // local copy; requested DIGITS
  Int   padding;                   // work

  #if DECCHECK
  if (decCheckOperands(res, lhs, rhs, set)) return res;
  #endif







>










|







>
>















|

|







3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*   negate is DECNEG if rhs should be negated, or 0 otherwise        */
/*   status accumulates status for the caller                         */
/*                                                                    */
/* C must have space for set->digits digits.                          */
/* Inexact in status must be 0 for correct Exact zero sign in result  */
/* ------------------------------------------------------------------ */
/* If possible, the coefficient is calculated directly into C.        */
/* However, if:                                                       */
/*   -- a digits+1 calculation is needed because the numbers are      */
/*      unaligned and span more than set->digits digits               */
/*   -- a carry to digits+1 digits looks possible                     */
/*   -- C is the same as A or B, and the result would destructively   */
/*      overlap the A or B coefficient                                */
/* then the result must be calculated into a temporary buffer.  In    */
/* this case a local (stack) buffer is used if possible, and only if  */
/* too long for that does malloc become the final resort.             */
/*                                                                    */
/* Misalignment is handled as follows:                                */
/*   Apad: (AExp>BExp) Swap operands and proceed as for BExp>AExp.    */
/*   BPad: Apply the padding by a combination of shifting (whole      */
/*         units) and multiplication (part units).                    */
/*                                                                    */
/* Addition, especially x=x+1, is speed-critical.                     */
/* The static buffer is larger than might be expected to allow for    */
/* calls from higher-level funtions (notable exp).                    */
/* ------------------------------------------------------------------ */
static decNumber * decAddOp(decNumber *res, const decNumber *lhs,
                            const decNumber *rhs, decContext *set,
                            uByte negate, uInt *status) {
  #if DECSUBSET
  decNumber *alloclhs=NULL;        // non-NULL if rounded lhs allocated
  decNumber *allocrhs=NULL;        // .., rhs
  #endif
  Int   rhsshift;                  // working shift (in Units)
  Int   maxdigits;                 // longest logical length
  Int   mult;                      // multiplier
  Int   residue;                   // rounding accumulator
  uByte bits;                      // result bits
  Flag  diffsign;                  // non-0 if arguments have different sign
  Unit  *acc;                      // accumulator for result
  Unit  accbuff[SD2U(DECBUFFER*2+20)]; // local buffer [*2+20 reduces many
                                   // allocations when called from
                                   // other operations, notable exp]
  Unit  *allocacc=NULL;            // -> allocated acc buffer, iff allocated
  Int   reqdigits=set->digits;     // local copy; requested DIGITS
  Int   padding;                   // work

  #if DECCHECK
  if (decCheckOperands(res, lhs, rhs, set)) return res;
  #endif
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473

    // note whether signs differ [used all paths]
    diffsign=(Flag)((lhs->bits^rhs->bits^negate)&DECNEG);

    // handle infinities and NaNs
    if (SPECIALARGS) {                  // a special bit set
      if (SPECIALARGS & (DECSNAN | DECNAN))  // a NaN
        decNaNs(res, lhs, rhs, status);
       else { // one or two infinities
        if (decNumberIsInfinite(lhs)) { // LHS is infinity
          // two infinities with different signs is invalid
          if (decNumberIsInfinite(rhs) && diffsign) {
            *status|=DEC_Invalid_operation;
            break;
            }







|







3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789

    // note whether signs differ [used all paths]
    diffsign=(Flag)((lhs->bits^rhs->bits^negate)&DECNEG);

    // handle infinities and NaNs
    if (SPECIALARGS) {                  // a special bit set
      if (SPECIALARGS & (DECSNAN | DECNAN))  // a NaN
        decNaNs(res, lhs, rhs, set, status);
       else { // one or two infinities
        if (decNumberIsInfinite(lhs)) { // LHS is infinity
          // two infinities with different signs is invalid
          if (decNumberIsInfinite(rhs) && diffsign) {
            *status|=DEC_Invalid_operation;
            break;
            }
2539
2540
2541
2542
2543
2544
2545

2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557

2558
2559
2560
2561
2562
2563
2564
          res->exponent+=adjust;                // set the exponent.
          }
      #if DECSUBSET
        } // extended
      #endif
      decFinish(res, set, &residue, status);      // clean and finalize
      break;}

    // [NB: both fastpath and mainpath code below assume these cases
    // (notably 0-0) have already been handled]

    // calculate the padding needed to align the operands
    padding=rhs->exponent-lhs->exponent;

    // Fastpath cases where the numbers are aligned and normal, the RHS
    // is all in one unit, no operand rounding is needed, and no carry,
    // lengthening, or borrow is needed
    if (padding==0
        && rhs->digits<=DECDPUN
        && rhs->exponent>=set->emin     // [some normals drop through]

        && rhs->digits<=reqdigits
        && lhs->digits<=reqdigits) {
      Int partial=*lhs->lsu;
      if (!diffsign) {                  // adding
        partial+=*rhs->lsu;
        if ((partial<=DECDPUNMAX)       // result fits in unit
         && (lhs->digits>=DECDPUN ||    // .. and no digits-count change







>












>







3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
          res->exponent+=adjust;                // set the exponent.
          }
      #if DECSUBSET
        } // extended
      #endif
      decFinish(res, set, &residue, status);      // clean and finalize
      break;}

    // [NB: both fastpath and mainpath code below assume these cases
    // (notably 0-0) have already been handled]

    // calculate the padding needed to align the operands
    padding=rhs->exponent-lhs->exponent;

    // Fastpath cases where the numbers are aligned and normal, the RHS
    // is all in one unit, no operand rounding is needed, and no carry,
    // lengthening, or borrow is needed
    if (padding==0
        && rhs->digits<=DECDPUN
        && rhs->exponent>=set->emin     // [some normals drop through]
        && rhs->exponent<=set->emax-set->digits+1 // [could clamp]
        && rhs->digits<=reqdigits
        && lhs->digits<=reqdigits) {
      Int partial=*lhs->lsu;
      if (!diffsign) {                  // adding
        partial+=*rhs->lsu;
        if ((partial<=DECDPUNMAX)       // result fits in unit
         && (lhs->digits>=DECDPUN ||    // .. and no digits-count change
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
    // other) padding with up to DIGITS-1 trailing zeros may be
    // needed; then apply rounding (as exotic rounding modes may be
    // affected by the residue).
    rhsshift=0;               // rhs shift to left (padding) in Units
    bits=lhs->bits;           // assume sign is that of LHS
    mult=1;                   // likely multiplier

    // if padding==0 the operands are aligned; no padding needed
    if (padding!=0) {
      // some padding needed; always pad the RHS, as any required
      // padding can then be effected by a simple combination of
      // shifts and a multiply
      Flag swapped=0;
      if (padding<0) {                  // LHS needs the padding
        const decNumber *t;







|







3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
    // other) padding with up to DIGITS-1 trailing zeros may be
    // needed; then apply rounding (as exotic rounding modes may be
    // affected by the residue).
    rhsshift=0;               // rhs shift to left (padding) in Units
    bits=lhs->bits;           // assume sign is that of LHS
    mult=1;                   // likely multiplier

    // [if padding==0 the operands are aligned; no padding is needed]
    if (padding!=0) {
      // some padding needed; always pad the RHS, as any required
      // padding can then be effected by a simple combination of
      // shifts and a multiply
      Flag swapped=0;
      if (padding<0) {                  // LHS needs the padding
        const decNumber *t;
2648
2649
2650
2651
2652
2653
2654

2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
    if ((maxdigits>=reqdigits)          // is, or could be, too large
     || (res==rhs && rhsshift>0)) {     // destructive overlap
      // buffer needed, choose it; units for maxdigits digits will be
      // needed, +1 Unit for carry or borrow
      Int need=D2U(maxdigits)+1;
      acc=accbuff;                      // assume use local buffer
      if (need*sizeof(Unit)>sizeof(accbuff)) {

        allocacc=(Unit *)malloc(need*sizeof(Unit));
        if (allocacc==NULL) {           // hopeless -- abandon
          *status|=DEC_Insufficient_storage;
          break;}
        acc=allocacc;
        }
      }

    res->bits=(uByte)(bits&DECNEG);     // it's now safe to overwrite..
    res->exponent=lhs->exponent;        // .. operands (even if aliased)

    #if DECTRACE
      decDumpAr('A', lhs->lsu, D2U(lhs->digits));
      decDumpAr('B', rhs->lsu, D2U(rhs->digits));
      printf("  :h: %d %d\n", rhsshift, mult);
    #endif

    // add [A+B*m] or subtract [A+B*(-m)]
    res->digits=decUnitAddSub(lhs->lsu, D2U(lhs->digits),
                              rhs->lsu, D2U(rhs->digits),
                              rhsshift, acc, mult)
               *DECDPUN;           // [units -> digits]







>














|







3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
    if ((maxdigits>=reqdigits)          // is, or could be, too large
     || (res==rhs && rhsshift>0)) {     // destructive overlap
      // buffer needed, choose it; units for maxdigits digits will be
      // needed, +1 Unit for carry or borrow
      Int need=D2U(maxdigits)+1;
      acc=accbuff;                      // assume use local buffer
      if (need*sizeof(Unit)>sizeof(accbuff)) {
        // printf("malloc add %ld %ld\n", need, sizeof(accbuff));
        allocacc=(Unit *)malloc(need*sizeof(Unit));
        if (allocacc==NULL) {           // hopeless -- abandon
          *status|=DEC_Insufficient_storage;
          break;}
        acc=allocacc;
        }
      }

    res->bits=(uByte)(bits&DECNEG);     // it's now safe to overwrite..
    res->exponent=lhs->exponent;        // .. operands (even if aliased)

    #if DECTRACE
      decDumpAr('A', lhs->lsu, D2U(lhs->digits));
      decDumpAr('B', rhs->lsu, D2U(rhs->digits));
      printf("  :h: %ld %ld\n", rhsshift, mult);
    #endif

    // add [A+B*m] or subtract [A+B*(-m)]
    res->digits=decUnitAddSub(lhs->lsu, D2U(lhs->digits),
                              rhs->lsu, D2U(rhs->digits),
                              rhsshift, acc, mult)
               *DECDPUN;           // [units -> digits]
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
    // apply checks and rounding
    decFinish(res, set, &residue, status);

    // "When the sum of two operands with opposite signs is exactly
    // zero, the sign of that sum shall be '+' in all rounding modes
    // except round toward -Infinity, in which mode that sign shall be
    // '-'."  [Subset zeros also never have '-', set by decFinish.]
    if (ISZERO(res)
     && diffsign
     #if DECSUBSET
     && set->extended
     #endif
     && (*status&DEC_Inexact)==0) {
      if (set->round==DEC_ROUND_FLOOR) res->bits|=DECNEG;   // sign -
                                  else res->bits&=~DECNEG;  // sign +
      }







|
<







4052
4053
4054
4055
4056
4057
4058
4059

4060
4061
4062
4063
4064
4065
4066
    // apply checks and rounding
    decFinish(res, set, &residue, status);

    // "When the sum of two operands with opposite signs is exactly
    // zero, the sign of that sum shall be '+' in all rounding modes
    // except round toward -Infinity, in which mode that sign shall be
    // '-'."  [Subset zeros also never have '-', set by decFinish.]
    if (ISZERO(res) && diffsign

     #if DECSUBSET
     && set->extended
     #endif
     && (*status&DEC_Inexact)==0) {
      if (set->round==DEC_ROUND_FLOOR) res->bits|=DECNEG;   // sign -
                                  else res->bits&=~DECNEG;  // sign +
      }
2819
2820
2821
2822
2823
2824
2825


2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
/*     Return (Result is defined by Var1)                             */
/*                                                                    */
/* ------------------------------------------------------------------ */
/* Two working buffers are needed during the division; one (digits+   */
/* 1) to accumulate the result, and the other (up to 2*digits+1) for  */
/* long subtractions.  These are acc and var1 respectively.           */
/* var1 is a copy of the lhs coefficient, var2 is the rhs coefficient.*/


/* ------------------------------------------------------------------ */
static decNumber * decDivideOp(decNumber *res,
                               const decNumber *lhs, const decNumber *rhs,
                               decContext *set, Flag op, uInt *status) {
  #if DECSUBSET
  decNumber *alloclhs=NULL;        // non-NULL if rounded lhs allocated
  decNumber *allocrhs=NULL;        // .., rhs
  #endif
  Unit  accbuff[SD2U(DECBUFFER+DECDPUN)]; // local buffer
  Unit  *acc=accbuff;              // -> accumulator array for result
  Unit  *allocacc=NULL;            // -> allocated buffer, iff allocated
  Unit  *accnext;                  // -> where next digit will go
  Int   acclength;                 // length of acc needed [Units]
  Int   accunits;                  // count of units accumulated
  Int   accdigits;                 // count of digits accumulated








>
>








|







4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
/*     Return (Result is defined by Var1)                             */
/*                                                                    */
/* ------------------------------------------------------------------ */
/* Two working buffers are needed during the division; one (digits+   */
/* 1) to accumulate the result, and the other (up to 2*digits+1) for  */
/* long subtractions.  These are acc and var1 respectively.           */
/* var1 is a copy of the lhs coefficient, var2 is the rhs coefficient.*/
/* The static buffers may be larger than might be expected to allow   */
/* for calls from higher-level funtions (notable exp).                */
/* ------------------------------------------------------------------ */
static decNumber * decDivideOp(decNumber *res,
                               const decNumber *lhs, const decNumber *rhs,
                               decContext *set, Flag op, uInt *status) {
  #if DECSUBSET
  decNumber *alloclhs=NULL;        // non-NULL if rounded lhs allocated
  decNumber *allocrhs=NULL;        // .., rhs
  #endif
  Unit  accbuff[SD2U(DECBUFFER+DECDPUN+10)]; // local buffer
  Unit  *acc=accbuff;              // -> accumulator array for result
  Unit  *allocacc=NULL;            // -> allocated buffer, iff allocated
  Unit  *accnext;                  // -> where next digit will go
  Int   acclength;                 // length of acc needed [Units]
  Int   accunits;                  // count of units accumulated
  Int   accdigits;                 // count of digits accumulated

2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
    // [following code does not require input rounding]

    bits=(lhs->bits^rhs->bits)&DECNEG;  // assumed sign for divisions

    // handle infinities and NaNs
    if (SPECIALARGS) {                  // a special bit set
      if (SPECIALARGS & (DECSNAN | DECNAN)) { // one or two NaNs
        decNaNs(res, lhs, rhs, status);
        break;
        }
      // one or two infinities
      if (decNumberIsInfinite(lhs)) {   // LHS (dividend) is infinite
        if (decNumberIsInfinite(rhs) || // two infinities are invalid ..
            op & (REMAINDER | REMNEAR)) { // as is remainder of infinity
          *status|=DEC_Invalid_operation;







|







4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
    // [following code does not require input rounding]

    bits=(lhs->bits^rhs->bits)&DECNEG;  // assumed sign for divisions

    // handle infinities and NaNs
    if (SPECIALARGS) {                  // a special bit set
      if (SPECIALARGS & (DECSNAN | DECNAN)) { // one or two NaNs
        decNaNs(res, lhs, rhs, set, status);
        break;
        }
      // one or two infinities
      if (decNumberIsInfinite(lhs)) {   // LHS (dividend) is infinite
        if (decNumberIsInfinite(rhs) || // two infinities are invalid ..
            op & (REMAINDER | REMNEAR)) { // as is remainder of infinity
          *status|=DEC_Invalid_operation;
3009
3010
3011
3012
3013
3014
3015

3016
3017
3018
3019
3020
3021
3022

    /* Long (slow) division is needed; roll up the sleeves... */

    // The accumulator will hold the quotient of the division.
    // If it needs to be too long for stack storage, then allocate.
    acclength=D2U(reqdigits+DECDPUN);   // in Units
    if (acclength*sizeof(Unit)>sizeof(accbuff)) {

      allocacc=(Unit *)malloc(acclength*sizeof(Unit));
      if (allocacc==NULL) {             // hopeless -- abandon
        *status|=DEC_Insufficient_storage;
        break;}
      acc=allocacc;                     // use the allocated space
      }








>







4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343

    /* Long (slow) division is needed; roll up the sleeves... */

    // The accumulator will hold the quotient of the division.
    // If it needs to be too long for stack storage, then allocate.
    acclength=D2U(reqdigits+DECDPUN);   // in Units
    if (acclength*sizeof(Unit)>sizeof(accbuff)) {
      // printf("malloc dvacc %ld units\n", acclength);
      allocacc=(Unit *)malloc(acclength*sizeof(Unit));
      if (allocacc==NULL) {             // hopeless -- abandon
        *status|=DEC_Insufficient_storage;
        break;}
      acc=allocacc;                     // use the allocated space
      }

3033
3034
3035
3036
3037
3038
3039

3040
3041
3042
3043
3044
3045
3046
    // [Note: unused units do not participate in decUnitAddSub data]
    maxdigits=rhs->digits+reqdigits-1;
    if (lhs->digits>maxdigits) maxdigits=lhs->digits;
    var1units=D2U(maxdigits)+2;
    // allocate a guard unit above msu1 for REMAINDERNEAR
    if (!(op&DIVIDE)) var1units++;
    if ((var1units+1)*sizeof(Unit)>sizeof(varbuff)) {

      varalloc=(Unit *)malloc((var1units+1)*sizeof(Unit));
      if (varalloc==NULL) {             // hopeless -- abandon
        *status|=DEC_Insufficient_storage;
        break;}
      var1=varalloc;                    // use the allocated space
      }








>







4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
    // [Note: unused units do not participate in decUnitAddSub data]
    maxdigits=rhs->digits+reqdigits-1;
    if (lhs->digits>maxdigits) maxdigits=lhs->digits;
    var1units=D2U(maxdigits)+2;
    // allocate a guard unit above msu1 for REMAINDERNEAR
    if (!(op&DIVIDE)) var1units++;
    if ((var1units+1)*sizeof(Unit)>sizeof(varbuff)) {
      // printf("malloc dvvar %ld units\n", var1units+1);
      varalloc=(Unit *)malloc((var1units+1)*sizeof(Unit));
      if (varalloc==NULL) {             // hopeless -- abandon
        *status|=DEC_Insufficient_storage;
        break;}
      var1=varalloc;                    // use the allocated space
      }

3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
        thisunit=(Unit)(thisunit+mult);      // accumulate
        // subtract var1-var2, into var1; only the overlap needs
        // processing, as this is an in-place calculation
        shift=var2ulen-var2units;
        #if DECTRACE
          decDumpAr('1', &var1[shift], var1units-shift);
          decDumpAr('2', var2, var2units);
          printf("m=%d\n", -mult);
        #endif
        decUnitAddSub(&var1[shift], var1units-shift,
                      var2, var2units, 0,
                      &var1[shift], -mult);
        #if DECTRACE
          decDumpAr('#', &var1[shift], var1units-shift);
        #endif







|







4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
        thisunit=(Unit)(thisunit+mult);      // accumulate
        // subtract var1-var2, into var1; only the overlap needs
        // processing, as this is an in-place calculation
        shift=var2ulen-var2units;
        #if DECTRACE
          decDumpAr('1', &var1[shift], var1units-shift);
          decDumpAr('2', var2, var2units);
          printf("m=%ld\n", -mult);
        #endif
        decUnitAddSub(&var1[shift], var1units-shift,
                      var2, var2units, 0,
                      &var1[shift], -mult);
        #if DECTRACE
          decDumpAr('#', &var1[shift], var1units-shift);
        #endif
3274
3275
3276
3277
3278
3279
3280

3281
3282
3283
3284
3285
3286
3287
          Int exp=lhs->exponent;             // save min(exponents)
          if (rhs->exponent<exp) exp=rhs->exponent;
          decNumberZero(res);                // 0 coefficient
          #if DECSUBSET
          if (set->extended)
          #endif
          res->exponent=exp;                 // .. with proper exponent

          break;
          }
        // note if the quotient was odd
        if (*accnext & 0x01) wasodd=1;       // acc is odd
        quotlsu=accnext;                     // save in case need to reinspect
        quotdigits=accdigits;                // ..








>







4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
          Int exp=lhs->exponent;             // save min(exponents)
          if (rhs->exponent<exp) exp=rhs->exponent;
          decNumberZero(res);                // 0 coefficient
          #if DECSUBSET
          if (set->extended)
          #endif
          res->exponent=exp;                 // .. with proper exponent
          decFinish(res, set, &residue, status);   // might clamp
          break;
          }
        // note if the quotient was odd
        if (*accnext & 0x01) wasodd=1;       // acc is odd
        quotlsu=accnext;                     // save in case need to reinspect
        quotdigits=accdigits;                // ..

3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320

        // Now correct the result if doing remainderNear; if it
        // (looking just at coefficients) is > rhs/2, or == rhs/2 and
        // the integer was odd then the result should be rem-rhs.
        if (op&REMNEAR) {
          Int compare, tarunits;        // work
          Unit *up;                     // ..


          // calculate remainder*2 into the var1 buffer (which has
          // 'headroom' of an extra unit and hence enough space)
          // [a dedicated 'double' loop would be faster, here]
          tarunits=decUnitAddSub(accnext, accunits, accnext, accunits,
                                 0, accnext, 1);
          // decDumpAr('r', accnext, tarunits);








<
<







4628
4629
4630
4631
4632
4633
4634


4635
4636
4637
4638
4639
4640
4641

        // Now correct the result if doing remainderNear; if it
        // (looking just at coefficients) is > rhs/2, or == rhs/2 and
        // the integer was odd then the result should be rem-rhs.
        if (op&REMNEAR) {
          Int compare, tarunits;        // work
          Unit *up;                     // ..


          // calculate remainder*2 into the var1 buffer (which has
          // 'headroom' of an extra unit and hence enough space)
          // [a dedicated 'double' loop would be faster, here]
          tarunits=decUnitAddSub(accnext, accunits, accnext, accunits,
                                 0, accnext, 1);
          // decDumpAr('r', accnext, tarunits);

3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
    // Now the coefficient.
    decSetCoeff(res, set, accnext, accdigits, &residue, status);

    decFinish(res, set, &residue, status);   // final cleanup

    #if DECSUBSET
    // If a divide then strip trailing zeros if subset [after round]
    if (!set->extended && (op==DIVIDE)) decTrim(res, 0, &dropped);
    #endif
    } while(0);                              // end protected

  if (varalloc!=NULL) free(varalloc);   // drop any storage used
  if (allocacc!=NULL) free(allocacc);   // ..
  #if DECSUBSET
  if (allocrhs!=NULL) free(allocrhs);   // ..







|







4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
    // Now the coefficient.
    decSetCoeff(res, set, accnext, accdigits, &residue, status);

    decFinish(res, set, &residue, status);   // final cleanup

    #if DECSUBSET
    // If a divide then strip trailing zeros if subset [after round]
    if (!set->extended && (op==DIVIDE)) decTrim(res, set, 0, &dropped);
    #endif
    } while(0);                              // end protected

  if (varalloc!=NULL) free(varalloc);   // drop any storage used
  if (allocacc!=NULL) free(allocacc);   // ..
  #if DECSUBSET
  if (allocrhs!=NULL) free(allocrhs);   // ..
3433
3434
3435
3436
3437
3438
3439


3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
/* units for continuing processing.  Despite this overhead, the       */
/* fastpath can speed up some 16-digit operations by 10x (and much    */
/* more for higher-precision calculations).                           */
/*                                                                    */
/* A buffer always has to be used for the accumulator; in the         */
/* fastpath, buffers are also always needed for the chunked copies of */
/* of the operand coefficients.                                       */


/* ------------------------------------------------------------------ */
#define FASTMUL (DECUSE64 && DECDPUN<5)
static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
                                 const decNumber *rhs, decContext *set,
                                 uInt *status) {
  Int    accunits;                 // Units of accumulator in use
  Int    exponent;                 // work
  Int    residue=0;                // rounding residue
  uByte  bits;                     // result sign
  Unit  *acc;                      // -> accumulator Unit array
  Int    needbytes;                // size calculator
  void  *allocacc=NULL;            // -> allocated accumulator, iff allocated
  Unit accbuff[SD2U(DECBUFFER*2+5)]; // buffer (+1 for DECBUFFER==0,
                                   // + 4 for calls from other operations)
  const Unit *mer, *mermsup;       // work
  Int  madlength;                  // Units in multiplicand
  Int  shift;                      // Units to shift multiplicand by

  #if FASTMUL
    // if DECDPUN is 1 or 3 work in base 10**9, otherwise
    // (DECDPUN is 2 or 4) then work in base 10**8
    #if DECDPUN & 1                // odd
      #define FASTBASE 1000000000  // base
      #define FASTDIGS          9  // digits in base
      #define FASTLAZY         18  // carry resolution point [1->18]
    #else
      #define FASTBASE  100000000
      #define FASTDIGS          8
      #define FASTLAZY       1844  // carry resolution point [1->1844]
    #endif
    // three buffers are used, two for chunked copies of the operands
    // (base 10**8 or base 10**9) and one base 2**64 accumulator with
    // lazy carry evaluation
    uInt   zlhibuff[(DECBUFFER+7)/8+1]; // buffer (+1 for DECBUFFER==0)
    uInt  *zlhi=zlhibuff;               // -> lhs array
    uInt  *alloclhi=NULL;               // -> allocated buffer, iff allocated
    uInt   zrhibuff[(DECBUFFER+7)/8+1]; // buffer (+1 for DECBUFFER==0)
    uInt  *zrhi=zrhibuff;               // -> rhs array
    uInt  *allocrhi=NULL;               // -> allocated buffer, iff allocated
    uLong  zaccbuff[(DECBUFFER+3)/4+2]; // buffer (+1 for DECBUFFER==0)
                                        // + 1 for calls from other operations)
    // [allocacc is shared for both paths, as only one will run]
    uLong *zacc=zaccbuff;          // -> accumulator array for exact result
    #if DECDPUN==1
    Int    zoff;                   // accumulator offset
    #endif
    uInt  *lip, *rip;              // item pointers
    uInt  *lmsi, *rmsi;            // most significant items







>
>












|
|

|
|
















|
|
|
|
|
|
|
<







4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802

4803
4804
4805
4806
4807
4808
4809
/* units for continuing processing.  Despite this overhead, the       */
/* fastpath can speed up some 16-digit operations by 10x (and much    */
/* more for higher-precision calculations).                           */
/*                                                                    */
/* A buffer always has to be used for the accumulator; in the         */
/* fastpath, buffers are also always needed for the chunked copies of */
/* of the operand coefficients.                                       */
/* Static buffers are larger than needed just for multiply, to allow  */
/* for calls from other operations (notably exp).                     */
/* ------------------------------------------------------------------ */
#define FASTMUL (DECUSE64 && DECDPUN<5)
static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
                                 const decNumber *rhs, decContext *set,
                                 uInt *status) {
  Int    accunits;                 // Units of accumulator in use
  Int    exponent;                 // work
  Int    residue=0;                // rounding residue
  uByte  bits;                     // result sign
  Unit  *acc;                      // -> accumulator Unit array
  Int    needbytes;                // size calculator
  void  *allocacc=NULL;            // -> allocated accumulator, iff allocated
  Unit  accbuff[SD2U(DECBUFFER*4+1)]; // buffer (+1 for DECBUFFER==0,
                                   // *4 for calls from other operations)
  const Unit *mer, *mermsup;       // work
  Int   madlength;                 // Units in multiplicand
  Int   shift;                     // Units to shift multiplicand by

  #if FASTMUL
    // if DECDPUN is 1 or 3 work in base 10**9, otherwise
    // (DECDPUN is 2 or 4) then work in base 10**8
    #if DECDPUN & 1                // odd
      #define FASTBASE 1000000000  // base
      #define FASTDIGS          9  // digits in base
      #define FASTLAZY         18  // carry resolution point [1->18]
    #else
      #define FASTBASE  100000000
      #define FASTDIGS          8
      #define FASTLAZY       1844  // carry resolution point [1->1844]
    #endif
    // three buffers are used, two for chunked copies of the operands
    // (base 10**8 or base 10**9) and one base 2**64 accumulator with
    // lazy carry evaluation
    uInt   zlhibuff[(DECBUFFER*2+1)/8+1]; // buffer (+1 for DECBUFFER==0)
    uInt  *zlhi=zlhibuff;                 // -> lhs array
    uInt  *alloclhi=NULL;                 // -> allocated buffer, iff allocated
    uInt   zrhibuff[(DECBUFFER*2+1)/8+1]; // buffer (+1 for DECBUFFER==0)
    uInt  *zrhi=zrhibuff;                 // -> rhs array
    uInt  *allocrhi=NULL;                 // -> allocated buffer, iff allocated
    uLong  zaccbuff[(DECBUFFER*2+1)/4+2]; // buffer (+1 for DECBUFFER==0)

    // [allocacc is shared for both paths, as only one will run]
    uLong *zacc=zaccbuff;          // -> accumulator array for exact result
    #if DECDPUN==1
    Int    zoff;                   // accumulator offset
    #endif
    uInt  *lip, *rip;              // item pointers
    uInt  *lmsi, *rmsi;            // most significant items
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521

  // precalculate result sign
  bits=(uByte)((lhs->bits^rhs->bits)&DECNEG);

  // handle infinities and NaNs
  if (SPECIALARGS) {               // a special bit set
    if (SPECIALARGS & (DECSNAN | DECNAN)) { // one or two NaNs
      decNaNs(res, lhs, rhs, status);
      return res;}
    // one or two infinities; Infinity * 0 is invalid
    if (((lhs->bits & DECINF)==0 && ISZERO(lhs))
      ||((rhs->bits & DECINF)==0 && ISZERO(rhs))) {
      *status|=DEC_Invalid_operation;
      return res;}
    decNumberZero(res);







|







4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843

  // precalculate result sign
  bits=(uByte)((lhs->bits^rhs->bits)&DECNEG);

  // handle infinities and NaNs
  if (SPECIALARGS) {               // a special bit set
    if (SPECIALARGS & (DECSNAN | DECNAN)) { // one or two NaNs
      decNaNs(res, lhs, rhs, set, status);
      return res;}
    // one or two infinities; Infinity * 0 is invalid
    if (((lhs->bits & DECINF)==0 && ISZERO(lhs))
      ||((rhs->bits & DECINF)==0 && ISZERO(rhs))) {
      *status|=DEC_Invalid_operation;
      return res;}
    decNumberZero(res);
3728
3729
3730
3731
3732
3733
3734

3735
3736
3737
3738
3739
3740
3741
    // both their magnitudes are large.  If there was a wrap, set a
    // safe very negative exponent, from which decFinalize() will
    // raise a hard underflow shortly.
    exponent=lhs->exponent+rhs->exponent;    // calculate exponent
    if (lhs->exponent<0 && rhs->exponent<0 && exponent>0)
      exponent=-2*DECNUMMAXE;                // force underflow
    res->exponent=exponent;                  // OK to overwrite now


    // Set the coefficient.  If any rounding, residue records
    decSetCoeff(res, set, acc, res->digits, &residue, status);
    decFinish(res, set, &residue, status);   // final cleanup
    } while(0);                         // end protected

  if (allocacc!=NULL) free(allocacc);   // drop any storage used







>







5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
    // both their magnitudes are large.  If there was a wrap, set a
    // safe very negative exponent, from which decFinalize() will
    // raise a hard underflow shortly.
    exponent=lhs->exponent+rhs->exponent;    // calculate exponent
    if (lhs->exponent<0 && rhs->exponent<0 && exponent>0)
      exponent=-2*DECNUMMAXE;                // force underflow
    res->exponent=exponent;                  // OK to overwrite now


    // Set the coefficient.  If any rounding, residue records
    decSetCoeff(res, set, acc, res->digits, &residue, status);
    decFinish(res, set, &residue, status);   // final cleanup
    } while(0);                         // end protected

  if (allocacc!=NULL) free(allocacc);   // drop any storage used
3821
3822
3823
3824
3825
3826
3827



3828
3829
3830
3831
3832
3833
3834
3835
3836
3837

3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
/*    which dominates when the number of iterations is small (less    */
/*    than ten) or when rhs is short.  As an example, the adjustment  */
/*    x**10,000,000 needs 31 multiplications, all but one full-width. */
/*                                                                    */
/* 3. The restrictions (especially precision) could be raised with    */
/*    care, but the full decNumber range seems very hard within the   */
/*    32-bit limits.                                                  */



/* ------------------------------------------------------------------ */
decNumber * decExpOp(decNumber *res, const decNumber *rhs,
                         decContext *set, uInt *status) {
  uInt ignore=0;                   // working status
  Int h;                           // adjusted exponent for 0.xxxx
  Int p;                           // working precision
  Int residue;                     // rounding residue
  uInt needbytes;                  // for space calculations
  const decNumber *x=rhs;          // (may point to safe copy later)
  decContext aset, tset, dset;     // working contexts


  // the argument is often copied to normalize it, so (unusually) it
  // is treated like other buffers, using DECBUFFER, +1 in case
  // DECBUFFER is 0
  decNumber bufr[D2N(DECBUFFER+1)];
  decNumber *allocrhs=NULL;        // non-NULL if rhs buffer allocated

  // the working precision will be no more than set->digits+8+1
  // so for on-stack buffers DECBUFFER+9 is used, +1 in case DECBUFFER
  // is 0 (and twice that for the accumulator)

  // buffer for t, term (working precision plus)
  decNumber buft[D2N(DECBUFFER+9+1)];
  decNumber *allocbuft=NULL;       // -> allocated buft, iff allocated
  decNumber *t=buft;               // term
  // buffer for a, accumulator (working precision * 2), at least 9
  decNumber bufa[D2N(DECBUFFER*2+18+1)];
  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated
  decNumber *a=bufa;               // accumulator
  // decNumber for the divisor term; this needs at most 9 digits
  // and so can be fixed size [16 so can use standard context]
  decNumber bufd[D2N(16)];
  decNumber *d=bufd;               // divisor
  decNumber numone;                // constant 1

  #if DECCHECK
  Int iterations=0;                // for later sanity check
  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
  #endif

  do {                                  // protect allocated storage
    if (SPECIALARG) {                   // handle infinities and NaNs
      if (decNumberIsInfinite(rhs)) {   // an infinity
        if (decNumberIsNegative(rhs))   // -Infinity -> +0
          decNumberZero(res);
         else decNumberCopy(res, rhs);  // +Infinity -> self
        }
       else decNaNs(res, rhs, NULL, status); // a NaN
      break;}

    if (ISZERO(rhs)) {                  // zeros -> exact 1
      decNumberZero(res);               // make clean 1
      *res->lsu=1;                      // ..
      break;}                           // [no status to set]








>
>
>










>




|







|



|




















|







5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
/*    which dominates when the number of iterations is small (less    */
/*    than ten) or when rhs is short.  As an example, the adjustment  */
/*    x**10,000,000 needs 31 multiplications, all but one full-width. */
/*                                                                    */
/* 3. The restrictions (especially precision) could be raised with    */
/*    care, but the full decNumber range seems very hard within the   */
/*    32-bit limits.                                                  */
/*                                                                    */
/* 4. The working precisions for the static buffers are twice the     */
/*    obvious size to allow for calls from decNumberPower.            */
/* ------------------------------------------------------------------ */
decNumber * decExpOp(decNumber *res, const decNumber *rhs,
                         decContext *set, uInt *status) {
  uInt ignore=0;                   // working status
  Int h;                           // adjusted exponent for 0.xxxx
  Int p;                           // working precision
  Int residue;                     // rounding residue
  uInt needbytes;                  // for space calculations
  const decNumber *x=rhs;          // (may point to safe copy later)
  decContext aset, tset, dset;     // working contexts
  Int comp;                        // work

  // the argument is often copied to normalize it, so (unusually) it
  // is treated like other buffers, using DECBUFFER, +1 in case
  // DECBUFFER is 0
  decNumber bufr[D2N(DECBUFFER*2+1)];
  decNumber *allocrhs=NULL;        // non-NULL if rhs buffer allocated

  // the working precision will be no more than set->digits+8+1
  // so for on-stack buffers DECBUFFER+9 is used, +1 in case DECBUFFER
  // is 0 (and twice that for the accumulator)

  // buffer for t, term (working precision plus)
  decNumber buft[D2N(DECBUFFER*2+9+1)];
  decNumber *allocbuft=NULL;       // -> allocated buft, iff allocated
  decNumber *t=buft;               // term
  // buffer for a, accumulator (working precision * 2), at least 9
  decNumber bufa[D2N(DECBUFFER*4+18+1)];
  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated
  decNumber *a=bufa;               // accumulator
  // decNumber for the divisor term; this needs at most 9 digits
  // and so can be fixed size [16 so can use standard context]
  decNumber bufd[D2N(16)];
  decNumber *d=bufd;               // divisor
  decNumber numone;                // constant 1

  #if DECCHECK
  Int iterations=0;                // for later sanity check
  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
  #endif

  do {                                  // protect allocated storage
    if (SPECIALARG) {                   // handle infinities and NaNs
      if (decNumberIsInfinite(rhs)) {   // an infinity
        if (decNumberIsNegative(rhs))   // -Infinity -> +0
          decNumberZero(res);
         else decNumberCopy(res, rhs);  // +Infinity -> self
        }
       else decNaNs(res, rhs, NULL, set, status); // a NaN
      break;}

    if (ISZERO(rhs)) {                  // zeros -> exact 1
      decNumberZero(res);               // make clean 1
      *res->lsu=1;                      // ..
      break;}                           // [no status to set]

3894
3895
3896
3897
3898
3899
3900
3901




3902
3903
3904
3905
3906
3907
3908
    // 1.0000001.  Hence, tiny will be 0.0000004  if digits=7 and x>0
    // or 0.00000004 if digits=7 and x<0.  If RHS not larger than
    // this then the result will be 1.000000
    decNumberZero(d);                   // clean
    *d->lsu=4;                          // set 4 ..
    d->exponent=-set->digits;           // * 10**(-d)
    if (decNumberIsNegative(rhs)) d->exponent--;  // negative case
    if (decCompare(d, rhs, 1)>=0) {     // signless compare




      Int shift=set->digits-1;
      decNumberZero(res);               // set 1
      *res->lsu=1;                      // ..
      res->digits=decShiftToMost(res->lsu, 1, shift);
      res->exponent=-shift;                  // make 1.0000...
      *status|=DEC_Inexact | DEC_Rounded;    // .. inexactly
      break;} // tiny







|
>
>
>
>







5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
    // 1.0000001.  Hence, tiny will be 0.0000004  if digits=7 and x>0
    // or 0.00000004 if digits=7 and x<0.  If RHS not larger than
    // this then the result will be 1.000000
    decNumberZero(d);                   // clean
    *d->lsu=4;                          // set 4 ..
    d->exponent=-set->digits;           // * 10**(-d)
    if (decNumberIsNegative(rhs)) d->exponent--;  // negative case
    comp=decCompare(d, rhs, 1);         // signless compare
    if (comp==BADINT) {
      *status|=DEC_Insufficient_storage;
      break;}
    if (comp>=0) {                      // rhs < d
      Int shift=set->digits-1;
      decNumberZero(res);               // set 1
      *res->lsu=1;                      // ..
      res->digits=decShiftToMost(res->lsu, 1, shift);
      res->exponent=-shift;                  // make 1.0000...
      *status|=DEC_Inexact | DEC_Rounded;    // .. inexactly
      break;} // tiny
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
      // a=1, and the divisor d=2.

      // First determine the working precision.  From Hull & Abrham
      // this is set->digits+h+2.  However, if x is 'over-precise' we
      // need to allow for all its digits to potentially participate
      // (consider an x where all the excess digits are 9s) so in
      // this case use x->digits+h+2
      p=MAX(x->digits, set->digits)+h+2;

      // a and t are variable precision, and depend on p, so space
      // must be allocated for them if necessary

      // the accumulator needs to be able to hold 2p digits so that
      // the additions on the second and subsequent iterations are
      // sufficiently exact.







|







5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
      // a=1, and the divisor d=2.

      // First determine the working precision.  From Hull & Abrham
      // this is set->digits+h+2.  However, if x is 'over-precise' we
      // need to allow for all its digits to potentially participate
      // (consider an x where all the excess digits are 9s) so in
      // this case use x->digits+h+2
      p=MAX(x->digits, set->digits)+h+2;     // [h<=8]

      // a and t are variable precision, and depend on p, so space
      // must be allocated for them if necessary

      // the accumulator needs to be able to hold 2p digits so that
      // the additions on the second and subsequent iterations are
      // sufficiently exact.
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
            && (a->digits>=p)) break;
        decAddOp(d, d, &numone, &dset, 0, &ignore);    // d=d+1
        } // iterate

      #if DECCHECK
      // just a sanity check; comment out test to show always
      if (iterations>p+3)
        printf("Exp iterations=%d, status=%08x, p=%d, d=%d\n",
               iterations, *status, p, x->digits);
      #endif
      } // h<=8

    // apply postconditioning: a=a**(10**h) -- this is calculated
    // at a slightly higher precision than Hull & Abrham suggest
    if (h>0) {







|







5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
            && (a->digits>=p)) break;
        decAddOp(d, d, &numone, &dset, 0, &ignore);    // d=d+1
        } // iterate

      #if DECCHECK
      // just a sanity check; comment out test to show always
      if (iterations>p+3)
        printf("Exp iterations=%ld, status=%08lx, p=%ld, d=%ld\n",
               iterations, *status, p, x->digits);
      #endif
      } // h<=8

    // apply postconditioning: a=a**(10**h) -- this is calculated
    // at a slightly higher precision than Hull & Abrham suggest
    if (h>0) {
4173
4174
4175
4176
4177
4178
4179



4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
/* 4. An iteration might be saved by widening the LNnn table, and     */
/*    would certainly save at least one if it were made ten times     */
/*    bigger, too (for truncated fractions 0.100 through 0.999).      */
/*    However, for most practical evaluations, at least four or five  */
/*    iterations will be neede -- so this would only speed up by      */
/*    20-25% and that probably does not justify increasing the table  */
/*    size.                                                           */



/* ------------------------------------------------------------------ */
decNumber * decLnOp(decNumber *res, const decNumber *rhs,
                    decContext *set, uInt *status) {
  uInt ignore=0;                   // working status accumulator
  uInt needbytes;                  // for space calculations
  Int residue;                     // rounding residue
  Int r;                           // rhs=f*10**r [see below]
  Int p;                           // working precision
  Int pp;                          // precision for iteration
  Int t;                           // work

  // buffers for a (accumulator, typically precision+2) and b
  // (adjustment calculator, same size)
  decNumber bufa[D2N(DECBUFFER+2)];
  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated
  decNumber *a=bufa;               // accumulator/work
  decNumber bufb[D2N(DECBUFFER+2)];
  decNumber *allocbufb=NULL;       // -> allocated bufa, iff allocated
  decNumber *b=bufb;               // adjustment/work

  decNumber  numone;               // constant 1
  decNumber  cmp;                  // work
  decContext aset, bset;           // working contexts

  #if DECCHECK
  Int iterations=0;                // for later sanity check
  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
  #endif

  do {                                  // protect allocated storage
    if (SPECIALARG) {                   // handle infinities and NaNs
      if (decNumberIsInfinite(rhs)) {   // an infinity
        if (decNumberIsNegative(rhs))   // -Infinity -> error
          *status|=DEC_Invalid_operation;
         else decNumberCopy(res, rhs);  // +Infinity -> self
        }
       else decNaNs(res, rhs, NULL, status); // a NaN
      break;}

    if (ISZERO(rhs)) {                  // +/- zeros -> -Infinity
      decNumberZero(res);               // make clean
      res->bits=DECINF|DECNEG;          // set - infinity
      break;}                           // [no status to set]








>
>
>













|


|



















|







5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
/* 4. An iteration might be saved by widening the LNnn table, and     */
/*    would certainly save at least one if it were made ten times     */
/*    bigger, too (for truncated fractions 0.100 through 0.999).      */
/*    However, for most practical evaluations, at least four or five  */
/*    iterations will be neede -- so this would only speed up by      */
/*    20-25% and that probably does not justify increasing the table  */
/*    size.                                                           */
/*                                                                    */
/* 5. The static buffers are larger than might be expected to allow   */
/*    for calls from decNumberPower.                                  */
/* ------------------------------------------------------------------ */
decNumber * decLnOp(decNumber *res, const decNumber *rhs,
                    decContext *set, uInt *status) {
  uInt ignore=0;                   // working status accumulator
  uInt needbytes;                  // for space calculations
  Int residue;                     // rounding residue
  Int r;                           // rhs=f*10**r [see below]
  Int p;                           // working precision
  Int pp;                          // precision for iteration
  Int t;                           // work

  // buffers for a (accumulator, typically precision+2) and b
  // (adjustment calculator, same size)
  decNumber bufa[D2N(DECBUFFER+12)];
  decNumber *allocbufa=NULL;       // -> allocated bufa, iff allocated
  decNumber *a=bufa;               // accumulator/work
  decNumber bufb[D2N(DECBUFFER*2+2)];
  decNumber *allocbufb=NULL;       // -> allocated bufa, iff allocated
  decNumber *b=bufb;               // adjustment/work

  decNumber  numone;               // constant 1
  decNumber  cmp;                  // work
  decContext aset, bset;           // working contexts

  #if DECCHECK
  Int iterations=0;                // for later sanity check
  if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
  #endif

  do {                                  // protect allocated storage
    if (SPECIALARG) {                   // handle infinities and NaNs
      if (decNumberIsInfinite(rhs)) {   // an infinity
        if (decNumberIsNegative(rhs))   // -Infinity -> error
          *status|=DEC_Invalid_operation;
         else decNumberCopy(res, rhs);  // +Infinity -> self
        }
       else decNaNs(res, rhs, NULL, set, status); // a NaN
      break;}

    if (ISZERO(rhs)) {                  // +/- zeros -> -Infinity
      decNumberZero(res);               // make clean
      res->bits=DECINF|DECNEG;          // set - infinity
      break;}                           // [no status to set]

4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
    //   ln(x) = ln(f) + ln(10)*r
    // Get the initial estimate for ln(f) from a small lookup
    // table (see above) indexed by the first two digits of f,
    // truncated.

    decContextDefault(&aset, DEC_INIT_DECIMAL64); // 16-digit extended
    r=rhs->exponent+rhs->digits;        // 'normalised' exponent
    decPutInt(a, r);                    // a=r
    decPutInt(b, 2302585);              // b=ln(10) (2.302585)
    b->exponent=-6;                     //  ..
    decMultiplyOp(a, a, b, &aset, &ignore);  // a=a*b
    // now get top two digits of rhs into b by simple truncate and
    // force to integer
    residue=0;                          // (no residue)
    aset.digits=2; aset.round=DEC_ROUND_DOWN;
    decCopyFit(b, rhs, &aset, &residue, &ignore); // copy & shorten
    b->exponent=0;                      // make integer
    t=decGetInt(b);                     // [cannot fail]
    if (t<10) t=X10(t);                 // adjust single-digit b
    t=LNnn[t-10];                       // look up ln(b)
    decPutInt(b, t>>2);                 // b=ln(b) coefficient
    b->exponent=-(t&3)-3;               // set exponent
    b->bits=DECNEG;                     // ln(0.10)->ln(0.99) always -ve
    aset.digits=16; aset.round=DEC_ROUND_HALF_EVEN; // restore
    decAddOp(a, a, b, &aset, 0, &ignore); // acc=a+b
    // the initial estimate is now in a, with up to 4 digits correct.
    // When rhs is at or near Nmax the estimate will be low, so we
    // will approach it from below, avoiding overflow when calling exp.







|
|











|







5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
    //   ln(x) = ln(f) + ln(10)*r
    // Get the initial estimate for ln(f) from a small lookup
    // table (see above) indexed by the first two digits of f,
    // truncated.

    decContextDefault(&aset, DEC_INIT_DECIMAL64); // 16-digit extended
    r=rhs->exponent+rhs->digits;        // 'normalised' exponent
    decNumberFromInt32(a, r);           // a=r
    decNumberFromInt32(b, 2302585);     // b=ln(10) (2.302585)
    b->exponent=-6;                     //  ..
    decMultiplyOp(a, a, b, &aset, &ignore);  // a=a*b
    // now get top two digits of rhs into b by simple truncate and
    // force to integer
    residue=0;                          // (no residue)
    aset.digits=2; aset.round=DEC_ROUND_DOWN;
    decCopyFit(b, rhs, &aset, &residue, &ignore); // copy & shorten
    b->exponent=0;                      // make integer
    t=decGetInt(b);                     // [cannot fail]
    if (t<10) t=X10(t);                 // adjust single-digit b
    t=LNnn[t-10];                       // look up ln(b)
    decNumberFromInt32(b, t>>2);        // b=ln(b) coefficient
    b->exponent=-(t&3)-3;               // set exponent
    b->bits=DECNEG;                     // ln(0.10)->ln(0.99) always -ve
    aset.digits=16; aset.round=DEC_ROUND_HALF_EVEN; // restore
    decAddOp(a, a, b, &aset, 0, &ignore); // acc=a+b
    // the initial estimate is now in a, with up to 4 digits correct.
    // When rhs is at or near Nmax the estimate will be low, so we
    // will approach it from below, avoiding overflow when calling exp.
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
      aset.digits=pp;                        // working context
      bset.digits=pp+rhs->digits;            // wider context
      } // Newton's iteration

    #if DECCHECK
    // just a sanity check; remove the test to show always
    if (iterations>24)
      printf("Ln iterations=%d, status=%08x, p=%d, d=%d\n",
            iterations, *status, p, rhs->digits);
    #endif

    // Copy and round the result to res
    residue=1;                          // indicate dirt to right
    if (ISZERO(a)) residue=0;           // .. unless underflowed to 0
    aset.digits=set->digits;            // [use default rounding]







|







5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
      aset.digits=pp;                        // working context
      bset.digits=pp+rhs->digits;            // wider context
      } // Newton's iteration

    #if DECCHECK
    // just a sanity check; remove the test to show always
    if (iterations>24)
      printf("Ln iterations=%ld, status=%08lx, p=%ld, d=%ld\n",
            iterations, *status, p, rhs->digits);
    #endif

    // Copy and round the result to res
    residue=1;                          // indicate dirt to right
    if (ISZERO(a)) residue=0;           // .. unless underflowed to 0
    aset.digits=set->digits;            // [use default rounding]
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
    #endif
    // [following code does not require input rounding]

    // Handle special values
    if (SPECIALARGS) {
      // NaNs get usual processing
      if (SPECIALARGS & (DECSNAN | DECNAN))
        decNaNs(res, lhs, rhs, status);
      // one infinity but not both is bad
      else if ((lhs->bits ^ rhs->bits) & DECINF)
        *status|=DEC_Invalid_operation;
      // both infinity: return lhs
      else decNumberCopy(res, lhs);          // [nop if in place]
      break;
      }







|







5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
    #endif
    // [following code does not require input rounding]

    // Handle special values
    if (SPECIALARGS) {
      // NaNs get usual processing
      if (SPECIALARGS & (DECSNAN | DECNAN))
        decNaNs(res, lhs, rhs, set, status);
      // one infinity but not both is bad
      else if ((lhs->bits ^ rhs->bits) & DECINF)
        *status|=DEC_Invalid_operation;
      // both infinity: return lhs
      else decNumberCopy(res, lhs);          // [nop if in place]
      break;
      }
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574


4575
4576

4577

4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
  return res;
  } // decQuantizeOp

/* ------------------------------------------------------------------ */
/* decCompareOp -- compare, min, or max two Numbers                   */
/*                                                                    */
/*   This computes C = A ? B and carries out one of four operations:  */
/*     COMPARE   -- returns the signum (as a number) giving the       */
/*                  result of a comparison unless one or both         */
/*                  operands is a NaN (in which case a NaN results)   */


/*     COMPMAX   -- returns the larger of the operands, using the     */
/*                  754r maxnum operation                             */

/*     COMPMIN   -- the 754r minnum operation                         */

/*     COMTOTAL  -- returns the signum (as a number) giving the       */
/*                  result of a comparison using 754r total ordering  */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*   op  is the operation flag                                        */
/*   status is the usual accumulator                                  */
/*                                                                    */
/* C must have space for one digit for COMPARE or set->digits for     */
/* COMPMAX and COMPMIN.                                               */
/* ------------------------------------------------------------------ */
/* The emphasis here is on speed for common cases, and avoiding       */
/* coefficient comparison if possible.                                */
/* ------------------------------------------------------------------ */
decNumber * decCompareOp(decNumber *res, const decNumber *lhs,
                         const decNumber *rhs, decContext *set,
                         Flag op, uInt *status) {







|
|
|
>
>
|
|
>
|
>
|
|









|







5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
  return res;
  } // decQuantizeOp

/* ------------------------------------------------------------------ */
/* decCompareOp -- compare, min, or max two Numbers                   */
/*                                                                    */
/*   This computes C = A ? B and carries out one of four operations:  */
/*     COMPARE    -- returns the signum (as a number) giving the      */
/*                   result of a comparison unless one or both        */
/*                   operands is a NaN (in which case a NaN results)  */
/*     COMPSIG    -- as COMPARE except that a quiet NaN raises        */
/*                   Invalid operation.                               */
/*     COMPMAX    -- returns the larger of the operands, using the    */
/*                   754r maxnum operation                            */
/*     COMPMAXMAG -- ditto, comparing absolute values                 */
/*     COMPMIN    -- the 754r minnum operation                        */
/*     COMPMINMAG -- ditto, comparing absolute values                 */
/*     COMTOTAL   -- returns the signum (as a number) giving the      */
/*                   result of a comparison using 754r total ordering */
/*                                                                    */
/*   res is C, the result.  C may be A and/or B (e.g., X=X?X)         */
/*   lhs is A                                                         */
/*   rhs is B                                                         */
/*   set is the context                                               */
/*   op  is the operation flag                                        */
/*   status is the usual accumulator                                  */
/*                                                                    */
/* C must have space for one digit for COMPARE or set->digits for     */
/* COMPMAX, COMPMIN, COMPMAXMAG, or COMPMINMAG.                       */
/* ------------------------------------------------------------------ */
/* The emphasis here is on speed for common cases, and avoiding       */
/* coefficient comparison if possible.                                */
/* ------------------------------------------------------------------ */
decNumber * decCompareOp(decNumber *res, const decNumber *lhs,
                         const decNumber *rhs, decContext *set,
                         Flag op, uInt *status) {
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642


4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675


4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
        rhs=allocrhs;
        }
      }
    #endif
    // [following code does not require input rounding]

    // If total ordering then handle differing signs 'up front'
    if (op == COMPTOTAL) {              // total ordering
      if (decNumberIsNegative(lhs) & !decNumberIsNegative(rhs)) {
        result=-1;
        break;
        }
      if (!decNumberIsNegative(lhs) & decNumberIsNegative(rhs)) {
        result=+1;
        break;
        }
      }

    // handle NaNs specially; let infinities drop through
    // This assumes sNaN (even just one) leads to NaN.
    merged=(lhs->bits | rhs->bits) & (DECSNAN | DECNAN);
    if (merged) {                       // a NaN bit set
      if (op == COMPARE);               // result will be NaN


       else if (op == COMPTOTAL) {      // total ordering, always finite
        // signs are known to be the same; compute the ordering here
        // as if the signs are both positive, then invert for negatives
        if (!decNumberIsNaN(lhs)) result=-1;
         else if (!decNumberIsNaN(rhs)) result=+1;
         // here if both NaNs
         else if (decNumberIsSNaN(lhs) && decNumberIsQNaN(rhs)) result=-1;
         else if (decNumberIsQNaN(lhs) && decNumberIsSNaN(rhs)) result=+1;
         else { // both NaN or both sNaN
          // now it just depends on the payload
          result=decUnitCompare(lhs->lsu, D2U(lhs->digits),
                                rhs->lsu, D2U(rhs->digits), 0);
          // [Error not possible, as these are 'aligned']
          } // both same NaNs
        if (decNumberIsNegative(lhs)) result=-result;
        break;
        } // total order

       else if (merged & DECSNAN);      // sNaN -> qNaN
       else { // here if MIN or MAX and one or two quiet NaNs
        // min or max -- 754r rules ignore single NaN
        if (!decNumberIsNaN(lhs) || !decNumberIsNaN(rhs)) {
          // just one NaN; force choice to be the non-NaN operand
          op=COMPMAX;
          if (lhs->bits & DECNAN) result=-1; // pick rhs
                             else result=+1; // pick lhs
          break;
          }
        } // max or min
      op = COMPNAN;                     // use special path
      decNaNs(res, lhs, rhs, status);
      break;
      }


    result=decCompare(lhs, rhs, 0);     // have numbers
    } while(0);                         // end protected

  if (result==BADINT) *status|=DEC_Insufficient_storage; // rare
   else {
    if (op == COMPARE || op == COMPTOTAL) {  // returning signum
      if (op == COMPTOTAL && result==0) {
        // operands are numerically equal or same NaN (and same sign,
        // tested first); if identical, leave result 0
        if (lhs->exponent!=rhs->exponent) {
          if (lhs->exponent<rhs->exponent) result=-1;
           else result=+1;
          if (decNumberIsNegative(lhs)) result=-result;
          } // lexp!=rexp
        } // total-order by exponent
      decNumberZero(res);               // [always a valid result]
      if (result!=0) {                  // must be -1 or +1
        *res->lsu=1;
        if (result<0) res->bits=DECNEG;
        }
      }
     else if (op == COMPNAN);           // special, drop through
     else {                             // MAX or MIN, non-NaN result
      Int residue=0;                    // rounding accumulator
      // choose the operand for the result
      const decNumber *choice;
      if (result==0) { // operands are numerically equal
        // choose according to sign then exponent (see 754r)
        uByte slhs=(lhs->bits & DECNEG);







|














|
>
>
|

















|










|
|


>
>
|
|



|
|














|







5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
        rhs=allocrhs;
        }
      }
    #endif
    // [following code does not require input rounding]

    // If total ordering then handle differing signs 'up front'
    if (op==COMPTOTAL) {                // total ordering
      if (decNumberIsNegative(lhs) & !decNumberIsNegative(rhs)) {
        result=-1;
        break;
        }
      if (!decNumberIsNegative(lhs) & decNumberIsNegative(rhs)) {
        result=+1;
        break;
        }
      }

    // handle NaNs specially; let infinities drop through
    // This assumes sNaN (even just one) leads to NaN.
    merged=(lhs->bits | rhs->bits) & (DECSNAN | DECNAN);
    if (merged) {                       // a NaN bit set
      if (op==COMPARE);                 // result will be NaN
       else if (op==COMPSIG)            // treat qNaN as sNaN
        *status|=DEC_Invalid_operation | DEC_sNaN;
       else if (op==COMPTOTAL) {        // total ordering, always finite
        // signs are known to be the same; compute the ordering here
        // as if the signs are both positive, then invert for negatives
        if (!decNumberIsNaN(lhs)) result=-1;
         else if (!decNumberIsNaN(rhs)) result=+1;
         // here if both NaNs
         else if (decNumberIsSNaN(lhs) && decNumberIsQNaN(rhs)) result=-1;
         else if (decNumberIsQNaN(lhs) && decNumberIsSNaN(rhs)) result=+1;
         else { // both NaN or both sNaN
          // now it just depends on the payload
          result=decUnitCompare(lhs->lsu, D2U(lhs->digits),
                                rhs->lsu, D2U(rhs->digits), 0);
          // [Error not possible, as these are 'aligned']
          } // both same NaNs
        if (decNumberIsNegative(lhs)) result=-result;
        break;
        } // total order

       else if (merged & DECSNAN);           // sNaN -> qNaN
       else { // here if MIN or MAX and one or two quiet NaNs
        // min or max -- 754r rules ignore single NaN
        if (!decNumberIsNaN(lhs) || !decNumberIsNaN(rhs)) {
          // just one NaN; force choice to be the non-NaN operand
          op=COMPMAX;
          if (lhs->bits & DECNAN) result=-1; // pick rhs
                             else result=+1; // pick lhs
          break;
          }
        } // max or min
      op=COMPNAN;                            // use special path
      decNaNs(res, lhs, rhs, set, status);   // propagate NaN
      break;
      }
    // have numbers
    if (op==COMPMAXMAG || op==COMPMINMAG) result=decCompare(lhs, rhs, 1);
     else result=decCompare(lhs, rhs, 0);    // sign matters
    } while(0);                              // end protected

  if (result==BADINT) *status|=DEC_Insufficient_storage; // rare
   else {
    if (op==COMPARE || op==COMPSIG ||op==COMPTOTAL) { // returning signum
      if (op==COMPTOTAL && result==0) {
        // operands are numerically equal or same NaN (and same sign,
        // tested first); if identical, leave result 0
        if (lhs->exponent!=rhs->exponent) {
          if (lhs->exponent<rhs->exponent) result=-1;
           else result=+1;
          if (decNumberIsNegative(lhs)) result=-result;
          } // lexp!=rexp
        } // total-order by exponent
      decNumberZero(res);               // [always a valid result]
      if (result!=0) {                  // must be -1 or +1
        *res->lsu=1;
        if (result<0) res->bits=DECNEG;
        }
      }
     else if (op==COMPNAN);             // special, drop through
     else {                             // MAX or MIN, non-NaN result
      Int residue=0;                    // rounding accumulator
      // choose the operand for the result
      const decNumber *choice;
      if (result==0) { // operands are numerically equal
        // choose according to sign then exponent (see 754r)
        uByte slhs=(lhs->bits & DECNEG);
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
          }
         else {                    // both positive
          if (lhs->exponent>rhs->exponent) result=+1;
                                      else result=-1;
          // [ditto]
          }
        } // numerically equal
      // here result will be non-0
      if (op == COMPMIN) result=-result;// reverse if looking for MIN
      choice=(result>0 ? lhs : rhs);    // choose
      // copy chosen to result, rounding if need be
      decCopyFit(res, choice, set, &residue, status);
      decFinish(res, set, &residue, status);
      }
    }
  #if DECSUBSET







|
|







6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
          }
         else {                    // both positive
          if (lhs->exponent>rhs->exponent) result=+1;
                                      else result=-1;
          // [ditto]
          }
        } // numerically equal
      // here result will be non-0; reverse if looking for MIN
      if (op==COMPMIN || op==COMPMINMAG) result=-result;
      choice=(result>0 ? lhs : rhs);    // choose
      // copy chosen to result, rounding if need be
      decCopyFit(res, choice, set, &residue, status);
      decFinish(res, set, &residue, status);
      }
    }
  #if DECSUBSET
4757
4758
4759
4760
4761
4762
4763


4764

4765
4766
4767
4768
4769
4770
4771
4772

4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
  Int   result;                    // result value
  Int   sigr;                      // rhs signum
  Int   compare;                   // work

  result=1;                                  // assume signum(lhs)
  if (ISZERO(lhs)) result=0;
  if (abs) {


    if (!ISZERO(rhs)) result=1;              // not both 0

    }
   else {                                    // signs matter
    if (result && decNumberIsNegative(lhs)) result=-1;
    sigr=1;                                  // compute signum(rhs)
    if (ISZERO(rhs)) sigr=0;
     else if (decNumberIsNegative(rhs)) sigr=-1;
    if (result > sigr) return +1;            // L > R, return 1
    if (result < sigr) return -1;            // R < L, return -1

    }

  // signums are the same
  if (result==0) return 0;                   // both 0
  // Both non-zero
  if ((lhs->bits | rhs->bits) & DECINF) {    // one or more infinities
    if (decNumberIsInfinite(rhs)) {
      if (decNumberIsInfinite(lhs)) result=0;// both infinite
       else result=-result;                  // only rhs infinite
      }
    return result;
    }

  // must compare the coefficients, allowing for exponents
  if (lhs->exponent>rhs->exponent) {         // LHS exponent larger
    // swap sides, and sign
    const decNumber *temp=lhs;
    lhs=rhs;
    rhs=temp;
    result=-result;
    }

  compare=decUnitCompare(lhs->lsu, D2U(lhs->digits),
                         rhs->lsu, D2U(rhs->digits),
                         rhs->exponent-lhs->exponent);

  if (compare!=BADINT) compare*=result;      // comparison succeeded
  return compare;
  } // decCompare

/* ------------------------------------------------------------------ */
/* decUnitCompare -- compare two >=0 integers in Unit arrays          */
/*                                                                    */







>
>
|
>







|
>


|
<
<







<








<



<







6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121


6122
6123
6124
6125
6126
6127
6128

6129
6130
6131
6132
6133
6134
6135
6136

6137
6138
6139

6140
6141
6142
6143
6144
6145
6146
  Int   result;                    // result value
  Int   sigr;                      // rhs signum
  Int   compare;                   // work

  result=1;                                  // assume signum(lhs)
  if (ISZERO(lhs)) result=0;
  if (abs) {
    if (ISZERO(rhs)) return result;          // LHS wins or both 0
    // RHS is non-zero
    if (result==0) return -1;                // LHS is 0; RHS wins
    // [here, both non-zero, result=1]
    }
   else {                                    // signs matter
    if (result && decNumberIsNegative(lhs)) result=-1;
    sigr=1;                                  // compute signum(rhs)
    if (ISZERO(rhs)) sigr=0;
     else if (decNumberIsNegative(rhs)) sigr=-1;
    if (result > sigr) return +1;            // L > R, return 1
    if (result < sigr) return -1;            // L < R, return -1
    if (result==0) return 0;                   // both 0
    }

  // signums are the same; both are non-zero


  if ((lhs->bits | rhs->bits) & DECINF) {    // one or more infinities
    if (decNumberIsInfinite(rhs)) {
      if (decNumberIsInfinite(lhs)) result=0;// both infinite
       else result=-result;                  // only rhs infinite
      }
    return result;
    }

  // must compare the coefficients, allowing for exponents
  if (lhs->exponent>rhs->exponent) {         // LHS exponent larger
    // swap sides, and sign
    const decNumber *temp=lhs;
    lhs=rhs;
    rhs=temp;
    result=-result;
    }

  compare=decUnitCompare(lhs->lsu, D2U(lhs->digits),
                         rhs->lsu, D2U(rhs->digits),
                         rhs->exponent-lhs->exponent);

  if (compare!=BADINT) compare*=result;      // comparison succeeded
  return compare;
  } // decCompare

/* ------------------------------------------------------------------ */
/* decUnitCompare -- compare two >=0 integers in Unit arrays          */
/*                                                                    */
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
/*  returns -1, 0, or 1 for A<B, A==B, or A>B, or BADINT if failure   */
/*  (the only possible failure is an allocation error, which can      */
/*  only occur if E!=0)                                               */
/* ------------------------------------------------------------------ */
static Int decUnitCompare(const Unit *a, Int alength,
                          const Unit *b, Int blength, Int exp) {
  Unit  *acc;                      // accumulator for result
  Unit  accbuff[SD2U(DECBUFFER+1)];// local buffer
  Unit  *allocacc=NULL;            // -> allocated acc buffer, iff allocated
  Int   accunits, need;            // units in use or needed for acc
  const Unit *l, *r, *u;           // work
  Int   expunits, exprem, result;  // ..

  if (exp==0) {                    // aligned; fastpath
    if (alength>blength) return 1;







|







6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
/*  returns -1, 0, or 1 for A<B, A==B, or A>B, or BADINT if failure   */
/*  (the only possible failure is an allocation error, which can      */
/*  only occur if E!=0)                                               */
/* ------------------------------------------------------------------ */
static Int decUnitCompare(const Unit *a, Int alength,
                          const Unit *b, Int blength, Int exp) {
  Unit  *acc;                      // accumulator for result
  Unit  accbuff[SD2U(DECBUFFER*2+1)]; // local buffer
  Unit  *allocacc=NULL;            // -> allocated acc buffer, iff allocated
  Int   accunits, need;            // units in use or needed for acc
  const Unit *l, *r, *u;           // work
  Int   expunits, exprem, result;  // ..

  if (exp==0) {                    // aligned; fastpath
    if (alength>blength) return 1;
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
  Int  add;                        // work
  #if DECDPUN<=4                   // myriadal, millenary, etc.
  Int  est;                        // estimated quotient
  #endif

  #if DECTRACE
  if (alength<1 || blength<1)
    printf("decUnitAddSub: alen blen m %d %d [%d]\n", alength, blength, m);
  #endif

  maxC=c+alength;                  // A is usually the longer
  minC=c+blength;                  // .. and B the shorter
  if (bshift!=0) {                 // B is shifted; low As copy across
    minC+=bshift;
    // if in place [common], skip copy unless there's a gap [rare]







|







6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
  Int  add;                        // work
  #if DECDPUN<=4                   // myriadal, millenary, etc.
  Int  est;                        // estimated quotient
  #endif

  #if DECTRACE
  if (alength<1 || blength<1)
    printf("decUnitAddSub: alen blen m %ld %ld [%ld]\n", alength, blength, m);
  #endif

  maxC=c+alength;                  // A is usually the longer
  minC=c+blength;                  // .. and B the shorter
  if (bshift!=0) {                 // B is shifted; low As copy across
    minC+=bshift;
    // if in place [common], skip copy unless there's a gap [rare]
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166

5167
5168
5169
5170


5171
5172
5173
5174

5175
5176
5177
5178
5179
5180
5181
     else {
      *c=0;
      add=1;
      }
    }
  // add an extra unit iff it would be non-zero
  #if DECTRACE
    printf("UAS borrow: add %d, carry %d\n", add, carry);
  #endif
  if ((add-carry-1)!=0) {
    *c=(Unit)(add-carry-1);
    c++;                      // interesting, include it
    }
  return clsu-c;              // -ve result indicates borrowed
  } // decUnitAddSub

/* ------------------------------------------------------------------ */
/* decTrim -- trim trailing zeros or normalize                        */
/*                                                                    */
/*   dn is the number to trim or normalize                            */

/*   all is 1 to remove all trailing zeros, 0 for just fraction ones  */
/*   dropped returns the number of discarded trailing zeros           */
/*   returns dn                                                       */
/*                                                                    */


/* All fields are updated as required.  This is a utility operation,  */
/* so special values are unchanged and no error is possible.          */
/* ------------------------------------------------------------------ */
static decNumber * decTrim(decNumber *dn, Flag all, Int *dropped) {

  Int   d, exp;                    // work
  uInt  cut;                       // ..
  Unit  *up;                       // -> current Unit

  #if DECCHECK
  if (decCheckOperands(dn, DECUNUSED, DECUNUSED, DECUNUSED)) return dn;
  #endif







|












>




>
>



|
>







6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
     else {
      *c=0;
      add=1;
      }
    }
  // add an extra unit iff it would be non-zero
  #if DECTRACE
    printf("UAS borrow: add %ld, carry %ld\n", add, carry);
  #endif
  if ((add-carry-1)!=0) {
    *c=(Unit)(add-carry-1);
    c++;                      // interesting, include it
    }
  return clsu-c;              // -ve result indicates borrowed
  } // decUnitAddSub

/* ------------------------------------------------------------------ */
/* decTrim -- trim trailing zeros or normalize                        */
/*                                                                    */
/*   dn is the number to trim or normalize                            */
/*   set is the context to use to check for clamp                     */
/*   all is 1 to remove all trailing zeros, 0 for just fraction ones  */
/*   dropped returns the number of discarded trailing zeros           */
/*   returns dn                                                       */
/*                                                                    */
/* If clamp is set in the context then the number of zeros trimmed    */
/* may be limited if the exponent is high.                            */
/* All fields are updated as required.  This is a utility operation,  */
/* so special values are unchanged and no error is possible.          */
/* ------------------------------------------------------------------ */
static decNumber * decTrim(decNumber *dn, decContext *set, Flag all,
                           Int *dropped) {
  Int   d, exp;                    // work
  uInt  cut;                       // ..
  Unit  *up;                       // -> current Unit

  #if DECCHECK
  if (decCheckOperands(dn, DECUNUSED, DECUNUSED, DECUNUSED)) return dn;
  #endif
5210
5211
5212
5213
5214
5215
5216
5217







5218
5219
5220
5221
5222
5223
5224
5225




















5226
5227
5228
5229
5230
5231
5232
      }
    cut++;                         // next power
    if (cut>DECDPUN) {             // need new Unit
      up++;
      cut=1;
      }
    } // d
  if (d==0) return dn;             // none dropped








  // effect the drop
  decShiftToLeast(dn->lsu, D2U(dn->digits), d);
  dn->exponent+=d;                 // maintain numerical value
  dn->digits-=d;                   // new length
  *dropped=d;                      // report the count
  return dn;
  } // decTrim





















/* ------------------------------------------------------------------ */
/* decShiftToMost -- shift digits in array towards most significant   */
/*                                                                    */
/*   uar    is the array                                              */
/*   digits is the count of digits in use in the array                */
/*   shift  is the number of zeros to pad with (least significant);   */







|
>
>
>
>
>
>
>








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
      }
    cut++;                         // next power
    if (cut>DECDPUN) {             // need new Unit
      up++;
      cut=1;
      }
    } // d
  if (d==0) return dn;             // none to drop

  // may need to limit drop if clamping
  if (set->clamp) {
    Int maxd=set->emax-set->digits+1-dn->exponent;
    if (maxd<=0) return dn;        // nothing possible
    if (d>maxd) d=maxd;
    }

  // effect the drop
  decShiftToLeast(dn->lsu, D2U(dn->digits), d);
  dn->exponent+=d;                 // maintain numerical value
  dn->digits-=d;                   // new length
  *dropped=d;                      // report the count
  return dn;
  } // decTrim

/* ------------------------------------------------------------------ */
/* decReverse -- reverse a Unit array in place                        */
/*                                                                    */
/*   ulo    is the start of the array                                 */
/*   uhi    is the end of the array (highest Unit to include)         */
/*                                                                    */
/* The units ulo through uhi are reversed in place (if the number     */
/* of units is odd, the middle one is untouched).  Note that the      */
/* digit(s) in each unit are unaffected.                              */
/* ------------------------------------------------------------------ */
static void decReverse(Unit *ulo, Unit *uhi) {
  Unit temp;
  for (; ulo<uhi; ulo++, uhi--) {
    temp=*ulo;
    *ulo=*uhi;
    *uhi=temp;
    }
  return;
  } // decReverse

/* ------------------------------------------------------------------ */
/* decShiftToMost -- shift digits in array towards most significant   */
/*                                                                    */
/*   uar    is the array                                              */
/*   digits is the count of digits in use in the array                */
/*   shift  is the number of zeros to pad with (least significant);   */
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301




5302
5303
5304
5305
5306
5307
5308

/* ------------------------------------------------------------------ */
/* decShiftToLeast -- shift digits in array towards least significant */
/*                                                                    */
/*   uar   is the array                                               */
/*   units is length of the array, in units                           */
/*   shift is the number of digits to remove from the lsu end; it     */
/*     must be zero or positive and less than units*DECDPUN.          */
/*                                                                    */
/*   returns the new length of the integer in the array, in units     */
/*                                                                    */
/* Removed digits are discarded (lost).  Units not required to hold   */
/* the final result are unchanged.                                    */
/* ------------------------------------------------------------------ */
static Int decShiftToLeast(Unit *uar, Int units, Int shift) {
  Unit  *target, *up;              // work
  Int   cut, count;                // work
  Int   quot, rem;                 // for division

  if (shift==0) return units;      // [fastpath] nothing to do





  target=uar;                      // both paths
  cut=MSUDIGITS(shift);
  if (cut==DECDPUN) {              // unit-boundary case; easy
    up=uar+D2U(shift);
    for (; up<uar+units; target++, up++) *target=*up;
    return target-uar;







|












>
>
>
>







6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684

/* ------------------------------------------------------------------ */
/* decShiftToLeast -- shift digits in array towards least significant */
/*                                                                    */
/*   uar   is the array                                               */
/*   units is length of the array, in units                           */
/*   shift is the number of digits to remove from the lsu end; it     */
/*     must be zero or positive and <= than units*DECDPUN.            */
/*                                                                    */
/*   returns the new length of the integer in the array, in units     */
/*                                                                    */
/* Removed digits are discarded (lost).  Units not required to hold   */
/* the final result are unchanged.                                    */
/* ------------------------------------------------------------------ */
static Int decShiftToLeast(Unit *uar, Int units, Int shift) {
  Unit  *target, *up;              // work
  Int   cut, count;                // work
  Int   quot, rem;                 // for division

  if (shift==0) return units;      // [fastpath] nothing to do
  if (shift==units*DECDPUN) {      // [fastpath] little to do
    *uar=0;                        // all digits cleared gives zero
    return 1;                      // leaves just the one
    }

  target=uar;                      // both paths
  cut=MSUDIGITS(shift);
  if (cut==DECDPUN) {              // unit-boundary case; easy
    up=uar+D2U(shift);
    for (; up<uar+units; target++, up++) *target=*up;
    return target-uar;
5595
5596
5597
5598
5599
5600
5601
5602


5603
5604
5605
5606
5607
5608
5609
/*         guard and sticky information.  It may be:                  */
/*         6-9: rounding digit is >5                                  */
/*         5:   rounding digit is exactly half-way                    */
/*         1-4: rounding digit is <5 and >0                           */
/*         0:   the coefficient is exact                              */
/*        -1:   as 1, but the hidden digits are subtractive, that     */
/*              is, of the opposite sign to dn.  In this case the     */
/*              coefficient must be non-0.                            */


/*   status is the status accumulator, as usual                       */
/*                                                                    */
/* This routine applies rounding while keeping the length of the      */
/* coefficient constant.  The exponent and status are unchanged       */
/* except if:                                                         */
/*                                                                    */
/*   -- the coefficient was increased and is all nines (in which      */







|
>
>







6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
/*         guard and sticky information.  It may be:                  */
/*         6-9: rounding digit is >5                                  */
/*         5:   rounding digit is exactly half-way                    */
/*         1-4: rounding digit is <5 and >0                           */
/*         0:   the coefficient is exact                              */
/*        -1:   as 1, but the hidden digits are subtractive, that     */
/*              is, of the opposite sign to dn.  In this case the     */
/*              coefficient must be non-0.  This case occurs when     */
/*              subtracting a small number (which can be reduced to   */
/*              a sticky bit); see decAddOp.                          */
/*   status is the status accumulator, as usual                       */
/*                                                                    */
/* This routine applies rounding while keeping the length of the      */
/* coefficient constant.  The exponent and status are unchanged       */
/* except if:                                                         */
/*                                                                    */
/*   -- the coefficient was increased and is all nines (in which      */
5623
5624
5625
5626
5627
5628
5629












5630
5631
5632
5633
5634
5635
5636

  if (residue==0) return;     // nothing to apply

  bump=0;                     // assume a smooth ride

  // now decide whether, and how, to round, depending on mode
  switch (set->round) {












    case DEC_ROUND_DOWN: {
      // no change, except if negative residue
      if (residue<0) bump=-1;
      break;} // r-d

    case DEC_ROUND_HALF_DOWN: {
      if (residue>5) bump=1;







>
>
>
>
>
>
>
>
>
>
>
>







7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026

  if (residue==0) return;     // nothing to apply

  bump=0;                     // assume a smooth ride

  // now decide whether, and how, to round, depending on mode
  switch (set->round) {
    case DEC_ROUND_05UP: {    // round zero or five up (for reround)
      // This is the same as DEC_ROUND_DOWN unless there is a
      // positive residue and the lsd of dn is 0 or 5, in which case
      // it is bumped; when residue is <0, the number is therefore
      // bumped down unless the final digit was 1 or 6 (in which
      // case it is bumped down and then up -- a no-op)
      Int lsd5=*dn->lsu%5;     // get lsd and quintate
      if (residue<0 && lsd5!=1) bump=-1;
       else if (residue>0 && lsd5==0) bump=1;
      // [bump==1 could be applied directly; use common path for clarity]
      break;} // r-05

    case DEC_ROUND_DOWN: {
      // no change, except if negative residue
      if (residue<0) bump=-1;
      break;} // r-d

    case DEC_ROUND_HALF_DOWN: {
      if (residue>5) bump=1;
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
       else {
        if (residue>0) bump=1;
        }
      break;} // r-f

    default: {      // e.g., DEC_ROUND_MAX
      *status|=DEC_Invalid_context;
      #if DECTRACE
      printf("Unknown rounding mode: %d\n", set->round);
      #endif
      break;}
    } // switch

  // now bump the number, up or down, if need be
  if (bump==0) return;                       // no action required







|







7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
       else {
        if (residue>0) bump=1;
        }
      break;} // r-f

    default: {      // e.g., DEC_ROUND_MAX
      *status|=DEC_Invalid_context;
      #if DECTRACE || (DECCHECK && DECVERB)
      printf("Unknown rounding mode: %d\n", set->round);
      #endif
      break;}
    } // switch

  // now bump the number, up or down, if need be
  if (bump==0) return;                       // no action required
5816
5817
5818
5819
5820
5821
5822

5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834





5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845

5846
5847
5848
5849
5850
5851
5852
  // Must be careful, here, when checking the exponent as the
  // adjusted exponent could overflow 31 bits [because it may already
  // be up to twice the expected].

  // First test for subnormal.  This must be done before any final
  // round as the result could be rounded to Nmin or 0.
  if (dn->exponent<=tinyexp) {          // prefilter

    decNumber nmin;
    // A very nasty case here is dn == Nmin and residue<0
    if (dn->exponent<tinyexp) {
      // Go handle subnormals; this will apply round if needed.
      decSetSubnormal(dn, set, residue, status);
      return;
      }
    // Equals case: only subnormal if dn=Nmin and negative residue
    decNumberZero(&nmin);
    nmin.lsu[0]=1;
    nmin.exponent=set->emin;
    if (*residue<0 && decCompare(dn, &nmin, 1)==0) { // (signless compare)





      decApplyRound(dn, set, *residue, status);   // might force down
      decSetSubnormal(dn, set, residue, status);
      return;
      }
    }

  // now apply any pending round (this could raise overflow).
  if (*residue!=0) decApplyRound(dn, set, *residue, status);

  // Check for overflow [redundant in the 'rare' case] or clamp
  if (dn->exponent<=set->emax-set->digits+1) return;   // neither needed


  // here when might have an overflow or clamp to do
  if (dn->exponent>set->emax-dn->digits+1) {           // too big
    decSetOverflow(dn, set, status);
    return;
    }
  // here when the result is normal but in clamp range







>











|
>
>
>
>
>











>







7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
  // Must be careful, here, when checking the exponent as the
  // adjusted exponent could overflow 31 bits [because it may already
  // be up to twice the expected].

  // First test for subnormal.  This must be done before any final
  // round as the result could be rounded to Nmin or 0.
  if (dn->exponent<=tinyexp) {          // prefilter
    Int comp;
    decNumber nmin;
    // A very nasty case here is dn == Nmin and residue<0
    if (dn->exponent<tinyexp) {
      // Go handle subnormals; this will apply round if needed.
      decSetSubnormal(dn, set, residue, status);
      return;
      }
    // Equals case: only subnormal if dn=Nmin and negative residue
    decNumberZero(&nmin);
    nmin.lsu[0]=1;
    nmin.exponent=set->emin;
    comp=decCompare(dn, &nmin, 1);                // (signless compare)
    if (comp==BADINT) {                           // oops
      *status|=DEC_Insufficient_storage;          // abandon...
      return;
      }
    if (*residue<0 && comp==0) {                  // neg residue and dn==Nmin
      decApplyRound(dn, set, *residue, status);   // might force down
      decSetSubnormal(dn, set, residue, status);
      return;
      }
    }

  // now apply any pending round (this could raise overflow).
  if (*residue!=0) decApplyRound(dn, set, *residue, status);

  // Check for overflow [redundant in the 'rare' case] or clamp
  if (dn->exponent<=set->emax-set->digits+1) return;   // neither needed


  // here when might have an overflow or clamp to do
  if (dn->exponent>set->emax-dn->digits+1) {           // too big
    decSetOverflow(dn, set, status);
    return;
    }
  // here when the result is normal but in clamp range
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
  return;
  } // decFinalize

/* ------------------------------------------------------------------ */
/* decSetOverflow -- set number to proper overflow value              */
/*                                                                    */
/*   dn is the number (used for sign [only] and result)               */
/*   set is the context [used for the rounding mode]                  */
/*   status contains the current status to be updated                 */
/*                                                                    */
/* This sets the sign of a number and sets its value to either        */
/* Infinity or the maximum finite value, depending on the sign of     */
/* dn and therounding mode, following IEEE 854 rules.                 */
/* ------------------------------------------------------------------ */
static void decSetOverflow(decNumber *dn, decContext *set, uInt *status) {
  Flag needmax=0;                  // result is maximum finite value
  uByte sign=dn->bits&DECNEG;      // clean and save sign bit

  if (ISZERO(dn)) {                // zero does not overflow magnitude
    Int emax=set->emax;                      // limit value







|




|







7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
  return;
  } // decFinalize

/* ------------------------------------------------------------------ */
/* decSetOverflow -- set number to proper overflow value              */
/*                                                                    */
/*   dn is the number (used for sign [only] and result)               */
/*   set is the context [used for the rounding mode, etc.]            */
/*   status contains the current status to be updated                 */
/*                                                                    */
/* This sets the sign of a number and sets its value to either        */
/* Infinity or the maximum finite value, depending on the sign of     */
/* dn and the rounding mode, following IEEE 854 rules.                */
/* ------------------------------------------------------------------ */
static void decSetOverflow(decNumber *dn, decContext *set, uInt *status) {
  Flag needmax=0;                  // result is maximum finite value
  uByte sign=dn->bits&DECNEG;      // clean and save sign bit

  if (ISZERO(dn)) {                // zero does not overflow magnitude
    Int emax=set->emax;                      // limit value
5899
5900
5901
5902
5903
5904
5905
















5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
      break;} // r-c
    case DEC_ROUND_FLOOR: {
      if (!sign) needmax=1;        // Infinity if negative
      break;} // r-f
    default: break;                // Infinity in all other cases
    }
  if (needmax) {
















    Unit *up;                      // work
    Int count=set->digits;         // nines to add
    dn->digits=count;
    // fill in all nines to set maximum value
    for (up=dn->lsu; ; up++) {
      if (count>DECDPUN) *up=DECDPUNMAX;     // unit full o'nines
       else {                                // this is the msu
        *up=(Unit)(powers[count]-1);
        break;
        }
      count-=DECDPUN;              // filled those digits
      } // up
    dn->bits=sign;                 // sign
    dn->exponent=set->emax-set->digits+1;
    }
   else dn->bits=sign|DECINF;      // Value is +/-Infinity
  *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  } // decSetOverflow

/* ------------------------------------------------------------------ */
/* decSetSubnormal -- process value whose exponent is <Emin           */
/*                                                                    */
/*   dn is the number (used as input as well as output; it may have   */
/*         an allowed subnormal value, which may need to be rounded)  */
/*   set is the context [used for the rounding mode]                  */







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
|







7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332



7333
7334
7335
7336
7337
7338
7339
7340
      break;} // r-c
    case DEC_ROUND_FLOOR: {
      if (!sign) needmax=1;        // Infinity if negative
      break;} // r-f
    default: break;                // Infinity in all other cases
    }
  if (needmax) {
    decSetMaxValue(dn, set);
    dn->bits=sign;                 // set sign
    }
   else dn->bits=sign|DECINF;      // Value is +/-Infinity
  *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  } // decSetOverflow

/* ------------------------------------------------------------------ */
/* decSetMaxValue -- set number to +Nmax (maximum normal value)       */
/*                                                                    */
/*   dn is the number to set                                          */
/*   set is the context [used for digits and emax]                    */
/*                                                                    */
/* This sets the number to the maximum positive value.                */
/* ------------------------------------------------------------------ */
static void decSetMaxValue(decNumber *dn, decContext *set) {
  Unit *up;                        // work
  Int count=set->digits;           // nines to add
  dn->digits=count;
  // fill in all nines to set maximum value
  for (up=dn->lsu; ; up++) {
    if (count>DECDPUN) *up=DECDPUNMAX;  // unit full o'nines
     else {                             // this is the msu
      *up=(Unit)(powers[count]-1);
      break;
      }
    count-=DECDPUN;                // filled those digits
    } // up
  dn->bits=0;                      // + sign
  dn->exponent=set->emax-set->digits+1;



  } // decSetMaxValue

/* ------------------------------------------------------------------ */
/* decSetSubnormal -- process value whose exponent is <Emin           */
/*                                                                    */
/*   dn is the number (used as input as well as output; it may have   */
/*         an allowed subnormal value, which may need to be rounded)  */
/*   set is the context [used for the rounding mode]                  */
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
  // (Etiny) if needed
  etiny=set->emin-(set->digits-1);      // smallest allowed exponent

  if ISZERO(dn) {                       // value is zero
    // residue can never be non-zero here
    #if DECCHECK
      if (*residue!=0) {
        printf("++ Subnormal 0 residue %d\n", *residue);
        *status|=DEC_Invalid_operation;
        }
    #endif
    if (dn->exponent<etiny) {           // clamp required
      dn->exponent=etiny;
      *status|=DEC_Clamped;
      }







|







7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
  // (Etiny) if needed
  etiny=set->emin-(set->digits-1);      // smallest allowed exponent

  if ISZERO(dn) {                       // value is zero
    // residue can never be non-zero here
    #if DECCHECK
      if (*residue!=0) {
        printf("++ Subnormal 0 residue %ld\n", *residue);
        *status|=DEC_Invalid_operation;
        }
    #endif
    if (dn->exponent<etiny) {           // clamp required
      dn->exponent=etiny;
      *status|=DEC_Clamped;
      }
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
/* decGetInt -- get integer from a number                             */
/*                                                                    */
/*   dn is the number [which will not be altered]                     */
/*                                                                    */
/*   returns one of:                                                  */
/*     BADINT if there is a non-zero fraction                         */
/*     the converted integer                                          */
/*     BIGEVEN if the integer is even and > 2*10**9                   */
/*     BIGODD  if the integer is odd  and > 2*10**9                   */
/*                                                                    */
/* This checks and gets a whole number from the input decNumber.      */
/* The sign can be determined from dn by the caller when BIGEVEN or   */
/* BIGODD is returned.                                                */
/* ------------------------------------------------------------------ */
static Int decGetInt(const decNumber *dn) {
  Int  theInt;                          // result accumulator







|
|







7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
/* decGetInt -- get integer from a number                             */
/*                                                                    */
/*   dn is the number [which will not be altered]                     */
/*                                                                    */
/*   returns one of:                                                  */
/*     BADINT if there is a non-zero fraction                         */
/*     the converted integer                                          */
/*     BIGEVEN if the integer is even and magnitude > 2*10**9         */
/*     BIGODD  if the integer is odd  and magnitude > 2*10**9         */
/*                                                                    */
/* This checks and gets a whole number from the input decNumber.      */
/* The sign can be determined from dn by the caller when BIGEVEN or   */
/* BIGODD is returned.                                                */
/* ------------------------------------------------------------------ */
static Int decGetInt(const decNumber *dn) {
  Int  theInt;                          // result accumulator
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140

6141
6142


6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154

6155

6156
6157
6158
6159
6160
6161
6162
6163

6164
6165

6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
    }

  if (neg) theInt=-theInt;              // apply sign
  return theInt;
  } // decGetInt

/* ------------------------------------------------------------------ */
/* decPutInt -- put integer into a number                             */
/*                                                                    */
/*   res is the target number, with enough space for the biggest      */
/*       integer that the second argument will be                     */
/*   in  is the input integer                                         */

/*                                                                    */
/* Returns res, an integral value; no error is possible.              */


/* ------------------------------------------------------------------ */
static decNumber *decPutInt(decNumber *res, Int in) {
  Unit *up;                             // work pointer

  decNumberZero(res);                   // clean
  if (in<=0) {                          // handle sign, 0, and BADINT
    if (in==0) return res;              // easy
     else if (in!=BADINT) {
      res->bits=DECNEG;                 // set sign
      in=-in;                           // invert and drop through
      }
     else {                             // BADINT: invert would fail

      decContext set;

      decContextDefault(&set, DEC_INIT_DECIMAL64);     // 16 digits
      decNumberFromString(res, "-2147483648", &set);   // ugh
      return res;
      }
    }
  // in is now positive
  for (up=res->lsu; in>0; up++) {
    *up=(Unit)(in%(DECDPUNMAX+1));

    in=in/(DECDPUNMAX+1);
    }

  res->digits=decGetDigits(res->lsu, up-res->lsu);
  return res;
  } // decPutInt

/* ------------------------------------------------------------------ */
/* decBiStr -- compare string with pairwise options                   */
/*                                                                    */
/*   targ is the string to compare                                    */
/*   str1 is one of the strings to compare against (length may be 0)  */
/*   str2 is the other; it must be the same length as str1            */







|

|
|
|
>

|
>
>

|
|
<
|
|
|
|
<
<
<
<
>
|
>
|
<
|
|
<
<
|
<
>
|
<
>
|
|
|







7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558

7559
7560
7561
7562




7563
7564
7565
7566

7567
7568


7569

7570
7571

7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
    }

  if (neg) theInt=-theInt;              // apply sign
  return theInt;
  } // decGetInt

/* ------------------------------------------------------------------ */
/* decDecap -- decapitate the coefficient of a number                 */
/*                                                                    */
/*   dn   is the number to be decapitated                             */
/*   drop is the number of digits to be removed from the left of dn;  */
/*     this must be <= dn->digits (if equal, the coefficient is       */
/*     set to 0)                                                      */
/*                                                                    */
/* Returns dn; dn->digits will be <= the initial digits less drop     */
/* (after removing drop digits there may be leading zero digits       */
/* which will also be removed).  Only dn->lsu and dn->digits change.  */
/* ------------------------------------------------------------------ */
static decNumber *decDecap(decNumber *dn, Int drop) {
  Unit *msu;                            // -> target cut point

  Int cut;                              // work
  if (drop>=dn->digits) {               // losing the whole thing
    #if DECCHECK
    if (drop>dn->digits)




      printf("decDecap called with drop>digits [%ld>%ld]\n", drop, dn->digits);
    #endif
    dn->lsu[0]=0;
    dn->digits=1;

    return dn;
    }


  msu=dn->lsu+D2U(dn->digits-drop)-1;   // -> likely msu

  cut=MSUDIGITS(dn->digits-drop);       // digits to be in use in msu
  if (cut!=DECDPUN) *msu%=powers[cut];  // clear left digits

  // that may have left leading zero digits, so do a proper count...
  dn->digits=decGetDigits(dn->lsu, msu-dn->lsu+1);
  return dn;
  } // decDecap

/* ------------------------------------------------------------------ */
/* decBiStr -- compare string with pairwise options                   */
/*                                                                    */
/*   targ is the string to compare                                    */
/*   str1 is one of the strings to compare against (length may be 0)  */
/*   str2 is the other; it must be the same length as str1            */
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199

6200
6201
6202
6203
6204
6205
6206
6207
6208

6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220

6221












6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
    } // forever
  return 1;
  } // decBiStr

/* ------------------------------------------------------------------ */
/* decNaNs -- handle NaN operand or operands                          */
/*                                                                    */
/*   res    is the result number                                      */
/*   lhs    is the first operand                                      */
/*   rhs    is the second operand, or NULL if none                    */

/*   status contains the current status                               */
/*   returns res in case convenient                                   */
/*                                                                    */
/* Called when one or both operands is a NaN, and propagates the      */
/* appropriate result to res.  When an sNaN is found, it is changed   */
/* to a qNaN and Invalid operation is set.                            */
/* ------------------------------------------------------------------ */
static decNumber * decNaNs(decNumber *res, const decNumber *lhs,
                           const decNumber *rhs, uInt *status) {

  // This decision tree ends up with LHS being the source pointer,
  // and status updated if need be
  if (lhs->bits & DECSNAN)
    *status|=DEC_Invalid_operation | DEC_sNaN;
   else if (rhs==NULL);
   else if (rhs->bits & DECSNAN) {
    lhs=rhs;
    *status|=DEC_Invalid_operation | DEC_sNaN;
    }
   else if (lhs->bits & DECNAN);
   else lhs=rhs;


  decNumberCopy(res, lhs);












  res->bits&=~DECSNAN;        // convert any sNaN to NaN, while
  res->bits|=DECNAN;          // .. preserving sign
  res->exponent=0;            // clean exponent
                              // [coefficient was copied]
  return res;
  } // decNaNs

/* ------------------------------------------------------------------ */
/* decStatus -- apply non-zero status                                 */
/*                                                                    */
/*   dn     is the number to set if error                             */







|
|
|
>
|







|
>












>
|
>
>
>
>
>
>
>
>
>
>
>
>



|







7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
    } // forever
  return 1;
  } // decBiStr

/* ------------------------------------------------------------------ */
/* decNaNs -- handle NaN operand or operands                          */
/*                                                                    */
/*   res     is the result number                                     */
/*   lhs     is the first operand                                     */
/*   rhs     is the second operand, or NULL if none                   */
/*   context is used to limit payload length                          */
/*   status  contains the current status                              */
/*   returns res in case convenient                                   */
/*                                                                    */
/* Called when one or both operands is a NaN, and propagates the      */
/* appropriate result to res.  When an sNaN is found, it is changed   */
/* to a qNaN and Invalid operation is set.                            */
/* ------------------------------------------------------------------ */
static decNumber * decNaNs(decNumber *res, const decNumber *lhs,
                           const decNumber *rhs, decContext *set,
                           uInt *status) {
  // This decision tree ends up with LHS being the source pointer,
  // and status updated if need be
  if (lhs->bits & DECSNAN)
    *status|=DEC_Invalid_operation | DEC_sNaN;
   else if (rhs==NULL);
   else if (rhs->bits & DECSNAN) {
    lhs=rhs;
    *status|=DEC_Invalid_operation | DEC_sNaN;
    }
   else if (lhs->bits & DECNAN);
   else lhs=rhs;

  // propagate the payload
  if (lhs->digits<=set->digits) decNumberCopy(res, lhs); // easy
   else { // too long
    const Unit *ul;
    Unit *ur, *uresp1;
    // copy safe number of units, then decapitate
    res->bits=lhs->bits;                // need sign etc.
    uresp1=res->lsu+D2U(set->digits);
    for (ur=res->lsu, ul=lhs->lsu; ur<uresp1; ur++, ul++) *ur=*ul;
    res->digits=D2U(set->digits)*DECDPUN;
    // maybe still too long
    if (res->digits>set->digits) decDecap(res, res->digits-set->digits);
    }

  res->bits&=~DECSNAN;        // convert any sNaN to NaN, while
  res->bits|=DECNAN;          // .. preserving sign
  res->exponent=0;            // clean exponent
                              // [coefficient was copied/decapitated]
  return res;
  } // decNaNs

/* ------------------------------------------------------------------ */
/* decStatus -- apply non-zero status                                 */
/*                                                                    */
/*   dn     is the number to set if error                             */
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276




6277
6278
6279
6280
6281
6282
6283
  } // decStatus

/* ------------------------------------------------------------------ */
/* decGetDigits -- count digits in a Units array                      */
/*                                                                    */
/*   uar is the Unit array holding the number (this is often an       */
/*          accumulator of some sort)                                 */
/*   len is the length of the array in units                          */
/*                                                                    */
/*   returns the number of (significant) digits in the array          */
/*                                                                    */
/* All leading zeros are excluded, except the last if the array has   */
/* only zero Units.                                                   */
/* ------------------------------------------------------------------ */
// This may be called twice during some operations.
static Int decGetDigits(Unit *uar, Int len) {
  Unit *up=uar+(len-1);            // -> msu
  Int  digits=(len-1)*DECDPUN+1;   // possible digits excluding msu
                                   // (at least 1 in final msu)
  #if DECDPUN>4
  uInt const *pow;                 // work
  #endif





  for (; up>=uar; up--) {
    if (*up==0) {                  // unit is all 0s
      if (digits==1) break;        // a zero has one digit
      digits-=DECDPUN;             // adjust for 0 unit
      continue;}
    // found the first (most significant) non-zero Unit







|










<



>
>
>
>







7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694

7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
  } // decStatus

/* ------------------------------------------------------------------ */
/* decGetDigits -- count digits in a Units array                      */
/*                                                                    */
/*   uar is the Unit array holding the number (this is often an       */
/*          accumulator of some sort)                                 */
/*   len is the length of the array in units [>=1]                    */
/*                                                                    */
/*   returns the number of (significant) digits in the array          */
/*                                                                    */
/* All leading zeros are excluded, except the last if the array has   */
/* only zero Units.                                                   */
/* ------------------------------------------------------------------ */
// This may be called twice during some operations.
static Int decGetDigits(Unit *uar, Int len) {
  Unit *up=uar+(len-1);            // -> msu
  Int  digits=(len-1)*DECDPUN+1;   // possible digits excluding msu

  #if DECDPUN>4
  uInt const *pow;                 // work
  #endif
                                   // (at least 1 in final msu)
  #if DECCHECK
  if (len<1) printf("decGetDigits called with len<1 [%ld]\n", len);
  #endif

  for (; up>=uar; up--) {
    if (*up==0) {                  // unit is all 0s
      if (digits==1) break;        // a zero has one digit
      digits-=DECDPUN;             // adjust for 0 unit
      continue;}
    // found the first (most significant) non-zero Unit
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
    #endif
    #endif
    #endif
    break;
    } // up
  return digits;
  } // decGetDigits


#if DECTRACE | DECCHECK
/* ------------------------------------------------------------------ */
/* decNumberShow -- display a number [debug aid]                      */
/*   dn is the number to show                                         */
/*                                                                    */
/* Shows: sign, exponent, coefficient (msu first), digits             */







<







7721
7722
7723
7724
7725
7726
7727

7728
7729
7730
7731
7732
7733
7734
    #endif
    #endif
    #endif
    break;
    } // up
  return digits;
  } // decGetDigits


#if DECTRACE | DECCHECK
/* ------------------------------------------------------------------ */
/* decNumberShow -- display a number [debug aid]                      */
/*   dn is the number to show                                         */
/*                                                                    */
/* Shows: sign, exponent, coefficient (msu first), digits             */
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
      return;}
    // drop through to report other information
    printf(" ");
    }

  // now carefully display the coefficient
  up=dn->lsu+D2U(dn->digits)-1;         // msu
  printf("%d", *up);
  for (up=up-1; up>=dn->lsu; up--) {
    u=*up;
    printf(":");
    for (cut=DECDPUN-1; cut>=0; cut--) {
      d=u/powers[cut];
      u-=d*powers[cut];
      printf("%d", d);
      } // cut
    } // up
  if (dn->exponent!=0) {
    char esign='+';
    if (dn->exponent<0) esign='-';
    printf(" E%c%d", esign, abs(dn->exponent));
    }
  printf(" [%d]\n", dn->digits);
  } // decNumberShow
#endif

#if DECTRACE || DECCHECK
/* ------------------------------------------------------------------ */
/* decDumpAr -- display a unit array [debug aid]                      */
/*   name is a single-character tag name                              */







|






|







|







7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
      return;}
    // drop through to report other information
    printf(" ");
    }

  // now carefully display the coefficient
  up=dn->lsu+D2U(dn->digits)-1;         // msu
  printf("%ld", (Int)*up);
  for (up=up-1; up>=dn->lsu; up--) {
    u=*up;
    printf(":");
    for (cut=DECDPUN-1; cut>=0; cut--) {
      d=u/powers[cut];
      u-=d*powers[cut];
      printf("%ld", d);
      } // cut
    } // up
  if (dn->exponent!=0) {
    char esign='+';
    if (dn->exponent<0) esign='-';
    printf(" E%c%d", esign, abs(dn->exponent));
    }
  printf(" [%ld]\n", dn->digits);
  } // decNumberShow
#endif

#if DECTRACE || DECCHECK
/* ------------------------------------------------------------------ */
/* decDumpAr -- display a unit array [debug aid]                      */
/*   name is a single-character tag name                              */
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
  #elif DECDPUN==2
    char *spec="%02d ";
  #else
    char *spec="%d ";
  #endif
  printf("  :%c: ", name);
  for (i=len-1; i>=0; i--) {
    if (i==len-1) printf("%d ", ar[i]);
     else printf(spec, ar[i]);
    }
  printf("\n");
  return;}
#endif

#if DECCHECK







|







7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
  #elif DECDPUN==2
    char *spec="%02d ";
  #else
    char *spec="%d ";
  #endif
  printf("  :%c: ", name);
  for (i=len-1; i>=0; i--) {
    if (i==len-1) printf("%ld ", (Int)ar[i]);
     else printf(spec, ar[i]);
    }
  printf("\n");
  return;}
#endif

#if DECCHECK
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429

6430
6431
6432
6433
6434
6435
6436
6437
/*     handle this so res=NULL case is safe.                          */
/* The caller is expected to abandon immediately if 1 is returned.    */
/* ------------------------------------------------------------------ */
static Flag decCheckOperands(decNumber *res, const decNumber *lhs,
                             const decNumber *rhs, decContext *set) {
  Flag bad=0;
  if (set==NULL) {                 // oops; hopeless
    #if DECTRACE
    printf("Context is NULL.\n");
    #endif
    bad=1;
    return 1;}
   else if (set!=DECUNUSED
     && (set->digits<1 || set->round<0 || set->round>=DEC_ROUND_MAX)) {
    bad=1;
    #if DECTRACE
    printf("Bad context [digits=%d round=%d].\n", set->digits, set->round);
    #endif
    }
   else {
    if (res==NULL) {
      bad=1;
      #if DECTRACE

      printf("Bad result [is NULL].\n");
      #endif
      }
    if (!bad && lhs!=DECUNUSED) bad=(decCheckNumber(lhs, set));
    if (!bad && rhs!=DECUNUSED) bad=(decCheckNumber(rhs, set));
    }
  if (bad) {
    if (set!=DECUNUSED) decContextSetStatus(set, DEC_Invalid_operation);







|
|






|
|






>
|







7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
/*     handle this so res=NULL case is safe.                          */
/* The caller is expected to abandon immediately if 1 is returned.    */
/* ------------------------------------------------------------------ */
static Flag decCheckOperands(decNumber *res, const decNumber *lhs,
                             const decNumber *rhs, decContext *set) {
  Flag bad=0;
  if (set==NULL) {                 // oops; hopeless
    #if DECTRACE || DECVERB
    printf("Reference to context is NULL.\n");
    #endif
    bad=1;
    return 1;}
   else if (set!=DECUNUSED
     && (set->digits<1 || set->round<0 || set->round>=DEC_ROUND_MAX)) {
    bad=1;
    #if DECTRACE || DECVERB
    printf("Bad context [digits=%ld round=%d].\n", set->digits, set->round);
    #endif
    }
   else {
    if (res==NULL) {
      bad=1;
      #if DECTRACE
      // this one not DECVERB as standard tests include NULL
      printf("Reference to result is NULL.\n");
      #endif
      }
    if (!bad && lhs!=DECUNUSED) bad=(decCheckNumber(lhs, set));
    if (!bad && rhs!=DECUNUSED) bad=(decCheckNumber(rhs, set));
    }
  if (bad) {
    if (set!=DECUNUSED) decContextSetStatus(set, DEC_Invalid_operation);
6456
6457
6458
6459
6460
6461
6462

6463
6464
6465
6466
6467
6468
6469
6470
6471

6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558

6559
6560
6561
6562
6563
6564
6565
6566
6567
6568

6569
6570
6571
6572
6573
6574
6575
  const Unit *up;             // work
  uInt maxuint;               // ..
  Int ae, d, digits;          // ..
  Int emin, emax;             // ..

  if (dn==NULL) {             // hopeless
    #if DECTRACE

    printf("Reference to decNumber is NULL.\n");
    #endif
    return 1;}

  // check special values
  if (dn->bits & DECSPECIAL) {
    if (dn->exponent!=0) {
      #if DECTRACE
      printf("Exponent %d (not 0) for a special value.\n", dn->exponent);

      #endif
      return 1;}

    // 2003.09.08: NaNs may now have coefficients, so next tests Inf only
    if (decNumberIsInfinite(dn)) {
      if (dn->digits!=1) {
        #if DECTRACE
        printf("Digits %d (not 1) for an infinity.\n", dn->digits);
        #endif
        return 1;}
      if (*dn->lsu!=0) {
        #if DECTRACE
        printf("LSU %d (not 0) for an infinity.\n", *dn->lsu);
        #endif
        return 1;}
      } // Inf
    // 2002.12.26: negative NaNs can now appear through proposed IEEE
    //             concrete formats (decimal64, etc.), though they are
    //             never visible in strings.
    return 0;

    // if ((dn->bits & DECINF) || (dn->bits & DECNEG)==0) return 0;
    // #if DECTRACE
    // printf("Negative NaN in number.\n");
    // #endif
    // return 1;
    }

  // check the coefficient
  if (dn->digits<1 || dn->digits>DECNUMMAXP) {
    #if DECTRACE
    printf("Digits %d in number.\n", dn->digits);
    #endif
    return 1;}

  d=dn->digits;

  for (up=dn->lsu; d>0; up++) {
    if (d>DECDPUN) maxuint=DECDPUNMAX;
     else {                   // reached the msu
      maxuint=powers[d]-1;
      if (dn->digits>1 && *up<powers[d-1]) {
        #if DECTRACE
        printf("Leading 0 in number.\n");
        decNumberShow(dn);
        #endif
        return 1;}
      }
    if (*up>maxuint) {
      #if DECTRACE
      printf("Bad Unit [%08x] in %d-digit number at offset %d [maxuint %d].\n",
              *up, dn->digits, up-dn->lsu, maxuint);
      #endif
      return 1;}
    d-=DECDPUN;
    }

  // check the exponent.  Note that input operands can have exponents
  // which are out of the set->emin/set->emax and set->digits range
  // (just as they can have more digits than set->digits).
  ae=dn->exponent+dn->digits-1;    // adjusted exponent
  emax=DECNUMMAXE;
  emin=DECNUMMINE;
  digits=DECNUMMAXP;
  if (ae<emin-(digits-1)) {
    #if DECTRACE
    printf("Adjusted exponent underflow [%d].\n", ae);
    decNumberShow(dn);
    #endif
    return 1;}
  if (ae>+emax) {
    #if DECTRACE
    printf("Adjusted exponent overflow [%d].\n", ae);
    decNumberShow(dn);
    #endif
    return 1;}

  return 0;              // it's OK
  } // decCheckNumber


/* ------------------------------------------------------------------ */
/* decCheckInexact -- check a normal finite inexact result has digits */
/*   dn is the number to check                                        */
/*   set is the context (for status and precision)                    */
/*   sets Invalid operation, etc., if some digits are missing         */
/* [this check is not made for DECSUBSET compilation]                 */

/* ------------------------------------------------------------------ */
static void decCheckInexact(const decNumber *dn, decContext *set) {
  #if !DECSUBSET
    if ((set->status & (DEC_Inexact|DEC_Subnormal))==DEC_Inexact
     && (set->digits!=dn->digits) && !(dn->bits & DECSPECIAL)) {
      decContextSetStatus(set, DEC_Invalid_operation);
      #if DECTRACE
      printf("Insufficient digits [%d] on normal Inexact result.\n", dn->digits);
      decNumberShow(dn);
      #endif

      }
  #endif
  return;
  } // decCheckInexact
#endif

#if DECALLOC







>







|
|
>






|
|



|
|




|
<

<
<
<
<
<
<




|
|










|






|
|
|













|
|




|
|







<





|
>


|


<
|
|


>







7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916

7917






7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971

7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983

7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
  const Unit *up;             // work
  uInt maxuint;               // ..
  Int ae, d, digits;          // ..
  Int emin, emax;             // ..

  if (dn==NULL) {             // hopeless
    #if DECTRACE
    // this one not DECVERB as standard tests include NULL
    printf("Reference to decNumber is NULL.\n");
    #endif
    return 1;}

  // check special values
  if (dn->bits & DECSPECIAL) {
    if (dn->exponent!=0) {
      #if DECTRACE || DECVERB
      printf("Exponent %ld (not 0) for a special value [%02x].\n",
        dn->exponent, dn->bits);
      #endif
      return 1;}

    // 2003.09.08: NaNs may now have coefficients, so next tests Inf only
    if (decNumberIsInfinite(dn)) {
      if (dn->digits!=1) {
        #if DECTRACE || DECVERB
        printf("Digits %ld (not 1) for an infinity.\n", dn->digits);
        #endif
        return 1;}
      if (*dn->lsu!=0) {
        #if DECTRACE || DECVERB
        printf("LSU %ld (not 0) for an infinity.\n", (Int)*dn->lsu);
        #endif
        return 1;}
      } // Inf
    // 2002.12.26: negative NaNs can now appear through proposed IEEE
    //             concrete formats (decimal64, etc.).

    return 0;






    }

  // check the coefficient
  if (dn->digits<1 || dn->digits>DECNUMMAXP) {
    #if DECTRACE || DECVERB
    printf("Digits %ld in number.\n", dn->digits);
    #endif
    return 1;}

  d=dn->digits;

  for (up=dn->lsu; d>0; up++) {
    if (d>DECDPUN) maxuint=DECDPUNMAX;
     else {                   // reached the msu
      maxuint=powers[d]-1;
      if (dn->digits>1 && *up<powers[d-1]) {
        #if DECTRACE || DECVERB
        printf("Leading 0 in number.\n");
        decNumberShow(dn);
        #endif
        return 1;}
      }
    if (*up>maxuint) {
      #if DECTRACE || DECVERB
      printf("Bad Unit [%08lx] in %ld-digit number at offset %ld [maxuint %ld].\n",
              (Int)*up, dn->digits, (Int)(up-dn->lsu), maxuint);
      #endif
      return 1;}
    d-=DECDPUN;
    }

  // check the exponent.  Note that input operands can have exponents
  // which are out of the set->emin/set->emax and set->digits range
  // (just as they can have more digits than set->digits).
  ae=dn->exponent+dn->digits-1;    // adjusted exponent
  emax=DECNUMMAXE;
  emin=DECNUMMINE;
  digits=DECNUMMAXP;
  if (ae<emin-(digits-1)) {
    #if DECTRACE || DECVERB
    printf("Adjusted exponent underflow [%ld].\n", ae);
    decNumberShow(dn);
    #endif
    return 1;}
  if (ae>+emax) {
    #if DECTRACE || DECVERB
    printf("Adjusted exponent overflow [%ld].\n", ae);
    decNumberShow(dn);
    #endif
    return 1;}

  return 0;              // it's OK
  } // decCheckNumber


/* ------------------------------------------------------------------ */
/* decCheckInexact -- check a normal finite inexact result has digits */
/*   dn is the number to check                                        */
/*   set is the context (for status and precision)                    */
/*   sets Invalid operation, etc., if some digits are missing         */
/* [this check is not made for DECSUBSET compilation or when          */
/* subnormal is not set]                                              */
/* ------------------------------------------------------------------ */
static void decCheckInexact(const decNumber *dn, decContext *set) {
  #if !DECSUBSET && DECEXTFLAG
    if ((set->status & (DEC_Inexact|DEC_Subnormal))==DEC_Inexact
     && (set->digits!=dn->digits) && !(dn->bits & DECSPECIAL)) {

      #if DECTRACE || DECVERB
      printf("Insufficient digits [%ld] on normal Inexact result.\n", dn->digits);
      decNumberShow(dn);
      #endif
      decContextSetStatus(set, DEC_Invalid_operation);
      }
  #endif
  return;
  } // decCheckInexact
#endif

#if DECALLOC
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611

  alloc=malloc(size);              // -> allocated storage
  if (alloc==NULL) return NULL;    // out of strorage
  b0=(uByte *)alloc;               // as bytes
  decAllocBytes+=n;                // account for storage
  j=(uInt *)alloc;                 // -> first four bytes
  *j=n;                            // save n
  // printf(" allo ++ dAB: %d (%d)\n", decAllocBytes, n);
  for (b=b0+4; b<b0+8; b++) *b=DECFENCE;
  for (b=b0+n+8; b<b0+n+12; b++) *b=DECFENCE;
  return b0+8;                     // -> play area
  } // decMalloc

/* ------------------------------------------------------------------ */
/* decFree -- accountable free routine                                */







|







8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031

  alloc=malloc(size);              // -> allocated storage
  if (alloc==NULL) return NULL;    // out of strorage
  b0=(uByte *)alloc;               // as bytes
  decAllocBytes+=n;                // account for storage
  j=(uInt *)alloc;                 // -> first four bytes
  *j=n;                            // save n
  // printf(" alloc ++ dAB: %ld (%d)\n", decAllocBytes, n);
  for (b=b0+4; b<b0+8; b++) *b=DECFENCE;
  for (b=b0+n+8; b<b0+n+12; b++) *b=DECFENCE;
  return b0+8;                     // -> play area
  } // decMalloc

/* ------------------------------------------------------------------ */
/* decFree -- accountable free routine                                */
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643

  if (alloc==NULL) return;         // allowed; it's a nop
  b0=(uByte *)alloc;               // as bytes
  b0-=8;                           // -> true start of storage
  j=(uInt *)b0;                    // -> first four bytes
  n=*j;                            // lift
  for (b=b0+4; b<b0+8; b++) if (*b!=DECFENCE)
    printf("=== Corrupt byte [%02x] at offset %d from %d ===\n", *b,
           b-b0-8, (Int)b0);
  for (b=b0+n+8; b<b0+n+12; b++) if (*b!=DECFENCE)
    printf("=== Corrupt byte [%02x] at offset +%d from %d, n=%d ===\n", *b,
           b-b0-8, (Int)b0, n);
  free(b0);                        // drop the storage
  decAllocBytes-=n;                // account for storage
  // printf(" free -- dAB: %d (%d)\n", decAllocBytes, -n);
  } // decFree
#define malloc(a) decMalloc(a)
#define free(a) decFree(a)
#endif







|


|








8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063

  if (alloc==NULL) return;         // allowed; it's a nop
  b0=(uByte *)alloc;               // as bytes
  b0-=8;                           // -> true start of storage
  j=(uInt *)b0;                    // -> first four bytes
  n=*j;                            // lift
  for (b=b0+4; b<b0+8; b++) if (*b!=DECFENCE)
    printf("=== Corrupt byte [%02x] at offset %d from %ld ===\n", *b,
           b-b0-8, (Int)b0);
  for (b=b0+n+8; b<b0+n+12; b++) if (*b!=DECFENCE)
    printf("=== Corrupt byte [%02x] at offset +%d from %ld, n=%ld ===\n", *b,
           b-b0-8, (Int)b0, n);
  free(b0);                        // drop the storage
  decAllocBytes-=n;                // account for storage
  // printf(" free -- dAB: %d (%d)\n", decAllocBytes, -n);
  } // decFree
#define malloc(a) decMalloc(a)
#define free(a) decFree(a)
#endif

Changes to decNumber/decNumber.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

72
73
74
75
76
77
78
79
80
81
82

83
84
85
86

87
88
89
90
91


























92
93
94
95
96


97
98
99




100
101
102
103

104

105

106
107
108


109

110
111

112

113
114
115

116
117
118
119
120
121

122


123
124

125

126
127


128






129
130
131
132
133
134

135


136


137
138
139
140

141

142

143
144
/* ------------------------------------------------------------------ */
/* Decimal Number arithmetic module header                            */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2006.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is called decNumber.pdf.  This document is           */
/* available, together with arithmetic and format specifications,     */
/* testcases, and Web links, at: http://www2.hursley.ibm.com/decimal  */
/*                                                                    */
/* Please send comments, suggestions, and corrections to the author:  */
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */

#if !defined(DECNUMBER)
  #define DECNUMBER
  #define DECNAME     "decNumber"                       /* Short name */
  #define DECVERSION  "decNumber 3.37"           /* Version [16 max.] */
  #define DECFULLNAME "Decimal Number Module"         /* Verbose name */
  #define DECAUTHOR   "Mike Cowlishaw"                /* Who to blame */

  #if !defined(DECCONTEXT)
    #include "decContext.h"
  #endif

  // Bit settings for decNumber.bits
  #define DECNEG    0x80        // Sign; 1=negative, 0=positive or zero
  #define DECINF    0x40        // 1=Infinity
  #define DECNAN    0x20        // 1=NaN
  #define DECSNAN   0x10        // 1=sNaN
  // The remaining bits are reserved; they must be 0
  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) // any special value

  // Define the decNumber data structure.  The size and shape of the
  // units array in the structure is determined by the following
  // constant.  This must not be changed without recompiling the
  // decNumber library modules.

  #define DECDPUN 3                // DECimal Digits Per UNit [must be in
                                   // range 1-9; 3 or powers of 2 are best].

  // DECNUMDIGITS is the default number of digits that can be held in
  // the structure.  If undefined, 1 is assumed and it is assumed that
  // the structure will be immediately followed by extra space, as
  // required.  DECNUMDIGITS is always >0.
  #if !defined(DECNUMDIGITS)
    #define DECNUMDIGITS 1
  #endif

  // The size (integer data type) of each unit is determined by the
  // number of digits it will hold.
  #if   DECDPUN<=2
    #define decNumberUnit uint8_t
  #elif DECDPUN<=4
    #define decNumberUnit uint16_t
  #else
    #define decNumberUnit uint32_t
  #endif
  // The number of decNumberUnits needed is ceil(DECNUMDIGITS/DECDPUN)
  #define DECNUMUNITS ((DECNUMDIGITS+DECDPUN-1)/DECDPUN)

  // The data structure...
  typedef struct {
    int32_t digits;                // Count of digits in the coefficient; >0
    int32_t exponent;              // Unadjusted exponent, unbiased, in
                                   // range: -1999999997 through 999999999
    uint8_t bits;                  // Indicator bits (see above)

    decNumberUnit lsu[DECNUMUNITS];// Coefficient, from least significant unit
    } decNumber;

  // Notes:
  // 1. If digits is > DECDPUN then there will one or more
  //    decNumberUnits immediately following the first element of lsu.
  //    These contain the remaining (more significant) digits of the
  //    number, and may be in the lsu array, or may be guaranteed by
  //    some other mechanism (such as being contained in another
  //    structure, or being overlaid on dynamically allocated storage).
  //

  //    Each integer of the coefficient (except potentially the last)
  //    contains DECDPUN digits (e.g., a value in the range 0 through
  //    99999999 if DECDPUN is 8, or 0 through 999 if DECDPUN is 3).
  //

  // 2. A decNumber converted to a string may need up to digits+14
  //    characters.  The worst cases (non-exponential and exponential
  //    formats) are: -0.00000{9...}#
  //             and: -9.{9...}E+999999999#   (where # is '\0')




























  /* ------------------------------------------------------------------ */
  /* decNumber public functions and macros                              */
  /* ------------------------------------------------------------------ */
  // Conversions


  decNumber * decNumberFromString(decNumber *, const char *, decContext *);
  char * decNumberToString(const decNumber *, char *);
  char * decNumberToEngString(const decNumber *, char *);





  // Operators and elementary functions
  decNumber * decNumberAbs(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberAdd(decNumber *, const decNumber *, const decNumber *, decContext *);

  decNumber * decNumberCompare(decNumber *, const decNumber *, const decNumber *, decContext *);

  decNumber * decNumberCompareTotal(decNumber *, const decNumber *, const decNumber *, decContext *);

  decNumber * decNumberDivide(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberDivideInteger(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberExp(decNumber *, const decNumber *, decContext *);


  decNumber * decNumberLn(decNumber *, const decNumber *, decContext *);

  decNumber * decNumberLog10(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberMax(decNumber *, const decNumber *, const decNumber *, decContext *);

  decNumber * decNumberMin(decNumber *, const decNumber *, const decNumber *, decContext *);

  decNumber * decNumberMinus(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberMultiply(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberNormalize(decNumber *, const decNumber *, decContext *);

  decNumber * decNumberPlus(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberPower(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberQuantize(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberRemainder(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberRemainderNear(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberRescale(decNumber *, const decNumber *, const decNumber *, decContext *);

  decNumber * decNumberSameQuantum(decNumber *, const decNumber *, const decNumber *);


  decNumber * decNumberSquareRoot(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberSubtract(decNumber *, const decNumber *, const decNumber *, decContext *);

  decNumber * decNumberToIntegralValue(decNumber *, const decNumber *, decContext *);


  // Utilities


  decNumber  * decNumberCopy(decNumber *, const decNumber *);






  decNumber  * decNumberTrim(decNumber *);
  const char * decNumberVersion(void);
  decNumber  * decNumberZero(decNumber *);

  // Macros for testing decNumbers
  #define decNumberIsZero(dn)     (*(dn)->lsu==0 \

                                   && (dn)->digits==1 \


                                   && (((dn)->bits&DECSPECIAL)==0))


  #define decNumberIsNegative(dn) (((dn)->bits&DECNEG)!=0)
  #define decNumberIsNaN(dn)      (((dn)->bits&(DECNAN|DECSNAN))!=0)
  #define decNumberIsQNaN(dn)     (((dn)->bits&(DECNAN))!=0)
  #define decNumberIsSNaN(dn)     (((dn)->bits&(DECSNAN))!=0)

  #define decNumberIsInfinite(dn) (((dn)->bits&DECINF)!=0)

  #define decNumberIsSpecial(dn)  (((dn)->bits&DECSPECIAL)!=0)


#endif



|


















|







|
|
|
|
|
|
|

|
|
|
|
>
|
|

|
|
|
|




|
|







|


|

|
|
|
|
>
|


|
|
|
|
|
|
|
|
>
|
|
|
<
>
|
|
|
|

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|
|
|
|
>
>

|
|
>
>
>
>

|


>

>

>



>
>

>


>

>



>






>

>
>


>

>

|
>
>

>
>
>
>
>
>




|
|
>
|
>
>
|
>
>
|
<
|
|
>
|
>
|
>


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199

200
201
202
203
204
205
206
207
208
/* ------------------------------------------------------------------ */
/* Decimal Number arithmetic module header                            */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is called decNumber.pdf.  This document is           */
/* available, together with arithmetic and format specifications,     */
/* testcases, and Web links, at: http://www2.hursley.ibm.com/decimal  */
/*                                                                    */
/* Please send comments, suggestions, and corrections to the author:  */
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */

#if !defined(DECNUMBER)
  #define DECNUMBER
  #define DECNAME     "decNumber"                       /* Short name */
  #define DECVERSION  "decNumber 3.41"           /* Version [16 max.] */
  #define DECFULLNAME "Decimal Number Module"         /* Verbose name */
  #define DECAUTHOR   "Mike Cowlishaw"                /* Who to blame */

  #if !defined(DECCONTEXT)
    #include "decContext.h"
  #endif

  /* Bit settings for decNumber.bits                                  */
  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */
  #define DECINF    0x40      /* 1=Infinity                           */
  #define DECNAN    0x20      /* 1=NaN                                */
  #define DECSNAN   0x10      /* 1=sNaN                               */
  /* The remaining bits are reserved; they must be 0                  */
  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */

  /* Define the decNumber data structure.  The size and shape of the  */
  /* units array in the structure is determined by the following      */
  /* constant.  This must not be changed without recompiling the      */
  /* decNumber library modules. */

  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
                              /* and <10; 3 or powers of 2 are best]. */

  /* DECNUMDIGITS is the default number of digits that can be held in */
  /* the structure.  If undefined, 1 is assumed and it is assumed     */
  /* that the structure will be immediately followed by extra space,  */
  /* as required.  DECNUMDIGITS is always >0.                         */
  #if !defined(DECNUMDIGITS)
    #define DECNUMDIGITS 1
  #endif

  /* The size (integer data type) of each unit is determined by the   */
  /* number of digits it will hold.                                   */
  #if   DECDPUN<=2
    #define decNumberUnit uint8_t
  #elif DECDPUN<=4
    #define decNumberUnit uint16_t
  #else
    #define decNumberUnit uint32_t
  #endif
  /* The number of units needed is ceil(DECNUMDIGITS/DECDPUN)         */
  #define DECNUMUNITS ((DECNUMDIGITS+DECDPUN-1)/DECDPUN)

  /* The data structure... */
  typedef struct {
    int32_t digits;      /* Count of digits in the coefficient; >0    */
    int32_t exponent;    /* Unadjusted exponent, unbiased, in         */
                         /* range: -1999999997 through 999999999      */
    uint8_t bits;        /* Indicator bits (see above)                */
                         /* Coefficient, from least significant unit  */
    decNumberUnit lsu[DECNUMUNITS];
    } decNumber;

  /* Notes:                                                           */
  /* 1. If digits is > DECDPUN then there will one or more            */
  /*    decNumberUnits immediately following the first element of lsu.*/
  /*    These contain the remaining (more significant) digits of the  */
  /*    number, and may be in the lsu array, or may be guaranteed by  */
  /*    some other mechanism (such as being contained in another      */
  /*    structure, or being overlaid on dynamically allocated         */
  /*    storage).                                                     */
  /*                                                                  */
  /*    Each integer of the coefficient (except potentially the last) */
  /*    contains DECDPUN digits (e.g., a value in the range 0 through */
  /*    99999999 if DECDPUN is 8, or 0 through 999 if DECDPUN is 3).  */

  /*                                                                  */
  /* 2. A decNumber converted to a string may need up to digits+14    */
  /*    characters.  The worst cases (non-exponential and exponential */
  /*    formats) are -0.00000{9...}# and -9.{9...}E+999999999#        */
  /*    (where # is '\0')                                             */

  /* Classifications for decNumbers, aligned with 754r (note that     */
  /* 'normal' and 'subnormal' are meaningful only with a decContext)  */
  enum decClass {
    DEC_CLASS_SNAN,
    DEC_CLASS_QNAN,
    DEC_CLASS_NEG_INF,
    DEC_CLASS_NEG_NORMAL,
    DEC_CLASS_NEG_SUBNORMAL,
    DEC_CLASS_NEG_ZERO,
    DEC_CLASS_POS_ZERO,
    DEC_CLASS_POS_SUBNORMAL,
    DEC_CLASS_POS_NORMAL,
    DEC_CLASS_POS_INF,
    };
  /* Strings for the decClasses */
  #define DEC_ClassString_SN  "sNaN"
  #define DEC_ClassString_QN  "NaN"
  #define DEC_ClassString_NI  "-Infinity"
  #define DEC_ClassString_NN  "-Normal"
  #define DEC_ClassString_NS  "-Subnormal"
  #define DEC_ClassString_NZ  "-Zero"
  #define DEC_ClassString_PZ  "+Zero"
  #define DEC_ClassString_PS  "+Subnormal"
  #define DEC_ClassString_PN  "+Normal"
  #define DEC_ClassString_PI  "+Infinity"
  #define DEC_ClassString_UN  "Invalid"

  /* ---------------------------------------------------------------- */
  /* decNumber public functions and macros                            */
  /* ---------------------------------------------------------------- */
  /* Conversions                                                      */
  decNumber * decNumberFromInt32(decNumber *, int32_t);
  decNumber * decNumberFromUInt32(decNumber *, uint32_t);
  decNumber * decNumberFromString(decNumber *, const char *, decContext *);
  char      * decNumberToString(const decNumber *, char *);
  char      * decNumberToEngString(const decNumber *, char *);
  uint32_t    decNumberToUInt32(const decNumber *, decContext *);
  int32_t     decNumberToInt32(const decNumber *, decContext *);
  uint8_t   * decNumberGetBCD(const decNumber *, uint8_t *);
  decNumber * decNumberSetBCD(decNumber *, const uint8_t *, uint32_t);

  /* Operators and elementary functions                               */
  decNumber * decNumberAbs(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberAdd(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberAnd(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberCompare(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberCompareSignal(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberCompareTotal(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberCompareTotalMag(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberDivide(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberDivideInteger(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberExp(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberFMA(decNumber *, const decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberInvert(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberLn(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberLogB(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberLog10(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberMax(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberMaxMag(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberMin(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberMinMag(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberMinus(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberMultiply(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberNormalize(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberOr(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberPlus(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberPower(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberQuantize(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberRemainder(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberRemainderNear(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberRescale(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberRotate(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberSameQuantum(decNumber *, const decNumber *, const decNumber *);
  decNumber * decNumberScaleB(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberShift(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberSquareRoot(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberSubtract(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber * decNumberToIntegralExact(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberToIntegralValue(decNumber *, const decNumber *, decContext *);
  decNumber * decNumberXor(decNumber *, const decNumber *, const decNumber *, decContext *);

  /* Utilities                                                        */
  enum decClass decNumberClass(const decNumber *, decContext *);
  const char * decNumberClassToString(enum decClass);
  decNumber  * decNumberCopy(decNumber *, const decNumber *);
  decNumber  * decNumberCopyAbs(decNumber *, const decNumber *);
  decNumber  * decNumberCopyNegate(decNumber *, const decNumber *);
  decNumber  * decNumberCopySign(decNumber *, const decNumber *, const decNumber *);
  decNumber  * decNumberNextMinus(decNumber *, const decNumber *, decContext *);
  decNumber  * decNumberNextPlus(decNumber *, const decNumber *, decContext *);
  decNumber  * decNumberNextToward(decNumber *, const decNumber *, const decNumber *, decContext *);
  decNumber  * decNumberTrim(decNumber *);
  const char * decNumberVersion(void);
  decNumber  * decNumberZero(decNumber *);

  /* Functions for testing decNumbers (normality depends on context)  */
  int32_t decNumberIsNormal(const decNumber *, decContext *);
  int32_t decNumberIsSubnormal(const decNumber *, decContext *);

  /* Macros for testing decNumber *dn                                 */
  #define decNumberIsCanonical(dn) (1)  /* All decNumbers are saintly */
  #define decNumberIsFinite(dn)    (((dn)->bits&DECSPECIAL)==0)
  #define decNumberIsInfinite(dn)  (((dn)->bits&DECINF)!=0)
  #define decNumberIsNaN(dn)       (((dn)->bits&(DECNAN|DECSNAN))!=0)
  #define decNumberIsNegative(dn)  (((dn)->bits&DECNEG)!=0)

  #define decNumberIsQNaN(dn)      (((dn)->bits&(DECNAN))!=0)
  #define decNumberIsSNaN(dn)      (((dn)->bits&(DECSNAN))!=0)
  #define decNumberIsSpecial(dn)   (((dn)->bits&DECSPECIAL)!=0)
  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
                                    && (dn)->digits==1 \
                                    && (((dn)->bits&DECSPECIAL)==0))
  #define decNumberRadix(dn)       (10)

#endif

Changes to decNumber/decNumberLocal.h.

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43






44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* Please send comments, suggestions, and corrections to the author:  */
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */
/* This header file is included by all modules in the decNumber       */
/* library, and contains local type definitions, tuning parameters,   */
/* etc.  It must only be included once, and should not need to be     */
/* used by application programs.  decNumber.h must be included first. */
/* ------------------------------------------------------------------ */

#if !defined(DECNUMBERLOC)
  #define DECNUMBERLOC
  #define DECNLAUTHOR   "Mike Cowlishaw"              /* Who to blame */

  /* Tuning parameter */

  #define DECBUFFER 36        // Maximum size basis for local buffers.
                              // Should be a common maximum precision
                              // rounded up to a multiple of 4; must
                              // be zero or positive.

  /* Conditional code flags -- set these to 1 for best performance */
  #define DECENDIAN 1         // 1=concrete formats are endian
  #define DECUSE64  1         // 1 to allow use of 64-bit integers

  /* Conditional check flags -- set these to 0 for best performance */
  #define DECCHECK  0         // 1 to enable robust checking
  #define DECALLOC  0         // 1 to enable memory allocation accounting
  #define DECTRACE  0         // 1 to trace critical intermediates, etc.







  /* Local names for common types -- for safety, decNumber modules do
     not use int or long directly */
  #define Flag   uint8_t
  #define Byte   int8_t
  #define uByte  uint8_t
  #define Short  int16_t
  #define uShort uint16_t
  #define Int    int32_t
  #define uInt   uint32_t
  #define Unit   decNumberUnit
  #if DECUSE64
  #define Long   int64_t
  #define uLong  uint64_t
  #endif

  /* Development-use defines */

  #if DECALLOC
    // if these interfere with your C includes, just comment them out
    #define  int ?            // enable to ensure that plain C 'int' or
    #define  long ??          // .. 'long' types are not used
  #endif

  /* Limits and constants */
  #define DECNUMMAXP 999999999  // maximum precision code can handle
  #define DECNUMMAXE 999999999  // maximum adjusted exponent ditto
  #define DECNUMMINE -999999999 // minimum adjusted exponent ditto
  #if (DECNUMMAXP != DEC_MAX_DIGITS)
    #error Maximum digits mismatch
  #endif
  #if (DECNUMMAXE != DEC_MAX_EMAX)
    #error Maximum exponent mismatch
  #endif
  #if (DECNUMMINE != DEC_MIN_EMIN)
    #error Minimum exponent mismatch
  #endif

  /* Set DECDPUNMAX -- the maximum integer that fits in DECDPUN    */
  /* digits, and D2UTABLE -- the initializer for the D2U table     */
  #if   DECDPUN==1
    #define DECDPUNMAX 9
    #define D2UTABLE {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,  \
                      18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, \
                      33,34,35,36,37,38,39,40,41,42,43,44,45,46,47, \
                      48,49}
  #elif DECDPUN==2







|
|






|
>
|
<
<
<

|
<
|

|
|
|
|

>
>
>
>
>
>
|
|













|
>
|
|
|
|



|
|
|










|
|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31



32
33

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* Please send comments, suggestions, and corrections to the author:  */
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */
/* This header file is included by all modules in the decNumber       */
/* library, and contains local type definitions, tuning parameters,   */
/* etc.  It should not need to be used by application programs.       */
/* decNumber.h must be included first.                                */
/* ------------------------------------------------------------------ */

#if !defined(DECNUMBERLOC)
  #define DECNUMBERLOC
  #define DECNLAUTHOR   "Mike Cowlishaw"              /* Who to blame */


  /* Conditional code flag -- set this to match hardware platform     */
  #define DECLITEND 1         /* 1=little-endian, 0=big-endian        */




  /* Conditional code flag -- set this to 1 for best performance      */

  #define DECUSE64  1         /* 1 to allow use of 64-bit integers    */

  /* Conditional check flags -- set these to 0 for best performance   */
  #define DECCHECK  0         /* 1 to enable robust checking          */
  #define DECALLOC  0         /* 1 to enable memory accounting        */
  #define DECTRACE  0         /* 1 to trace certain internals, etc.   */

  /* Tuning parameter */
  #define DECBUFFER 36        /* Size basis for local buffers.  This  */
                              /* should be a common maximum precision */
                              /* rounded up to a multiple of 4; must  */
                              /* be zero or positive.                 */

  /* Local names for common types -- for safety, decNumber modules do */
  /* not use int or long directly.                                    */
  #define Flag   uint8_t
  #define Byte   int8_t
  #define uByte  uint8_t
  #define Short  int16_t
  #define uShort uint16_t
  #define Int    int32_t
  #define uInt   uint32_t
  #define Unit   decNumberUnit
  #if DECUSE64
  #define Long   int64_t
  #define uLong  uint64_t
  #endif

  /* Development-use definitions */
  #define DECNOINT  0         /* 1 to check no internal use of 'int'  */
  #if DECNOINT
    /* if these interfere with your C includes, do not set DECNOINT   */
    #define  int ?            /* enable to ensure that plain C 'int'  */
    #define  long ??          /* .. or 'long' types are not used      */
  #endif

  /* Limits and constants */
  #define DECNUMMAXP 999999999  /* maximum precision code can handle  */
  #define DECNUMMAXE 999999999  /* maximum adjusted exponent ditto    */
  #define DECNUMMINE -999999999 /* minimum adjusted exponent ditto    */
  #if (DECNUMMAXP != DEC_MAX_DIGITS)
    #error Maximum digits mismatch
  #endif
  #if (DECNUMMAXE != DEC_MAX_EMAX)
    #error Maximum exponent mismatch
  #endif
  #if (DECNUMMINE != DEC_MIN_EMIN)
    #error Minimum exponent mismatch
  #endif

  /* Set DECDPUNMAX -- the maximum integer that fits in DECDPUN       */
  /* digits, and D2UTABLE -- the initializer for the D2U table        */
  #if   DECDPUN==1
    #define DECDPUNMAX 9
    #define D2UTABLE {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,  \
                      18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, \
                      33,34,35,36,37,38,39,40,41,42,43,44,45,46,47, \
                      48,49}
  #elif DECDPUN==2
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
                      3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,  \
                      5,5,6,6,6,6}
  #elif defined(DECDPUN)
    #error DECDPUN must be in the range 1-9
  #endif

  /* ----- Shared data (in decNumber.c) ----- */
  // Public powers of of ten array (powers[n]==10**n, 0<=n<=10)
  extern const uInt powers[];
  // Public lookup table used by the D2U macro (see below)
  #define DECMAXD2U 49
  extern const uByte d2utable[DECMAXD2U+1];

  /* ----- Macros ----- */
  // ISZERO -- return true if decNumber dn is a zero
  // [performance-critical in some situations]
  #define ISZERO(dn) decNumberIsZero(dn)     // now just a local name

  // X10 and X100 -- multiply integer i by 10 or 100
  // [shifts are usually faster than multiply; could be conditional]
  #define X10(i)  (((i)<<1)+((i)<<3))
  #define X100(i) (((i)<<2)+((i)<<5)+((i)<<6))

  // D2U -- return the number of Units needed to hold d digits
  // (runtime version, with table lookaside for small d)
  #if DECDPUN==8
    #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+7)>>3))
  #elif DECDPUN==4
    #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+3)>>2))
  #else
    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  #endif
  // SD2U -- static D2U macro (for compile-time calculation)
  #define SD2U(d) (((d)+DECDPUN-1)/DECDPUN)

  // MSUDIGITS -- returns digits in msu, calculated using D2U

  #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)

  // D2N -- return the number of decNumber structs that would be
  // needed to contain that number of digits (and the initial
  // decNumber struct) safely.  Note that one Unit is included in the
  // initial structure.  Used for allocating space that is aligned on
  // a decNumber struct boundary.
  #define D2N(d) \
    ((((SD2U(d)-1)*sizeof(Unit))+sizeof(decNumber)*2-1)/sizeof(decNumber))

  // TODIGIT -- macro to remove the leading digit from the unsigned
  // integer u at column cut (counting from the right, LSD=0) and
  // place it as an ASCII character into the character pointed to by
  // c.  Note that cut must be <= 9, and the maximum value for u is
  // 2,000,000,000 (as is needed for negative exponents of
  // subnormals).  The unsigned integer pow is used as a temporary
  // variable.
  #define TODIGIT(u, cut, c, pow) {       \
    *(c)='0';                             \
    pow=powers[cut]*2;                    \
    if ((u)>pow) {                        \
      pow*=4;                             \
      if ((u)>=pow) {(u)-=pow; *(c)+=8;}  \
      pow/=2;                             \
      if ((u)>=pow) {(u)-=pow; *(c)+=4;}  \
      pow/=2;                             \
      }                                   \
    if ((u)>=pow) {(u)-=pow; *(c)+=2;}    \
    pow/=2;                               \
    if ((u)>=pow) {(u)-=pow; *(c)+=1;}    \
    }

  // MAX and MIN -- general max & min (not in ANSI)
  #define MAX(x,y) ((x)<(y)?(y):(x))
  #define MIN(x,y) ((x)>(y)?(y):(x))

#else
  #error decNumberLocal included more than once
#endif







|

|




|
|
|

|
|



|
|







|


|
>


|
|
|
|
|



|
|
|
|
|
|
|















|






130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
                      3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,  \
                      5,5,6,6,6,6}
  #elif defined(DECDPUN)
    #error DECDPUN must be in the range 1-9
  #endif

  /* ----- Shared data (in decNumber.c) ----- */
  /* Public powers of of ten array (powers[n]==10**n, 0<=n<=10)       */
  extern const uInt powers[];
  /* Public lookup table used by the D2U macro (see below)            */
  #define DECMAXD2U 49
  extern const uByte d2utable[DECMAXD2U+1];

  /* ----- Macros ----- */
  /* ISZERO -- return true if decNumber dn is a zero                  */
  /* [performance-critical in some situations]                        */
  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */

  /* X10 and X100 -- multiply integer i by 10 or 100                  */
  /* [shifts are usually faster than multiply; could be conditional]  */
  #define X10(i)  (((i)<<1)+((i)<<3))
  #define X100(i) (((i)<<2)+((i)<<5)+((i)<<6))

  /* D2U -- return the number of Units needed to hold d digits        */
  /* (runtime version, with table lookaside for small d)              */
  #if DECDPUN==8
    #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+7)>>3))
  #elif DECDPUN==4
    #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+3)>>2))
  #else
    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  #endif
  /* SD2U -- static D2U macro (for compile-time calculation)          */
  #define SD2U(d) (((d)+DECDPUN-1)/DECDPUN)

  /* MSUDIGITS -- returns digits in msu, from digits, calculated      */
  /* using D2U                                                        */
  #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)

  /* D2N -- return the number of decNumber structs that would be      */
  /* needed to contain that number of digits (and the initial         */
  /* decNumber struct) safely.  Note that one Unit is included in the */
  /* initial structure.  Used for allocating space that is aligned on */
  /* a decNumber struct boundary. */
  #define D2N(d) \
    ((((SD2U(d)-1)*sizeof(Unit))+sizeof(decNumber)*2-1)/sizeof(decNumber))

  /* TODIGIT -- macro to remove the leading digit from the unsigned   */
  /* integer u at column cut (counting from the right, LSD=0) and     */
  /* place it as an ASCII character into the character pointed to by  */
  /* c.  Note that cut must be <= 9, and the maximum value for u is   */
  /* 2,000,000,000 (as is needed for negative exponents of            */
  /* subnormals).  The unsigned integer pow is used as a temporary    */
  /* variable. */
  #define TODIGIT(u, cut, c, pow) {       \
    *(c)='0';                             \
    pow=powers[cut]*2;                    \
    if ((u)>pow) {                        \
      pow*=4;                             \
      if ((u)>=pow) {(u)-=pow; *(c)+=8;}  \
      pow/=2;                             \
      if ((u)>=pow) {(u)-=pow; *(c)+=4;}  \
      pow/=2;                             \
      }                                   \
    if ((u)>=pow) {(u)-=pow; *(c)+=2;}    \
    pow/=2;                               \
    if ((u)>=pow) {(u)-=pow; *(c)+=1;}    \
    }

  /* MAX and MIN -- general max & min (not in ANSI)                   */
  #define MAX(x,y) ((x)<(y)?(y):(x))
  #define MIN(x,y) ((x)>(y)?(y):(x))

#else
  #error decNumberLocal included more than once
#endif

Changes to decNumber/decPacked.h.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

#if !defined(DECPACKED)
  #define DECPACKED
  #define DECPNAME     "decPacked"                      /* Short name */
  #define DECPFULLNAME "Packed Decimal conversions"   /* Verbose name */
  #define DECPAUTHOR   "Mike Cowlishaw"               /* Who to blame */

  #define DECPACKED_DefP 32             // default precision

  #ifndef  DECNUMDIGITS
    #define DECNUMDIGITS DECPACKED_DefP // size if not already defined
  #endif
  #include "decNumber.h"                // context and number library

  /* Sign nibble constants */
  #define DECPPLUSALT  0x0A   // alternate plus nibble
  #define DECPMINUSALT 0x0B   // alternate minus nibble
  #define DECPPLUS     0x0C   // preferred plus nibble
  #define DECPMINUS    0x0D   // preferred minus nibble
  #define DECPPLUSALT2 0x0E   // alternate plus nibble
  #define DECPUNSIGNED 0x0F   // alternate plus nibble (unsigned)

  /* ---------------------------------------------------------------- */
  /* decPacked public routines                                        */
  /* ---------------------------------------------------------------- */
  // Conversions
  uint8_t * decPackedFromNumber(uint8_t *, int32_t, int32_t *,
                                const decNumber *);
  decNumber * decPackedToNumber(const uint8_t *, int32_t, const int32_t *,
                                decNumber *);

#endif







|


|

|

|
|
|
|
|
|
|




|






19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

#if !defined(DECPACKED)
  #define DECPACKED
  #define DECPNAME     "decPacked"                      /* Short name */
  #define DECPFULLNAME "Packed Decimal conversions"   /* Verbose name */
  #define DECPAUTHOR   "Mike Cowlishaw"               /* Who to blame */

  #define DECPACKED_DefP 32             /* default precision          */

  #ifndef  DECNUMDIGITS
    #define DECNUMDIGITS DECPACKED_DefP /* size if not already defined*/
  #endif
  #include "decNumber.h"                /* context and number library */

  /* Sign nibble constants                                            */
  #define DECPPLUSALT  0x0A   /* alternate plus  nibble               */
  #define DECPMINUSALT 0x0B   /* alternate minus nibble               */
  #define DECPPLUS     0x0C   /* preferred plus  nibble               */
  #define DECPMINUS    0x0D   /* preferred minus nibble               */
  #define DECPPLUSALT2 0x0E   /* alternate plus  nibble               */
  #define DECPUNSIGNED 0x0F   /* alternate plus  nibble (unsigned)    */

  /* ---------------------------------------------------------------- */
  /* decPacked public routines                                        */
  /* ---------------------------------------------------------------- */
  /* Conversions                                                      */
  uint8_t * decPackedFromNumber(uint8_t *, int32_t, int32_t *,
                                const decNumber *);
  decNumber * decPackedToNumber(const uint8_t *, int32_t, const int32_t *,
                                decNumber *);

#endif

Changes to decNumber/decimal128.c.

1
2
3
4
5
6
7
8
9
10
11
/* ------------------------------------------------------------------ */
/* Decimal 128-bit format module                                      */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2006.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is called decNumber.pdf.  This document is           */
/* available, together with arithmetic and format specifications,     */



|







1
2
3
4
5
6
7
8
9
10
11
/* ------------------------------------------------------------------ */
/* Decimal 128-bit format module                                      */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is called decNumber.pdf.  This document is           */
/* available, together with arithmetic and format specifications,     */
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
extern void decDigitsToDPD(const decNumber *, uInt *, Int);

#if DECTRACE || DECCHECK
void decimal128Show(const decimal128 *);          // for debug
extern void decNumberShow(const decNumber *);     // ..
#endif

/* compile-time endian tester [assumes sizeof(int)>1] */
static  const  Int mfcone=1;                 // constant 1
static  const  Flag *mfctop=(Flag *)&mfcone; // -> top byte
#define LITEND mfctop[0]           // named flag; 1=little-endian

/* Useful macro */
// Clear a structure (e.g., a decNumber)
#define DEC_clear(d) memset(d, 0, sizeof(*d))

/* ------------------------------------------------------------------ */
/* decimal128FromNumber -- convert decNumber to decimal128            */
/*                                                                    */







<
<
<
<
<







41
42
43
44
45
46
47





48
49
50
51
52
53
54
extern void decDigitsToDPD(const decNumber *, uInt *, Int);

#if DECTRACE || DECCHECK
void decimal128Show(const decimal128 *);          // for debug
extern void decNumberShow(const decNumber *);     // ..
#endif






/* Useful macro */
// Clear a structure (e.g., a decNumber)
#define DEC_clear(d) memset(d, 0, sizeof(*d))

/* ------------------------------------------------------------------ */
/* decimal128FromNumber -- convert decNumber to decimal128            */
/*                                                                    */
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
      }
    targhi|=comb<<26;              // add combination field ..
    targhi|=(exp&0xfff)<<14;       // .. and exponent continuation
    } // finite

  if (dn->bits&DECNEG) targhi|=0x80000000; // add sign bit

  // now write to storage; this may be endian, or not
  #if DECENDIAN
  // DECENDIAN -- direct store, in the right order
  pu=(uInt *)d128->bytes;          // overlay
  if (LITEND) {
    pu[0]=targlo;                  // directly store the low int
    pu[1]=targml;                  // then the mid-low
    pu[2]=targmh;                  // then the mid-high
    pu[3]=targhi;                  // then the high int
    }
   else {
    pu[0]=targhi;                  // directly store the high int
    pu[1]=targmh;                  // then the mid-high
    pu[2]=targml;                  // then the mid-low
    pu[3]=targlo;                  // then the low int
    }
  #else
  // not DECENDIAN -- use network byte order
  if (LITEND) {                    // little-endian needs reversal
    uByte *pb;                     // work
    Int off;                       // ..
    for (pb=&d128->bytes[15]; pb>=d128->bytes; pb--) {
      off=3-((pb-d128->bytes)>>2); // 0, then 1, 2, 3
      *pb=(uByte)(targar[off]&0xff);
      targar[off]>>=8;
      } // i
    }
   else { // big-endian; it's the right way round already
    pu=(uInt *)d128->bytes;        // overlay
    pu[0]=targhi;                  // directly store the high int
    pu[1]=targmh;                  // then the mid-high
    pu[2]=targml;                  // then the mid-low
    pu[3]=targlo;                  // then the low int
    }
  #endif

  if (status!=0) decContextSetStatus(set, status); // pass on status
  // decimal128Show(d128);
  return d128;
  } // decimal128FromNumber

/* ------------------------------------------------------------------ */







|
<
<

|











<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







150
151
152
153
154
155
156
157


158
159
160
161
162
163
164
165
166
167
168
169
170



















171
172
173
174
175
176
177
      }
    targhi|=comb<<26;              // add combination field ..
    targhi|=(exp&0xfff)<<14;       // .. and exponent continuation
    } // finite

  if (dn->bits&DECNEG) targhi|=0x80000000; // add sign bit

  // now write to storage; this is endian


  pu=(uInt *)d128->bytes;          // overlay
  if (DECLITEND) {
    pu[0]=targlo;                  // directly store the low int
    pu[1]=targml;                  // then the mid-low
    pu[2]=targmh;                  // then the mid-high
    pu[3]=targhi;                  // then the high int
    }
   else {
    pu[0]=targhi;                  // directly store the high int
    pu[1]=targmh;                  // then the mid-high
    pu[2]=targml;                  // then the mid-low
    pu[3]=targlo;                  // then the low int
    }




















  if (status!=0) decContextSetStatus(set, status); // pass on status
  // decimal128Show(d128);
  return d128;
  } // decimal128FromNumber

/* ------------------------------------------------------------------ */
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
  Int  need;                       // ..
  uInt sourar[4];                  // source 128-bit
  #define sourhi sourar[3]         // name the word with the sign
  #define sourmh sourar[2]         // and the mid-high word
  #define sourml sourar[1]         // and the mod-low word
  #define sourlo sourar[0]         // and the lowest word

  // load source from storage; this may be endian, or not
  #if DECENDIAN
  // DECENDIAN -- direct load, in the right order
  pu=(uInt *)d128->bytes;          // overlay
  if (LITEND) {
    sourlo=pu[0];                  // directly load the low int
    sourml=pu[1];                  // then the mid-low
    sourmh=pu[2];                  // then the mid-high
    sourhi=pu[3];                  // then the high int
    }
   else {
    sourhi=pu[0];                  // directly load the high int
    sourmh=pu[1];                  // then the mid-high
    sourml=pu[2];                  // then the mid-low
    sourlo=pu[3];                  // then the low int
    }
  #else
  // not DECENDIAN -- use network byte order
  if (LITEND) {                    // little-endian needs reversal
    const uByte *pb;               // work
    Int off;                       // ..
    for (pb=d128->bytes; pb<=&d128->bytes[15]; pb++) {
      off=3-((pb-d128->bytes)>>2); // 3, then 2, 1, 0
      sourar[off]<<=8;
      sourar[off]|=*pb;
      } // i
    }
   else { // big-endian; it's the right way round already
    pu=(uInt *)d128->bytes;        // overlay
    sourhi=pu[0];                  // directly load the high int
    sourmh=pu[1];                  // then the mid-high
    sourml=pu[2];                  // then the mid-low
    sourlo=pu[3];                  // then the low int
    }
  #endif

  comb=(sourhi>>26)&0x1f;          // combination field

  decNumberZero(dn);               // clean number
  if (sourhi&0x80000000) dn->bits=DECNEG; // set sign if negative

  msd=COMBMSD[comb];               // decode the combination field







|
<
<

|











<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







188
189
190
191
192
193
194
195


196
197
198
199
200
201
202
203
204
205
206
207
208



















209
210
211
212
213
214
215
  Int  need;                       // ..
  uInt sourar[4];                  // source 128-bit
  #define sourhi sourar[3]         // name the word with the sign
  #define sourmh sourar[2]         // and the mid-high word
  #define sourml sourar[1]         // and the mod-low word
  #define sourlo sourar[0]         // and the lowest word

  // load source from storage; this is endian


  pu=(uInt *)d128->bytes;          // overlay
  if (DECLITEND) {
    sourlo=pu[0];                  // directly load the low int
    sourml=pu[1];                  // then the mid-low
    sourmh=pu[2];                  // then the mid-high
    sourhi=pu[3];                  // then the high int
    }
   else {
    sourhi=pu[0];                  // directly load the high int
    sourmh=pu[1];                  // then the mid-high
    sourml=pu[2];                  // then the mid-low
    sourlo=pu[3];                  // then the low int
    }




















  comb=(sourhi>>26)&0x1f;          // combination field

  decNumberZero(dn);               // clean number
  if (sourhi&0x80000000) dn->bits=DECNEG; // set sign if negative

  msd=COMBMSD[comb];               // decode the combination field
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377

  uInt sourar[4];                  // source 128-bit
  #define sourhi sourar[3]         // name the word with the sign
  #define sourmh sourar[2]         // and the mid-high word
  #define sourml sourar[1]         // and the mod-low word
  #define sourlo sourar[0]         // and the lowest word

  // load source from storage; this may be endian, or not
  #if DECENDIAN
  // DECENDIAN -- direct load, in the right order
  pu=(uInt *)d128->bytes;          // overlay
  if (LITEND) {
    sourlo=pu[0];                  // directly load the low int
    sourml=pu[1];                  // then the mid-low
    sourmh=pu[2];                  // then the mid-high
    sourhi=pu[3];                  // then the high int
    }
   else {
    sourhi=pu[0];                  // directly load the high int
    sourmh=pu[1];                  // then the mid-high
    sourml=pu[2];                  // then the mid-low
    sourlo=pu[3];                  // then the low int
    }
  #else
  // not DECENDIAN -- use network byte order
  if (LITEND) {                    // little-endian needs reversal
    const uByte *pb;               // work
    Int off;                       // ..
    for (pb=d128->bytes; pb<=&d128->bytes[15]; pb++) {
      off=3-((pb-d128->bytes)>>2); // 3, then 2, 1, 0
      sourar[off]<<=8;
      sourar[off]|=*pb;
      } // i
    }
   else { // big-endian; it's the right way round already
    pu=(uInt *)d128->bytes;        // overlay
    sourhi=pu[0];                  // directly load the high int
    sourmh=pu[1];                  // then the mid-high
    sourml=pu[2];                  // then the mid-low
    sourlo=pu[3];                  // then the low int
    }
  #endif

  c=string;                        // where result will go
  if (((Int)sourhi)<0) *c++='-';   // handle sign

  comb=(sourhi>>26)&0x1f;          // combination field
  msd=COMBMSD[comb];               // decode the combination field
  exp=COMBEXP[comb];               // ..







|
<
<

|











<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







282
283
284
285
286
287
288
289


290
291
292
293
294
295
296
297
298
299
300
301
302



















303
304
305
306
307
308
309

  uInt sourar[4];                  // source 128-bit
  #define sourhi sourar[3]         // name the word with the sign
  #define sourmh sourar[2]         // and the mid-high word
  #define sourml sourar[1]         // and the mod-low word
  #define sourlo sourar[0]         // and the lowest word

  // load source from storage; this is endian


  pu=(uInt *)d128->bytes;          // overlay
  if (DECLITEND) {
    sourlo=pu[0];                  // directly load the low int
    sourml=pu[1];                  // then the mid-low
    sourmh=pu[2];                  // then the mid-high
    sourhi=pu[3];                  // then the high int
    }
   else {
    sourhi=pu[0];                  // directly load the high int
    sourmh=pu[1];                  // then the mid-high
    sourml=pu[2];                  // then the mid-low
    sourlo=pu[3];                  // then the low int
    }




















  c=string;                        // where result will go
  if (((Int)sourhi)<0) *c++='-';   // handle sign

  comb=(sourhi>>26)&0x1f;          // combination field
  msd=COMBMSD[comb];               // decode the combination field
  exp=COMBEXP[comb];               // ..
523
524
525
526
527
528
529
































530


























531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
  decimal128FromNumber(result, &dn, &dc);
  if (dc.status!=0) {                        // something happened
    decContextSetStatus(set, dc.status);     // .. pass it on
    }
  return result;
  } // decimal128FromString

































#if DECTRACE || DECCHECK


























/* ------------------------------------------------------------------ */
/* decimal128Show -- display a decimal128 in hexadecimal [debug aid]  */
/*   d128 -- the number to show                                       */
/* ------------------------------------------------------------------ */
// Also shows sign/cob/expconfields extracted
void decimal128Show(const decimal128 *d128) {
  char buf[DECIMAL128_Bytes*2+1];
  Int i, j=0;

  #if DECENDIAN
  if (LITEND) {
    for (i=0; i<DECIMAL128_Bytes; i++, j+=2) {
      sprintf(&buf[j], "%02x", d128->bytes[15-i]);
      }
    printf(" D128> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf,
           d128->bytes[15]>>7, (d128->bytes[15]>>2)&0x1f,
           ((d128->bytes[15]&0x3)<<10)|(d128->bytes[14]<<2)|
           (d128->bytes[13]>>6));
    }
   else {
  #endif
    for (i=0; i<DECIMAL128_Bytes; i++, j+=2) {
      sprintf(&buf[j], "%02x", d128->bytes[i]);
      }
    printf(" D128> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf,
           decimal128Sign(d128), decimal128Comb(d128),
           decimal128ExpCon(d128));
  #if DECENDIAN
    }
  #endif
  } // decimal128Show
#endif







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









<
|









<






<

<


455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529

530
531
532
533
534
535
536
537
538
539

540
541
542
543
544
545

546

547
548
  decimal128FromNumber(result, &dn, &dc);
  if (dc.status!=0) {                        // something happened
    decContextSetStatus(set, dc.status);     // .. pass it on
    }
  return result;
  } // decimal128FromString

/* ------------------------------------------------------------------ */
/* decimal128IsCanonical -- test whether encoding is canonical        */
/*   d128 is the source decimal128                                    */
/*   returns 1 if the encoding of d128 is canonical, 0 otherwise      */
/* No error is possible.                                              */
/* ------------------------------------------------------------------ */
uint32_t decimal128IsCanonical(const decimal128 *d128) {
  decNumber dn;                         // work
  decimal128 canon;                      // ..
  decContext dc;                        // ..
  decContextDefault(&dc, DEC_INIT_DECIMAL128);
  decimal128ToNumber(d128, &dn);
  decimal128FromNumber(&canon, &dn, &dc);// canon will now be canonical
  return memcmp(d128, &canon, DECIMAL128_Bytes)==0;
  } // decimal128IsCanonical

/* ------------------------------------------------------------------ */
/* decimal128Canonical -- copy an encoding, ensuring it is canonical  */
/*   d128 is the source decimal128                                    */
/*   result is the target (may be the same decimal128)                */
/*   returns result                                                   */
/* No error is possible.                                              */
/* ------------------------------------------------------------------ */
decimal128 * decimal128Canonical(decimal128 *result, const decimal128 *d128) {
  decNumber dn;                         // work
  decContext dc;                        // ..
  decContextDefault(&dc, DEC_INIT_DECIMAL128);
  decimal128ToNumber(d128, &dn);
  decimal128FromNumber(result, &dn, &dc);// result will now be canonical
  return result;
  } // decimal128Canonical

#if DECTRACE || DECCHECK
/* Macros for accessing decimal128 fields.  These assume the argument
   is a reference (pointer) to the decimal128 structure, and the
   decimal128 is in network byte order (big-endian) */
// Get sign
#define decimal128Sign(d)       ((unsigned)(d)->bytes[0]>>7)

// Get combination field
#define decimal128Comb(d)       (((d)->bytes[0] & 0x7c)>>2)

// Get exponent continuation [does not remove bias]
#define decimal128ExpCon(d)     ((((d)->bytes[0] & 0x03)<<10)         \
                              | ((unsigned)(d)->bytes[1]<<2)          \
                              | ((unsigned)(d)->bytes[2]>>6))

// Set sign [this assumes sign previously 0] */
#define decimal128SetSign(d, b) {                                     \
  (d)->bytes[0]|=((unsigned)(b)<<7);}

// Set exponent continuation [does not apply bias]
// This assumes range has been checked and exponent previously 0;
// type of exponent must be unsigned
#define decimal128SetExpCon(d, e) {                                   \
  (d)->bytes[0]|=(uint8_t)((e)>>10);                                  \
  (d)->bytes[1] =(uint8_t)(((e)&0x3fc)>>2);                           \
  (d)->bytes[2]|=(uint8_t)(((e)&0x03)<<6);}

/* ------------------------------------------------------------------ */
/* decimal128Show -- display a decimal128 in hexadecimal [debug aid]  */
/*   d128 -- the number to show                                       */
/* ------------------------------------------------------------------ */
// Also shows sign/cob/expconfields extracted
void decimal128Show(const decimal128 *d128) {
  char buf[DECIMAL128_Bytes*2+1];
  Int i, j=0;


  if (DECLITEND) {
    for (i=0; i<DECIMAL128_Bytes; i++, j+=2) {
      sprintf(&buf[j], "%02x", d128->bytes[15-i]);
      }
    printf(" D128> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf,
           d128->bytes[15]>>7, (d128->bytes[15]>>2)&0x1f,
           ((d128->bytes[15]&0x3)<<10)|(d128->bytes[14]<<2)|
           (d128->bytes[13]>>6));
    }
   else {

    for (i=0; i<DECIMAL128_Bytes; i++, j+=2) {
      sprintf(&buf[j], "%02x", d128->bytes[i]);
      }
    printf(" D128> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf,
           decimal128Sign(d128), decimal128Comb(d128),
           decimal128ExpCon(d128));

    }

  } // decimal128Show
#endif

Changes to decNumber/decimal128.h.

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101




102
103
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */

#if !defined(DECIMAL128)
  #define DECIMAL128
  #define DEC128NAME     "decimal128"                 /* Short name */
  #define DEC128FULLNAME "Decimal 128-bit Number"     /* Verbose name */
  #define DEC128AUTHOR   "Mike Cowlishaw"             /* Who to blame */

  /* parameters for decimal128s */
  #define DECIMAL128_Bytes  16          // length
  #define DECIMAL128_Pmax   34          // maximum precision (digits)
  #define DECIMAL128_Emax   6144        // maximum adjusted exponent
  #define DECIMAL128_Emin  -6143        // minimum adjusted exponent
  #define DECIMAL128_Bias   6176        // bias for the exponent
  #define DECIMAL128_String 43          // maximum string length, +1
  #define DECIMAL128_EconL  12          // exponent continuation length
  // highest biased exponent (Elimit-1)
  #define DECIMAL128_Ehigh  (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1)

  // check enough digits, if pre-defined
  #if defined(DECNUMDIGITS)
    #if (DECNUMDIGITS<DECIMAL128_Pmax)
      #error decimal128.h needs pre-defined DECNUMDIGITS>=34 for safe use
    #endif
  #endif

  #ifndef DECNUMDIGITS
    #define DECNUMDIGITS DECIMAL128_Pmax // size if not already defined
  #endif
  #ifndef DECNUMBER
    #include "decNumber.h"              // context and number library
  #endif

  /* Decimal 128-bit type, accessible by bytes */
  typedef struct {
    uint8_t bytes[DECIMAL128_Bytes];    // decimal128: 1, 5, 12, 110 bits
    } decimal128;

  /* special values [top byte excluding sign bit; last two bits are
     don't-care for Infinity on input, last bit don't-care for NaN] */
  #if !defined(DECIMAL_NaN)
    #define DECIMAL_NaN     0x7c        // 0 11111 00 NaN
    #define DECIMAL_sNaN    0x7e        // 0 11111 10 sNaN
    #define DECIMAL_Inf     0x78        // 0 11110 00 Infinity
  #endif

  /* Macros for accessing decimal128 fields.  These assume the argument
     is a reference (pointer) to the decimal128 structure, and the
     decimal128 is in network byte order (big-endian) */
  // Get sign
  #define decimal128Sign(d)       ((unsigned)(d)->bytes[0]>>7)

  // Get combination field
  #define decimal128Comb(d)       (((d)->bytes[0] & 0x7c)>>2)

  // Get exponent continuation [does not remove bias]
  #define decimal128ExpCon(d)     ((((d)->bytes[0] & 0x03)<<10)       \
                                | ((unsigned)(d)->bytes[1]<<2)        \
                                | ((unsigned)(d)->bytes[2]>>6))

  // Set sign [this assumes sign previously 0]
  #define decimal128SetSign(d, b) {                                   \
    (d)->bytes[0]|=((unsigned)(b)<<7);}

  // Set exponent continuation [does not apply bias]
  // This assumes range has been checked and exponent previously 0;
  // type of exponent must be unsigned
  #define decimal128SetExpCon(d, e) {                                 \
    (d)->bytes[0]|=(uint8_t)((e)>>10);                                \
    (d)->bytes[1] =(uint8_t)(((e)&0x3fc)>>2);                         \
    (d)->bytes[2]|=(uint8_t)(((e)&0x03)<<6);}

  /* ------------------------------------------------------------------ */
  /* Routines                                                           */
  /* ------------------------------------------------------------------ */
  // String conversions
  decimal128 * decimal128FromString(decimal128 *, const char *, decContext *);
  char * decimal128ToString(const decimal128 *, char *);
  char * decimal128ToEngString(const decimal128 *, char *);

  // decNumber conversions
  decimal128 * decimal128FromNumber(decimal128 *, const decNumber *,
                                    decContext *);
  decNumber * decimal128ToNumber(const decimal128 *, decNumber *);





#endif







|




|
|
|
|
|
|
|
|


|







|


|


|

|


|
|

|
|
|


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
|




|



>
>
>
>


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63


























64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */

#if !defined(DECIMAL128)
  #define DECIMAL128
  #define DEC128NAME     "decimal128"                 /* Short name   */
  #define DEC128FULLNAME "Decimal 128-bit Number"     /* Verbose name */
  #define DEC128AUTHOR   "Mike Cowlishaw"             /* Who to blame */

  /* parameters for decimal128s */
  #define DECIMAL128_Bytes  16          /* length                     */
  #define DECIMAL128_Pmax   34          /* maximum precision (digits) */
  #define DECIMAL128_Emax   6144        /* maximum adjusted exponent  */
  #define DECIMAL128_Emin  -6143        /* minimum adjusted exponent  */
  #define DECIMAL128_Bias   6176        /* bias for the exponent      */
  #define DECIMAL128_String 43          /* maximum string length, +1  */
  #define DECIMAL128_EconL  12          /* exp. continuation length   */
  /* highest biased exponent (Elimit-1)                               */
  #define DECIMAL128_Ehigh  (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1)

  /* check enough digits, if pre-defined                              */
  #if defined(DECNUMDIGITS)
    #if (DECNUMDIGITS<DECIMAL128_Pmax)
      #error decimal128.h needs pre-defined DECNUMDIGITS>=34 for safe use
    #endif
  #endif

  #ifndef DECNUMDIGITS
    #define DECNUMDIGITS DECIMAL128_Pmax /* size if not already defined*/
  #endif
  #ifndef DECNUMBER
    #include "decNumber.h"              /* context and number library */
  #endif

  /* Decimal 128-bit type, accessible by bytes                        */
  typedef struct {
    uint8_t bytes[DECIMAL128_Bytes]; /* decimal128: 1, 5, 12, 110 bits*/
    } decimal128;

  /* special values [top byte excluding sign bit; last two bits are   */
  /* don't-care for Infinity on input, last bit don't-care for NaN]   */
  #if !defined(DECIMAL_NaN)
    #define DECIMAL_NaN     0x7c        /* 0 11111 00 NaN             */
    #define DECIMAL_sNaN    0x7e        /* 0 11111 10 sNaN            */
    #define DECIMAL_Inf     0x78        /* 0 11110 00 Infinity        */
  #endif



























  /* ---------------------------------------------------------------- */
  /* Routines                                                         */
  /* ---------------------------------------------------------------- */
  /* String conversions                                               */
  decimal128 * decimal128FromString(decimal128 *, const char *, decContext *);
  char * decimal128ToString(const decimal128 *, char *);
  char * decimal128ToEngString(const decimal128 *, char *);

  /* decNumber conversions                                            */
  decimal128 * decimal128FromNumber(decimal128 *, const decNumber *,
                                    decContext *);
  decNumber * decimal128ToNumber(const decimal128 *, decNumber *);

  /* Format-dependent utilities                                       */
  uint32_t    decimal128IsCanonical(const decimal128 *);
  decimal128 * decimal128Canonical(decimal128 *, const decimal128 *);

#endif

Changes to decNumber/decimal32.c.

1
2
3
4
5
6
7
8
9
10
11
/* ------------------------------------------------------------------ */
/* Decimal 32-bit format module                                       */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2006.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is called decNumber.pdf.  This document is           */
/* available, together with arithmetic and format specifications,     */



|







1
2
3
4
5
6
7
8
9
10
11
/* ------------------------------------------------------------------ */
/* Decimal 32-bit format module                                       */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is called decNumber.pdf.  This document is           */
/* available, together with arithmetic and format specifications,     */
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
extern void decNumberShow(const decNumber *);     // ..
#endif

/* Useful macro */
// Clear a structure (e.g., a decNumber)
#define DEC_clear(d) memset(d, 0, sizeof(*d))

#if !DECENDIAN || DECTRACE || DECCHECK
/* compile-time endian tester [assumes sizeof(int)>1] */
static  const  Int mfcone=1;                 // constant 1
static  const  Flag *mfctop=(Flag *)&mfcone; // -> top byte
#define LITEND mfctop[0]           // named flag; 1=little-endian
#endif

/* ------------------------------------------------------------------ */
/* decimal32FromNumber -- convert decNumber to decimal32              */
/*                                                                    */
/*   ds is the target decimal32                                       */
/*   dn is the source number (assumed valid)                          */
/*   set is the context, used only for reporting errors               */
/*                                                                    */







<
<
<
<
<
<
<







45
46
47
48
49
50
51







52
53
54
55
56
57
58
extern void decNumberShow(const decNumber *);     // ..
#endif

/* Useful macro */
// Clear a structure (e.g., a decNumber)
#define DEC_clear(d) memset(d, 0, sizeof(*d))








/* ------------------------------------------------------------------ */
/* decimal32FromNumber -- convert decNumber to decimal32              */
/*                                                                    */
/*   ds is the target decimal32                                       */
/*   dn is the source number (assumed valid)                          */
/*   set is the context, used only for reporting errors               */
/*                                                                    */
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
      }
    targ|=comb<<26;                // add combination field ..
    targ|=(exp&0x3f)<<20;          // .. and exponent continuation
    } // finite

  if (dn->bits&DECNEG) targ|=0x80000000;  // add sign bit

  // now write to storage; this may be endian, or not
  #if DECENDIAN
  // DECENDIAN -- direct store
  pu=(uInt *)d32->bytes;           // overlay
  *pu=targ;                        // directly store the int
  #else
  // not DECENDIAN -- use network byte order
  if (LITEND) {                    // little-endian needs reversal
    uByte *pb;                     // work
    for (pb=&d32->bytes[3]; pb>=d32->bytes; pb--) {
      *pb=(uByte)(targ&0xff);
      targ>>=8;
      } // i
    }
   else { // big-endian; it's the right way round already
    pu=(uInt *)d32->bytes;         // overlay
    *pu=targ;                      // directly store the int
    }
  #endif

  if (status!=0) decContextSetStatus(set, status); // pass on status
  // decimal32Show(d32);
  return d32;
  } // decimal32FromNumber

/* ------------------------------------------------------------------ */
/* decimal32ToNumber -- convert decimal32 to decNumber                */
/*   d32 is the source decimal32                                      */
/*   dn is the target number, with appropriate space                  */
/* No error is possible.                                              */
/* ------------------------------------------------------------------ */
decNumber * decimal32ToNumber(const decimal32 *d32, decNumber *dn) {
  uInt msd;                        // coefficient MSD
  uInt exp;                        // exponent top two bits
  uInt comb;                       // combination field
  uInt *pu;                        // work
  uInt sour;                       // source 32-bit

  // load source from storage; this may be endian, or not
  #if DECENDIAN
  // DECENDIAN -- direct load
  pu=(uInt *)d32->bytes;           // overlay
  sour=*pu;                        // directly load the int
  #else
  // not DECENDIAN -- use network byte order
  if (LITEND) {                    // little-endian needs reversal
    const uByte *pb;               // work
    sour=0;                        // [keep compiler quiet]
    for (pb=d32->bytes; pb<=&d32->bytes[3]; pb++) {
      sour<<=8;
      sour|=*pb;
      } // i
    }
   else { // big-endian; it's the right way round already
    pu=(uInt *)d32->bytes;         // overlay
    sour=*pu;                      // directly load the int
    }
  #endif

  comb=(sour>>26)&0x1f;            // combination field

  decNumberZero(dn);               // clean number
  if (sour&0x80000000) dn->bits=DECNEG; // set sign if negative

  msd=COMBMSD[comb];               // decode the combination field







|
<
<


<
<
<
<
<
<
<
<
<
<
<
<
<
<



















|
<
<


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







153
154
155
156
157
158
159
160


161
162














163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182


183
184















185
186
187
188
189
190
191
      }
    targ|=comb<<26;                // add combination field ..
    targ|=(exp&0x3f)<<20;          // .. and exponent continuation
    } // finite

  if (dn->bits&DECNEG) targ|=0x80000000;  // add sign bit

  // now write to storage; this is endian


  pu=(uInt *)d32->bytes;           // overlay
  *pu=targ;                        // directly store the int















  if (status!=0) decContextSetStatus(set, status); // pass on status
  // decimal32Show(d32);
  return d32;
  } // decimal32FromNumber

/* ------------------------------------------------------------------ */
/* decimal32ToNumber -- convert decimal32 to decNumber                */
/*   d32 is the source decimal32                                      */
/*   dn is the target number, with appropriate space                  */
/* No error is possible.                                              */
/* ------------------------------------------------------------------ */
decNumber * decimal32ToNumber(const decimal32 *d32, decNumber *dn) {
  uInt msd;                        // coefficient MSD
  uInt exp;                        // exponent top two bits
  uInt comb;                       // combination field
  uInt *pu;                        // work
  uInt sour;                       // source 32-bit

  // load source from storage; this is endian


  pu=(uInt *)d32->bytes;           // overlay
  sour=*pu;                        // directly load the int
















  comb=(sour>>26)&0x1f;            // combination field

  decNumberZero(dn);               // clean number
  if (sour&0x80000000) dn->bits=DECNEG; // set sign if negative

  msd=COMBMSD[comb];               // decode the combination field
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
  uInt *pu;                        // work
  char *s, *t;                     // .. (source, target)
  Int  dpd;                        // ..
  Int  pre, e;                     // ..
  const uByte *u;                  // ..
  uInt sour;                       // source 32-bit

  // load source from storage; this may be endian, or not
  #if DECENDIAN
  // DECENDIAN -- direct load
  pu=(uInt *)d32->bytes;           // overlay
  sour=*pu;                        // directly load the int
  #else
  // not DECENDIAN -- use network byte order
  if (LITEND) {                    // little-endian needs reversal
    const uByte *pb;               // work
    sour=0;                        // [keep compiler quiet]
    for (pb=d32->bytes; pb<=&d32->bytes[3]; pb++) {
      sour<<=8;
      sour|=*pb;
      } // i
    }
   else { // big-endian; it's the right way round already
    pu=(uInt *)d32->bytes;         // overlay
    sour=*pu;                      // directly load the int
    }
  #endif

  c=string;                        // where result will go
  if (((Int)sour)<0) *c++='-';     // handle sign

  comb=(sour>>26)&0x1f;            // combination field
  msd=COMBMSD[comb];               // decode the combination field
  exp=COMBEXP[comb];               // ..







|
<
<


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







250
251
252
253
254
255
256
257


258
259















260
261
262
263
264
265
266
  uInt *pu;                        // work
  char *s, *t;                     // .. (source, target)
  Int  dpd;                        // ..
  Int  pre, e;                     // ..
  const uByte *u;                  // ..
  uInt sour;                       // source 32-bit

  // load source from storage; this is endian


  pu=(uInt *)d32->bytes;           // overlay
  sour=*pu;                        // directly load the int
















  c=string;                        // where result will go
  if (((Int)sour)<0) *c++='-';     // handle sign

  comb=(sour>>26)&0x1f;            // combination field
  msd=COMBMSD[comb];               // decode the combination field
  exp=COMBEXP[comb];               // ..
441
442
443
444
445
446
447
































448
























449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
  decimal32FromNumber(result, &dn, &dc);
  if (dc.status!=0) {                        // something happened
    decContextSetStatus(set, dc.status);     // .. pass it on
    }
  return result;
  } // decimal32FromString

































#if DECTRACE || DECCHECK
























/* ------------------------------------------------------------------ */
/* decimal32Show -- display a decimal32 in hexadecimal [debug aid]    */
/*   d32 -- the number to show                                        */
/* ------------------------------------------------------------------ */
// Also shows sign/cob/expconfields extracted - valid bigendian only
void decimal32Show(const decimal32 *d32) {
  char buf[DECIMAL32_Bytes*2+1];
  Int i, j=0;

  #if DECENDIAN
  if (LITEND) {
    for (i=0; i<DECIMAL32_Bytes; i++, j+=2) {
      sprintf(&buf[j], "%02x", d32->bytes[3-i]);
      }
    printf(" D32> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf,
           d32->bytes[3]>>7, (d32->bytes[3]>>2)&0x1f,
           ((d32->bytes[3]&0x3)<<4)| (d32->bytes[2]>>4));
    }
   else {
  #endif
    for (i=0; i<DECIMAL32_Bytes; i++, j+=2) {
      sprintf(&buf[j], "%02x", d32->bytes[i]);
      }
    printf(" D32> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf,
           decimal32Sign(d32), decimal32Comb(d32), decimal32ExpCon(d32));
  #if DECENDIAN
    }
  #endif
  } // decimal32Show
#endif







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









<
|








<





<

<


384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456

457
458
459
460
461
462
463
464
465

466
467
468
469
470

471

472
473
  decimal32FromNumber(result, &dn, &dc);
  if (dc.status!=0) {                        // something happened
    decContextSetStatus(set, dc.status);     // .. pass it on
    }
  return result;
  } // decimal32FromString

/* ------------------------------------------------------------------ */
/* decimal32IsCanonical -- test whether encoding is canonical         */
/*   d32 is the source decimal32                                      */
/*   returns 1 if the encoding of d32 is canonical, 0 otherwise       */
/* No error is possible.                                              */
/* ------------------------------------------------------------------ */
uint32_t decimal32IsCanonical(const decimal32 *d32) {
  decNumber dn;                         // work
  decimal32 canon;                      // ..
  decContext dc;                        // ..
  decContextDefault(&dc, DEC_INIT_DECIMAL32);
  decimal32ToNumber(d32, &dn);
  decimal32FromNumber(&canon, &dn, &dc);// canon will now be canonical
  return memcmp(d32, &canon, DECIMAL32_Bytes)==0;
  } // decimal32IsCanonical

/* ------------------------------------------------------------------ */
/* decimal32Canonical -- copy an encoding, ensuring it is canonical   */
/*   d32 is the source decimal32                                      */
/*   result is the target (may be the same decimal32)                 */
/*   returns result                                                   */
/* No error is possible.                                              */
/* ------------------------------------------------------------------ */
decimal32 * decimal32Canonical(decimal32 *result, const decimal32 *d32) {
  decNumber dn;                         // work
  decContext dc;                        // ..
  decContextDefault(&dc, DEC_INIT_DECIMAL32);
  decimal32ToNumber(d32, &dn);
  decimal32FromNumber(result, &dn, &dc);// result will now be canonical
  return result;
  } // decimal32Canonical

#if DECTRACE || DECCHECK
/* Macros for accessing decimal32 fields.  These assume the argument
   is a reference (pointer) to the decimal32 structure, and the
   decimal32 is in network byte order (big-endian) */
// Get sign
#define decimal32Sign(d)       ((unsigned)(d)->bytes[0]>>7)

// Get combination field
#define decimal32Comb(d)       (((d)->bytes[0] & 0x7c)>>2)

// Get exponent continuation [does not remove bias]
#define decimal32ExpCon(d)     ((((d)->bytes[0] & 0x03)<<4)           \
                             | ((unsigned)(d)->bytes[1]>>4))

// Set sign [this assumes sign previously 0]
#define decimal32SetSign(d, b) {                                      \
  (d)->bytes[0]|=((unsigned)(b)<<7);}

// Set exponent continuation [does not apply bias]
// This assumes range has been checked and exponent previously 0;
// type of exponent must be unsigned
#define decimal32SetExpCon(d, e) {                                    \
  (d)->bytes[0]|=(uint8_t)((e)>>4);                                   \
  (d)->bytes[1]|=(uint8_t)(((e)&0x0F)<<4);}

/* ------------------------------------------------------------------ */
/* decimal32Show -- display a decimal32 in hexadecimal [debug aid]    */
/*   d32 -- the number to show                                        */
/* ------------------------------------------------------------------ */
// Also shows sign/cob/expconfields extracted - valid bigendian only
void decimal32Show(const decimal32 *d32) {
  char buf[DECIMAL32_Bytes*2+1];
  Int i, j=0;


  if (DECLITEND) {
    for (i=0; i<DECIMAL32_Bytes; i++, j+=2) {
      sprintf(&buf[j], "%02x", d32->bytes[3-i]);
      }
    printf(" D32> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf,
           d32->bytes[3]>>7, (d32->bytes[3]>>2)&0x1f,
           ((d32->bytes[3]&0x3)<<4)| (d32->bytes[2]>>4));
    }
   else {

    for (i=0; i<DECIMAL32_Bytes; i++, j+=2) {
      sprintf(&buf[j], "%02x", d32->bytes[i]);
      }
    printf(" D32> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf,
           decimal32Sign(d32), decimal32Comb(d32), decimal32ExpCon(d32));

    }

  } // decimal32Show
#endif

Changes to decNumber/decimal32.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100




101
/* ------------------------------------------------------------------ */
/* Decimal 32-bit format module header                                */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2005.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is called decNumber.pdf.  This document is           */
/* available, together with arithmetic and format specifications,     */
/* testcases, and Web links, at: http://www2.hursley.ibm.com/decimal  */
/*                                                                    */
/* Please send comments, suggestions, and corrections to the author:  */
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */

#if !defined(DECIMAL32)
  #define DECIMAL32
  #define DEC32NAME     "decimal32"                   /* Short name */
  #define DEC32FULLNAME "Decimal 32-bit Number"       /* Verbose name */
  #define DEC32AUTHOR   "Mike Cowlishaw"              /* Who to blame */

  /* parameters for decimal32s */
  #define DECIMAL32_Bytes  4            // length
  #define DECIMAL32_Pmax   7            // maximum precision (digits)
  #define DECIMAL32_Emax   96           // maximum adjusted exponent
  #define DECIMAL32_Emin  -95           // minimum adjusted exponent
  #define DECIMAL32_Bias   101          // bias for the exponent
  #define DECIMAL32_String 15           // maximum string length, +1
  #define DECIMAL32_EconL  6            // exponent continuation length
  // highest biased exponent (Elimit-1)
  #define DECIMAL32_Ehigh  (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1)

  // check enough digits, if pre-defined
  #if defined(DECNUMDIGITS)
    #if (DECNUMDIGITS<DECIMAL32_Pmax)
      #error decimal32.h needs pre-defined DECNUMDIGITS>=7 for safe use
    #endif
  #endif

  #ifndef DECNUMDIGITS
    #define DECNUMDIGITS DECIMAL32_Pmax // size if not already defined
  #endif
  #ifndef DECNUMBER
    #include "decNumber.h"              // context and number library
  #endif

  /* Decimal 32-bit type, accessible by bytes */
  typedef struct {
    uint8_t bytes[DECIMAL32_Bytes];     // decimal32: 1, 5, 6, 20 bits
    } decimal32;

  /* special values [top byte excluding sign bit; last two bits are
     don't-care for Infinity on input, last bit don't-care for NaN] */
  #if !defined(DECIMAL_NaN)
    #define DECIMAL_NaN     0x7c        // 0 11111 00 NaN
    #define DECIMAL_sNaN    0x7e        // 0 11111 10 sNaN
    #define DECIMAL_Inf     0x78        // 0 11110 00 Infinity
  #endif

  /* Macros for accessing decimal32 fields.  These assume the argument
     is a reference (pointer) to the decimal32 structure, and the
     decimal32 is in network byte order (big-endian) */
  // Get sign
  #define decimal32Sign(d)       ((unsigned)(d)->bytes[0]>>7)

  // Get combination field
  #define decimal32Comb(d)       (((d)->bytes[0] & 0x7c)>>2)

  // Get exponent continuation [does not remove bias]
  #define decimal32ExpCon(d)     ((((d)->bytes[0] & 0x03)<<4)         \
                               | ((unsigned)(d)->bytes[1]>>4))

  // Set sign [this assumes sign previously 0]
  #define decimal32SetSign(d, b) {                                    \
    (d)->bytes[0]|=((unsigned)(b)<<7);}

  // Set exponent continuation [does not apply bias]
  // This assumes range has been checked and exponent previously 0;
  // type of exponent must be unsigned
  #define decimal32SetExpCon(d, e) {                                  \
    (d)->bytes[0]|=(uint8_t)((e)>>4);                                 \
    (d)->bytes[1]|=(uint8_t)(((e)&0x0F)<<4);}

  /* ------------------------------------------------------------------ */
  /* Routines                                                           */
  /* ------------------------------------------------------------------ */
  // String conversions
  decimal32 * decimal32FromString(decimal32 *, const char *, decContext *);
  char * decimal32ToString(const decimal32 *, char *);
  char * decimal32ToEngString(const decimal32 *, char *);

  // decNumber conversions
  decimal32 * decimal32FromNumber(decimal32 *, const decNumber *,
                                  decContext *);
  decNumber * decimal32ToNumber(const decimal32 *, decNumber *);





#endif



|

















|




|
|
|
|
|
|
|
|


|







|


|




|


|
|

|
|
|


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
|




|




>
>
>
>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
























64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* ------------------------------------------------------------------ */
/* Decimal 32-bit format module header                                */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2006.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is called decNumber.pdf.  This document is           */
/* available, together with arithmetic and format specifications,     */
/* testcases, and Web links, at: http://www2.hursley.ibm.com/decimal  */
/*                                                                    */
/* Please send comments, suggestions, and corrections to the author:  */
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */

#if !defined(DECIMAL32)
  #define DECIMAL32
  #define DEC32NAME     "decimal32"                   /* Short name   */
  #define DEC32FULLNAME "Decimal 32-bit Number"       /* Verbose name */
  #define DEC32AUTHOR   "Mike Cowlishaw"              /* Who to blame */

  /* parameters for decimal32s */
  #define DECIMAL32_Bytes  4            /* length                     */
  #define DECIMAL32_Pmax   7            /* maximum precision (digits) */
  #define DECIMAL32_Emax   96           /* maximum adjusted exponent  */
  #define DECIMAL32_Emin  -95           /* minimum adjusted exponent  */
  #define DECIMAL32_Bias   101          /* bias for the exponent      */
  #define DECIMAL32_String 15           /* maximum string length, +1  */
  #define DECIMAL32_EconL  6            /* exp. continuation length   */
  /* highest biased exponent (Elimit-1)                               */
  #define DECIMAL32_Ehigh  (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1)

  /* check enough digits, if pre-defined                              */
  #if defined(DECNUMDIGITS)
    #if (DECNUMDIGITS<DECIMAL32_Pmax)
      #error decimal32.h needs pre-defined DECNUMDIGITS>=7 for safe use
    #endif
  #endif

  #ifndef DECNUMDIGITS
    #define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined*/
  #endif
  #ifndef DECNUMBER
    #include "decNumber.h"              /* context and number library */
  #endif

  /* Decimal 32-bit type, accessible by bytes */
  typedef struct {
    uint8_t bytes[DECIMAL32_Bytes];     /* decimal32: 1, 5, 6, 20 bits*/
    } decimal32;

  /* special values [top byte excluding sign bit; last two bits are   */
  /* don't-care for Infinity on input, last bit don't-care for NaN]   */
  #if !defined(DECIMAL_NaN)
    #define DECIMAL_NaN     0x7c        /* 0 11111 00 NaN             */
    #define DECIMAL_sNaN    0x7e        /* 0 11111 10 sNaN            */
    #define DECIMAL_Inf     0x78        /* 0 11110 00 Infinity        */
  #endif

























  /* ---------------------------------------------------------------- */
  /* Routines                                                         */
  /* ---------------------------------------------------------------- */
  /* String conversions                                               */
  decimal32 * decimal32FromString(decimal32 *, const char *, decContext *);
  char * decimal32ToString(const decimal32 *, char *);
  char * decimal32ToEngString(const decimal32 *, char *);

  /* decNumber conversions                                            */
  decimal32 * decimal32FromNumber(decimal32 *, const decNumber *,
                                  decContext *);
  decNumber * decimal32ToNumber(const decimal32 *, decNumber *);

  /* Format-dependent utilities                                       */
  uint32_t    decimal32IsCanonical(const decimal32 *);
  decimal32 * decimal32Canonical(decimal32 *, const decimal32 *);

#endif

Changes to decNumber/decimal64.c.

1
2
3
4
5
6
7
8
9
10
11
/* ------------------------------------------------------------------ */
/* Decimal 64-bit format module                                       */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2006.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is called decNumber.pdf.  This document is           */
/* available, together with arithmetic and format specifications,     */



|







1
2
3
4
5
6
7
8
9
10
11
/* ------------------------------------------------------------------ */
/* Decimal 64-bit format module                                       */
/* ------------------------------------------------------------------ */
/* Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   */
/*                                                                    */
/* This software is made available under the terms of the             */
/* ICU License -- ICU 1.8.1 and later.                                */
/*                                                                    */
/* The description and User's Guide ("The decNumber C Library") for   */
/* this software is called decNumber.pdf.  This document is           */
/* available, together with arithmetic and format specifications,     */
27
28
29
30
31
32
33
34
35




36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>            // [for printf]

#define  DECNUMDIGITS 16      // make decNumbers with space for 16
#include "decNumber.h"        // base number library
#include "decNumberLocal.h"   // decNumber local types, etc.
#include "decimal64.h"        // our primary include

/* Utility routines and tables [in decimal64.c] */
extern const uInt COMBEXP[32], COMBMSD[32];




extern void decDigitsFromDPD(decNumber *, const uInt *, Int);
extern void decDigitsToDPD(const decNumber *, uInt *, Int);

#if DECTRACE || DECCHECK
void decimal64Show(const decimal64 *);            // for debug
extern void decNumberShow(const decNumber *);     // ..
#endif

/* compile-time endian tester [assumes sizeof(Int)>1] */
static  const  Int mfcone=1;                 // constant 1
static  const  Flag *mfctop=(Flag *)&mfcone; // -> top byte
#define LITEND *mfctop             // named flag; 1=little-endian

/* Useful macro */
// Clear a structure (e.g., a decNumber)
#define DEC_clear(d) memset(d, 0, sizeof(*d))

/* define and include the tables to use for conversions */
#define DEC_BIN2CHAR 1
#define DEC_DPD2BIN  1







|

>
>
>
>








<
<
<
<
<







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47





48
49
50
51
52
53
54
#include <stdio.h>            // [for printf]

#define  DECNUMDIGITS 16      // make decNumbers with space for 16
#include "decNumber.h"        // base number library
#include "decNumberLocal.h"   // decNumber local types, etc.
#include "decimal64.h"        // our primary include

/* Utility routines and tables [in decimal64.c]; externs for C++ */
extern const uInt COMBEXP[32], COMBMSD[32];
extern const uShort DPD2BIN[1024];
extern const uShort BIN2DPD[1000];
extern const uByte  BIN2CHAR[4001];

extern void decDigitsFromDPD(decNumber *, const uInt *, Int);
extern void decDigitsToDPD(const decNumber *, uInt *, Int);

#if DECTRACE || DECCHECK
void decimal64Show(const decimal64 *);            // for debug
extern void decNumberShow(const decNumber *);     // ..
#endif






/* Useful macro */
// Clear a structure (e.g., a decNumber)
#define DEC_clear(d) memset(d, 0, sizeof(*d))

/* define and include the tables to use for conversions */
#define DEC_BIN2CHAR 1
#define DEC_DPD2BIN  1
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
      }
    targhi|=comb<<26;              // add combination field ..
    targhi|=(exp&0xff)<<18;        // .. and exponent continuation
    } // finite

  if (dn->bits&DECNEG) targhi|=0x80000000; // add sign bit

  // now write to storage; this may be endian, or not
  #if DECENDIAN
  // DECENDIAN -- direct store, in the right order
  pu=(uInt *)d64->bytes;           // overlay
  if (LITEND) {
    pu[0]=targar[0];               // directly store the low int
    pu[1]=targar[1];               // then the high int
    }
   else {
    pu[0]=targar[1];               // directly store the high int
    pu[1]=targar[0];               // then the low int
    }
  #else
  // not DECENDIAN -- use network byte order
  if (LITEND) {                    // little-endian needs reversal
    uByte *pb;                     // work
    Int off;                       // ..
    for (pb=&d64->bytes[7]; pb>=d64->bytes; pb--) {
      off=1-((pb-d64->bytes)>>2);  // 0 then 1
      *pb=(uByte)(targar[off]&0xff);
      targar[off]>>=8;
      } // i
    }
   else { // big-endian; it's the right way round already
    pu=(uInt *)d64->bytes;         // overlay
    pu[0]=targar[1];               // directly store the high int
    pu[1]=targar[0];               // then the low int
    }
  #endif

  if (status!=0) decContextSetStatus(set, status); // pass on status
  // decimal64Show(d64);
  return d64;
  } // decimal64FromNumber

/* ------------------------------------------------------------------ */







|
<
<

|







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







171
172
173
174
175
176
177
178


179
180
181
182
183
184
185
186
187

















188
189
190
191
192
193
194
      }
    targhi|=comb<<26;              // add combination field ..
    targhi|=(exp&0xff)<<18;        // .. and exponent continuation
    } // finite

  if (dn->bits&DECNEG) targhi|=0x80000000; // add sign bit

  // now write to storage; this is now always endian


  pu=(uInt *)d64->bytes;           // overlay
  if (DECLITEND) {
    pu[0]=targar[0];               // directly store the low int
    pu[1]=targar[1];               // then the high int
    }
   else {
    pu[0]=targar[1];               // directly store the high int
    pu[1]=targar[0];               // then the low int
    }


















  if (status!=0) decContextSetStatus(set, status); // pass on status
  // decimal64Show(d64);
  return d64;
  } // decimal64FromNumber

/* ------------------------------------------------------------------ */
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
  uInt comb;                       // combination field
  uInt *pu;                        // work
  Int  need;                       // ..
  uInt sourar[2];                  // source 64-bit
  #define sourhi sourar[1]         // name the word with the sign
  #define sourlo sourar[0]         // and the lower word

  // load source from storage; this may be endian, or not
  #if DECENDIAN
  // DECENDIAN -- direct load, in the right order
  pu=(uInt *)d64->bytes;           // overlay
  if (LITEND) {
    sourlo=pu[0];                  // directly load the low int
    sourhi=pu[1];                  // then the high int
    }
   else {
    sourhi=pu[0];                  // directly load the high int
    sourlo=pu[1];                  // then the low int
    }
  #else
  // not DECENDIAN -- use network byte order
  if (LITEND) {                    // little-endian needs reversal
    const uByte *pb;               // work
    Int off;                       // ..
    for (pb=d64->bytes; pb<=&d64->bytes[7]; pb++) {
      off=1-((pb-d64->bytes)>>2);  // 1 then 0
      sourar[off]<<=8;
      sourar[off]|=*pb;
      } // i
    }
   else { // big-endian; it's the right way round already
    pu=(uInt *)d64->bytes;         // overlay
    sourhi=pu[0];                  // directly load the high int
    sourlo=pu[1];                  // then the low int
    }
  #endif

  comb=(sourhi>>26)&0x1f;          // combination field

  decNumberZero(dn);               // clean number
  if (sourhi&0x80000000) dn->bits=DECNEG; // set sign if negative

  msd=COMBMSD[comb];               // decode the combination field







|
<
<

|







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







203
204
205
206
207
208
209
210


211
212
213
214
215
216
217
218
219

















220
221
222
223
224
225
226
  uInt comb;                       // combination field
  uInt *pu;                        // work
  Int  need;                       // ..
  uInt sourar[2];                  // source 64-bit
  #define sourhi sourar[1]         // name the word with the sign
  #define sourlo sourar[0]         // and the lower word

  // load source from storage; this is endian


  pu=(uInt *)d64->bytes;           // overlay
  if (DECLITEND) {
    sourlo=pu[0];                  // directly load the low int
    sourhi=pu[1];                  // then the high int
    }
   else {
    sourhi=pu[0];                  // directly load the high int
    sourlo=pu[1];                  // then the low int
    }


















  comb=(sourhi>>26)&0x1f;          // combination field

  decNumberZero(dn);               // clean number
  if (sourhi&0x80000000) dn->bits=DECNEG; // set sign if negative

  msd=COMBMSD[comb];               // decode the combination field
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
  Int  pre, e;                     // ..
  const uByte *u;                  // ..

  uInt sourar[2];                  // source 64-bit
  #define sourhi sourar[1]         // name the word with the sign
  #define sourlo sourar[0]         // and the lower word

  // load source from storage; this may be endian, or not
  #if DECENDIAN
  // DECENDIAN -- direct load, in the right order
  pu=(uInt *)d64->bytes;           // overlay
  if (LITEND) {
    sourlo=pu[0];                  // directly load the low int
    sourhi=pu[1];                  // then the high int
    }
   else {
    sourhi=pu[0];                  // directly load the high int
    sourlo=pu[1];                  // then the low int
    }
  #else
  // not DECENDIAN -- use network byte order
  if (LITEND) {                    // little-endian needs reversal
    const uByte *pb;               // work
    Int off;                       // ..
    for (pb=d64->bytes; pb<=&d64->bytes[7]; pb++) {
      off=1-((pb-d64->bytes)>>2);  // 1 then 0
      sourar[off]<<=8;
      sourar[off]|=*pb;
      } // i
    }
   else { // big-endian; it's the right way round already
    pu=(uInt *)d64->bytes;         // overlay
    sourhi=pu[0];                  // directly load the high int
    sourlo=pu[1];                  // then the low int
    }
  #endif

  c=string;                        // where result will go
  if (((Int)sourhi)<0) *c++='-';   // handle sign

  comb=(sourhi>>26)&0x1f;          // combination field
  msd=COMBMSD[comb];               // decode the combination field
  exp=COMBEXP[comb];               // ..







|
<
<

|







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







296
297
298
299
300
301
302
303


304
305
306
307
308
309
310
311
312

















313
314
315
316
317
318
319
  Int  pre, e;                     // ..
  const uByte *u;                  // ..

  uInt sourar[2];                  // source 64-bit
  #define sourhi sourar[1]         // name the word with the sign
  #define sourlo sourar[0]         // and the lower word

  // load source from storage; this is endian


  pu=(uInt *)d64->bytes;           // overlay
  if (DECLITEND) {
    sourlo=pu[0];                  // directly load the low int
    sourhi=pu[1];                  // then the high int
    }
   else {
    sourhi=pu[0];                  // directly load the high int
    sourlo=pu[1];                  // then the low int
    }


















  c=string;                        // where result will go
  if (((Int)sourhi)<0) *c++='-';   // handle sign

  comb=(sourhi>>26)&0x1f;          // combination field
  msd=COMBMSD[comb];               // decode the combination field
  exp=COMBEXP[comb];               // ..
502
503
504
505
506
507
508
































509
























510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
  decimal64FromNumber(result, &dn, &dc);
  if (dc.status!=0) {                        // something happened
    decContextSetStatus(set, dc.status);     // .. pass it on
    }
  return result;
  } // decimal64FromString

































#if DECTRACE || DECCHECK
























/* ------------------------------------------------------------------ */
/* decimal64Show -- display a decimal64 in hexadecimal [debug aid]    */
/*   d64 -- the number to show                                        */
/* ------------------------------------------------------------------ */
// Also shows sign/cob/expconfields extracted
void decimal64Show(const decimal64 *d64) {
  char buf[DECIMAL64_Bytes*2+1];
  Int i, j=0;

  #if DECENDIAN
  if (LITEND) {
    for (i=0; i<DECIMAL64_Bytes; i++, j+=2) {
      sprintf(&buf[j], "%02x", d64->bytes[7-i]);
      }
    printf(" D64> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf,
           d64->bytes[7]>>7, (d64->bytes[7]>>2)&0x1f,
           ((d64->bytes[7]&0x3)<<6)| (d64->bytes[6]>>2));
    }
   else {
  #endif
    for (i=0; i<DECIMAL64_Bytes; i++, j+=2) {
      sprintf(&buf[j], "%02x", d64->bytes[i]);
      }
    printf(" D64> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf,
           decimal64Sign(d64), decimal64Comb(d64), decimal64ExpCon(d64));
  #if DECENDIAN
    }
  #endif
  } // decimal64Show
#endif

/* ================================================================== */
/* Shared utility routines and tables                                 */
/* ================================================================== */
// define and include the conversion tables to use for shared code







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









<
|







|
<





<

<







444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516

517
518
519
520
521
522
523
524
525

526
527
528
529
530

531

532
533
534
535
536
537
538
  decimal64FromNumber(result, &dn, &dc);
  if (dc.status!=0) {                        // something happened
    decContextSetStatus(set, dc.status);     // .. pass it on
    }
  return result;
  } // decimal64FromString

/* ------------------------------------------------------------------ */
/* decimal64IsCanonical -- test whether encoding is canonical         */
/*   d64 is the source decimal64                                      */
/*   returns 1 if the encoding of d64 is canonical, 0 otherwise       */
/* No error is possible.                                              */
/* ------------------------------------------------------------------ */
uint32_t decimal64IsCanonical(const decimal64 *d64) {
  decNumber dn;                         // work
  decimal64 canon;                      // ..
  decContext dc;                        // ..
  decContextDefault(&dc, DEC_INIT_DECIMAL64);
  decimal64ToNumber(d64, &dn);
  decimal64FromNumber(&canon, &dn, &dc);// canon will now be canonical
  return memcmp(d64, &canon, DECIMAL64_Bytes)==0;
  } // decimal64IsCanonical

/* ------------------------------------------------------------------ */
/* decimal64Canonical -- copy an encoding, ensuring it is canonical   */
/*   d64 is the source decimal64                                      */
/*   result is the target (may be the same decimal64)                 */
/*   returns result                                                   */
/* No error is possible.                                              */
/* ------------------------------------------------------------------ */
decimal64 * decimal64Canonical(decimal64 *result, const decimal64 *d64) {
  decNumber dn;                         // work
  decContext dc;                        // ..
  decContextDefault(&dc, DEC_INIT_DECIMAL64);
  decimal64ToNumber(d64, &dn);
  decimal64FromNumber(result, &dn, &dc);// result will now be canonical
  return result;
  } // decimal64Canonical

#if DECTRACE || DECCHECK
/* Macros for accessing decimal64 fields.  These assume the
   argument is a reference (pointer) to the decimal64 structure,
   and the decimal64 is in network byte order (big-endian) */
// Get sign
#define decimal64Sign(d)       ((unsigned)(d)->bytes[0]>>7)

// Get combination field
#define decimal64Comb(d)       (((d)->bytes[0] & 0x7c)>>2)

// Get exponent continuation [does not remove bias]
#define decimal64ExpCon(d)     ((((d)->bytes[0] & 0x03)<<6)           \
                             | ((unsigned)(d)->bytes[1]>>2))

// Set sign [this assumes sign previously 0]
#define decimal64SetSign(d, b) {                                      \
  (d)->bytes[0]|=((unsigned)(b)<<7);}

// Set exponent continuation [does not apply bias]
// This assumes range has been checked and exponent previously 0;
// type of exponent must be unsigned
#define decimal64SetExpCon(d, e) {                                    \
  (d)->bytes[0]|=(uint8_t)((e)>>6);                                   \
  (d)->bytes[1]|=(uint8_t)(((e)&0x3F)<<2);}

/* ------------------------------------------------------------------ */
/* decimal64Show -- display a decimal64 in hexadecimal [debug aid]    */
/*   d64 -- the number to show                                        */
/* ------------------------------------------------------------------ */
// Also shows sign/cob/expconfields extracted
void decimal64Show(const decimal64 *d64) {
  char buf[DECIMAL64_Bytes*2+1];
  Int i, j=0;


  if (DECLITEND) {
    for (i=0; i<DECIMAL64_Bytes; i++, j+=2) {
      sprintf(&buf[j], "%02x", d64->bytes[7-i]);
      }
    printf(" D64> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf,
           d64->bytes[7]>>7, (d64->bytes[7]>>2)&0x1f,
           ((d64->bytes[7]&0x3)<<6)| (d64->bytes[6]>>2));
    }
   else { // big-endian

    for (i=0; i<DECIMAL64_Bytes; i++, j+=2) {
      sprintf(&buf[j], "%02x", d64->bytes[i]);
      }
    printf(" D64> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf,
           decimal64Sign(d64), decimal64Comb(d64), decimal64ExpCon(d64));

    }

  } // decimal64Show
#endif

/* ================================================================== */
/* Shared utility routines and tables                                 */
/* ================================================================== */
// define and include the conversion tables to use for shared code
563
564
565
566
567
568
569
570

571

572
573


574
575
576
577
578
579
580
/*      COMBEXP - 2-bit most-significant-bits of exponent             */
/*                [11 if an Infinity or NaN]                          */
/*      COMBMSD - 4-bit most-significant-digit                        */
/*                [0=Infinity, 1=NaN if COMBEXP=11]                   */
/*                                                                    */
/* Both are indexed by the 5-bit combination field (0-31)             */
/* ------------------------------------------------------------------ */
const uInt COMBEXP[32]={0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,

                        2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2, 3, 3};

const uInt COMBMSD[32]={0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
                        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 9, 8, 9, 0, 1};



/* ------------------------------------------------------------------ */
/* decDigitsToDPD -- pack coefficient into DPD form                   */
/*                                                                    */
/*   dn   is the source number (assumed valid, max DECMAX754 digits)  */
/*   targ is 1, 2, or 4-element uInt array, which the caller must     */
/*        have cleared to zeros                                       */







|
>
|
>
|
|
>
>







557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
/*      COMBEXP - 2-bit most-significant-bits of exponent             */
/*                [11 if an Infinity or NaN]                          */
/*      COMBMSD - 4-bit most-significant-digit                        */
/*                [0=Infinity, 1=NaN if COMBEXP=11]                   */
/*                                                                    */
/* Both are indexed by the 5-bit combination field (0-31)             */
/* ------------------------------------------------------------------ */
const uInt COMBEXP[32]={0, 0, 0, 0, 0, 0, 0, 0,
                        1, 1, 1, 1, 1, 1, 1, 1,
                        2, 2, 2, 2, 2, 2, 2, 2,
                        0, 0, 1, 1, 2, 2, 3, 3};
const uInt COMBMSD[32]={0, 1, 2, 3, 4, 5, 6, 7,
                        0, 1, 2, 3, 4, 5, 6, 7,
                        0, 1, 2, 3, 4, 5, 6, 7,
                        8, 9, 8, 9, 8, 9, 0, 1};

/* ------------------------------------------------------------------ */
/* decDigitsToDPD -- pack coefficient into DPD form                   */
/*                                                                    */
/*   dn   is the source number (assumed valid, max DECMAX754 digits)  */
/*   targ is 1, 2, or 4-element uInt array, which the caller must     */
/*        have cleared to zeros                                       */

Changes to decNumber/decimal64.h.

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101




102
103
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */

#if !defined(DECIMAL64)
  #define DECIMAL64
  #define DEC64NAME     "decimal64"                   /* Short name */
  #define DEC64FULLNAME "Decimal 64-bit Number"       /* Verbose name */
  #define DEC64AUTHOR   "Mike Cowlishaw"              /* Who to blame */


  /* parameters for decimal64s */
  #define DECIMAL64_Bytes  8            // length
  #define DECIMAL64_Pmax   16           // maximum precision (digits)
  #define DECIMAL64_Emax   384          // maximum adjusted exponent
  #define DECIMAL64_Emin  -383          // minimum adjusted exponent
  #define DECIMAL64_Bias   398          // bias for the exponent
  #define DECIMAL64_String 24           // maximum string length, +1
  #define DECIMAL64_EconL  8            // exponent continuation length
  // highest biased exponent (Elimit-1)
  #define DECIMAL64_Ehigh  (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1)

  // check enough digits, if pre-defined
  #if defined(DECNUMDIGITS)
    #if (DECNUMDIGITS<DECIMAL64_Pmax)
      #error decimal64.h needs pre-defined DECNUMDIGITS>=16 for safe use
    #endif
  #endif


  #ifndef DECNUMDIGITS
    #define DECNUMDIGITS DECIMAL64_Pmax // size if not already defined
  #endif
  #ifndef DECNUMBER
    #include "decNumber.h"              // context and number library
  #endif

  /* Decimal 64-bit type, accessible by bytes */
  typedef struct {
    uint8_t bytes[DECIMAL64_Bytes];     // decimal64: 1, 5, 8, 50 bits
    } decimal64;

  /* special values [top byte excluding sign bit; last two bits are
     don't-care for Infinity on input, last bit don't-care for NaN] */
  #if !defined(DECIMAL_NaN)
    #define DECIMAL_NaN     0x7c        // 0 11111 00 NaN
    #define DECIMAL_sNaN    0x7e        // 0 11111 10 sNaN
    #define DECIMAL_Inf     0x78        // 0 11110 00 Infinity
  #endif

  /* Macros for accessing decimal64 fields.  These assume the argument
     is a reference (pointer) to the decimal64 structure, and the
     decimal64 is in network byte order (big-endian) */
  // Get sign
  #define decimal64Sign(d)       ((unsigned)(d)->bytes[0]>>7)

  // Get combination field
  #define decimal64Comb(d)       (((d)->bytes[0] & 0x7c)>>2)

  // Get exponent continuation [does not remove bias]
  #define decimal64ExpCon(d)     ((((d)->bytes[0] & 0x03)<<6)         \
                               | ((unsigned)(d)->bytes[1]>>2))

  // Set sign [this assumes sign previously 0]
  #define decimal64SetSign(d, b) {                                    \
    (d)->bytes[0]|=((unsigned)(b)<<7);}

  // Set exponent continuation [does not apply bias]
  // This assumes range has been checked and exponent previously 0; type
  // of exponent must be unsigned
  #define decimal64SetExpCon(d, e) {                                  \
    (d)->bytes[0]|=(uint8_t)((e)>>6);                                 \
    (d)->bytes[1]|=(uint8_t)(((e)&0x3F)<<2);}

  /* ------------------------------------------------------------------ */
  /* Routines                                                           */
  /* ------------------------------------------------------------------ */
  // String conversions
  decimal64 * decimal64FromString(decimal64 *, const char *, decContext *);
  char * decimal64ToString(const decimal64 *, char *);
  char * decimal64ToEngString(const decimal64 *, char *);

  // decNumber conversions
  decimal64 * decimal64FromNumber(decimal64 *, const decNumber *,
                                  decContext *);
  decNumber * decimal64ToNumber(const decimal64 *, decNumber *);





#endif







|




|
|
|
|
|
|
|
|
|


|








|


|


|

|


|
|

|
|
|


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
|




|



>
>
>
>


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
























66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*   mfc@uk.ibm.com                                                   */
/*   Mike Cowlishaw, IBM Fellow                                       */
/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
/* ------------------------------------------------------------------ */

#if !defined(DECIMAL64)
  #define DECIMAL64
  #define DEC64NAME     "decimal64"                   /* Short name   */
  #define DEC64FULLNAME "Decimal 64-bit Number"       /* Verbose name */
  #define DEC64AUTHOR   "Mike Cowlishaw"              /* Who to blame */


  /* parameters for decimal64s                                        */
  #define DECIMAL64_Bytes  8            /* length                     */
  #define DECIMAL64_Pmax   16           /* maximum precision (digits) */
  #define DECIMAL64_Emax   384          /* maximum adjusted exponent  */
  #define DECIMAL64_Emin  -383          /* minimum adjusted exponent  */
  #define DECIMAL64_Bias   398          /* bias for the exponent      */
  #define DECIMAL64_String 24           /* maximum string length, +1  */
  #define DECIMAL64_EconL  8            /* exp. continuation length   */
  /* highest biased exponent (Elimit-1)                               */
  #define DECIMAL64_Ehigh  (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1)

  /* check enough digits, if pre-defined                              */
  #if defined(DECNUMDIGITS)
    #if (DECNUMDIGITS<DECIMAL64_Pmax)
      #error decimal64.h needs pre-defined DECNUMDIGITS>=16 for safe use
    #endif
  #endif


  #ifndef DECNUMDIGITS
    #define DECNUMDIGITS DECIMAL64_Pmax /* size if not already defined*/
  #endif
  #ifndef DECNUMBER
    #include "decNumber.h"              /* context and number library */
  #endif

  /* Decimal 64-bit type, accessible by bytes                         */
  typedef struct {
    uint8_t bytes[DECIMAL64_Bytes];     /* decimal64: 1, 5, 8, 50 bits*/
    } decimal64;

  /* special values [top byte excluding sign bit; last two bits are   */
  /* don't-care for Infinity on input, last bit don't-care for NaN]   */
  #if !defined(DECIMAL_NaN)
    #define DECIMAL_NaN     0x7c        /* 0 11111 00 NaN             */
    #define DECIMAL_sNaN    0x7e        /* 0 11111 10 sNaN            */
    #define DECIMAL_Inf     0x78        /* 0 11110 00 Infinity        */
  #endif

























  /* ---------------------------------------------------------------- */
  /* Routines                                                         */
  /* ---------------------------------------------------------------- */
  /* String conversions                                               */
  decimal64 * decimal64FromString(decimal64 *, const char *, decContext *);
  char * decimal64ToString(const decimal64 *, char *);
  char * decimal64ToEngString(const decimal64 *, char *);

  /* decNumber conversions                                            */
  decimal64 * decimal64FromNumber(decimal64 *, const decNumber *,
                                  decContext *);
  decNumber * decimal64ToNumber(const decimal64 *, decNumber *);

  /* Format-dependent utilities                                       */
  uint32_t    decimal64IsCanonical(const decimal64 *);
  decimal64 * decimal64Canonical(decimal64 *, const decimal64 *);

#endif

Changes to decNumber/example6.c.

48
49
50
51
52
53
54
55
56
57
58
59

  decPackedFromNumber(respack, sizeof(respack), &resscale, &total);

  // lay out the total as sixteen hexadecimal pairs
  for (i=0; i<16; i++) {
    sprintf(&hexes[i*3], "%02x ", respack[i]);
    }
  printf("Result: %s (scale=%d)\n", hexes, resscale);

  } //---------------------------------------------------------------|
  return 0;
  } // main







|




48
49
50
51
52
53
54
55
56
57
58
59

  decPackedFromNumber(respack, sizeof(respack), &resscale, &total);

  // lay out the total as sixteen hexadecimal pairs
  for (i=0; i<16; i++) {
    sprintf(&hexes[i*3], "%02x ", respack[i]);
    }
  printf("Result: %s (scale=%ld)\n", hexes, resscale);

  } //---------------------------------------------------------------|
  return 0;
  } // main

Changes to decNumber/readme.txt.

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60


61
62
63
64
65
66
67

     Note: a commercial license for this code is also available by
     following the 'License this technology' link from the alphaWorks
     page: http://www.alphaWorks.ibm.com/tech/decnumber

  *  decNumber.pdf (documentation)

  *  The .c and .h file for each module in the package (see
     documentation), decDPD.h (used by decimal32), and
     decNumberLocal.h (local definitions)

  *  The .c files for each of the examples (example1.c through
     example6.c)

The alphaWorks package is made available under the terms of the IBM
alphaWorks License Agreement (included in various languages in the
file alphaWorks-license-files.zip), unless you have agreed different
licensing terms with IBM.  Your use of that package indicates your
acceptance of the terms and conditions of that Agreement.

The ICU package is made available under the terms of the ICU License
(ICU 1.8.1 and later) included in the package as ICU-license.html.
Your use of that package indicates your acceptance of the terms and
conditions of that Agreement.



To use and check decNumber
--------------------------

  Please read the appropriate license and documentation before using
  this package.



  1. Compile and link example1.c, decNumber.c, and decContext.c
     For example:

       gcc -o example1 example1.c decNumber.c decContext.c

     Note: If your compiler does not provide stdint.h or if your C







|
|



|


















|
>
>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

     Note: a commercial license for this code is also available by
     following the 'License this technology' link from the alphaWorks
     page: http://www.alphaWorks.ibm.com/tech/decnumber

  *  decNumber.pdf (documentation)

  *  The .c and .h file for each module in the package (see the
     decNumber documentation), decDPD.h (used by decimal64), and
     decNumberLocal.h (local definitions)

  *  The .c files for each of the examples (example1.c through
     example6.c).

The alphaWorks package is made available under the terms of the IBM
alphaWorks License Agreement (included in various languages in the
file alphaWorks-license-files.zip), unless you have agreed different
licensing terms with IBM.  Your use of that package indicates your
acceptance of the terms and conditions of that Agreement.

The ICU package is made available under the terms of the ICU License
(ICU 1.8.1 and later) included in the package as ICU-license.html.
Your use of that package indicates your acceptance of the terms and
conditions of that Agreement.



To use and check decNumber
--------------------------

  Please read the appropriate license and documentation before using
  this package.  If you are upgrading an existing use of decNumber
  (version <= 3.37) please read the Changes Appendix for later
  versions -- you may need to change the DECLITEND flag.

  1. Compile and link example1.c, decNumber.c, and decContext.c
     For example:

       gcc -o example1 example1.c decNumber.c decContext.c

     Note: If your compiler does not provide stdint.h or if your C

Changes to doc/ldecNumber.odt.

cannot compute difference between binary files

Changes to doc/ldecNumber.pod.

134
135
136
137
138
139
140





141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
retaining the spelling, and 

=item *

retaining the case for constant names

=back






Wherever there was a predefined Lua metamethod, e. g., C<__add>, the 
appropriate function is bound to that name as well as the B<decNumber> 
package function name.

Where it seemed appropriate, functions are provided both as methods 
on decimal numbers, as well as functions in the C<decNumber> module.

=head2 Mutability

The decimal numbers created by Lua are not mutable. This decision 
was based on my judgment that the potential performance benefit, 
mainly lower memory consumption and less garbage collection, was 
outweighed by the safety and lack of “surprise†that immutability 
provides. This makes decimal numbers compatible with Lua numbers 
and strings, both of which are also not mutable.

=head2 Conversion

All the functions in the C<decNumber> module automatically convert 
their arguments from Lua numbers or strings as necessary to perform 







>
>
>
>
>













|







134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
retaining the spelling, and 

=item *

retaining the case for constant names

=back

There are two cases where in following these rules the B<decNumber> 
names clash with Lua reserved words C<or> and C<and> -- in these 
cases the B<decNumber> functions are called "logical" operations,
so I called the functions C<lor> and C<land>.

Wherever there was a predefined Lua metamethod, e. g., C<__add>, the 
appropriate function is bound to that name as well as the B<decNumber> 
package function name.

Where it seemed appropriate, functions are provided both as methods 
on decimal numbers, as well as functions in the C<decNumber> module.

=head2 Mutability

The decimal numbers created by Lua are not mutable. This decision 
was based on my judgment that the potential performance benefit, 
mainly lower memory consumption and less garbage collection, was 
outweighed by the safety and lack of "surprise" that immutability 
provides. This makes decimal numbers compatible with Lua numbers 
and strings, both of which are also not mutable.

=head2 Conversion

All the functions in the C<decNumber> module automatically convert 
their arguments from Lua numbers or strings as necessary to perform 
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
is included, but has been designed for WindowsXP.

=head2 Compliance Test

File: I<ldecNumberTestDriver.lua>

This is the big test. It uses dectest sources from IBM, and has 
over 25,000 test cases. The Lua file is a driver to execute the tests 
specified by dectest.

Since version 10 of the Lua C<decNumber> module, the results for this 
test are: 

C<For all 26205 tests, 26047 succeeded, 5 failed, 54 failed(conv), 69 skipped(#), 30 skipped(prec).>

This is as good as possible with the default configuration. What this means is:

	26047 succeeded	woot!
	5 failed	these 5 tests are know to fail in the decNumber C library;
             these edge cases are under reconsideration in the Decimal Number Specification
	54 failed(conv)	 the precision required for the operands is insufficient in the Lua wrapper
	69 skipped(#)	 the test is for NULL arguments or format conversions not supported
	30 skipped(prec) the test called for a  precision larger than provided in the Lua wrapper

=head1 REFERENCE

Here is a reference to the data types, constants, and functions in the 
C<decNumber> module. Many of these will refer to the decNumber C library 
User's Guide, I<decNumber.pdf>, for implementation details.








|


|
|

|



|


|
|
|







211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
is included, but has been designed for WindowsXP.

=head2 Compliance Test

File: I<ldecNumberTestDriver.lua>

This is the big test. It uses dectest sources from IBM, and has 
over 60,000 test cases. The Lua file is a driver to execute the tests 
specified by dectest.

As of version 21 of the Lua C<decNumber> module, the results for this 
test (dectest version 2.55) are: 

C<For all 60937 tests, 59951 succeeded, 5 failed, 301 failed(conv), 644 skipped(#), 36 skipped(prec).>

This is as good as possible with the default configuration. What this means is:

	59951 succeeded	woot!
	5 failed	these 5 tests are know to fail in the decNumber C library;
             these edge cases are under reconsideration in the Decimal Number Specification
	301 failed(conv)	 the precision required for the operands is insufficient in the Lua wrapper
	644 skipped(#)	 the test is for NULL arguments or format conversions not supported
	36 skipped(prec) the test called for a  precision larger than provided in the Lua wrapper

=head1 REFERENCE

Here is a reference to the data types, constants, and functions in the 
C<decNumber> module. Many of these will refer to the decNumber C library 
User's Guide, I<decNumber.pdf>, for implementation details.

312
313
314
315
316
317
318

319
320
321
322
323
324
325
    decNumber.ROUND_CEILING     round towards +infinity
    decNumber.ROUND_UP          round away from 0
    decNumber.ROUND_HALF_UP     0.5 rounds up
    decNumber.ROUND_HALF_EVEN   0.5 rounds to nearest even
    decNumber.ROUND_HALF_DOWN   0.5 rounds down
    decNumber.ROUND_DOWN        round towards 0 (truncate)
    decNumber.ROUND_FLOOR       round towards -infinity


=head1 Status Flags

These numeric status flags are used with 
L<C<decctx:getstatus()>|/decctx:getstatus>

    decNumber.Conversion_syntax







>







317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
    decNumber.ROUND_CEILING     round towards +infinity
    decNumber.ROUND_UP          round away from 0
    decNumber.ROUND_HALF_UP     0.5 rounds up
    decNumber.ROUND_HALF_EVEN   0.5 rounds to nearest even
    decNumber.ROUND_HALF_DOWN   0.5 rounds down
    decNumber.ROUND_DOWN        round towards 0 (truncate)
    decNumber.ROUND_FLOOR       round towards -infinity
    decNumber.ROUND_05UP        round for reround

=head1 Status Flags

These numeric status flags are used with 
L<C<decctx:getstatus()>|/decctx:getstatus>

    decNumber.Conversion_syntax
343
344
345
346
347
348
349





















350
351
352
353
354
355
356
    decNumber.IEEE_854_Invalid_operation
    decNumber.IEEE_854_Overflow
    decNumber.IEEE_854_Underflow
    decNumber.Errors       normally errors (results are qNaN, infinite, or 0)
    decNumber.NaNs         cause a result to become qNaN
    decNumber.Information  normally for information only (have finite results)






















=head1 Initialization Descriptors

These constants are used with 
L<C<decctx:setdefault(x)>|/decctx:setdefault>

    decNumber.INIT_BASE
    decNumber.INIT_DECIMAL32







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
    decNumber.IEEE_854_Invalid_operation
    decNumber.IEEE_854_Overflow
    decNumber.IEEE_854_Underflow
    decNumber.Errors       normally errors (results are qNaN, infinite, or 0)
    decNumber.NaNs         cause a result to become qNaN
    decNumber.Information  normally for information only (have finite results)

=head1 Classifications

These numeric classifications for decNumbers are aligned with IEEE 754r 
and are returned by 
L<C<decnum:class()>|/decnum:class> 
Note that 'normal' and 'subnormal' are meaningful only with a decContext.

    decNumber.CLASS_SNAN
    decNumber.CLASS_QNAN
    decNumber.CLASS_NEG_INF
    decNumber.CLASS_NEG_NORMAL
    decNumber.CLASS_NEG_SUBNORMAL
    decNumber.CLASS_NEG_ZERO
    decNumber.CLASS_POS_ZERO
    decNumber.CLASS_POS_SUBNORMAL
    decNumber.CLASS_POS_NORMAL
    decNumber.CLASS_POS_INF

These classifications are also returned as string values from 
L<C<decnum:classasstring()>|/decnum:classasstring>

=head1 Initialization Descriptors

These constants are used with 
L<C<decctx:setdefault(x)>|/decctx:setdefault>

    decNumber.INIT_BASE
    decNumber.INIT_DECIMAL32
673
674
675
676
677
678
679




















































680
681
682
683
684
685
686

Note that by binding the method C<__add> to this function, the 
Lua addition operator (C<+>) may be used with a C<decnum> on the 
left and a C<decarg> on the right.

Uses the C library function C<decNumberAdd()>.





















































=head2 C<decnum:divide>

    decnum:divide (decarg)
    decnum:__div (decarg)
    decNumber.divide (decarg, decarg)

Returns a decimal number that is the left (1st) argument divided 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765

Note that by binding the method C<__add> to this function, the 
Lua addition operator (C<+>) may be used with a C<decnum> on the 
left and a C<decarg> on the right.

Uses the C library function C<decNumberAdd()>.

=head2 C<decnum:copy>

    decnum:copy ()
    decNumber.copy (decarg)

Returns a decimal number that is a copy of its argument. This is 
not too useful since C<decnum>s are immutable in B<ldecNumber>,
but it could be used as an alternative to 
L<C<decnum:tonumber>|/decnum:tonumber>
No error is possible from this function when its argument is a 
C<decnum>.

Uses the C library function C<decNumberCopy()>.

=head2 C<decnum:copyabs>

    decnum:copyabs ()
    decNumber.copyabs (decarg)

Returns a decimal number that is the absolute value of its argument.
This is the quiet C<abs> function described in IEEE 754r.
No error is possible from this function when its argument is a 
C<decnum>.

Uses the C library function C<decNumberCopyAbs()>.

=head2 C<decnum:copynegate>

    decnum:copynegate ()
    decNumber.copynegate (decarg)

Returns a decimal number that is the negation of its argument, in
other words it returns a copy of its argument with the sign inverted.
This is the quiet C<negate> function described in IEEE 754r.
No error is possible from this function when its argument is a 
C<decnum>.

Uses the C library function C<decNumberCopyNegate()>.

=head2 C<decnum:copysign>

    decnum:copysign (decarg)
    decNumber.copysign (decarg, decarg)

Returns a decimal number that is a copy of its first argument but 
with the sign of its second argument.
This is the quiet C<copysign> function described in IEEE 754r.
No error is possible from this function when its arguments are 
both C<decnum>s.

Uses the C library function C<decNumberCopySign()>.

=head2 C<decnum:divide>

    decnum:divide (decarg)
    decnum:__div (decarg)
    decNumber.divide (decarg, decarg)

Returns a decimal number that is the left (1st) argument divided 
732
733
734
735
736
737
738



































739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758

























759
760
761
762
763
764
765
766
767












768
769
770
771
772
773
774
775
776












777
778
779
780
781
782
783
The current context's rounding mode is used. 
See L<C<decnum:mod>|/decnum:mod>.

Uses the C library function C<decNumberDivideInteger()>, and then 
C<decNumberMultiply()> followed by C<decNumberCompare() decNumberIsZero()> 
to check if the remainder is zero, and C<decNumberSubtract()>.




































=head2 C<decnum:ln>

    decnum:ln ()
    decNumber.ln (decarg)

Returns a decimal number that is the natural logarithm (logarithm in 
base e) of the argument.

Uses the C library function C<decNumberLn()>.

=head2 C<decnum:log10>

    decnum:log10 ()
    decNumber.log10 (decarg)

Returns a decimal number that is the logarithm in base ten of the 
argument.

Uses the C library function C<decNumberLog10()>.


























=head2 C<decnum:max>

    decnum:max (decarg)
    decNumber.max (decarg, decarg)

Returns a decimal number that is the maximum of its arguments.

Uses the C library function C<decNumberMax()>.













=head2 C<decnum:min>

    decnum:min (decarg)
    decNumber.min (decarg, decarg)

Returns a decimal number that is the minimum of its arguments.

Uses the C library function C<decNumberMin()>.













=head2 C<decnum:minus>

    decnum:minus ()
    decnum:__unm ()
    decNumber.minus (decarg)

Returns a decimal number that is the result of subtracting 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









>
>
>
>
>
>
>
>
>
>
>
>









>
>
>
>
>
>
>
>
>
>
>
>







811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
The current context's rounding mode is used. 
See L<C<decnum:mod>|/decnum:mod>.

Uses the C library function C<decNumberDivideInteger()>, and then 
C<decNumberMultiply()> followed by C<decNumberCompare() decNumberIsZero()> 
to check if the remainder is zero, and C<decNumberSubtract()>.

=head2 C<decnum:fma>

    decnum:fma (decarg,decarg)
    decNumber.fma (decarg, decarg, decarg)

Returns a decimal number that is the result of multiplying the first
argument by the second argument and then adding the third argument to 
that intermediate result. It is equivalent to a multiplication followed 
by an addition except that the intermediate result is not rounded and 
will not cause overflow or underflow. That is, only the final result 
is rounded and checked.

Uses the C library function C<decNumberFMA()>.

=head2 C<decnum:invert>

    decnum:invert ()
    decNumber.invert (decarg)

Returns a decimal number that is the result of the digit-wise logical 
inversion of the argument (a 0 digit becomes 1 and vice versa).

Uses the C library function C<decNumberInvert()>.

=head2 C<decnum:land>

    decnum:land (decarg)
    decNumber.land (decarg, decarg)

Returns a decimal number that is the digit-wise logical and of the 
arguments. Note that all digits of the arguments must be 0 or 1 or
else this operation returns NaN,

Uses the C library function C<decNumberAnd()>.

=head2 C<decnum:ln>

    decnum:ln ()
    decNumber.ln (decarg)

Returns a decimal number that is the natural logarithm (logarithm in 
base e) of the argument.

Uses the C library function C<decNumberLn()>.

=head2 C<decnum:log10>

    decnum:log10 ()
    decNumber.log10 (decarg)

Returns a decimal number that is the logarithm in base ten of the 
argument.

Uses the C library function C<decNumberLog10()>.

=head2 C<decnum:logb>

    decnum:logb ()
    decNumber.logb (decarg)

Returns a decimal number that is the adjusted exponent of the 
argument, according to the rules for the C<logB> operation of the 
IEEE 754r proposal. This returns the exponent of the argument as 
though its decimal point had been moved to follow the first digit 
while keeping the same value. The result is not limited by 
C<emin> or C<emax>.

Uses the C library function C<decNumberLogB()>.

=head2 C<decnum:lor>

    decnum:lor (decarg)
    decNumber.lor (decarg, decarg)

Returns a decimal number that is the digit-wise logical inclusive or 
of the arguments. Note that all digits of the arguments must be 0 or 
1 or else this operation returns NaN,

Uses the C library function C<decNumberOr()>.

=head2 C<decnum:max>

    decnum:max (decarg)
    decNumber.max (decarg, decarg)

Returns a decimal number that is the maximum of its arguments.

Uses the C library function C<decNumberMax()>.

=head2 C<decnum:maxmag>

    decnum:maxmag (decarg)
    decNumber.maxmag (decarg, decarg)

Returns a decimal number that is the one of its arguments that 
has the maximum magnitude. It is identical to 
L<C<decnum:max>|/decnum:max> except that the signs of the operands 
are ignored and taken to be 0 (non-negative).

Uses the C library function C<decNumberMaxMag()>.

=head2 C<decnum:min>

    decnum:min (decarg)
    decNumber.min (decarg, decarg)

Returns a decimal number that is the minimum of its arguments.

Uses the C library function C<decNumberMin()>.

=head2 C<decnum:minmag>

    decnum:minmag (decarg)
    decNumber.minmag (decarg, decarg)

Returns a decimal number that is the one of its arguments that 
has the minimum magnitude. It is identical to 
L<C<decnum:min>|/decnum:min> except that the signs of the operands 
are ignored and taken to be 0 (non-negative).

Uses the C library function C<decNumberMinMag()>.

=head2 C<decnum:minus>

    decnum:minus ()
    decnum:__unm ()
    decNumber.minus (decarg)

Returns a decimal number that is the result of subtracting 
826
827
828
829
830
831
832




















































833
834
835
836
837
838
839
840

Note that by binding the method C<__mul> to this function, the Lua 
multiplication operator (C<*>) may be used with a C<decnum> on the 
left and a C<decarg> on the right.

Uses the C library function C<decNumberMultiply()>.





















































=head2 C<ddecnum:normalize>

    decnum:normalize ()
    decNumber.normalize (decarg)

Returns a decimal number that is the result of adding the argument 
to 0, and putting the result in its simplest form. That is, a non-zero 
number which has any trailing zeros in the coefficient has those zeros 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055

Note that by binding the method C<__mul> to this function, the Lua 
multiplication operator (C<*>) may be used with a C<decnum> on the 
left and a C<decarg> on the right.

Uses the C library function C<decNumberMultiply()>.

=head2 C<decnum:nextminus>

    decnum:nextminus ()
    decNumber.nextminus (decarg)

Returns a decimal number that is the closest value to the argument 
in the direction of -Infinity. This is computed as though by 
subtracting an infinitesimal amount from the argument 
using C<ROUND_FLOOR>, except that no flags are set as long as the 
argument is a C<decnum> (unless the argument is a signaling NaN).

This function is a generalization of the IEEE 754 C<nextDown> 
operation.

Uses the C library function C<decNumberNextMinus()>.

=head2 C<decnum:nextplus>

    decnum:nextplus ()
    decNumber.nextplus (decarg)

Returns a decimal number that is the closest value to the argument 
in the direction of +Infinity. This is computed as though by 
adding an infinitesimal amount from the argument 
using C<ROUND_CEILING>, except that no flags are set as long as the 
argument is a C<decnum> (unless the argument is a signaling NaN).

This function is a generalization of the IEEE 754 C<nextUp> 
operation.

Uses the C library function C<decNumberNextPlus()>.

=head2 C<decnum:nexttoward>

    decnum:nexttoward (decarg)
    decNumber.nexttoward (decarg, decarg)

Returns a decimal number that is the closest value to the first 
argument in the direction of the second argument. This is computed 
as though by adding or subtracting an infinitesimal amount to the 
first argument using either C<ROUND_CEILING> or C<ROUND_FLOOR>
depending on whether the second argument is larger or smaller than
the first argument. If the arguments are numerically equal, then 
the result is a copy of the first argument with the sign of the 
second argument. Flags are set as usual for an addition or 
subtraction (no flags are set in the equals case). 

This function is a generalization of the IEEE 754 C<nextAfter> 
operation.

Uses the C library function C<decNumberNextToward()>.

=head2 C<decnum:normalize>

    decnum:normalize ()
    decNumber.normalize (decarg)

Returns a decimal number that is the result of adding the argument 
to 0, and putting the result in its simplest form. That is, a non-zero 
number which has any trailing zeros in the coefficient has those zeros 
931
932
933
934
935
936
937




















938
939
940
941
942
943
944
945
946
947
948
949
950


































951
952
953
954
955
956
957
has the value of the right (2nd) argument. See 
L<C<decnum:quantize>|/decnum:quantize>. 
The right (2nd) argument must be a whole number (before any rounding); 
that is, any digits in the fractional part of the number must be zero.

Uses the C library function C<decNumberRescale()>.





















=head2 C<decnum:samequantum>

    decnum:samequantum (decarg)
    decNumber.samequantum (decarg, decarg)

Returns the decimal number 1 when the exponents of the arguments are 
equal, or if they are both Infinities or they are both NaNs; in all 
other cases returns the decimal number 0. This function is used to 
test whether the exponents of two numbers are equal. The coefficients 
and signs of the arguments are ignored.

Uses the C library function C<decNumberSameQuantum()>.



































=head2 C<decnum:squareroot>

    decnum:squareroot ()
    decNumber.squareroot (decarg)

Returns a decimal number that is the square root of its argument, 
rounded if necessary using the digits setting in the decimal context 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>













>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
has the value of the right (2nd) argument. See 
L<C<decnum:quantize>|/decnum:quantize>. 
The right (2nd) argument must be a whole number (before any rounding); 
that is, any digits in the fractional part of the number must be zero.

Uses the C library function C<decNumberRescale()>.

=head2 C<decnum:rotate>

    decnum:rotate (decarg)
    decNumber.rotate (decarg, decarg)

Returns a decimal number that is the first argument with the digits 
of its coefficient rotated to the left (if the second argument is 
positive) or to the right (if the second argument is negative) 
without adjusting the exponent or the sign.

If the first argument has fewer digits than context C<digits> the 
coefficient is padded with zeros on the left before the
rotate. Any leading zeros in the result are ignored, as usual.

The second argument is the count of digits to rotate; it must be an 
integer (that is, it must have an exponent of 0) and must be in the 
range C<-digits> through C<+digits> in the current context.

Uses the C library function C<decNumberRotate()>.

=head2 C<decnum:samequantum>

    decnum:samequantum (decarg)
    decNumber.samequantum (decarg, decarg)

Returns the decimal number 1 when the exponents of the arguments are 
equal, or if they are both Infinities or they are both NaNs; in all 
other cases returns the decimal number 0. This function is used to 
test whether the exponents of two numbers are equal. The coefficients 
and signs of the arguments are ignored.

Uses the C library function C<decNumberSameQuantum()>.

=head2 C<decnum:scaleb>

    decnum:scaleb (decarg)
    decNumber.scaleb (decarg, decarg)

This function returns the result of multiplying the first argument by
ten raised to the power of the second argument. It is used to adjust 
(scale) the exponent of a number, using the rules of the C<scaleB> 
operation in the IEEE 754r proposal. The second argument must be an 
integer (that is, it must have an exponent of 0) and it must also be 
in the range C<-n> through C<+n>, where C<n> is 
C<2 * (context.emax + context.digits)>.

Uses the C library function C<decNumberScaleB()>.

=head2 C<decnum:shift>

    decnum:shift (decarg)
    decNumber.shift (decarg, decarg)

Returns a decimal number that is the first argument with the digits 
of its coefficient shifted to the left (if the second argument is 
positive) or to the right (if the second argument is negative) 
without adjusting the exponent or the sign.

The coefficient is padded with zeros on the left or right, as 
necessary. Any leading zeros in the result are ignored, as usual.

The second argument is the count of digits to shift; it must be an 
integer (that is, it must have an exponent of 0) and must be in the 
range C<-digits> through C<+digits> in the current context.

Uses the C library function C<decNumberShift()>.

=head2 C<decnum:squareroot>

    decnum:squareroot ()
    decNumber.squareroot (decarg)

Returns a decimal number that is the square root of its argument, 
rounded if necessary using the digits setting in the decimal context 
970
971
972
973
974
975
976
















977
978
979
980
981
982
983
984




985
986
987
988
989
990
991
992
993
994
995
996
997
998
999











1000
1001


































1002
1003
1004
1005
1006
1007
1008

Note that by binding the method C<__sub> to this function, the Lua 
subtraction operator (C<->) may be used with a C<decnum> on the left 
and a C<decarg> on the right.

Uses the C library function C<decNumberSubtract()>.

















=head2 C<decnum:tointegralvalue>

    decnum:tointegralvalue ()
    decNumber.tointegralvalue (decarg)

Returns a decimal number that is the argument with any fractional 
part removed, if necessary, using the rounding mode in the decimal 
context.





Uses the C library function C<decNumberToIntegralValue()>.

=head2 C<decnum:trim>

    decnum:trim ()
    decNumber.trim (decarg)

Returns a decimal number that is the argument with any insignificant 
trailing zeros removed. That is, if the number has any fractional 
trailing zeros they are removed by dividing the coefficient by the 
appropriate power of ten and adjusting the exponent accordingly.

Uses the C library function C<decNumberTrim()>.












B<Comparisons and Predicates>



































=head2 C<decnum:compare>

    decnum:compare (decarg)
    decNumber.compare (decarg, decarg)

Returns a decimal number that is the comparison of its arguments 
numerically. If the left (1st) argument is less than the right (2nd) 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








>
>
>
>















>
>
>
>
>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342

Note that by binding the method C<__sub> to this function, the Lua 
subtraction operator (C<->) may be used with a C<decnum> on the left 
and a C<decarg> on the right.

Uses the C library function C<decNumberSubtract()>.

=head2 C<decnum:tointegralexact>

    decnum:tointegralexact ()
    decNumber.tointegralexact (decarg)

Returns a decimal number that is the argument with any fractional 
part removed, if necessary, using the rounding mode in the decimal 
context.

The C<Inexact> flag is set if the result is numerically different 
from the argument. Other than that, no flags are set as long as the 
argument is a C<decnum> (unless the argument is a signaling NaN).
The result may have a positive exponent.

Uses the C library function C<decNumberToIntegralExact()>.

=head2 C<decnum:tointegralvalue>

    decnum:tointegralvalue ()
    decNumber.tointegralvalue (decarg)

Returns a decimal number that is the argument with any fractional 
part removed, if necessary, using the rounding mode in the decimal 
context.

No flags, not even C<Inexact>, are set as long as the 
argument is a C<decnum> (unless the argument is a signaling NaN).
The result may have a positive exponent.

Uses the C library function C<decNumberToIntegralValue()>.

=head2 C<decnum:trim>

    decnum:trim ()
    decNumber.trim (decarg)

Returns a decimal number that is the argument with any insignificant 
trailing zeros removed. That is, if the number has any fractional 
trailing zeros they are removed by dividing the coefficient by the 
appropriate power of ten and adjusting the exponent accordingly.

Uses the C library function C<decNumberTrim()>.

=head2 C<decnum:xor>

    decnum:xor (decarg)
    decNumber.xor (decarg, decarg)

Returns a decimal number that is the digit-wise logical exclusive or 
of the arguments. Note that all digits of the arguments must be 0 or 
1 or else this operation returns NaN,

Uses the C library function C<decNumberXor()>.

B<Comparisons and Predicates>

=head2 C<decnum:class>

    decnum:class ()
    decNumber.class (decarg)

Returns the class of a decNumber. No error is possible. The class is
one of the decNumber L</Classifications>.

Uses the C library function C<decNumberClass()>.

=head2 C<decnum:classasstring>

    decnum:classasstring ()
    decNumber.classasstring (decarg)

Returns the class of a decNumber as a string. No error is 
possible. The class is one of "-Infinity", "-Normal",  
"-Subnormal", "-Zero", "+Zero", "+Subnormal",
"+Normal", "+Infinity", "NaN", "sNaN", or "Invalid"

Uses the C library functions C<decNumberClass()> and 
C<decNumberClassToString()>.

=head2 C<classtostring>

    decNumber.classtostring (enum)

Converts the L</Classifications> of a decNumber to a string. 
No error is possible. The class is one of "-Infinity", 
"-Normal", "-Subnormal", "-Zero", "+Zero", "+Subnormal",
"+Normal", "+Infinity", "NaN", "sNaN", or "Invalid".

Uses the C library function C<decNumberClassToString()>.

=head2 C<decnum:compare>

    decnum:compare (decarg)
    decNumber.compare (decarg, decarg)

Returns a decimal number that is the comparison of its arguments 
numerically. If the left (1st) argument is less than the right (2nd) 
1027
1028
1029
1030
1031
1032
1033












1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051











1052
1053
1054
1055
1056

1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079





















1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101






















1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115

    -NaN <  -sNaN < -Infinity < -finites < -0 < +0 < +finites < +Infinity < +sNaN < +NaN.

Also, C<1.000 < 1.0> (etc.) and NaNs are ordered by payload.

Uses the C library function C<decNumberCompareTotal()>.













=head2 C<decnum:eq>

    decnum:eq (decarg)
    decnum:__eq (decarg)
    decNumber.eq (<decarg>, <decarg>)

Returns a boolean that is true when the arguments are equal, false 
otherwise.

Note that by binding the method C<__eq> to this function, the Lua 
equality operators (C<==> and C<~=>) may be used with a C<decnum> 
on the left and a C<decnum> on the right.

Uses the C library functions C<decNumberCompare()> and 
C<decNumberIsZero()>.

=head2 C<decnum:iszero>












    decnum:iszero
    decNumber.iszero (decarg)

Returns a boolean that is true if the argument is zero, false 
otherwise


Uses the C library function C<decNumberIsZero()>.

=head2 C<decnum:isnegative>

    decnum:isnegative ()
    decNumber.isnegative (decarg)

Returns a boolean that is true if the argument is negative, false 
otherwise

Uses the C library function C<decNumberIsNegative()>.

=head2 C<decnum:isnan>

    decnum:isnan ()
    decNumber.isnan (decarg)

Returns a boolean that is true if the argument is a NaN (quiet or 
signaling), false otherwise

Uses the C library function C<decNumberIsNaN()>.






















=head2 C<decnum:isqnan>

    decnum:isqnan ()
    decNumber.isqnan (decarg)

Returns a boolean that is true if the argument is a quiet NaN, 
false otherwise

Uses the C library function C<decNumberIsQNaN()>.

=head2 C<decnum:issnan>

    decnum:issnan ()
    decNumber.issnan (decarg)

Returns a boolean that is true if the argument is a signaling NaN, 
false otherwise

Uses the C library function C<decNumberIsSNaN()>.

=head2 C<decnum:isinfinite>























    decnum:isinfinite ()
    decNumber.isinfinite (decarg)

Returns a boolean that is true if the argument is infinite, 
false otherwise.

Uses the C library function C<decNumberIsInfinite()>.

=head2 C<decnum:le>

    decnum:le (decarg)
    decnum:__le (decarg)
    decNumber.le (<decarg>, <decarg>)








>
>
>
>
>
>
>
>
>
>
>
>
















|

>
>
>
>
>
>
>
>
>
>
>
|
|

|
|
>

|

|

|
|

|
|

|







|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






|









|



|

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|

|
|

|







1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516

    -NaN <  -sNaN < -Infinity < -finites < -0 < +0 < +finites < +Infinity < +sNaN < +NaN.

Also, C<1.000 < 1.0> (etc.) and NaNs are ordered by payload.

Uses the C library function C<decNumberCompareTotal()>.

=head2 C<decnum:comparetotalmag>

    decnum:comparetotalmag (decarg)
    decNumber.comparetotalmag (decarg, decarg)

Returns a decimal number that is the comparison of the magnitude of 
its arguments using the IEEE 754r proposed ordering. It is identical 
to L<C<decnum:comparetotal>|/decnum:comparetotal> above except that 
the signs of the operands are ignored and taken to be 0 (non-negative).

Uses the C library function C<decNumberCompareTotalMag()>.

=head2 C<decnum:eq>

    decnum:eq (decarg)
    decnum:__eq (decarg)
    decNumber.eq (<decarg>, <decarg>)

Returns a boolean that is true when the arguments are equal, false 
otherwise.

Note that by binding the method C<__eq> to this function, the Lua 
equality operators (C<==> and C<~=>) may be used with a C<decnum> 
on the left and a C<decnum> on the right.

Uses the C library functions C<decNumberCompare()> and 
C<decNumberIsZero()>.

=head2 C<decnum:iscanonical>

    decnum:iscanonical ()
    decNumber.iscanonical (decarg)

Returns true always, because decNumbers always have canonical 
encodings (the function is provided for compatibility with the
IEEE 754r operation C<isCanonical>). No error is possible.

Uses the C library function C<decNumberIsCanonical()>.

=head2 C<decnum:isfinite>

    decnum:isfinite ()
    decNumber.isfinite (decarg)

Returns a boolean that is true if the argument is finite, false 
otherwise (that is, the argument is an infinity or a NaN).
No error is possible.

Uses the C library function C<decNumberIsFinite()>.

=head2 C<decnum:isinfinite>

    decnum:isinfinite ()
    decNumber.isinfinite (decarg)

Returns a boolean that is true if the argument is infinite, 
false otherwise. No error is possible.

Uses the C library function C<decNumberIsInfinite()>.

=head2 C<decnum:isnan>

    decnum:isnan ()
    decNumber.isnan (decarg)

Returns a boolean that is true if the argument is a NaN (quiet or 
signaling), false otherwise. No error is possible.

Uses the C library function C<decNumberIsNaN()>.

=head2 C<decnum:isnegative>

    decnum:isnegative ()
    decNumber.isnegative (decarg)

Returns a boolean that is true if the argument is is normal (that 
is, finite, non-zero, and not subnormal), false otherwise.
No error is possible.
 
Uses the C library function C<decNumberIsNegative()>.

=head2 C<decnum:isnormal>

    decnum:isnormal ()
    decNumber.isnormal (decarg)

Returns a boolean that is true if the argument is negative, false 
otherwise.  No error is possible.

Uses the C library function C<decNumberIsNormal()>.

=head2 C<decnum:isqnan>

    decnum:isqnan ()
    decNumber.isqnan (decarg)

Returns a boolean that is true if the argument is a quiet NaN, 
false otherwise. No error is possible.

Uses the C library function C<decNumberIsQNaN()>.

=head2 C<decnum:issnan>

    decnum:issnan ()
    decNumber.issnan (decarg)

Returns a boolean that is true if the argument is a signaling NaN, 
false otherwise. No error is possible.

Uses the C library function C<decNumberIsSNaN()>.

=head2 C<decnum:isspecial>

    decnum:isspecial ()
    decNumber.isspecial (decarg)

Returns a boolean that is true if the argument has a special 
value (Infinity or NaN), false otherwise; it is the inversion of 
L<C<decnum:isfinite>|/decnum:isfinite>. No error is possible.

Uses the C library function C<decNumberIsSpecial()>.

=head2 C<decnum:issubnormal>

    decnum:issubnormal ()
    decNumber.issubnormal (decarg)

Returns a boolean that is true if the argument is subnormal (that 
is, finite, non-zero, and not in the range of normal values), false 
otherwise. No error is possible.

Uses the C library function C<decNumberIsSubnormal()>.

=head2 C<decnum:iszero>

    decnum:iszero
    decNumber.iszero (decarg)

Returns a boolean that is true if the argument is zero, false 
otherwise. No error is possible.

Uses the C library function C<decNumberIsZero()>.

=head2 C<decnum:le>

    decnum:le (decarg)
    decnum:__le (decarg)
    decNumber.le (<decarg>, <decarg>)

1138
1139
1140
1141
1142
1143
1144










1145
1146
1147
1148
1149
1150
1151
that C<a E<lt>= b> is equivalent to C<not (b E<lt> a)> which in the 
presence of NaNs may or may not be what you want - if not, use 
L<C<decnum:compare>|/decnum:compare> directly.

Uses the C library functions C<decNumberCompare()> and 
C<decNumberIsNegative()>.











=head1 Operations on Random States

The following functions operate on random states.

The random number generator in the B<ldecNumber> package is based 
on a lagged Fibonacci generator ("LFIB4"). George Marsaglia has this 
to say about LFIB4:







>
>
>
>
>
>
>
>
>
>







1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
that C<a E<lt>= b> is equivalent to C<not (b E<lt> a)> which in the 
presence of NaNs may or may not be what you want - if not, use 
L<C<decnum:compare>|/decnum:compare> directly.

Uses the C library functions C<decNumberCompare()> and 
C<decNumberIsNegative()>.

=head2 C<decnum:radix>

    decnum:radix ()
    decNumber.radix (decarg)

Returns the radix (number base) used by the decNumber package. This
always returns 10. No error is possible..

Uses the C library function C<decNumberRadix()>.

=head1 Operations on Random States

The following functions operate on random states.

The random number generator in the B<ldecNumber> package is based 
on a lagged Fibonacci generator ("LFIB4"). George Marsaglia has this 
to say about LFIB4:
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
number of decimal digits in the new random decimal number; the default 
is 12. If supplied, C<exponent> is the exponent of the new random 
decimal number; the default is C<-digits> so the new random decimal 
number is between zero (inclusive) and one (exclusive).

=head1 VERSION

This is B<ldecNumber> version 19.

=head1 CREDITS

B<ldecNumber> was developed by Doug Currie, Londonderry, NH, USA.

B<decNumber> was developed by Mike Cowlishaw at IBM.








|







1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
number of decimal digits in the new random decimal number; the default 
is 12. If supplied, C<exponent> is the exponent of the new random 
decimal number; the default is C<-digits> so the new random decimal 
number is between zero (inclusive) and one (exclusive).

=head1 VERSION

This is B<ldecNumber> version 21.

=head1 CREDITS

B<ldecNumber> was developed by Doug Currie, Londonderry, NH, USA.

B<decNumber> was developed by Mike Cowlishaw at IBM.

Changes to ldecNumber.c.

310
311
312
313
314
315
316





317
318
319
320
321
322
323
DN_OP1(dn_log10,  decNumberLog10)
DN_OP1(dn_abs,    decNumberAbs)
DN_OP1(dn_neg,    decNumberMinus)
DN_OP1(dn_norm,   decNumberNormalize)
DN_OP1(dn_plus,   decNumberPlus)
DN_OP1(dn_sqrt,   decNumberSquareRoot)
DN_OP1(dn_intval, decNumberToIntegralValue)






#define DN_OP2(name,fun) \
static int name (lua_State *L) \
{ \
    decContext *dc = ldn_get_context (L); \
    decNumber *dn1 = ldn_get (L, dc, 1); \
    decNumber *dn2 = ldn_get (L, dc, 2); \







>
>
>
>
>







310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
DN_OP1(dn_log10,  decNumberLog10)
DN_OP1(dn_abs,    decNumberAbs)
DN_OP1(dn_neg,    decNumberMinus)
DN_OP1(dn_norm,   decNumberNormalize)
DN_OP1(dn_plus,   decNumberPlus)
DN_OP1(dn_sqrt,   decNumberSquareRoot)
DN_OP1(dn_intval, decNumberToIntegralValue)
DN_OP1(dn_invert, decNumberInvert)
DN_OP1(dn_logb,   decNumberLogB)
DN_OP1(dn_intxct, decNumberToIntegralExact)
DN_OP1(dn_intnmn, decNumberNextMinus)
DN_OP1(dn_intnpl, decNumberNextPlus)

#define DN_OP2(name,fun) \
static int name (lua_State *L) \
{ \
    decContext *dc = ldn_get_context (L); \
    decNumber *dn1 = ldn_get (L, dc, 1); \
    decNumber *dn2 = ldn_get (L, dc, 2); \
337
338
339
340
341
342
343






















344
345
346
347
348
349
350
DN_OP2(dn_divideinteger, decNumberDivideInteger)
DN_OP2(dn_max,           decNumberMax)
DN_OP2(dn_min,           decNumberMin)
DN_OP2(dn_quantize,      decNumberQuantize)
DN_OP2(dn_remainder,     decNumberRemainder)
DN_OP2(dn_remaindernear, decNumberRemainderNear)
DN_OP2(dn_rescale,       decNumberRescale)























/* mod -- needs to be fudged from remainder */

static int dn_mod (lua_State *L)
{
    decContext *dc = ldn_get_context (L);
    decNumber *dn1 = ldn_get (L, dc, 1);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
DN_OP2(dn_divideinteger, decNumberDivideInteger)
DN_OP2(dn_max,           decNumberMax)
DN_OP2(dn_min,           decNumberMin)
DN_OP2(dn_quantize,      decNumberQuantize)
DN_OP2(dn_remainder,     decNumberRemainder)
DN_OP2(dn_remaindernear, decNumberRemainderNear)
DN_OP2(dn_rescale,       decNumberRescale)

DN_OP2(dn_and,             decNumberAnd)
DN_OP2(dn_comparetotalmag, decNumberCompareTotalMag)
DN_OP2(dn_maxmag,          decNumberMaxMag)
DN_OP2(dn_minmag,          decNumberMinMag)
DN_OP2(dn_nexttoward,      decNumberNextToward)
DN_OP2(dn_or,              decNumberOr)
DN_OP2(dn_rotate,          decNumberRotate)
DN_OP2(dn_scaleb,          decNumberScaleB)
DN_OP2(dn_shift,           decNumberShift)
DN_OP2(dn_xor,             decNumberXor)

static int dn_fma (lua_State *L)
{
    decContext *dc = ldn_get_context (L);
    decNumber *dn1 = ldn_get (L, dc, 1);
    decNumber *dn2 = ldn_get (L, dc, 2);
    decNumber *dn3 = ldn_get (L, dc, 3);
    decNumber *dnr = ldn_make_decNumber (L);
    decNumberFMA (dnr, dn1, dn2, dn3, dc);
    return 1;
}

/* mod -- needs to be fudged from remainder */

static int dn_mod (lua_State *L)
{
    decContext *dc = ldn_get_context (L);
    decNumber *dn1 = ldn_get (L, dc, 1);
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414




























415
416
417
418
419
420
421

422
423
424
425
426
427
428
429
430
431















432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449








































450
451
452
453
454
455
456
            // subtract one from result
            decNumberSubtract (dnr, dnr, &dnc_one, dc);
        }
    }
    return 1;
}

/* samequantum -- call needs no context */

static int dn_samequantum (lua_State *L)
{
    decContext *dc = ldn_get_context (L);
    decNumber *dn1 = ldn_get (L, dc, 1);
    decNumber *dn2 = ldn_get (L, dc, 2);
    decNumber *dnr = ldn_make_decNumber (L);
    decNumberSameQuantum(dnr, dn1, dn2);
    return 1;
}

/* trim -- needs decNumberCopy */

static int dn_trim (lua_State *L)
{
    decContext *dc = ldn_get_context (L);
    decNumber *dn1 = ldn_get (L, dc, 1);
    decNumber *dnr = ldn_make_decNumber (L);
    decNumberCopy (dnr, dn1);
    decNumberTrim (dnr);
    return 1;
}





























/* predicates */

#define DN_P1(name,pmac) \
static int name (lua_State *L) \
{ \
    decContext *dc = ldn_get_context (L); \
    decNumber *dn1 = ldn_get (L, dc, 1); \

    lua_pushboolean (L, pmac(dn1)); \
    return 1; \
}

DN_P1(dn_iszero, decNumberIsZero)
DN_P1(dn_isneg,  decNumberIsNegative)
DN_P1(dn_isnan,  decNumberIsNaN)
DN_P1(dn_isqnan, decNumberIsQNaN)
DN_P1(dn_issnan, decNumberIsSNaN)
DN_P1(dn_isinf,  decNumberIsInfinite)
















#define DN_PR2(name,fun,pmac) \
static int name (lua_State *L) \
{ \
    decNumber dnr; \
    decContext *dc = ldn_get_context (L); \
    decNumber *dn1 = ldn_get (L, dc, 1); \
    decNumber *dn2 = ldn_get (L, dc, 2); \
    fun(&dnr, dn1, dn2, dc); \
    lua_pushboolean (L, pmac(&dnr)); \
    return 1; \
}

#define decNumberIsNegativeOrZero(d) (decNumberIsNegative(d) || decNumberIsZero(d))

DN_PR2(dn_eq,decNumberCompare,decNumberIsZero)
DN_PR2(dn_lt,decNumberCompare,decNumberIsNegative)
DN_PR2(dn_le,decNumberCompare,decNumberIsNegativeOrZero)









































/* to string */

static int ldn_string (lua_State *L, int x, char *(*sf)(const decNumber *, char *))
{
    char buf[128];
    decContext *dc = ldn_get_context (L);







<
<
<
<
<
<
<
<
<
<
<
<












>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







>










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







411
412
413
414
415
416
417












418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
            // subtract one from result
            decNumberSubtract (dnr, dnr, &dnc_one, dc);
        }
    }
    return 1;
}













/* trim -- needs decNumberCopy */

static int dn_trim (lua_State *L)
{
    decContext *dc = ldn_get_context (L);
    decNumber *dn1 = ldn_get (L, dc, 1);
    decNumber *dnr = ldn_make_decNumber (L);
    decNumberCopy (dnr, dn1);
    decNumberTrim (dnr);
    return 1;
}

#define DN_OP1nc(name,fun) \
static int name (lua_State *L) \
{ \
    decContext *dc = ldn_get_context (L); \
    decNumber *dn1 = ldn_get (L, dc, 1); \
    decNumber *dnr = ldn_make_decNumber (L); \
    fun(dnr, dn1); \
    return 1; \
}

DN_OP1nc(dn_copy, decNumberCopy)
DN_OP1nc(dn_copyabs, decNumberCopyAbs)
DN_OP1nc(dn_copynegate, decNumberCopyNegate)

#define DN_OP2nc(name,fun) \
static int name (lua_State *L) \
{ \
    decContext *dc = ldn_get_context (L); \
    decNumber *dn1 = ldn_get (L, dc, 1); \
    decNumber *dn2 = ldn_get (L, dc, 2); \
    decNumber *dnr = ldn_make_decNumber (L); \
    fun(dnr, dn1, dn2); \
    return 1; \
}

DN_OP2nc(dn_samequantum, decNumberSameQuantum)
DN_OP2nc(dn_copysign, decNumberCopySign)

/* predicates */

#define DN_P1(name,pmac) \
static int name (lua_State *L) \
{ \
    decContext *dc = ldn_get_context (L); \
    decNumber *dn1 = ldn_get (L, dc, 1); \
    dn1 = dn1; \
    lua_pushboolean (L, pmac(dn1)); \
    return 1; \
}

DN_P1(dn_iszero, decNumberIsZero)
DN_P1(dn_isneg,  decNumberIsNegative)
DN_P1(dn_isnan,  decNumberIsNaN)
DN_P1(dn_isqnan, decNumberIsQNaN)
DN_P1(dn_issnan, decNumberIsSNaN)
DN_P1(dn_isinf,  decNumberIsInfinite)
DN_P1(dn_iscncl, decNumberIsCanonical)
DN_P1(dn_isfini, decNumberIsFinite)
DN_P1(dn_isspec, decNumberIsSpecial)

#define DN_P1c(name,pmac) \
static int name (lua_State *L) \
{ \
    decContext *dc = ldn_get_context (L); \
    decNumber *dn1 = ldn_get (L, dc, 1); \
    lua_pushboolean (L, pmac(dn1,dc)); \
    return 1; \
}

DN_P1c(dn_isnorm, decNumberIsNormal)
DN_P1c(dn_issubn, decNumberIsSubnormal)

#define DN_PR2(name,fun,pmac) \
static int name (lua_State *L) \
{ \
    decNumber dnr; \
    decContext *dc = ldn_get_context (L); \
    decNumber *dn1 = ldn_get (L, dc, 1); \
    decNumber *dn2 = ldn_get (L, dc, 2); \
    fun(&dnr, dn1, dn2, dc); \
    lua_pushboolean (L, pmac(&dnr)); \
    return 1; \
}

#define decNumberIsNegativeOrZero(d) (decNumberIsNegative(d) || decNumberIsZero(d))

DN_PR2(dn_eq,decNumberCompare,decNumberIsZero)
DN_PR2(dn_lt,decNumberCompare,decNumberIsNegative)
DN_PR2(dn_le,decNumberCompare,decNumberIsNegativeOrZero)

/* classifiers */

static int dn_radix (lua_State *L)
{
    decContext *dc = ldn_get_context (L);
    decNumber *dn1 = ldn_get (L, dc, 1);
    int r = decNumberRadix(dn1);
    dn1 = dn1;
    lua_pushinteger (L, r);
    return 1;
}

static int dn_class (lua_State *L)
{
    decContext *dc = ldn_get_context (L);
    decNumber *dn1 = ldn_get (L, dc, 1);
    int decClass = decNumberClass(dn1,dc);
    lua_pushinteger (L, decClass);
    return 1;
}

static int dn_classtostring (lua_State *L)
{
    //decContext *dc = ldn_get_context (L);
    int decClass = luaL_checkint (L,1);
    const char * s = decNumberClassToString(decClass);
    lua_pushstring (L, s);
    return 1;
}

static int dn_classasstring (lua_State *L)
{
    decContext *dc = ldn_get_context (L);
    decNumber *dn1 = ldn_get (L, dc, 1);
    int decClass = decNumberClass(dn1,dc);
    const char * s = decNumberClassToString(decClass);
    lua_pushstring (L, s);
    return 1;
}

/* to string */

static int ldn_string (lua_State *L, int x, char *(*sf)(const decNumber *, char *))
{
    char buf[128];
    decContext *dc = ldn_get_context (L);
747
748
749
750
751
752
753

754
755
756
757
758
759
760
    DEC_(ROUND_CEILING)             /* round towards +infinity */
    DEC_(ROUND_UP)                  /* round away from 0 */
    DEC_(ROUND_HALF_UP)             /* 0.5 rounds up */
    DEC_(ROUND_HALF_EVEN)           /* 0.5 rounds to nearest even */
    DEC_(ROUND_HALF_DOWN)           /* 0.5 rounds down */
    DEC_(ROUND_DOWN)                /* round towards 0 (truncate) */
    DEC_(ROUND_FLOOR)               /* round towards -infinity */

    /* Trap-enabler and Status flags */
    DEC_(Conversion_syntax)
    DEC_(Division_by_zero)
    DEC_(Division_impossible)
    DEC_(Division_undefined)
    DEC_(Insufficient_storage)
    DEC_(Inexact)







>







846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
    DEC_(ROUND_CEILING)             /* round towards +infinity */
    DEC_(ROUND_UP)                  /* round away from 0 */
    DEC_(ROUND_HALF_UP)             /* 0.5 rounds up */
    DEC_(ROUND_HALF_EVEN)           /* 0.5 rounds to nearest even */
    DEC_(ROUND_HALF_DOWN)           /* 0.5 rounds down */
    DEC_(ROUND_DOWN)                /* round towards 0 (truncate) */
    DEC_(ROUND_FLOOR)               /* round towards -infinity */
    DEC_(ROUND_05UP)                /* round for reround  */
    /* Trap-enabler and Status flags */
    DEC_(Conversion_syntax)
    DEC_(Division_by_zero)
    DEC_(Division_impossible)
    DEC_(Division_undefined)
    DEC_(Insufficient_storage)
    DEC_(Inexact)
778
779
780
781
782
783
784












785
786
787
788
789
790
791
    DEC_(NaNs)        /* flags which cause a result to become qNaN */
    DEC_(Information) /* flags which are normally for information only (have finite results) */
    /* Initialization descriptors, used by decContextDefault */
    DEC_(INIT_BASE)
    DEC_(INIT_DECIMAL32)
    DEC_(INIT_DECIMAL64)
    DEC_(INIT_DECIMAL128)












    /* compile time config */
    {"MAX_DIGITS", DECNUMDIGITS },
    /* terminator */
    { NULL, 0 }
};

#if LDN_ENABLE_RANDOM







>
>
>
>
>
>
>
>
>
>
>
>







878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
    DEC_(NaNs)        /* flags which cause a result to become qNaN */
    DEC_(Information) /* flags which are normally for information only (have finite results) */
    /* Initialization descriptors, used by decContextDefault */
    DEC_(INIT_BASE)
    DEC_(INIT_DECIMAL32)
    DEC_(INIT_DECIMAL64)
    DEC_(INIT_DECIMAL128)
    /* Classifications for decNumbers, aligned with 754r (note that     */
    /* 'normal' and 'subnormal' are meaningful only with a decContext)  */
    DEC_(CLASS_SNAN)
    DEC_(CLASS_QNAN)
    DEC_(CLASS_NEG_INF)
    DEC_(CLASS_NEG_NORMAL)
    DEC_(CLASS_NEG_SUBNORMAL)
    DEC_(CLASS_NEG_ZERO)
    DEC_(CLASS_POS_ZERO)
    DEC_(CLASS_POS_SUBNORMAL)
    DEC_(CLASS_POS_NORMAL)
    DEC_(CLASS_POS_INF)
    /* compile time config */
    {"MAX_DIGITS", DECNUMDIGITS },
    /* terminator */
    { NULL, 0 }
};

#if LDN_ENABLE_RANDOM
807
808
809
810
811
812
813










814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831













832
833
834
835
836
837
838
839
840





841





842
843
844
845
846
847
848
    {"log10",           dn_log10  },
    {"abs",             dn_abs    },
    {"minus",           dn_neg    },
    {"normalize",       dn_norm   },
    {"plus",            dn_plus   },
    {"squareroot",      dn_sqrt   },
    {"tointegralvalue", dn_intval },











    {"add",             dn_add    },
    {"divide",          dn_div    },
    {"multiply",        dn_mul    },
    {"power",           dn_pow    },
    {"subtract",        dn_sub    },

    {"compare",         dn_compare       },
    {"comparetotal",    dn_comparetotal  },
    {"divideinteger",   dn_divideinteger },
    {"max",             dn_max           },
    {"min",             dn_min           },
    {"quantize",        dn_quantize      },
    {"remainder",       dn_remainder     },
    {"remaindernear",   dn_remaindernear },
    {"rescale",         dn_rescale       },
    {"samequantum",     dn_samequantum   },
    













    {"mod",             dn_mod           },
    {"floor",           dn_floor         },

    {"iszero",          dn_iszero        },
    {"isnegative",      dn_isneg         },
    {"isnan",           dn_isnan         },
    {"isqnan",          dn_isqnan        },
    {"issnan",          dn_issnan        },
    {"isinfinite",      dn_isinf         },





    





    {"trim",            dn_trim          },

    {"tostring",        dn_string        },
    {"toengstring",     dn_engstring     },

    { "__unm",      dn_neg    },
    { "__add",      dn_add    },







>
>
>
>
>
>
>
>
>
>

















|
>
>
>
>
>
>
>
>
>
>
>
>
>









>
>
>
>
>
|
>
>
>
>
>







919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
    {"log10",           dn_log10  },
    {"abs",             dn_abs    },
    {"minus",           dn_neg    },
    {"normalize",       dn_norm   },
    {"plus",            dn_plus   },
    {"squareroot",      dn_sqrt   },
    {"tointegralvalue", dn_intval },
    {"invert",          dn_invert },
    {"logb",            dn_logb   },
    {"tointegralexact", dn_intxct },
    {"nextminus",       dn_intnmn },
    {"nextplus",        dn_intnpl },

    {"copy",            dn_copy       },
    {"copyabs",         dn_copyabs    },
    {"copynegate",      dn_copynegate },
    {"copysign",        dn_copysign   },

    {"add",             dn_add    },
    {"divide",          dn_div    },
    {"multiply",        dn_mul    },
    {"power",           dn_pow    },
    {"subtract",        dn_sub    },

    {"compare",         dn_compare       },
    {"comparetotal",    dn_comparetotal  },
    {"divideinteger",   dn_divideinteger },
    {"max",             dn_max           },
    {"min",             dn_min           },
    {"quantize",        dn_quantize      },
    {"remainder",       dn_remainder     },
    {"remaindernear",   dn_remaindernear },
    {"rescale",         dn_rescale       },
    {"samequantum",     dn_samequantum   },

    {"land",            dn_and           },
    {"comparetotalmag", dn_comparetotalmag },
    {"maxmag",          dn_maxmag        },
    {"minmag",          dn_minmag        },
    {"nexttoward",      dn_nexttoward    },
    {"lor",             dn_or            },
    {"rotate",          dn_rotate        },
    {"scaleb",          dn_scaleb        },
    {"shift",           dn_shift         },
    {"xor",             dn_xor           },
    
    {"fma",             dn_fma           },

    {"mod",             dn_mod           },
    {"floor",           dn_floor         },

    {"iszero",          dn_iszero        },
    {"isnegative",      dn_isneg         },
    {"isnan",           dn_isnan         },
    {"isqnan",          dn_isqnan        },
    {"issnan",          dn_issnan        },
    {"isinfinite",      dn_isinf         },
    {"isfinite",        dn_isfini        },
    {"iscanonical",     dn_iscncl        },
    {"isspecial",       dn_isspec        },
    {"isnormal",        dn_isnorm        },
    {"issubnormal",     dn_issubn        },

    {"radix",           dn_radix         },
    {"class",           dn_class         },
    {"classtostring",   dn_classtostring },
    {"classasstring",   dn_classasstring },

    {"trim",            dn_trim          },

    {"tostring",        dn_string        },
    {"toengstring",     dn_engstring     },

    { "__unm",      dn_neg    },
    { "__add",      dn_add    },
901
902
903
904
905
906
907










908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925













926
927
928
929
930
931
932
933
934










935
936
937
938
939
940
941
    {"log10",           dn_log10  },
    {"abs",             dn_abs    },
    {"minus",           dn_neg    },
    {"normalize",       dn_norm   },
    {"plus",            dn_plus   },
    {"squareroot",      dn_sqrt   },
    {"tointegralvalue", dn_intval },











    {"add",             dn_add    },
    {"divide",          dn_div    },
    {"multiply",        dn_mul    },
    {"power",           dn_pow    },
    {"subtract",        dn_sub    },

    {"compare",         dn_compare       },
    {"comparetotal",    dn_comparetotal  },
    {"divideinteger",   dn_divideinteger },
    {"max",             dn_max           },
    {"min",             dn_min           },
    {"quantize",        dn_quantize      },
    {"remainder",       dn_remainder     },
    {"remaindernear",   dn_remaindernear },
    {"rescale",         dn_rescale       },
    {"samequantum",     dn_samequantum   },














    {"mod",             dn_mod           },
    {"floor",           dn_floor         },

    {"iszero",          dn_iszero        },
    {"isnegative",      dn_isneg         },
    {"isnan",           dn_isnan         },
    {"isqnan",          dn_isqnan        },
    {"issnan",          dn_issnan        },
    {"isinfinite",      dn_isinf         },










    
    {"trim",            dn_trim          },

    {"getcontext",      dn_get_context   },
    {"setcontext",      dn_set_context   },
    {"tonumber",        dn_todecnumber   },
    {"tostring",        dn_string        },







>
>
>
>
>
>
>
>
>
>


















>
>
>
>
>
>
>
>
>
>
>
>
>









>
>
>
>
>
>
>
>
>
>







1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
    {"log10",           dn_log10  },
    {"abs",             dn_abs    },
    {"minus",           dn_neg    },
    {"normalize",       dn_norm   },
    {"plus",            dn_plus   },
    {"squareroot",      dn_sqrt   },
    {"tointegralvalue", dn_intval },
    {"invert",          dn_invert },
    {"logb",            dn_logb   },
    {"tointegralexact", dn_intxct },
    {"nextminus",       dn_intnmn },
    {"nextplus",        dn_intnpl },

    {"copy",            dn_copy       },
    {"copyabs",         dn_copyabs    },
    {"copynegate",      dn_copynegate },
    {"copysign",        dn_copysign   },

    {"add",             dn_add    },
    {"divide",          dn_div    },
    {"multiply",        dn_mul    },
    {"power",           dn_pow    },
    {"subtract",        dn_sub    },

    {"compare",         dn_compare       },
    {"comparetotal",    dn_comparetotal  },
    {"divideinteger",   dn_divideinteger },
    {"max",             dn_max           },
    {"min",             dn_min           },
    {"quantize",        dn_quantize      },
    {"remainder",       dn_remainder     },
    {"remaindernear",   dn_remaindernear },
    {"rescale",         dn_rescale       },
    {"samequantum",     dn_samequantum   },

    {"land",            dn_and           },
    {"comparetotalmag", dn_comparetotalmag },
    {"maxmag",          dn_maxmag        },
    {"minmag",          dn_minmag        },
    {"nexttoward",      dn_nexttoward    },
    {"lor",             dn_or            },
    {"rotate",          dn_rotate        },
    {"scaleb",          dn_scaleb        },
    {"shift",           dn_shift         },
    {"xor",             dn_xor           },

    {"fma",             dn_fma           },

    {"mod",             dn_mod           },
    {"floor",           dn_floor         },

    {"iszero",          dn_iszero        },
    {"isnegative",      dn_isneg         },
    {"isnan",           dn_isnan         },
    {"isqnan",          dn_isqnan        },
    {"issnan",          dn_issnan        },
    {"isinfinite",      dn_isinf         },
    {"isfinite",        dn_isfini        },
    {"iscanonical",     dn_iscncl        },
    {"isspecial",       dn_isspec        },
    {"isnormal",        dn_isnorm        },
    {"issubnormal",     dn_issubn        },

    {"radix",           dn_radix         },
    {"class",           dn_class         },
    {"classtostring",   dn_classtostring },
    {"classasstring",   dn_classasstring },
    
    {"trim",            dn_trim          },

    {"getcontext",      dn_get_context   },
    {"setcontext",      dn_set_context   },
    {"tonumber",        dn_todecnumber   },
    {"tostring",        dn_string        },

Changes to test/dectest/abs.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- abs.decTest -- decimal absolute value                              --
-- Copyright (c) IBM Corporation, 1981, 2004.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- This set of tests primarily tests the existence of the operator.
-- Additon, subtraction, rounding, and more overflows are tested
-- elsewhere.

precision:   9
rounding:    half_up


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- abs.decTest -- decimal absolute value                              --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests primarily tests the existence of the operator.
-- Additon, subtraction, rounding, and more overflows are tested
-- elsewhere.

precision:   9
rounding:    half_up

Changes to test/dectest/add.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- add.decTest -- decimal addition                                    --
-- Copyright (c) IBM Corporation, 1981, 2004.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383
extended:    1

|

|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------/cancell----------------------------------------------------------
-- add.decTest -- decimal addition                                    --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383
extended:    1

82
83
84
85
86
87
88

89
90
91
92
93
94
95
precision: 15
addx046 add '10000e+9'  '7' -> '10000000000007'
addx047 add '10000e+9'  '70' -> '10000000000070'
addx048 add '10000e+9'  '700' -> '10000000000700'
addx049 add '10000e+9'  '7000' -> '10000000007000'
addx050 add '10000e+9'  '70000' -> '10000000070000'
addx051 add '10000e+9'  '700000' -> '10000000700000'


-- examples from decarith
addx053 add '12' '7.00' -> '19.00'
addx054 add '1.3' '-1.07' -> '0.23'
addx055 add '1.3' '-1.30' -> '0.00'
addx056 add '1.3' '-2.07' -> '-0.77'
addx057 add '1E+2' '1E+4' -> '1.01E+4'







>







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
precision: 15
addx046 add '10000e+9'  '7' -> '10000000000007'
addx047 add '10000e+9'  '70' -> '10000000000070'
addx048 add '10000e+9'  '700' -> '10000000000700'
addx049 add '10000e+9'  '7000' -> '10000000007000'
addx050 add '10000e+9'  '70000' -> '10000000070000'
addx051 add '10000e+9'  '700000' -> '10000000700000'
addx052 add '10000e+9'  '7000000' -> '10000007000000'

-- examples from decarith
addx053 add '12' '7.00' -> '19.00'
addx054 add '1.3' '-1.07' -> '0.23'
addx055 add '1.3' '-1.30' -> '0.00'
addx056 add '1.3' '-2.07' -> '-0.77'
addx057 add '1E+2' '1E+4' -> '1.01E+4'
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
addx163 add '1.11'  '1E+12' -> '1000000000001.11'
addx164 add '-1'    '1E+12' -> '999999999999'
addx165 add '7E+12' '-1'    -> '6999999999999'
addx166 add '7E+12'  '1.11' -> '7000000000001.11'
addx167 add '1.11'  '7E+12' -> '7000000000001.11'
addx168 add '-1'    '7E+12' -> '6999999999999'

--            123456789012345      123456789012345      1 23456789012345
addx170 add '0.444444444444444'  '0.555555555555563' -> '1.00000000000001' Inexact Rounded
addx171 add '0.444444444444444'  '0.555555555555562' -> '1.00000000000001' Inexact Rounded
addx172 add '0.444444444444444'  '0.555555555555561' -> '1.00000000000001' Inexact Rounded
addx173 add '0.444444444444444'  '0.555555555555560' -> '1.00000000000000' Inexact Rounded
addx174 add '0.444444444444444'  '0.555555555555559' -> '1.00000000000000' Inexact Rounded
addx175 add '0.444444444444444'  '0.555555555555558' -> '1.00000000000000' Inexact Rounded
addx176 add '0.444444444444444'  '0.555555555555557' -> '1.00000000000000' Inexact Rounded







|







213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
addx163 add '1.11'  '1E+12' -> '1000000000001.11'
addx164 add '-1'    '1E+12' -> '999999999999'
addx165 add '7E+12' '-1'    -> '6999999999999'
addx166 add '7E+12'  '1.11' -> '7000000000001.11'
addx167 add '1.11'  '7E+12' -> '7000000000001.11'
addx168 add '-1'    '7E+12' -> '6999999999999'

--             123456789012345      123456789012345      1 23456789012345
addx170 add '0.444444444444444'  '0.555555555555563' -> '1.00000000000001' Inexact Rounded
addx171 add '0.444444444444444'  '0.555555555555562' -> '1.00000000000001' Inexact Rounded
addx172 add '0.444444444444444'  '0.555555555555561' -> '1.00000000000001' Inexact Rounded
addx173 add '0.444444444444444'  '0.555555555555560' -> '1.00000000000000' Inexact Rounded
addx174 add '0.444444444444444'  '0.555555555555559' -> '1.00000000000000' Inexact Rounded
addx175 add '0.444444444444444'  '0.555555555555558' -> '1.00000000000000' Inexact Rounded
addx176 add '0.444444444444444'  '0.555555555555557' -> '1.00000000000000' Inexact Rounded
392
393
394
395
396
397
398

399
400
401
402
403
404
405
precision:   7
rounding:    half_up
maxExponent: 92
minexponent: -92
addx361  add 0E+50 10000E+1  -> 1.0000E+5
addx362  add 10000E+1 0E-50  -> 100000.0  Rounded
addx363  add 10000E+1 10000E-50  -> 100000.0  Rounded Inexact


-- a curiosity from JSR 13 testing
rounding:    half_down
precision:   10
addx370 add 99999999 81512 -> 100081511
precision:      6
addx371 add 99999999 81512 -> 1.00082E+8 Rounded Inexact







>







393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
precision:   7
rounding:    half_up
maxExponent: 92
minexponent: -92
addx361  add 0E+50 10000E+1  -> 1.0000E+5
addx362  add 10000E+1 0E-50  -> 100000.0  Rounded
addx363  add 10000E+1 10000E-50  -> 100000.0  Rounded Inexact
addx364  add 9.999999E+92 -9.999999E+92 -> 0E+86

-- a curiosity from JSR 13 testing
rounding:    half_down
precision:   10
addx370 add 99999999 81512 -> 100081511
precision:      6
addx371 add 99999999 81512 -> 1.00082E+8 Rounded Inexact
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
-- verify a query
precision:    16
maxExponent: +394
minExponent: -393
rounding:     down
addx561 add 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
addx562 add      0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
-- and using decimal64 bounds...
precision:    16
maxExponent: +384
minExponent: -383
rounding:     down
addx563 add 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
addx564 add      0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded








|







566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
-- verify a query
precision:    16
maxExponent: +394
minExponent: -393
rounding:     down
addx561 add 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
addx562 add      0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
-- and using decimal64 bounds (see also ddadd.decTest)
precision:    16
maxExponent: +384
minExponent: -383
rounding:     down
addx563 add 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
addx564 add      0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded

1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
addx574 subtract  1E-383  1E-384  ->   9E-384 Subnormal

-- Here we explore the boundary of rounding a subnormal to Nmin
addx575 subtract  1E-383  1E-398  ->   9.99999999999999E-384  Subnormal
addx576 subtract  1E-383  1E-398  ->   9.99999999999999E-384  Subnormal
addx577 subtract  1E-383  1E-399  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
addx578 subtract  1E-383  1E-400  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
--addx579 subtract  1E-383  1E-401  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
--addx580 subtract  1E-383  1E-402  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded

-- check overflow edge case
precision:   7
rounding:    half_up
maxExponent: 96
minExponent: -95
addx972 apply   9.999999E+96         -> 9.999999E+96







|
|







1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
addx574 subtract  1E-383  1E-384  ->   9E-384 Subnormal

-- Here we explore the boundary of rounding a subnormal to Nmin
addx575 subtract  1E-383  1E-398  ->   9.99999999999999E-384  Subnormal
addx576 subtract  1E-383  1E-398  ->   9.99999999999999E-384  Subnormal
addx577 subtract  1E-383  1E-399  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
addx578 subtract  1E-383  1E-400  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
addx579 subtract  1E-383  1E-401  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
addx580 subtract  1E-383  1E-402  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded

-- check overflow edge case
precision:   7
rounding:    half_up
maxExponent: 96
minExponent: -95
addx972 apply   9.999999E+96         -> 9.999999E+96
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
addx1469 add 1.123456789012345  0E-9   -> 1.123456789012345
addx1470 add 1.123456789012345  0E-10  -> 1.123456789012345
addx1471 add 1.123456789012345  0E-11  -> 1.123456789012345
addx1472 add 1.123456789012345  0E-12  -> 1.123456789012345
addx1473 add 1.123456789012345  0E-13  -> 1.123456789012345
addx1474 add 1.123456789012345  0E-14  -> 1.123456789012345
addx1475 add 1.123456789012345  0E-15  -> 1.123456789012345
-- next four flag Rounded becuase the 0 extends the result
addx1476 add 1.123456789012345  0E-16  -> 1.123456789012345 Rounded
addx1477 add 1.123456789012345  0E-17  -> 1.123456789012345 Rounded
addx1478 add 1.123456789012345  0E-18  -> 1.123456789012345 Rounded
addx1479 add 1.123456789012345  0E-19  -> 1.123456789012345 Rounded

-- sum of two opposite-sign operands is exactly 0 and floor => -0
precision:   16







|







1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
addx1469 add 1.123456789012345  0E-9   -> 1.123456789012345
addx1470 add 1.123456789012345  0E-10  -> 1.123456789012345
addx1471 add 1.123456789012345  0E-11  -> 1.123456789012345
addx1472 add 1.123456789012345  0E-12  -> 1.123456789012345
addx1473 add 1.123456789012345  0E-13  -> 1.123456789012345
addx1474 add 1.123456789012345  0E-14  -> 1.123456789012345
addx1475 add 1.123456789012345  0E-15  -> 1.123456789012345
-- next four flag Rounded because the 0 extends the result
addx1476 add 1.123456789012345  0E-16  -> 1.123456789012345 Rounded
addx1477 add 1.123456789012345  0E-17  -> 1.123456789012345 Rounded
addx1478 add 1.123456789012345  0E-18  -> 1.123456789012345 Rounded
addx1479 add 1.123456789012345  0E-19  -> 1.123456789012345 Rounded

-- sum of two opposite-sign operands is exactly 0 and floor => -0
precision:   16
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
addx1704  add 1E2       1E4       -> 1.01E+4
addx1705  subtract 130E-2  120E-2 -> 0.10
addx1706  subtract 130E-2  12E-1  -> 0.10
addx1707  subtract 130E-2  1E0    -> 0.30
addx1708  subtract 1E2     1E4    -> -9.9E+3

------------------------------------------------------------------------
-- Same as above, using decimal64default parameters                   --
------------------------------------------------------------------------
precision:   16
rounding:    half_even
maxExponent: 384
minexponent: -383

-- [first group are 'quick confidence check']







|







1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
addx1704  add 1E2       1E4       -> 1.01E+4
addx1705  subtract 130E-2  120E-2 -> 0.10
addx1706  subtract 130E-2  12E-1  -> 0.10
addx1707  subtract 130E-2  1E0    -> 0.30
addx1708  subtract 1E2     1E4    -> -9.9E+3

------------------------------------------------------------------------
-- Same as above, using decimal64 default parameters                  --
------------------------------------------------------------------------
precision:   16
rounding:    half_even
maxExponent: 384
minexponent: -383

-- [first group are 'quick confidence check']
1661
1662
1663
1664
1665
1666
1667



1668
1669
1670
1671
1672
1673
1674
addx6063 add 1 '0.001' -> '1.001'
addx6064 add 1 '0.0001' -> '1.0001'
addx6065 add 1 '0.00001' -> '1.00001'
addx6066 add 1 '0.000001' -> '1.000001'
addx6067 add 1 '0.0000001' -> '1.0000001'
addx6068 add 1 '0.00000001' -> '1.00000001'




-- some funny zeros [in case of bad signum]
addx6070 add 1  0    -> 1
addx6071 add 1 0.    -> 1
addx6072 add 1  .0   -> 1.0
addx6073 add 1 0.0   -> 1.0
addx6074 add 1 0.00  -> 1.00
addx6075 add  0  1   -> 1







>
>
>







1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
addx6063 add 1 '0.001' -> '1.001'
addx6064 add 1 '0.0001' -> '1.0001'
addx6065 add 1 '0.00001' -> '1.00001'
addx6066 add 1 '0.000001' -> '1.000001'
addx6067 add 1 '0.0000001' -> '1.0000001'
addx6068 add 1 '0.00000001' -> '1.00000001'

-- cancellation to integer
addx6069 add 99999999999999123456789 -99999999999999E+9 -> 123456789

-- some funny zeros [in case of bad signum]
addx6070 add 1  0    -> 1
addx6071 add 1 0.    -> 1
addx6072 add 1  .0   -> 1.0
addx6073 add 1 0.0   -> 1.0
addx6074 add 1 0.00  -> 1.00
addx6075 add  0  1   -> 1
1913
1914
1915
1916
1917
1918
1919

1920
1921
1922
1923
1924
1925
1926
addx6350 add 1E+16   7    ->   1.000000000000001E+16  Inexact Rounded
addx6351 add 1E+17   7    ->   1.000000000000000E+17  Inexact Rounded

-- tryzeros cases
addx6361  add 0E+50 10000E+1  -> 1.0000E+5
addx6362  add 10000E+1 0E-50  -> 100000.0000000000  Rounded
addx6363  add 10000E+1 10000E-50  -> 100000.0000000000  Rounded Inexact


-- ulp replacement tests
addx6400 add   1   77e-14      ->  1.00000000000077
addx6401 add   1   77e-15      ->  1.000000000000077
addx6402 add   1   77e-16      ->  1.000000000000008 Inexact Rounded
addx6403 add   1   77e-17      ->  1.000000000000001 Inexact Rounded
addx6404 add   1   77e-18      ->  1.000000000000000 Inexact Rounded







>







1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
addx6350 add 1E+16   7    ->   1.000000000000001E+16  Inexact Rounded
addx6351 add 1E+17   7    ->   1.000000000000000E+17  Inexact Rounded

-- tryzeros cases
addx6361  add 0E+50 10000E+1  -> 1.0000E+5
addx6362  add 10000E+1 0E-50  -> 100000.0000000000  Rounded
addx6363  add 10000E+1 10000E-50  -> 100000.0000000000  Rounded Inexact
addx6364  add 12.34    0e-398  -> 12.34000000000000  Rounded

-- ulp replacement tests
addx6400 add   1   77e-14      ->  1.00000000000077
addx6401 add   1   77e-15      ->  1.000000000000077
addx6402 add   1   77e-16      ->  1.000000000000008 Inexact Rounded
addx6403 add   1   77e-17      ->  1.000000000000001 Inexact Rounded
addx6404 add   1   77e-18      ->  1.000000000000000 Inexact Rounded
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
addx6574 subtract  1E-383  1E-384  ->   9E-384 Subnormal

-- Here we explore the boundary of rounding a subnormal to Nmin
addx6575 subtract  1E-383  1E-398  ->   9.99999999999999E-384  Subnormal
addx6576 subtract  1E-383  1E-398  ->   9.99999999999999E-384  Subnormal
addx6577 subtract  1E-383  1E-399  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
addx6578 subtract  1E-383  1E-400  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
--addx6579 subtract  1E-383  1E-401  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
--addx6580 subtract  1E-383  1E-402  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded

-- check overflow edge case
--               1234567890123456
addx6972 apply   9.999999999999999E+384         -> 9.999999999999999E+384
addx6973 add     9.999999999999999E+384  1      -> 9.999999999999999E+384 Inexact Rounded
addx6974 add      9999999999999999E+369  1      -> 9.999999999999999E+384 Inexact Rounded
addx6975 add      9999999999999999E+369  1E+369  -> Infinity Overflow Inexact Rounded







|
|







2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
addx6574 subtract  1E-383  1E-384  ->   9E-384 Subnormal

-- Here we explore the boundary of rounding a subnormal to Nmin
addx6575 subtract  1E-383  1E-398  ->   9.99999999999999E-384  Subnormal
addx6576 subtract  1E-383  1E-398  ->   9.99999999999999E-384  Subnormal
addx6577 subtract  1E-383  1E-399  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
addx6578 subtract  1E-383  1E-400  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
addx6579 subtract  1E-383  1E-401  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
addx6580 subtract  1E-383  1E-402  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded

-- check overflow edge case
--               1234567890123456
addx6972 apply   9.999999999999999E+384         -> 9.999999999999999E+384
addx6973 add     9.999999999999999E+384  1      -> 9.999999999999999E+384 Inexact Rounded
addx6974 add      9999999999999999E+369  1      -> 9.999999999999999E+384 Inexact Rounded
addx6975 add      9999999999999999E+369  1E+369  -> Infinity Overflow Inexact Rounded
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
addx61469 add 1.123456789012345  0E-9   -> 1.123456789012345
addx61470 add 1.123456789012345  0E-10  -> 1.123456789012345
addx61471 add 1.123456789012345  0E-11  -> 1.123456789012345
addx61472 add 1.123456789012345  0E-12  -> 1.123456789012345
addx61473 add 1.123456789012345  0E-13  -> 1.123456789012345
addx61474 add 1.123456789012345  0E-14  -> 1.123456789012345
addx61475 add 1.123456789012345  0E-15  -> 1.123456789012345
-- next four flag Rounded becuase the 0 extends the result
addx61476 add 1.123456789012345  0E-16  -> 1.123456789012345 Rounded
addx61477 add 1.123456789012345  0E-17  -> 1.123456789012345 Rounded
addx61478 add 1.123456789012345  0E-18  -> 1.123456789012345 Rounded
addx61479 add 1.123456789012345  0E-19  -> 1.123456789012345 Rounded

-- sum of two opposite-sign operands is exactly 0 and floor => -0
rounding:    half_up







|







2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
addx61469 add 1.123456789012345  0E-9   -> 1.123456789012345
addx61470 add 1.123456789012345  0E-10  -> 1.123456789012345
addx61471 add 1.123456789012345  0E-11  -> 1.123456789012345
addx61472 add 1.123456789012345  0E-12  -> 1.123456789012345
addx61473 add 1.123456789012345  0E-13  -> 1.123456789012345
addx61474 add 1.123456789012345  0E-14  -> 1.123456789012345
addx61475 add 1.123456789012345  0E-15  -> 1.123456789012345
-- next four flag Rounded because the 0 extends the result
addx61476 add 1.123456789012345  0E-16  -> 1.123456789012345 Rounded
addx61477 add 1.123456789012345  0E-17  -> 1.123456789012345 Rounded
addx61478 add 1.123456789012345  0E-18  -> 1.123456789012345 Rounded
addx61479 add 1.123456789012345  0E-19  -> 1.123456789012345 Rounded

-- sum of two opposite-sign operands is exactly 0 and floor => -0
rounding:    half_up
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601






























































































2602
2603
2604
2605
-- some exact zeros from non-zeros
addx61635 add  1E-401   1E-401 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
addx61636 add -1E-401   1E-401 -> -0E-398 Clamped  -- *
addx61637 add  1E-401  -1E-401 -> -0E-398 Clamped  -- *
addx61638 add -1E-401  -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow

-- Examples from SQL proposal (Krishna Kulkarni)
addx61701  add 130E-2    120E-2    -> 2.50
addx61702  add 130E-2    12E-1     -> 2.50
addx61703  add 130E-2    1E0       -> 2.30
addx61704  add 1E2       1E4       -> 1.01E+4
addx61705  subtract 130E-2  120E-2 -> 0.10
addx61706  subtract 130E-2  12E-1  -> 0.10
addx61707  subtract 130E-2  1E0    -> 0.30
addx61708  subtract 1E2     1E4    -> -9.9E+3































































































-- Null tests
addx9990 add 10  # -> NaN Invalid_operation
addx9991 add  # 10 -> NaN Invalid_operation







|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
-- some exact zeros from non-zeros
addx61635 add  1E-401   1E-401 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
addx61636 add -1E-401   1E-401 -> -0E-398 Clamped  -- *
addx61637 add  1E-401  -1E-401 -> -0E-398 Clamped  -- *
addx61638 add -1E-401  -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow

-- Examples from SQL proposal (Krishna Kulkarni)
addx61701 add 130E-2    120E-2    -> 2.50
addx61702 add 130E-2    12E-1     -> 2.50
addx61703 add 130E-2    1E0       -> 2.30
addx61704 add 1E2       1E4       -> 1.01E+4
addx61705 subtract 130E-2  120E-2 -> 0.10
addx61706 subtract 130E-2  12E-1  -> 0.10
addx61707 subtract 130E-2  1E0    -> 0.30
addx61708 subtract 1E2     1E4    -> -9.9E+3

-- Gappy coefficients; check residue handling even with full coefficient gap
rounding: half_even

addx62001 add 1234567890123456 1      -> 1234567890123457
addx62002 add 1234567890123456 0.6    -> 1234567890123457  Inexact Rounded
addx62003 add 1234567890123456 0.06   -> 1234567890123456  Inexact Rounded
addx62004 add 1234567890123456 6E-3   -> 1234567890123456  Inexact Rounded
addx62005 add 1234567890123456 6E-4   -> 1234567890123456  Inexact Rounded
addx62006 add 1234567890123456 6E-5   -> 1234567890123456  Inexact Rounded
addx62007 add 1234567890123456 6E-6   -> 1234567890123456  Inexact Rounded
addx62008 add 1234567890123456 6E-7   -> 1234567890123456  Inexact Rounded
addx62009 add 1234567890123456 6E-8   -> 1234567890123456  Inexact Rounded
addx62010 add 1234567890123456 6E-9   -> 1234567890123456  Inexact Rounded
addx62011 add 1234567890123456 6E-10  -> 1234567890123456  Inexact Rounded
addx62012 add 1234567890123456 6E-11  -> 1234567890123456  Inexact Rounded
addx62013 add 1234567890123456 6E-12  -> 1234567890123456  Inexact Rounded
addx62014 add 1234567890123456 6E-13  -> 1234567890123456  Inexact Rounded
addx62015 add 1234567890123456 6E-14  -> 1234567890123456  Inexact Rounded
addx62016 add 1234567890123456 6E-15  -> 1234567890123456  Inexact Rounded
addx62017 add 1234567890123456 6E-16  -> 1234567890123456  Inexact Rounded
addx62018 add 1234567890123456 6E-17  -> 1234567890123456  Inexact Rounded
addx62019 add 1234567890123456 6E-18  -> 1234567890123456  Inexact Rounded
addx62020 add 1234567890123456 6E-19  -> 1234567890123456  Inexact Rounded
addx62021 add 1234567890123456 6E-20  -> 1234567890123456  Inexact Rounded

-- widening second argument at gap
addx62030 add 12345678 1                       -> 12345679
addx62031 add 12345678 0.1                     -> 12345678.1
addx62032 add 12345678 0.12                    -> 12345678.12
addx62033 add 12345678 0.123                   -> 12345678.123
addx62034 add 12345678 0.1234                  -> 12345678.1234
addx62035 add 12345678 0.12345                 -> 12345678.12345
addx62036 add 12345678 0.123456                -> 12345678.123456
addx62037 add 12345678 0.1234567               -> 12345678.1234567
addx62038 add 12345678 0.12345678              -> 12345678.12345678
addx62039 add 12345678 0.123456789             -> 12345678.12345679 Inexact Rounded
addx62040 add 12345678 0.123456785             -> 12345678.12345678 Inexact Rounded
addx62041 add 12345678 0.1234567850            -> 12345678.12345678 Inexact Rounded
addx62042 add 12345678 0.1234567851            -> 12345678.12345679 Inexact Rounded
addx62043 add 12345678 0.12345678501           -> 12345678.12345679 Inexact Rounded
addx62044 add 12345678 0.123456785001          -> 12345678.12345679 Inexact Rounded
addx62045 add 12345678 0.1234567850001         -> 12345678.12345679 Inexact Rounded
addx62046 add 12345678 0.12345678500001        -> 12345678.12345679 Inexact Rounded
addx62047 add 12345678 0.123456785000001       -> 12345678.12345679 Inexact Rounded
addx62048 add 12345678 0.1234567850000001      -> 12345678.12345679 Inexact Rounded
addx62049 add 12345678 0.1234567850000000      -> 12345678.12345678 Inexact Rounded
--                               90123456
rounding: half_even
addx62050 add 12345678 0.0234567750000000      -> 12345678.02345678 Inexact Rounded
addx62051 add 12345678 0.0034567750000000      -> 12345678.00345678 Inexact Rounded
addx62052 add 12345678 0.0004567750000000      -> 12345678.00045678 Inexact Rounded
addx62053 add 12345678 0.0000567750000000      -> 12345678.00005678 Inexact Rounded
addx62054 add 12345678 0.0000067750000000      -> 12345678.00000678 Inexact Rounded
addx62055 add 12345678 0.0000007750000000      -> 12345678.00000078 Inexact Rounded
addx62056 add 12345678 0.0000000750000000      -> 12345678.00000008 Inexact Rounded
addx62057 add 12345678 0.0000000050000000      -> 12345678.00000000 Inexact Rounded
addx62060 add 12345678 0.0234567750000001      -> 12345678.02345678 Inexact Rounded
addx62061 add 12345678 0.0034567750000001      -> 12345678.00345678 Inexact Rounded
addx62062 add 12345678 0.0004567750000001      -> 12345678.00045678 Inexact Rounded
addx62063 add 12345678 0.0000567750000001      -> 12345678.00005678 Inexact Rounded
addx62064 add 12345678 0.0000067750000001      -> 12345678.00000678 Inexact Rounded
addx62065 add 12345678 0.0000007750000001      -> 12345678.00000078 Inexact Rounded
addx62066 add 12345678 0.0000000750000001      -> 12345678.00000008 Inexact Rounded
addx62067 add 12345678 0.0000000050000001      -> 12345678.00000001 Inexact Rounded
-- far-out residues (full coefficient gap is 16+15 digits)
rounding: up
addx62070 add 12345678 1E-8                    -> 12345678.00000001
addx62071 add 12345678 1E-9                    -> 12345678.00000001 Inexact Rounded
addx62072 add 12345678 1E-10                   -> 12345678.00000001 Inexact Rounded
addx62073 add 12345678 1E-11                   -> 12345678.00000001 Inexact Rounded
addx62074 add 12345678 1E-12                   -> 12345678.00000001 Inexact Rounded
addx62075 add 12345678 1E-13                   -> 12345678.00000001 Inexact Rounded
addx62076 add 12345678 1E-14                   -> 12345678.00000001 Inexact Rounded
addx62077 add 12345678 1E-15                   -> 12345678.00000001 Inexact Rounded
addx62078 add 12345678 1E-16                   -> 12345678.00000001 Inexact Rounded
addx62079 add 12345678 1E-17                   -> 12345678.00000001 Inexact Rounded
addx62080 add 12345678 1E-18                   -> 12345678.00000001 Inexact Rounded
addx62081 add 12345678 1E-19                   -> 12345678.00000001 Inexact Rounded
addx62082 add 12345678 1E-20                   -> 12345678.00000001 Inexact Rounded
addx62083 add 12345678 1E-25                   -> 12345678.00000001 Inexact Rounded
addx62084 add 12345678 1E-30                   -> 12345678.00000001 Inexact Rounded
addx62085 add 12345678 1E-31                   -> 12345678.00000001 Inexact Rounded
addx62086 add 12345678 1E-32                   -> 12345678.00000001 Inexact Rounded
addx62087 add 12345678 1E-33                   -> 12345678.00000001 Inexact Rounded
addx62088 add 12345678 1E-34                   -> 12345678.00000001 Inexact Rounded
addx62089 add 12345678 1E-35                   -> 12345678.00000001 Inexact Rounded

-- payload decapitate
precision: 5
addx62100 add      11  sNaN123456789 ->  NaN56789  Invalid_operation
addx62101 add     -11 -sNaN123456789 -> -NaN56789  Invalid_operation
addx62102 add      11   NaN123456789 ->  NaN56789
addx62103 add     -11  -NaN123456789 -> -NaN56789

-- Null tests
addx9990 add 10  # -> NaN Invalid_operation
addx9991 add  # 10 -> NaN Invalid_operation

Added test/dectest/and.decTest.





































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
------------------------------------------------------------------------
-- and.decTest -- digitwise logical AND                               --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

-- Sanity check (truth table)
andx001 and             0    0 ->    0
andx002 and             0    1 ->    0
andx003 and             1    0 ->    0
andx004 and             1    1 ->    1
andx005 and          1100 1010 -> 1000
andx006 and          1111   10 ->   10
andx007 and          1111 1010 -> 1010

-- and at msd and msd-1
andx010 and 000000000 000000000 ->           0
andx011 and 000000000 100000000 ->           0
andx012 and 100000000 000000000 ->           0
andx013 and 100000000 100000000 ->   100000000
andx014 and 000000000 000000000 ->           0
andx015 and 000000000 010000000 ->           0
andx016 and 010000000 000000000 ->           0
andx017 and 010000000 010000000 ->    10000000

-- Various lengths
--          123456789     123456789      123456789
andx021 and 111111111     111111111  ->  111111111
andx022 and 111111111111  111111111  ->  111111111
andx023 and 111111111111   11111111  ->   11111111
andx024 and 111111111      11111111  ->   11111111
andx025 and 111111111       1111111  ->    1111111
andx026 and 111111111111     111111  ->     111111
andx027 and 111111111111      11111  ->      11111
andx028 and 111111111111       1111  ->       1111
andx029 and 111111111111        111  ->        111
andx031 and 111111111111         11  ->         11
andx032 and 111111111111          1  ->          1
andx033 and 111111111111 1111111111  ->  111111111
andx034 and 11111111111 11111111111  ->  111111111
andx035 and 1111111111 111111111111  ->  111111111
andx036 and 111111111 1111111111111  ->  111111111

andx040 and 111111111  111111111111  ->  111111111
andx041 and  11111111  111111111111  ->   11111111
andx042 and  11111111     111111111  ->   11111111
andx043 and   1111111     111111111  ->    1111111
andx044 and    111111     111111111  ->     111111
andx045 and     11111     111111111  ->      11111
andx046 and      1111     111111111  ->       1111
andx047 and       111     111111111  ->        111
andx048 and        11     111111111  ->         11
andx049 and         1     111111111  ->          1

andx050 and 1111111111  1  ->  1
andx051 and  111111111  1  ->  1
andx052 and   11111111  1  ->  1
andx053 and    1111111  1  ->  1
andx054 and     111111  1  ->  1
andx055 and      11111  1  ->  1
andx056 and       1111  1  ->  1
andx057 and        111  1  ->  1
andx058 and         11  1  ->  1
andx059 and          1  1  ->  1

andx060 and 1111111111  0  ->  0
andx061 and  111111111  0  ->  0
andx062 and   11111111  0  ->  0
andx063 and    1111111  0  ->  0
andx064 and     111111  0  ->  0
andx065 and      11111  0  ->  0
andx066 and       1111  0  ->  0
andx067 and        111  0  ->  0
andx068 and         11  0  ->  0
andx069 and          1  0  ->  0

andx070 and 1  1111111111  ->  1
andx071 and 1   111111111  ->  1
andx072 and 1    11111111  ->  1
andx073 and 1     1111111  ->  1
andx074 and 1      111111  ->  1
andx075 and 1       11111  ->  1
andx076 and 1        1111  ->  1
andx077 and 1         111  ->  1
andx078 and 1          11  ->  1
andx079 and 1           1  ->  1

andx080 and 0  1111111111  ->  0
andx081 and 0   111111111  ->  0
andx082 and 0    11111111  ->  0
andx083 and 0     1111111  ->  0
andx084 and 0      111111  ->  0
andx085 and 0       11111  ->  0
andx086 and 0        1111  ->  0
andx087 and 0         111  ->  0
andx088 and 0          11  ->  0
andx089 and 0           1  ->  0

andx090 and 011111111  111111111  ->   11111111
andx091 and 101111111  111111111  ->  101111111
andx092 and 110111111  111111111  ->  110111111
andx093 and 111011111  111111111  ->  111011111
andx094 and 111101111  111111111  ->  111101111
andx095 and 111110111  111111111  ->  111110111
andx096 and 111111011  111111111  ->  111111011
andx097 and 111111101  111111111  ->  111111101
andx098 and 111111110  111111111  ->  111111110

andx100 and 111111111  011111111  ->   11111111
andx101 and 111111111  101111111  ->  101111111
andx102 and 111111111  110111111  ->  110111111
andx103 and 111111111  111011111  ->  111011111
andx104 and 111111111  111101111  ->  111101111
andx105 and 111111111  111110111  ->  111110111
andx106 and 111111111  111111011  ->  111111011
andx107 and 111111111  111111101  ->  111111101
andx108 and 111111111  111111110  ->  111111110

-- non-0/1 should not be accepted, nor should signs
andx220 and 111111112  111111111  ->  NaN Invalid_operation
andx221 and 333333333  333333333  ->  NaN Invalid_operation
andx222 and 555555555  555555555  ->  NaN Invalid_operation
andx223 and 777777777  777777777  ->  NaN Invalid_operation
andx224 and 999999999  999999999  ->  NaN Invalid_operation
andx225 and 222222222  999999999  ->  NaN Invalid_operation
andx226 and 444444444  999999999  ->  NaN Invalid_operation
andx227 and 666666666  999999999  ->  NaN Invalid_operation
andx228 and 888888888  999999999  ->  NaN Invalid_operation
andx229 and 999999999  222222222  ->  NaN Invalid_operation
andx230 and 999999999  444444444  ->  NaN Invalid_operation
andx231 and 999999999  666666666  ->  NaN Invalid_operation
andx232 and 999999999  888888888  ->  NaN Invalid_operation
-- a few randoms
andx240 and  567468689 -934981942 ->  NaN Invalid_operation
andx241 and  567367689  934981942 ->  NaN Invalid_operation
andx242 and -631917772 -706014634 ->  NaN Invalid_operation
andx243 and -756253257  138579234 ->  NaN Invalid_operation
andx244 and  835590149  567435400 ->  NaN Invalid_operation
-- test MSD
andx250 and  200000000 100000000 ->  NaN Invalid_operation
andx251 and  700000000 100000000 ->  NaN Invalid_operation
andx252 and  800000000 100000000 ->  NaN Invalid_operation
andx253 and  900000000 100000000 ->  NaN Invalid_operation
andx254 and  200000000 000000000 ->  NaN Invalid_operation
andx255 and  700000000 000000000 ->  NaN Invalid_operation
andx256 and  800000000 000000000 ->  NaN Invalid_operation
andx257 and  900000000 000000000 ->  NaN Invalid_operation
andx258 and  100000000 200000000 ->  NaN Invalid_operation
andx259 and  100000000 700000000 ->  NaN Invalid_operation
andx260 and  100000000 800000000 ->  NaN Invalid_operation
andx261 and  100000000 900000000 ->  NaN Invalid_operation
andx262 and  000000000 200000000 ->  NaN Invalid_operation
andx263 and  000000000 700000000 ->  NaN Invalid_operation
andx264 and  000000000 800000000 ->  NaN Invalid_operation
andx265 and  000000000 900000000 ->  NaN Invalid_operation
-- test MSD-1
andx270 and  020000000 100000000 ->  NaN Invalid_operation
andx271 and  070100000 100000000 ->  NaN Invalid_operation
andx272 and  080010000 100000001 ->  NaN Invalid_operation
andx273 and  090001000 100000010 ->  NaN Invalid_operation
andx274 and  100000100 020010100 ->  NaN Invalid_operation
andx275 and  100000000 070001000 ->  NaN Invalid_operation
andx276 and  100000010 080010100 ->  NaN Invalid_operation
andx277 and  100000000 090000010 ->  NaN Invalid_operation
-- test LSD
andx280 and  001000002 100000000 ->  NaN Invalid_operation
andx281 and  000000007 100000000 ->  NaN Invalid_operation
andx282 and  000000008 100000000 ->  NaN Invalid_operation
andx283 and  000000009 100000000 ->  NaN Invalid_operation
andx284 and  100000000 000100002 ->  NaN Invalid_operation
andx285 and  100100000 001000007 ->  NaN Invalid_operation
andx286 and  100010000 010000008 ->  NaN Invalid_operation
andx287 and  100001000 100000009 ->  NaN Invalid_operation
-- test Middie
andx288 and  001020000 100000000 ->  NaN Invalid_operation
andx289 and  000070001 100000000 ->  NaN Invalid_operation
andx290 and  000080000 100010000 ->  NaN Invalid_operation
andx291 and  000090000 100001000 ->  NaN Invalid_operation
andx292 and  100000010 000020100 ->  NaN Invalid_operation
andx293 and  100100000 000070010 ->  NaN Invalid_operation
andx294 and  100010100 000080001 ->  NaN Invalid_operation
andx295 and  100001000 000090000 ->  NaN Invalid_operation
-- signs
andx296 and -100001000 -000000000 ->  NaN Invalid_operation
andx297 and -100001000  000010000 ->  NaN Invalid_operation
andx298 and  100001000 -000000000 ->  NaN Invalid_operation
andx299 and  100001000  000011000 ->  1000

-- Nmax, Nmin, Ntiny
andx331 and  2   9.99999999E+999     -> NaN Invalid_operation
andx332 and  3   1E-999              -> NaN Invalid_operation
andx333 and  4   1.00000000E-999     -> NaN Invalid_operation
andx334 and  5   1E-1007             -> NaN Invalid_operation
andx335 and  6   -1E-1007            -> NaN Invalid_operation
andx336 and  7   -1.00000000E-999    -> NaN Invalid_operation
andx337 and  8   -1E-999             -> NaN Invalid_operation
andx338 and  9   -9.99999999E+999    -> NaN Invalid_operation
andx341 and  9.99999999E+999     -18 -> NaN Invalid_operation
andx342 and  1E-999               01 -> NaN Invalid_operation
andx343 and  1.00000000E-999     -18 -> NaN Invalid_operation
andx344 and  1E-1007              18 -> NaN Invalid_operation
andx345 and  -1E-1007            -10 -> NaN Invalid_operation
andx346 and  -1.00000000E-999     18 -> NaN Invalid_operation
andx347 and  -1E-999              10 -> NaN Invalid_operation
andx348 and  -9.99999999E+999    -18 -> NaN Invalid_operation

-- A few other non-integers
andx361 and  1.0                  1  -> NaN Invalid_operation
andx362 and  1E+1                 1  -> NaN Invalid_operation
andx363 and  0.0                  1  -> NaN Invalid_operation
andx364 and  0E+1                 1  -> NaN Invalid_operation
andx365 and  9.9                  1  -> NaN Invalid_operation
andx366 and  9E+1                 1  -> NaN Invalid_operation
andx371 and  0 1.0                   -> NaN Invalid_operation
andx372 and  0 1E+1                  -> NaN Invalid_operation
andx373 and  0 0.0                   -> NaN Invalid_operation
andx374 and  0 0E+1                  -> NaN Invalid_operation
andx375 and  0 9.9                   -> NaN Invalid_operation
andx376 and  0 9E+1                  -> NaN Invalid_operation

-- All Specials are in error
andx780 and -Inf  -Inf   -> NaN Invalid_operation
andx781 and -Inf  -1000  -> NaN Invalid_operation
andx782 and -Inf  -1     -> NaN Invalid_operation
andx783 and -Inf  -0     -> NaN Invalid_operation
andx784 and -Inf   0     -> NaN Invalid_operation
andx785 and -Inf   1     -> NaN Invalid_operation
andx786 and -Inf   1000  -> NaN Invalid_operation
andx787 and -1000 -Inf   -> NaN Invalid_operation
andx788 and -Inf  -Inf   -> NaN Invalid_operation
andx789 and -1    -Inf   -> NaN Invalid_operation
andx790 and -0    -Inf   -> NaN Invalid_operation
andx791 and  0    -Inf   -> NaN Invalid_operation
andx792 and  1    -Inf   -> NaN Invalid_operation
andx793 and  1000 -Inf   -> NaN Invalid_operation
andx794 and  Inf  -Inf   -> NaN Invalid_operation

andx800 and  Inf  -Inf   -> NaN Invalid_operation
andx801 and  Inf  -1000  -> NaN Invalid_operation
andx802 and  Inf  -1     -> NaN Invalid_operation
andx803 and  Inf  -0     -> NaN Invalid_operation
andx804 and  Inf   0     -> NaN Invalid_operation
andx805 and  Inf   1     -> NaN Invalid_operation
andx806 and  Inf   1000  -> NaN Invalid_operation
andx807 and  Inf   Inf   -> NaN Invalid_operation
andx808 and -1000  Inf   -> NaN Invalid_operation
andx809 and -Inf   Inf   -> NaN Invalid_operation
andx810 and -1     Inf   -> NaN Invalid_operation
andx811 and -0     Inf   -> NaN Invalid_operation
andx812 and  0     Inf   -> NaN Invalid_operation
andx813 and  1     Inf   -> NaN Invalid_operation
andx814 and  1000  Inf   -> NaN Invalid_operation
andx815 and  Inf   Inf   -> NaN Invalid_operation

andx821 and  NaN -Inf    -> NaN Invalid_operation
andx822 and  NaN -1000   -> NaN Invalid_operation
andx823 and  NaN -1      -> NaN Invalid_operation
andx824 and  NaN -0      -> NaN Invalid_operation
andx825 and  NaN  0      -> NaN Invalid_operation
andx826 and  NaN  1      -> NaN Invalid_operation
andx827 and  NaN  1000   -> NaN Invalid_operation
andx828 and  NaN  Inf    -> NaN Invalid_operation
andx829 and  NaN  NaN    -> NaN Invalid_operation
andx830 and -Inf  NaN    -> NaN Invalid_operation
andx831 and -1000 NaN    -> NaN Invalid_operation
andx832 and -1    NaN    -> NaN Invalid_operation
andx833 and -0    NaN    -> NaN Invalid_operation
andx834 and  0    NaN    -> NaN Invalid_operation
andx835 and  1    NaN    -> NaN Invalid_operation
andx836 and  1000 NaN    -> NaN Invalid_operation
andx837 and  Inf  NaN    -> NaN Invalid_operation

andx841 and  sNaN -Inf   ->  NaN  Invalid_operation
andx842 and  sNaN -1000  ->  NaN  Invalid_operation
andx843 and  sNaN -1     ->  NaN  Invalid_operation
andx844 and  sNaN -0     ->  NaN  Invalid_operation
andx845 and  sNaN  0     ->  NaN  Invalid_operation
andx846 and  sNaN  1     ->  NaN  Invalid_operation
andx847 and  sNaN  1000  ->  NaN  Invalid_operation
andx848 and  sNaN  NaN   ->  NaN  Invalid_operation
andx849 and  sNaN sNaN   ->  NaN  Invalid_operation
andx850 and  NaN  sNaN   ->  NaN  Invalid_operation
andx851 and -Inf  sNaN   ->  NaN  Invalid_operation
andx852 and -1000 sNaN   ->  NaN  Invalid_operation
andx853 and -1    sNaN   ->  NaN  Invalid_operation
andx854 and -0    sNaN   ->  NaN  Invalid_operation
andx855 and  0    sNaN   ->  NaN  Invalid_operation
andx856 and  1    sNaN   ->  NaN  Invalid_operation
andx857 and  1000 sNaN   ->  NaN  Invalid_operation
andx858 and  Inf  sNaN   ->  NaN  Invalid_operation
andx859 and  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
andx861 and  NaN1   -Inf    -> NaN Invalid_operation
andx862 and +NaN2   -1000   -> NaN Invalid_operation
andx863 and  NaN3    1000   -> NaN Invalid_operation
andx864 and  NaN4    Inf    -> NaN Invalid_operation
andx865 and  NaN5   +NaN6   -> NaN Invalid_operation
andx866 and -Inf     NaN7   -> NaN Invalid_operation
andx867 and -1000    NaN8   -> NaN Invalid_operation
andx868 and  1000    NaN9   -> NaN Invalid_operation
andx869 and  Inf    +NaN10  -> NaN Invalid_operation
andx871 and  sNaN11  -Inf   -> NaN Invalid_operation
andx872 and  sNaN12  -1000  -> NaN Invalid_operation
andx873 and  sNaN13   1000  -> NaN Invalid_operation
andx874 and  sNaN14   NaN17 -> NaN Invalid_operation
andx875 and  sNaN15  sNaN18 -> NaN Invalid_operation
andx876 and  NaN16   sNaN19 -> NaN Invalid_operation
andx877 and -Inf    +sNaN20 -> NaN Invalid_operation
andx878 and -1000    sNaN21 -> NaN Invalid_operation
andx879 and  1000    sNaN22 -> NaN Invalid_operation
andx880 and  Inf     sNaN23 -> NaN Invalid_operation
andx881 and +NaN25  +sNaN24 -> NaN Invalid_operation
andx882 and -NaN26    NaN28 -> NaN Invalid_operation
andx883 and -sNaN27  sNaN29 -> NaN Invalid_operation
andx884 and  1000    -NaN30 -> NaN Invalid_operation
andx885 and  1000   -sNaN31 -> NaN Invalid_operation

Changes to test/dectest/base.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
------------------------------------------------------------------------
-- base.decTest -- base decimal <--> string conversions               --
-- Copyright (c) IBM Corporation, 1981, 2003.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52


-- This file tests base conversions from string to a decimal number
-- and back to a string (in either Scientific or Engineering form)

-- Note that unlike other operations the operand is subject to rounding
-- to conform to emax and precision settings (that is, numbers will
-- conform to rules and exponent will be in permitted range).

precision:   15
rounding:    half_up
maxExponent: 999999999
minExponent: -999999999
extended:    1

basx001 toSci       0 -> 0
basx002 toSci       1 -> 1
basx003 toSci     1.0 -> 1.0
basx004 toSci    1.00 -> 1.00
basx005 toSci      10 -> 10
basx006 toSci    1000 -> 1000


|
















|
>








|

|
|
<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
------------------------------------------------------------------------
-- base.decTest -- base decimal <--> string conversions               --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55
extended:    1

-- This file tests base conversions from string to a decimal number
-- and back to a string (in either Scientific or Engineering form)

-- Note that unlike other operations the operand is subject to rounding
-- to conform to emax and precision settings (that is, numbers will
-- conform to rules and exponent will be in permitted range).

precision:   16
rounding:    half_up
maxExponent: 384
minExponent: -383


basx001 toSci       0 -> 0
basx002 toSci       1 -> 1
basx003 toSci     1.0 -> 1.0
basx004 toSci    1.00 -> 1.00
basx005 toSci      10 -> 10
basx006 toSci    1000 -> 1000
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110






















111
112
113
114
115
116
117
basx036 toSci '0.0000000123456789'  -> '1.23456789E-8'

basx037 toSci '0.123456789012344'   -> '0.123456789012344'
basx038 toSci '0.123456789012345'   -> '0.123456789012345'

-- String [many more examples are implicitly tested elsewhere]
-- strings without E cannot generate E in result
basx100 toSci "12"        -> '12'
basx101 toSci "-76"       -> '-76'
basx102 toSci "12.76"     -> '12.76'
basx103 toSci "+12.76"    -> '12.76'
basx104 toSci "012.76"    -> '12.76'
basx105 toSci "+0.003"    -> '0.003'
basx106 toSci "17."       -> '17'
basx107 toSci ".5"        -> '0.5'
basx108 toSci "044"       -> '44'
basx109 toSci "0044"      -> '44'
basx110 toSci "0.0005"      -> '0.0005'
basx111 toSci "00.00005"    -> '0.00005'
basx112 toSci "0.000005"    -> '0.000005'
basx113 toSci "0.0000050"   -> '0.0000050'
basx114 toSci "0.0000005"   -> '5E-7'
basx115 toSci "0.00000005"  -> '5E-8'
basx116 toSci "12345678.543210" -> '12345678.543210'
basx117 toSci "2345678.543210" -> '2345678.543210'
basx118 toSci "345678.543210" -> '345678.543210'
basx119 toSci "0345678.54321" -> '345678.54321'
basx120 toSci "345678.5432" -> '345678.5432'
basx121 toSci "+345678.5432" -> '345678.5432'
basx122 toSci "+0345678.5432" -> '345678.5432'
basx123 toSci "+00345678.5432" -> '345678.5432'
basx124 toSci "-345678.5432"  -> '-345678.5432'
basx125 toSci "-0345678.5432"  -> '-345678.5432'
basx126 toSci "-00345678.5432"  -> '-345678.5432'
-- examples
basx127 toSci "5E-6"        -> '0.000005'
basx128 toSci "50E-7"       -> '0.0000050'
basx129 toSci "5E-7"        -> '5E-7'


-- [No exotics as no Unicode]























-- Numbers with E
basx130 toSci "0.000E-1"  -> '0.0000'
basx131 toSci "0.000E-2"  -> '0.00000'
basx132 toSci "0.000E-3"  -> '0.000000'
basx133 toSci "0.000E-4"  -> '0E-7'
basx134 toSci "0.00E-2"   -> '0.0000'
basx135 toSci "0.00E-3"   -> '0.00000'







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
<



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
basx036 toSci '0.0000000123456789'  -> '1.23456789E-8'

basx037 toSci '0.123456789012344'   -> '0.123456789012344'
basx038 toSci '0.123456789012345'   -> '0.123456789012345'

-- String [many more examples are implicitly tested elsewhere]
-- strings without E cannot generate E in result
basx040 toSci "12"        -> '12'
basx041 toSci "-76"       -> '-76'
basx042 toSci "12.76"     -> '12.76'
basx043 toSci "+12.76"    -> '12.76'
basx044 toSci "012.76"    -> '12.76'
basx045 toSci "+0.003"    -> '0.003'
basx046 toSci "17."       -> '17'
basx047 toSci ".5"        -> '0.5'
basx048 toSci "044"       -> '44'
basx049 toSci "0044"      -> '44'
basx050 toSci "0.0005"      -> '0.0005'
basx051 toSci "00.00005"    -> '0.00005'
basx052 toSci "0.000005"    -> '0.000005'
basx053 toSci "0.0000050"   -> '0.0000050'
basx054 toSci "0.0000005"   -> '5E-7'
basx055 toSci "0.00000005"  -> '5E-8'
basx056 toSci "12345678.543210" -> '12345678.543210'
basx057 toSci "2345678.543210" -> '2345678.543210'
basx058 toSci "345678.543210" -> '345678.543210'
basx059 toSci "0345678.54321" -> '345678.54321'
basx060 toSci "345678.5432" -> '345678.5432'
basx061 toSci "+345678.5432" -> '345678.5432'
basx062 toSci "+0345678.5432" -> '345678.5432'
basx063 toSci "+00345678.5432" -> '345678.5432'
basx064 toSci "-345678.5432"  -> '-345678.5432'
basx065 toSci "-0345678.5432"  -> '-345678.5432'
basx066 toSci "-00345678.5432"  -> '-345678.5432'
-- examples
basx067 toSci "5E-6"        -> '0.000005'
basx068 toSci "50E-7"       -> '0.0000050'
basx069 toSci "5E-7"        -> '5E-7'


-- [No exotics as no Unicode]

-- rounded with dots in all (including edge) places
basx071 toSci  .1234567890123456123  -> 0.1234567890123456 Inexact Rounded
basx072 toSci  1.234567890123456123  -> 1.234567890123456 Inexact Rounded
basx073 toSci  12.34567890123456123  -> 12.34567890123456 Inexact Rounded
basx074 toSci  123.4567890123456123  -> 123.4567890123456 Inexact Rounded
basx075 toSci  1234.567890123456123  -> 1234.567890123456 Inexact Rounded
basx076 toSci  12345.67890123456123  -> 12345.67890123456 Inexact Rounded
basx077 toSci  123456.7890123456123  -> 123456.7890123456 Inexact Rounded
basx078 toSci  1234567.890123456123  -> 1234567.890123456 Inexact Rounded
basx079 toSci  12345678.90123456123  -> 12345678.90123456 Inexact Rounded
basx080 toSci  123456789.0123456123  -> 123456789.0123456 Inexact Rounded
basx081 toSci  1234567890.123456123  -> 1234567890.123456 Inexact Rounded
basx082 toSci  12345678901.23456123  -> 12345678901.23456 Inexact Rounded
basx083 toSci  123456789012.3456123  -> 123456789012.3456 Inexact Rounded
basx084 toSci  1234567890123.456123  -> 1234567890123.456 Inexact Rounded
basx085 toSci  12345678901234.56123  -> 12345678901234.56 Inexact Rounded
basx086 toSci  123456789012345.6123  -> 123456789012345.6 Inexact Rounded
basx087 toSci  1234567890123456.123  -> 1234567890123456  Inexact Rounded
basx088 toSci  12345678901234561.23  -> 1.234567890123456E+16 Inexact Rounded
basx089 toSci  123456789012345612.3  -> 1.234567890123456E+17 Inexact Rounded
basx090 toSci  1234567890123456123.  -> 1.234567890123456E+18 Inexact Rounded

-- Numbers with E
basx130 toSci "0.000E-1"  -> '0.0000'
basx131 toSci "0.000E-2"  -> '0.00000'
basx132 toSci "0.000E-3"  -> '0.000000'
basx133 toSci "0.000E-4"  -> '0E-7'
basx134 toSci "0.00E-2"   -> '0.0000'
basx135 toSci "0.00E-3"   -> '0.00000'
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
basx258 toSci "0.1265E+1"  -> '1.265'
basx259 toSci "0.1265E+2"  -> '12.65'
basx260 toSci "0.1265E+3"  -> '126.5'
basx261 toSci "0.1265E+4"  -> '1265'
basx262 toSci "0.1265E+8"  -> '1.265E+7'
basx263 toSci "0.1265E+20" -> '1.265E+19'

basx270 toSci "0.09e999"  -> '9E+997'
basx271 toSci "0.9e999"   -> '9E+998'
basx272 toSci "9e999"     -> '9E+999'
basx273 toSci "9.9e999"   -> '9.9E+999'
basx274 toSci "9.99e999"  -> '9.99E+999'
basx275 toSci "9.99e-999" -> '9.99E-999'
basx276 toSci "9.9e-999"  -> '9.9E-999'
basx277 toSci "9e-999"    -> '9E-999'
basx279 toSci "99e-999"   -> '9.9E-998'
basx280 toSci "999e-999"  -> '9.99E-997'
basx281 toSci '0.9e-998'  -> '9E-999'
basx282 toSci '0.09e-997' -> '9E-999'
basx283 toSci '0.1e1000'  -> '1E+999'
basx284 toSci '10e-1000'  -> '1.0E-999'

-- some more negative zeros [systematic tests below]
basx290 toSci "-0.000E-1"  -> '-0.0000'
basx291 toSci "-0.000E-2"  -> '-0.00000'
basx292 toSci "-0.000E-3"  -> '-0.000000'
basx293 toSci "-0.000E-4"  -> '-0E-7'
basx294 toSci "-0.00E-2"   -> '-0.0000'
basx295 toSci "-0.00E-3"   -> '-0.00000'







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







242
243
244
245
246
247
248















249
250
251
252
253
254
255
basx258 toSci "0.1265E+1"  -> '1.265'
basx259 toSci "0.1265E+2"  -> '12.65'
basx260 toSci "0.1265E+3"  -> '126.5'
basx261 toSci "0.1265E+4"  -> '1265'
basx262 toSci "0.1265E+8"  -> '1.265E+7'
basx263 toSci "0.1265E+20" -> '1.265E+19'
















-- some more negative zeros [systematic tests below]
basx290 toSci "-0.000E-1"  -> '-0.0000'
basx291 toSci "-0.000E-2"  -> '-0.00000'
basx292 toSci "-0.000E-3"  -> '-0.000000'
basx293 toSci "-0.000E-4"  -> '-0E-7'
basx294 toSci "-0.00E-2"   -> '-0.0000'
basx295 toSci "-0.00E-3"   -> '-0.00000'
414
415
416
417
418
419
420
















421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
basx470  toSci 1000000003000 -> 1.00000000E+12   Rounded Inexact
basx471  toEng 1000000003000 -> 1.00000000E+12   Rounded Inexact
basx472  toSci 1000000005000 -> 1.00000001E+12   Rounded Inexact
basx473  toEng 1000000005000 -> 1.00000001E+12   Rounded Inexact
basx474  toSci 1000000009000 -> 1.00000001E+12   Rounded Inexact
basx475  toEng 1000000009000 -> 1.00000001E+12   Rounded Inexact

















-- check rounding modes heeded
precision: 5
rounding:  ceiling
bsrx401  toSci  1.23450    ->  1.2345  Rounded
bsrx402  toSci  1.234549   ->  1.2346  Rounded Inexact
bsrx403  toSci  1.234550   ->  1.2346  Rounded Inexact
bsrx404  toSci  1.234551   ->  1.2346  Rounded Inexact
rounding:  down
bsrx405  toSci  1.23450    ->  1.2345  Rounded
bsrx406  toSci  1.234549   ->  1.2345  Rounded Inexact
bsrx407  toSci  1.234550   ->  1.2345  Rounded Inexact
bsrx408  toSci  1.234551   ->  1.2345  Rounded Inexact
rounding:  floor
bsrx410  toSci  1.23450    ->  1.2345  Rounded
bsrx411  toSci  1.234549   ->  1.2345  Rounded Inexact
bsrx412  toSci  1.234550   ->  1.2345  Rounded Inexact
bsrx413  toSci  1.234551   ->  1.2345  Rounded Inexact
rounding:  half_down
bsrx415  toSci  1.23450    ->  1.2345  Rounded







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







|

|
|
|







420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
basx470  toSci 1000000003000 -> 1.00000000E+12   Rounded Inexact
basx471  toEng 1000000003000 -> 1.00000000E+12   Rounded Inexact
basx472  toSci 1000000005000 -> 1.00000001E+12   Rounded Inexact
basx473  toEng 1000000005000 -> 1.00000001E+12   Rounded Inexact
basx474  toSci 1000000009000 -> 1.00000001E+12   Rounded Inexact
basx475  toEng 1000000009000 -> 1.00000001E+12   Rounded Inexact

-- all-nines rounding
precision: 9
rounding:  half_up
basx270  toSci 999999999          ->   999999999
basx271  toSci 9999999990         ->   9.99999999E+9      Rounded
basx272  toSci 9999999991         ->   9.99999999E+9      Rounded Inexact
basx273  toSci 9999999992         ->   9.99999999E+9      Rounded Inexact
basx274  toSci 9999999993         ->   9.99999999E+9      Rounded Inexact
basx275  toSci 9999999994         ->   9.99999999E+9      Rounded Inexact
basx276  toSci 9999999995         ->   1.00000000E+10     Rounded Inexact
basx277  toSci 9999999996         ->   1.00000000E+10     Rounded Inexact
basx278  toSci 9999999997         ->   1.00000000E+10     Rounded Inexact
basx279  toSci 9999999998         ->   1.00000000E+10     Rounded Inexact
basx280  toSci 9999999999         ->   1.00000000E+10     Rounded Inexact
basx281  toSci 9999999999999999   ->   1.00000000E+16     Rounded Inexact

-- check rounding modes heeded
precision: 5
rounding:  ceiling
bsrx401  toSci  1.23450    ->  1.2345  Rounded
bsrx402  toSci  1.234549   ->  1.2346  Rounded Inexact
bsrx403  toSci  1.234550   ->  1.2346  Rounded Inexact
bsrx404  toSci  1.234551   ->  1.2346  Rounded Inexact
rounding:  up
bsrx405  toSci  1.23450    ->  1.2345  Rounded
bsrx406  toSci  1.234549   ->  1.2346  Rounded Inexact
bsrx407  toSci  1.234550   ->  1.2346  Rounded Inexact
bsrx408  toSci  1.234551   ->  1.2346  Rounded Inexact
rounding:  floor
bsrx410  toSci  1.23450    ->  1.2345  Rounded
bsrx411  toSci  1.234549   ->  1.2345  Rounded Inexact
bsrx412  toSci  1.234550   ->  1.2345  Rounded Inexact
bsrx413  toSci  1.234551   ->  1.2345  Rounded Inexact
rounding:  half_down
bsrx415  toSci  1.23450    ->  1.2345  Rounded
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
bsrx435  toSci  1.234551   ->  1.2346  Rounded Inexact
-- negatives
rounding:  ceiling
bsrx501  toSci -1.23450    -> -1.2345  Rounded
bsrx502  toSci -1.234549   -> -1.2345  Rounded Inexact
bsrx503  toSci -1.234550   -> -1.2345  Rounded Inexact
bsrx504  toSci -1.234551   -> -1.2345  Rounded Inexact
rounding:  down
bsrx505  toSci -1.23450    -> -1.2345  Rounded
bsrx506  toSci -1.234549   -> -1.2345  Rounded Inexact
bsrx507  toSci -1.234550   -> -1.2345  Rounded Inexact
bsrx508  toSci -1.234551   -> -1.2345  Rounded Inexact
rounding:  floor
bsrx510  toSci -1.23450    -> -1.2345  Rounded
bsrx511  toSci -1.234549   -> -1.2346  Rounded Inexact
bsrx512  toSci -1.234550   -> -1.2346  Rounded Inexact
bsrx513  toSci -1.234551   -> -1.2346  Rounded Inexact
rounding:  half_down
bsrx515  toSci -1.23450    -> -1.2345  Rounded







|

|
|
|







482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
bsrx435  toSci  1.234551   ->  1.2346  Rounded Inexact
-- negatives
rounding:  ceiling
bsrx501  toSci -1.23450    -> -1.2345  Rounded
bsrx502  toSci -1.234549   -> -1.2345  Rounded Inexact
bsrx503  toSci -1.234550   -> -1.2345  Rounded Inexact
bsrx504  toSci -1.234551   -> -1.2345  Rounded Inexact
rounding:  up
bsrx505  toSci -1.23450    -> -1.2345  Rounded
bsrx506  toSci -1.234549   -> -1.2346  Rounded Inexact
bsrx507  toSci -1.234550   -> -1.2346  Rounded Inexact
bsrx508  toSci -1.234551   -> -1.2346  Rounded Inexact
rounding:  floor
bsrx510  toSci -1.23450    -> -1.2345  Rounded
bsrx511  toSci -1.234549   -> -1.2346  Rounded Inexact
bsrx512  toSci -1.234550   -> -1.2346  Rounded Inexact
bsrx513  toSci -1.234551   -> -1.2346  Rounded Inexact
rounding:  half_down
bsrx515  toSci -1.23450    -> -1.2345  Rounded
494
495
496
497
498
499
500


















501
502
503
504
505
506
507
rounding:  half_up
bsrx531  toSci -1.23450    -> -1.2345  Rounded
bsrx532  toSci -1.234549   -> -1.2345  Rounded Inexact
bsrx533  toSci -1.234550   -> -1.2346  Rounded Inexact
bsrx534  toSci -1.234650   -> -1.2347  Rounded Inexact
bsrx535  toSci -1.234551   -> -1.2346  Rounded Inexact



















rounding:  half_up
precision: 9

-- The 'baddies' tests from DiagBigDecimal, plus some new ones
basx500 toSci '1..2'            -> NaN Conversion_syntax
basx501 toSci '.'               -> NaN Conversion_syntax
basx502 toSci '..'              -> NaN Conversion_syntax







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
rounding:  half_up
bsrx531  toSci -1.23450    -> -1.2345  Rounded
bsrx532  toSci -1.234549   -> -1.2345  Rounded Inexact
bsrx533  toSci -1.234550   -> -1.2346  Rounded Inexact
bsrx534  toSci -1.234650   -> -1.2347  Rounded Inexact
bsrx535  toSci -1.234551   -> -1.2346  Rounded Inexact

-- a few larger exponents
maxExponent: 999999999
minExponent: -999999999
basx480 toSci "0.09e999"  -> '9E+997'
basx481 toSci "0.9e999"   -> '9E+998'
basx482 toSci "9e999"     -> '9E+999'
basx483 toSci "9.9e999"   -> '9.9E+999'
basx484 toSci "9.99e999"  -> '9.99E+999'
basx485 toSci "9.99e-999" -> '9.99E-999'
basx486 toSci "9.9e-999"  -> '9.9E-999'
basx487 toSci "9e-999"    -> '9E-999'
basx489 toSci "99e-999"   -> '9.9E-998'
basx490 toSci "999e-999"  -> '9.99E-997'
basx491 toSci '0.9e-998'  -> '9E-999'
basx492 toSci '0.09e-997' -> '9E-999'
basx493 toSci '0.1e1000'  -> '1E+999'
basx494 toSci '10e-1000'  -> '1.0E-999'

rounding:  half_up
precision: 9

-- The 'baddies' tests from DiagBigDecimal, plus some new ones
basx500 toSci '1..2'            -> NaN Conversion_syntax
basx501 toSci '.'               -> NaN Conversion_syntax
basx502 toSci '..'              -> NaN Conversion_syntax
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594

595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
basx570 toSci "9Inf"            -> NaN Conversion_syntax
basx571 toSci "-0Inf"           -> NaN Conversion_syntax
basx572 toSci "-9Inf"           -> NaN Conversion_syntax
basx573 toSci "-sNa"            -> NaN Conversion_syntax
basx574 toSci "xNaN"            -> NaN Conversion_syntax
basx575 toSci "0sNaN"           -> NaN Conversion_syntax

-- subnormals and overflows
basx576 toSci '99e999999999'       -> Infinity Overflow  Inexact Rounded
basx577 toSci '999e999999999'      -> Infinity Overflow  Inexact Rounded
basx578 toSci '0.9e-999999999'     -> 9E-1000000000 Subnormal
basx579 toSci '0.09e-999999999'    -> 9E-1000000001 Subnormal
basx580 toSci '0.1e1000000000'     -> 1E+999999999
basx581 toSci '10e-1000000000'     -> 1.0E-999999999
basx582 toSci '0.9e9999999999'     -> Infinity Overflow  Inexact Rounded
basx583 toSci '99e-9999999999'     -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped
basx584 toSci '111e9999999999'     -> Infinity Overflow  Inexact Rounded
basx585 toSci '1111e-9999999999'   -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped
basx586 toSci '1111e-99999999999'  -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped

basx587 toSci '7e1000000000'       -> Infinity Overflow  Inexact Rounded
-- negatives the same
basx588 toSci '-99e999999999'      -> -Infinity Overflow  Inexact Rounded
basx589 toSci '-999e999999999'     -> -Infinity Overflow  Inexact Rounded
basx590 toSci '-0.9e-999999999'    -> -9E-1000000000 Subnormal
basx591 toSci '-0.09e-999999999'   -> -9E-1000000001 Subnormal
basx592 toSci '-0.1e1000000000'    -> -1E+999999999
basx593 toSci '-10e-1000000000'    -> -1.0E-999999999
basx594 toSci '-0.9e9999999999'    -> -Infinity Overflow  Inexact Rounded
basx595 toSci '-99e-9999999999'    -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped
basx596 toSci '-111e9999999999'    -> -Infinity Overflow  Inexact Rounded
basx597 toSci '-1111e-9999999999'  -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped
basx598 toSci '-1111e-99999999999' -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped
basx599 toSci '-7e1000000000'      -> -Infinity Overflow  Inexact Rounded

-- Zeros
basx601 toSci 0.000000000       -> 0E-9
basx602 toSci 0.00000000        -> 0E-8
basx603 toSci 0.0000000         -> 0E-7
basx604 toSci 0.000000          -> 0.000000
basx605 toSci 0.00000           -> 0.00000







|
|
|
|
|
|
|
|
|
|
|
|
>
|
<
|
|
|
<
<
<
<
<
<
<
<
<







616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636

637
638
639









640
641
642
643
644
645
646
basx570 toSci "9Inf"            -> NaN Conversion_syntax
basx571 toSci "-0Inf"           -> NaN Conversion_syntax
basx572 toSci "-9Inf"           -> NaN Conversion_syntax
basx573 toSci "-sNa"            -> NaN Conversion_syntax
basx574 toSci "xNaN"            -> NaN Conversion_syntax
basx575 toSci "0sNaN"           -> NaN Conversion_syntax

-- some baddies with dots and Es and dots and specials
basx576 toSci  'e+1'            ->  NaN Conversion_syntax
basx577 toSci  '.e+1'           ->  NaN Conversion_syntax
basx578 toSci  '+.e+1'          ->  NaN Conversion_syntax
basx579 toSci  '-.e+'           ->  NaN Conversion_syntax
basx580 toSci  '-.e'            ->  NaN Conversion_syntax
basx581 toSci  'E+1'            ->  NaN Conversion_syntax
basx582 toSci  '.E+1'           ->  NaN Conversion_syntax
basx583 toSci  '+.E+1'          ->  NaN Conversion_syntax
basx584 toSci  '-.E+'           ->  NaN Conversion_syntax
basx585 toSci  '-.E'            ->  NaN Conversion_syntax

basx586 toSci  '.NaN'           ->  NaN Conversion_syntax
basx587 toSci  '-.NaN'          ->  NaN Conversion_syntax

basx588 toSci  '+.sNaN'         ->  NaN Conversion_syntax
basx589 toSci  '+.Inf'          ->  NaN Conversion_syntax
basx590 toSci  '.Infinity'      ->  NaN Conversion_syntax










-- Zeros
basx601 toSci 0.000000000       -> 0E-9
basx602 toSci 0.00000000        -> 0E-8
basx603 toSci 0.0000000         -> 0E-7
basx604 toSci 0.000000          -> 0.000000
basx605 toSci 0.00000           -> 0.00000
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
basx684 toSci      00.          ->  0
basx685 toSci       0.          ->  0
basx686 toSci  +00000.          ->  0
basx687 toSci  -00000.          -> -0
basx688 toSci  +0.              ->  0
basx689 toSci  -0.              -> -0

-- some baddies with dots and Es
basx690 toSci  'e+1'            ->  NaN Conversion_syntax
basx691 toSci  '.e+1'           ->  NaN Conversion_syntax
basx692 toSci  '+.e+1'          ->  NaN Conversion_syntax
basx693 toSci  '-.e+'           ->  NaN Conversion_syntax
basx694 toSci  '-.e'            ->  NaN Conversion_syntax
basx695 toSci  'E+1'            ->  NaN Conversion_syntax
basx696 toSci  '.E+1'           ->  NaN Conversion_syntax
basx697 toSci  '+.E+1'          ->  NaN Conversion_syntax
basx698 toSci  '-.E+'           ->  NaN Conversion_syntax
basx699 toSci  '-.E'            ->  NaN Conversion_syntax

-- Specials
precision: 4
basx700 toSci "NaN"             -> NaN
basx701 toSci "nan"             -> NaN
basx702 toSci "nAn"             -> NaN
basx703 toSci "NAN"             -> NaN
basx704 toSci "+NaN"            -> NaN







<
<
<
<
<
<
<
<
<
<
<
<







724
725
726
727
728
729
730












731
732
733
734
735
736
737
basx684 toSci      00.          ->  0
basx685 toSci       0.          ->  0
basx686 toSci  +00000.          ->  0
basx687 toSci  -00000.          -> -0
basx688 toSci  +0.              ->  0
basx689 toSci  -0.              -> -0













-- Specials
precision: 4
basx700 toSci "NaN"             -> NaN
basx701 toSci "nan"             -> NaN
basx702 toSci "nAn"             -> NaN
basx703 toSci "NAN"             -> NaN
basx704 toSci "+NaN"            -> NaN
886
887
888
889
890
891
892
























































893
894
895
896
897
898
899
basx873 toEng  0.00E-3          -> 0.00000
basx874 toEng  0.00E-4          -> 0.000000
basx875 toEng  0.00E-5          -> 0.0E-6
basx876 toEng  0.00E-6          -> 0.00E-6
basx877 toEng  0.00E-7          -> 0E-9
basx878 toEng  0.00E-8          -> 0.0E-9
basx879 toEng  0.00E-9          -> 0.00E-9

























































-- Giga exponent initial tests
maxExponent: 999999999
minExponent: -999999999

basx951 toSci '99e999'          -> '9.9E+1000'
basx952 toSci '999e999'         -> '9.99E+1001'







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
basx873 toEng  0.00E-3          -> 0.00000
basx874 toEng  0.00E-4          -> 0.000000
basx875 toEng  0.00E-5          -> 0.0E-6
basx876 toEng  0.00E-6          -> 0.00E-6
basx877 toEng  0.00E-7          -> 0E-9
basx878 toEng  0.00E-8          -> 0.0E-9
basx879 toEng  0.00E-9          -> 0.00E-9


rounding:  half_up
precision: 9
-- subnormals and overflows
basx906 toSci '99e999999999'       -> Infinity Overflow  Inexact Rounded
basx907 toSci '999e999999999'      -> Infinity Overflow  Inexact Rounded
basx908 toSci '0.9e-999999999'     -> 9E-1000000000 Subnormal
basx909 toSci '0.09e-999999999'    -> 9E-1000000001 Subnormal
basx910 toSci '0.1e1000000000'     -> 1E+999999999
basx911 toSci '10e-1000000000'     -> 1.0E-999999999
basx912 toSci '0.9e9999999999'     -> Infinity Overflow  Inexact Rounded
basx913 toSci '99e-9999999999'     -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped
basx914 toSci '111e9999999999'     -> Infinity Overflow  Inexact Rounded
basx915 toSci '1111e-9999999999'   -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped
basx916 toSci '1111e-99999999999'  -> 0E-1000000007 Underflow Subnormal Inexact Rounded Clamped
basx917 toSci '7e1000000000'       -> Infinity Overflow  Inexact Rounded
-- negatives the same
basx918 toSci '-99e999999999'      -> -Infinity Overflow  Inexact Rounded
basx919 toSci '-999e999999999'     -> -Infinity Overflow  Inexact Rounded
basx920 toSci '-0.9e-999999999'    -> -9E-1000000000 Subnormal
basx921 toSci '-0.09e-999999999'   -> -9E-1000000001 Subnormal
basx922 toSci '-0.1e1000000000'    -> -1E+999999999
basx923 toSci '-10e-1000000000'    -> -1.0E-999999999
basx924 toSci '-0.9e9999999999'    -> -Infinity Overflow  Inexact Rounded
basx925 toSci '-99e-9999999999'    -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped
basx926 toSci '-111e9999999999'    -> -Infinity Overflow  Inexact Rounded
basx927 toSci '-1111e-9999999999'  -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped
basx928 toSci '-1111e-99999999999' -> -0E-1000000007 Underflow Subnormal Inexact Rounded Clamped
basx929 toSci '-7e1000000000'      -> -Infinity Overflow  Inexact Rounded

rounding:  ceiling
basx930 toSci  '7e1000000000'      ->  Infinity Overflow  Inexact Rounded
basx931 toSci '-7e1000000000'      -> -9.99999999E+999999999 Overflow  Inexact Rounded
rounding:  up
basx932 toSci  '7e1000000000'      ->  Infinity Overflow  Inexact Rounded
basx933 toSci '-7e1000000000'      -> -Infinity Overflow  Inexact Rounded
rounding:  down
basx934 toSci  '7e1000000000'      ->  9.99999999E+999999999 Overflow  Inexact Rounded
basx935 toSci '-7e1000000000'      -> -9.99999999E+999999999 Overflow  Inexact Rounded
rounding:  floor
basx936 toSci  '7e1000000000'      ->  9.99999999E+999999999 Overflow  Inexact Rounded
basx937 toSci '-7e1000000000'      -> -Infinity Overflow  Inexact Rounded

rounding:  half_up
basx938 toSci  '7e1000000000'      ->  Infinity Overflow  Inexact Rounded
basx939 toSci '-7e1000000000'      -> -Infinity Overflow  Inexact Rounded
rounding:  half_even
basx940 toSci  '7e1000000000'      ->  Infinity Overflow  Inexact Rounded
basx941 toSci '-7e1000000000'      -> -Infinity Overflow  Inexact Rounded
rounding:  half_down
basx942 toSci  '7e1000000000'      ->  Infinity Overflow  Inexact Rounded
basx943 toSci '-7e1000000000'      -> -Infinity Overflow  Inexact Rounded

rounding:  half_even


-- Giga exponent initial tests
maxExponent: 999999999
minExponent: -999999999

basx951 toSci '99e999'          -> '9.9E+1000'
basx952 toSci '999e999'         -> '9.99E+1001'
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305



1306




1307


1308



1309




1310



1311






precision:   5
maxexponent: 79
minexponent: -79
basx1041 toSci     1.52444E-80  ->  1.524E-80 Inexact Rounded Subnormal Underflow
basx1042 toSci     1.52445E-80  ->  1.524E-80 Inexact Rounded Subnormal Underflow
basx1043 toSci     1.52446E-80  ->  1.524E-80 Inexact Rounded Subnormal Underflow

-- clamped zeros [see also clamped.decTest]
precision:   34
maxExponent: 6144
minExponent: -6143

basx1061 apply   0e+10000  ->  0E+6144 Clamped
basx1062 apply   0e-10000  ->  0E-6176 Clamped
basx1063 apply  -0e+10000  -> -0E+6144 Clamped
basx1064 apply  -0e-10000  -> -0E-6176 Clamped







































|









>
>
>

>
>
>
>

>
>

>
>
>

>
>
>
>

>
>
>

>
>
>
>
>
>
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
precision:   5
maxexponent: 79
minexponent: -79
basx1041 toSci     1.52444E-80  ->  1.524E-80 Inexact Rounded Subnormal Underflow
basx1042 toSci     1.52445E-80  ->  1.524E-80 Inexact Rounded Subnormal Underflow
basx1043 toSci     1.52446E-80  ->  1.524E-80 Inexact Rounded Subnormal Underflow

-- clamped zeros [see also clamp.decTest]
precision:   34
maxExponent: 6144
minExponent: -6143

basx1061 apply   0e+10000  ->  0E+6144 Clamped
basx1062 apply   0e-10000  ->  0E-6176 Clamped
basx1063 apply  -0e+10000  -> -0E+6144 Clamped
basx1064 apply  -0e-10000  -> -0E-6176 Clamped

precision:   16
maxExponent: 384
minExponent: -383

basx1065 apply   0e+10000  ->  0E+384  Clamped
basx1066 apply   0e-10000  ->  0E-398  Clamped
basx1067 apply  -0e+10000  -> -0E+384  Clamped
basx1068 apply  -0e-10000  -> -0E-398  Clamped

-- same with IEEE clamping
clamp:       1

precision:   34
maxExponent: 6144
minExponent: -6143

basx1071 apply   0e+10000  ->  0E+6111 Clamped
basx1072 apply   0e-10000  ->  0E-6176 Clamped
basx1073 apply  -0e+10000  -> -0E+6111 Clamped
basx1074 apply  -0e-10000  -> -0E-6176 Clamped

precision:   16
maxExponent: 384
minExponent: -383

basx1075 apply   0e+10000  ->  0E+369  Clamped
basx1076 apply   0e-10000  ->  0E-398  Clamped
basx1077 apply  -0e+10000  -> -0E+369  Clamped
basx1078 apply  -0e-10000  -> -0E-398  Clamped


Changes to test/dectest/clamp.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- clamp.decTest -- clamped exponent tests (format-independent)       --
-- Copyright (c) IBM Corporation, 2000, 2003.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- This set of tests uses the same limits as the 8-byte concrete
-- representation, but applies clamping without using format-specific
-- conversions.

extended:    1
precision:   16


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- clamp.decTest -- clamped exponent tests (format-independent)       --
-- Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests uses the same limits as the 8-byte concrete
-- representation, but applies clamping without using format-specific
-- conversions.

extended:    1
precision:   16

Added test/dectest/class.decTest.







































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
------------------------------------------------------------------------
-- class.decTest -- Class operations                                  --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- [New 2006.11.27]

precision:   9
maxExponent: 999
minExponent: -999
extended:    1
clamp:       1
rounding:    half_even

clasx001  class    0                        -> +Zero
clasx002  class    0.00                     -> +Zero
clasx003  class    0E+5                     -> +Zero
clasx004  class    1E-1007                  -> +Subnormal
clasx005  class  0.1E-999                   -> +Subnormal
clasx006  class  0.99999999E-999            -> +Subnormal
clasx007  class  1.00000000E-999            -> +Normal
clasx008  class   1E-999                    -> +Normal
clasx009  class   1E-100                    -> +Normal
clasx010  class   1E-10                     -> +Normal
clasx012  class   1E-1                      -> +Normal
clasx013  class   1                         -> +Normal
clasx014  class   2.50                      -> +Normal
clasx015  class   100.100                   -> +Normal
clasx016  class   1E+30                     -> +Normal
clasx017  class   1E+999                    -> +Normal
clasx018  class   9.99999999E+999           -> +Normal
clasx019  class   Inf                       -> +Infinity

clasx021  class   -0                        -> -Zero
clasx022  class   -0.00                     -> -Zero
clasx023  class   -0E+5                     -> -Zero
clasx024  class   -1E-1007                  -> -Subnormal
clasx025  class  -0.1E-999                  -> -Subnormal
clasx026  class  -0.99999999E-999           -> -Subnormal
clasx027  class  -1.00000000E-999           -> -Normal
clasx028  class  -1E-999                    -> -Normal
clasx029  class  -1E-100                    -> -Normal
clasx030  class  -1E-10                     -> -Normal
clasx032  class  -1E-1                      -> -Normal
clasx033  class  -1                         -> -Normal
clasx034  class  -2.50                      -> -Normal
clasx035  class  -100.100                   -> -Normal
clasx036  class  -1E+30                     -> -Normal
clasx037  class  -1E+999                    -> -Normal
clasx038  class  -9.99999999E+999           -> -Normal
clasx039  class  -Inf                       -> -Infinity

clasx041  class   NaN                       -> NaN
clasx042  class  -NaN                       -> NaN
clasx043  class  +NaN12345                  -> NaN
clasx044  class   sNaN                      -> sNaN
clasx045  class  -sNaN                      -> sNaN
clasx046  class  +sNaN12345                 -> sNaN


-- decimal64 bounds

precision:   16
maxExponent: 384
minExponent: -383
clamp:       1
rounding:    half_even

clasx201  class    0                        -> +Zero
clasx202  class    0.00                     -> +Zero
clasx203  class    0E+5                     -> +Zero
clasx204  class    1E-396                   -> +Subnormal
clasx205  class  0.1E-383                   -> +Subnormal
clasx206  class  0.999999999999999E-383     -> +Subnormal
clasx207  class  1.000000000000000E-383     -> +Normal
clasx208  class   1E-383                    -> +Normal
clasx209  class   1E-100                    -> +Normal
clasx210  class   1E-10                     -> +Normal
clasx212  class   1E-1                      -> +Normal
clasx213  class   1                         -> +Normal
clasx214  class   2.50                      -> +Normal
clasx215  class   100.100                   -> +Normal
clasx216  class   1E+30                     -> +Normal
clasx217  class   1E+384                    -> +Normal
clasx218  class   9.999999999999999E+384    -> +Normal
clasx219  class   Inf                       -> +Infinity

clasx221  class   -0                        -> -Zero
clasx222  class   -0.00                     -> -Zero
clasx223  class   -0E+5                     -> -Zero
clasx224  class   -1E-396                   -> -Subnormal
clasx225  class  -0.1E-383                  -> -Subnormal
clasx226  class  -0.999999999999999E-383    -> -Subnormal
clasx227  class  -1.000000000000000E-383    -> -Normal
clasx228  class  -1E-383                    -> -Normal
clasx229  class  -1E-100                    -> -Normal
clasx230  class  -1E-10                     -> -Normal
clasx232  class  -1E-1                      -> -Normal
clasx233  class  -1                         -> -Normal
clasx234  class  -2.50                      -> -Normal
clasx235  class  -100.100                   -> -Normal
clasx236  class  -1E+30                     -> -Normal
clasx237  class  -1E+384                    -> -Normal
clasx238  class  -9.999999999999999E+384    -> -Normal
clasx239  class  -Inf                       -> -Infinity

clasx241  class   NaN                       -> NaN
clasx242  class  -NaN                       -> NaN
clasx243  class  +NaN12345                  -> NaN
clasx244  class   sNaN                      -> sNaN
clasx245  class  -sNaN                      -> sNaN
clasx246  class  +sNaN12345                 -> sNaN



Changes to test/dectest/compare.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- compare.decTest -- decimal comparison                              --
-- Copyright (c) IBM Corporation, 1981, 2003.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- Note that we cannot assume add/subtract tests cover paths adequately,
-- here, because the code might be quite different (comparison cannot
-- overflow or underflow, so actual subtractions are not necessary).

extended: 1


|
|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- compare.decTest -- decimal comparison that allows quiet NaNs       --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Note that we cannot assume add/subtract tests cover paths adequately,
-- here, because the code might be quite different (comparison cannot
-- overflow or underflow, so actual subtractions are not necessary).

extended: 1

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
comx083 compare   2.0   0.0  -> 1
comx085 compare   2.0   1.0  -> 1
comx086 compare   2.0   2.0  -> 0

-- now some cases which might overflow if subtract were used
maxexponent: 999999999
minexponent: -999999999
comx090 compare  9.99999999E+999999999 9.99999999E+999999999  -> 0
comx091 compare -9.99999999E+999999999 9.99999999E+999999999  -> -1
comx092 compare  9.99999999E+999999999 -9.99999999E+999999999 -> 1
comx093 compare -9.99999999E+999999999 -9.99999999E+999999999 -> 0

-- some differing length/exponent cases
comx100 compare   7.0    7.0    -> 0
comx101 compare   7.0    7      -> 0
comx102 compare   7      7.0    -> 0
comx103 compare   7E+0   7.0    -> 0
comx104 compare   70E-1  7.0    -> 0







|
|
|
|







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
comx083 compare   2.0   0.0  -> 1
comx085 compare   2.0   1.0  -> 1
comx086 compare   2.0   2.0  -> 0

-- now some cases which might overflow if subtract were used
maxexponent: 999999999
minexponent: -999999999
comx095 compare  9.99999999E+999999999 9.99999999E+999999999  -> 0
comx096 compare -9.99999999E+999999999 9.99999999E+999999999  -> -1
comx097 compare  9.99999999E+999999999 -9.99999999E+999999999 -> 1
comx098 compare -9.99999999E+999999999 -9.99999999E+999999999 -> 0

-- some differing length/exponent cases
comx100 compare   7.0    7.0    -> 0
comx101 compare   7.0    7      -> 0
comx102 compare   7      7.0    -> 0
comx103 compare   7E+0   7.0    -> 0
comx104 compare   70E-1  7.0    -> 0
261
262
263
264
265
266
267















268
269
270
271
272
273
274
comx445 compare   -.8E+1  -9      -> 1
comx446 compare   -80E-1  -9      -> 1
comx447 compare   -8.0    -9E+0   -> 1
comx448 compare   -8.0    -90E-1  -> 1
comx449 compare   -8      -.9E+1  -> 1
comx450 compare   -8      -90E-1  -> 1

















-- testcases that subtract to lots of zeros at boundaries [pgr]
precision: 40
comx470 compare 123.4560000000000000E789 123.456E789 -> 0
comx471 compare 123.456000000000000E-89 123.456E-89 -> 0
comx472 compare 123.45600000000000E789 123.456E789 -> 0
comx473 compare 123.4560000000000E-89 123.456E-89 -> 0







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
comx445 compare   -.8E+1  -9      -> 1
comx446 compare   -80E-1  -9      -> 1
comx447 compare   -8.0    -9E+0   -> 1
comx448 compare   -8.0    -90E-1  -> 1
comx449 compare   -8      -.9E+1  -> 1
comx450 compare   -8      -90E-1  -> 1

-- misalignment traps for little-endian
comx451 compare      1.0       0.1  -> 1
comx452 compare      0.1       1.0  -> -1
comx453 compare     10.0       0.1  -> 1
comx454 compare      0.1      10.0  -> -1
comx455 compare      100       1.0  -> 1
comx456 compare      1.0       100  -> -1
comx457 compare     1000      10.0  -> 1
comx458 compare     10.0      1000  -> -1
comx459 compare    10000     100.0  -> 1
comx460 compare    100.0     10000  -> -1
comx461 compare   100000    1000.0  -> 1
comx462 compare   1000.0    100000  -> -1
comx463 compare  1000000   10000.0  -> 1
comx464 compare  10000.0   1000000  -> -1

-- testcases that subtract to lots of zeros at boundaries [pgr]
precision: 40
comx470 compare 123.4560000000000000E789 123.456E789 -> 0
comx471 compare 123.456000000000000E-89 123.456E-89 -> 0
comx472 compare 123.45600000000000E789 123.456E789 -> 0
comx473 compare 123.4560000000000E-89 123.456E-89 -> 0
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
comx565 compare    1E+9   1       ->  1
comx566 compare    1E+10  1       ->  1
comx567 compare    1E+11  1       ->  1
comx568 compare    1E+12  1       ->  1
comx569 compare    1E+13  1       ->  1
comx570 compare    1E+14  1       ->  1
comx571 compare    1E+15  1       ->  1
-- similar with an useful coefficient, one side only
comx580 compare  0.000000987654321     1E-15    -> 1
comx581 compare  0.000000987654321     1E-14    -> 1
comx582 compare  0.000000987654321     1E-13    -> 1
comx583 compare  0.000000987654321     1E-12    -> 1
comx584 compare  0.000000987654321     1E-11    -> 1
comx585 compare  0.000000987654321     1E-10    -> 1
comx586 compare  0.000000987654321     1E-9     -> 1







|







373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
comx565 compare    1E+9   1       ->  1
comx566 compare    1E+10  1       ->  1
comx567 compare    1E+11  1       ->  1
comx568 compare    1E+12  1       ->  1
comx569 compare    1E+13  1       ->  1
comx570 compare    1E+14  1       ->  1
comx571 compare    1E+15  1       ->  1
-- similar with a useful coefficient, one side only
comx580 compare  0.000000987654321     1E-15    -> 1
comx581 compare  0.000000987654321     1E-14    -> 1
comx582 compare  0.000000987654321     1E-13    -> 1
comx583 compare  0.000000987654321     1E-12    -> 1
comx584 compare  0.000000987654321     1E-11    -> 1
comx585 compare  0.000000987654321     1E-10    -> 1
comx586 compare  0.000000987654321     1E-9     -> 1
708
709
710
711
712
713
714


























715
716
717
comx903 compare -1e+777777777  1e+411111111 -> -1
comx904 compare -1e+777777777 -1e+411111111 -> -1
comx905 compare  1e-777777777  1e-411111111 -> -1
comx906 compare  1e-777777777 -1e-411111111 ->  1
comx907 compare -1e-777777777  1e-411111111 -> -1
comx908 compare -1e-777777777 -1e-411111111 ->  1



























-- Null tests
comx990 compare 10  # -> NaN Invalid_operation
comx991 compare  # 10 -> NaN Invalid_operation







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
comx903 compare -1e+777777777  1e+411111111 -> -1
comx904 compare -1e+777777777 -1e+411111111 -> -1
comx905 compare  1e-777777777  1e-411111111 -> -1
comx906 compare  1e-777777777 -1e-411111111 ->  1
comx907 compare -1e-777777777  1e-411111111 -> -1
comx908 compare -1e-777777777 -1e-411111111 ->  1

-- spread zeros
comx910 compare   0E-383  0       ->  0
comx911 compare   0E-383 -0       ->  0
comx912 compare  -0E-383  0       ->  0
comx913 compare  -0E-383 -0       ->  0
comx914 compare   0E-383  0E+384  ->  0
comx915 compare   0E-383 -0E+384  ->  0
comx916 compare  -0E-383  0E+384  ->  0
comx917 compare  -0E-383 -0E+384  ->  0
comx918 compare   0       0E+384  ->  0
comx919 compare   0      -0E+384  ->  0
comx920 compare  -0       0E+384  ->  0
comx921 compare  -0      -0E+384  ->  0
comx930 compare   0E+384  0       ->  0
comx931 compare   0E+384 -0       ->  0
comx932 compare  -0E+384  0       ->  0
comx933 compare  -0E+384 -0       ->  0
comx934 compare   0E+384  0E-383  ->  0
comx935 compare   0E+384 -0E-383  ->  0
comx936 compare  -0E+384  0E-383  ->  0
comx937 compare  -0E+384 -0E-383  ->  0
comx938 compare   0       0E-383  ->  0
comx939 compare   0      -0E-383  ->  0
comx940 compare  -0       0E-383  ->  0
comx941 compare  -0      -0E-383  ->  0

-- Null tests
comx990 compare 10  # -> NaN Invalid_operation
comx991 compare  # 10 -> NaN Invalid_operation

Changes to test/dectest/comparetotal.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- comparetotal.decTest -- decimal comparison using total ordering    --
-- Copyright (c) IBM Corporation, 1981, 2006.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- Note that we cannot assume add/subtract tests cover paths adequately,
-- here, because the code might be quite different (comparison cannot
-- overflow or underflow, so actual subtractions are not necessary).
-- Similarly, comparetotal will have some radically different paths
-- than compare.



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- comparetotal.decTest -- decimal comparison using total ordering    --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Note that we cannot assume add/subtract tests cover paths adequately,
-- here, because the code might be quite different (comparison cannot
-- overflow or underflow, so actual subtractions are not necessary).
-- Similarly, comparetotal will have some radically different paths
-- than compare.

114
115
116
117
118
119
120








121
122
123
124
125
126
127
maxexponent: 999999999
minexponent: -999999999
cotx090 comparetotal  9.99999999E+999999999 9.99999999E+999999999  -> 0
cotx091 comparetotal -9.99999999E+999999999 9.99999999E+999999999  -> -1
cotx092 comparetotal  9.99999999E+999999999 -9.99999999E+999999999 -> 1
cotx093 comparetotal -9.99999999E+999999999 -9.99999999E+999999999 -> 0









-- some differing length/exponent cases
-- in this first group, compare would compare all equal
cotx100 comparetotal   7.0    7.0    -> 0
cotx101 comparetotal   7.0    7      -> -1
cotx102 comparetotal   7      7.0    -> 1
cotx103 comparetotal   7E+0   7.0    -> 1
cotx104 comparetotal   70E-1  7.0    -> 0







>
>
>
>
>
>
>
>







114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
maxexponent: 999999999
minexponent: -999999999
cotx090 comparetotal  9.99999999E+999999999 9.99999999E+999999999  -> 0
cotx091 comparetotal -9.99999999E+999999999 9.99999999E+999999999  -> -1
cotx092 comparetotal  9.99999999E+999999999 -9.99999999E+999999999 -> 1
cotx093 comparetotal -9.99999999E+999999999 -9.99999999E+999999999 -> 0

-- Examples
cotx094 comparetotal  12.73  127.9  -> -1
cotx095 comparetotal  -127   12     -> -1
cotx096 comparetotal  12.30  12.3   -> -1
cotx097 comparetotal  12.30  12.30  ->  0
cotx098 comparetotal  12.3   12.300 ->  1
cotx099 comparetotal  12.3   NaN    -> -1

-- some differing length/exponent cases
-- in this first group, compare would compare all equal
cotx100 comparetotal   7.0    7.0    -> 0
cotx101 comparetotal   7.0    7      -> -1
cotx102 comparetotal   7      7.0    -> 1
cotx103 comparetotal   7E+0   7.0    -> 1
cotx104 comparetotal   70E-1  7.0    -> 0
754
755
756
757
758
759
760



























761
762
763
cotx1103 comparetotal -1e+777777777  1e+411111111 -> -1
cotx1104 comparetotal -1e+777777777 -1e+411111111 -> -1
cotx1105 comparetotal  1e-777777777  1e-411111111 -> -1
cotx1106 comparetotal  1e-777777777 -1e-411111111 ->  1
cotx1107 comparetotal -1e-777777777  1e-411111111 -> -1
cotx1108 comparetotal -1e-777777777 -1e-411111111 ->  1




























-- Null tests
cotx9990 comparetotal 10  # -> NaN Invalid_operation
cotx9991 comparetotal  # 10 -> NaN Invalid_operation







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
cotx1103 comparetotal -1e+777777777  1e+411111111 -> -1
cotx1104 comparetotal -1e+777777777 -1e+411111111 -> -1
cotx1105 comparetotal  1e-777777777  1e-411111111 -> -1
cotx1106 comparetotal  1e-777777777 -1e-411111111 ->  1
cotx1107 comparetotal -1e-777777777  1e-411111111 -> -1
cotx1108 comparetotal -1e-777777777 -1e-411111111 ->  1

-- spread zeros
cotx1110 comparetotal   0E-383  0       -> -1
cotx1111 comparetotal   0E-383 -0       ->  1
cotx1112 comparetotal  -0E-383  0       -> -1
cotx1113 comparetotal  -0E-383 -0       ->  1
cotx1114 comparetotal   0E-383  0E+384  -> -1
cotx1115 comparetotal   0E-383 -0E+384  ->  1
cotx1116 comparetotal  -0E-383  0E+384  -> -1
cotx1117 comparetotal  -0E-383 -0E+384  ->  1
cotx1118 comparetotal   0       0E+384  -> -1
cotx1119 comparetotal   0      -0E+384  ->  1
cotx1120 comparetotal  -0       0E+384  -> -1
cotx1121 comparetotal  -0      -0E+384  ->  1

cotx1130 comparetotal   0E+384  0       ->  1
cotx1131 comparetotal   0E+384 -0       ->  1
cotx1132 comparetotal  -0E+384  0       -> -1
cotx1133 comparetotal  -0E+384 -0       -> -1
cotx1134 comparetotal   0E+384  0E-383  ->  1
cotx1135 comparetotal   0E+384 -0E-383  ->  1
cotx1136 comparetotal  -0E+384  0E-383  -> -1
cotx1137 comparetotal  -0E+384 -0E-383  -> -1
cotx1138 comparetotal   0       0E-383  ->  1
cotx1139 comparetotal   0      -0E-383  ->  1
cotx1140 comparetotal  -0       0E-383  -> -1
cotx1141 comparetotal  -0      -0E-383  -> -1

-- Null tests
cotx9990 comparetotal 10  # -> NaN Invalid_operation
cotx9991 comparetotal  # 10 -> NaN Invalid_operation

Added test/dectest/comparetotmag.decTest.













































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
------------------------------------------------------------------------
-- comparetotmag.decTest -- decimal comparison, abs. total ordering   --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Note that it cannot be assumed that add/subtract tests cover paths
-- for this operation adequately, here, because the code might be
-- quite different (comparison cannot overflow or underflow, so
-- actual subtractions are not necessary). Similarly, comparetotal
-- will have some radically different paths than compare.

extended:    1
precision:   16
rounding:    half_up
maxExponent: 384
minExponent: -383

-- sanity checks
ctmx001 comparetotmag  -2  -2   ->   0
ctmx002 comparetotmag  -2  -1   ->   1
ctmx003 comparetotmag  -2   0   ->   1
ctmx004 comparetotmag  -2   1   ->   1
ctmx005 comparetotmag  -2   2   ->   0
ctmx006 comparetotmag  -1  -2   ->  -1
ctmx007 comparetotmag  -1  -1   ->   0
ctmx008 comparetotmag  -1   0   ->   1
ctmx009 comparetotmag  -1   1   ->   0
ctmx010 comparetotmag  -1   2   ->  -1
ctmx011 comparetotmag   0  -2   ->  -1
ctmx012 comparetotmag   0  -1   ->  -1
ctmx013 comparetotmag   0   0   ->   0
ctmx014 comparetotmag   0   1   ->  -1
ctmx015 comparetotmag   0   2   ->  -1
ctmx016 comparetotmag   1  -2   ->  -1
ctmx017 comparetotmag   1  -1   ->   0
ctmx018 comparetotmag   1   0   ->   1
ctmx019 comparetotmag   1   1   ->   0
ctmx020 comparetotmag   1   2   ->  -1
ctmx021 comparetotmag   2  -2   ->   0
ctmx022 comparetotmag   2  -1   ->   1
ctmx023 comparetotmag   2   0   ->   1
ctmx025 comparetotmag   2   1   ->   1
ctmx026 comparetotmag   2   2   ->   0

ctmx031 comparetotmag  -20  -20   ->   0
ctmx032 comparetotmag  -20  -10   ->   1
ctmx033 comparetotmag  -20   00   ->   1
ctmx034 comparetotmag  -20   10   ->   1
ctmx035 comparetotmag  -20   20   ->   0
ctmx036 comparetotmag  -10  -20   ->  -1
ctmx037 comparetotmag  -10  -10   ->   0
ctmx038 comparetotmag  -10   00   ->   1
ctmx039 comparetotmag  -10   10   ->   0
ctmx040 comparetotmag  -10   20   ->  -1
ctmx041 comparetotmag   00  -20   ->  -1
ctmx042 comparetotmag   00  -10   ->  -1
ctmx043 comparetotmag   00   00   ->   0
ctmx044 comparetotmag   00   10   ->  -1
ctmx045 comparetotmag   00   20   ->  -1
ctmx046 comparetotmag   10  -20   ->  -1
ctmx047 comparetotmag   10  -10   ->   0
ctmx048 comparetotmag   10   00   ->   1
ctmx049 comparetotmag   10   10   ->   0
ctmx050 comparetotmag   10   20   ->  -1
ctmx051 comparetotmag   20  -20   ->   0
ctmx052 comparetotmag   20  -10   ->   1
ctmx053 comparetotmag   20   00   ->   1
ctmx055 comparetotmag   20   10   ->   1
ctmx056 comparetotmag   20   20   ->   0

ctmx061 comparetotmag  -2.0  -2.0   ->   0
ctmx062 comparetotmag  -2.0  -1.0   ->   1
ctmx063 comparetotmag  -2.0   0.0   ->   1
ctmx064 comparetotmag  -2.0   1.0   ->   1
ctmx065 comparetotmag  -2.0   2.0   ->   0
ctmx066 comparetotmag  -1.0  -2.0   ->  -1
ctmx067 comparetotmag  -1.0  -1.0   ->   0
ctmx068 comparetotmag  -1.0   0.0   ->   1
ctmx069 comparetotmag  -1.0   1.0   ->   0
ctmx070 comparetotmag  -1.0   2.0   ->  -1
ctmx071 comparetotmag   0.0  -2.0   ->  -1
ctmx072 comparetotmag   0.0  -1.0   ->  -1
ctmx073 comparetotmag   0.0   0.0   ->   0
ctmx074 comparetotmag   0.0   1.0   ->  -1
ctmx075 comparetotmag   0.0   2.0   ->  -1
ctmx076 comparetotmag   1.0  -2.0   ->  -1
ctmx077 comparetotmag   1.0  -1.0   ->   0
ctmx078 comparetotmag   1.0   0.0   ->   1
ctmx079 comparetotmag   1.0   1.0   ->   0
ctmx080 comparetotmag   1.0   2.0   ->  -1
ctmx081 comparetotmag   2.0  -2.0   ->   0
ctmx082 comparetotmag   2.0  -1.0   ->   1
ctmx083 comparetotmag   2.0   0.0   ->   1
ctmx085 comparetotmag   2.0   1.0   ->   1
ctmx086 comparetotmag   2.0   2.0   ->   0

-- now some cases which might overflow if subtract were used
maxexponent: 999999999
minexponent: -999999999
ctmx090 comparetotmag  9.99999999E+999999999 9.99999999E+999999999   ->   0
ctmx091 comparetotmag -9.99999999E+999999999 9.99999999E+999999999   ->   0
ctmx092 comparetotmag  9.99999999E+999999999 -9.99999999E+999999999  ->   0
ctmx093 comparetotmag -9.99999999E+999999999 -9.99999999E+999999999  ->   0

-- some differing length/exponent cases
-- in this first group, compare would compare all equal
ctmx100 comparetotmag   7.0    7.0     ->   0
ctmx101 comparetotmag   7.0    7       ->  -1
ctmx102 comparetotmag   7      7.0     ->   1
ctmx103 comparetotmag   7E+0   7.0     ->   1
ctmx104 comparetotmag   70E-1  7.0     ->   0
ctmx105 comparetotmag   0.7E+1 7       ->   0
ctmx106 comparetotmag   70E-1  7       ->  -1
ctmx107 comparetotmag   7.0    7E+0    ->  -1
ctmx108 comparetotmag   7.0    70E-1   ->   0
ctmx109 comparetotmag   7      0.7E+1  ->   0
ctmx110 comparetotmag   7      70E-1   ->   1

ctmx120 comparetotmag   8.0    7.0     ->   1
ctmx121 comparetotmag   8.0    7       ->   1
ctmx122 comparetotmag   8      7.0     ->   1
ctmx123 comparetotmag   8E+0   7.0     ->   1
ctmx124 comparetotmag   80E-1  7.0     ->   1
ctmx125 comparetotmag   0.8E+1 7       ->   1
ctmx126 comparetotmag   80E-1  7       ->   1
ctmx127 comparetotmag   8.0    7E+0    ->   1
ctmx128 comparetotmag   8.0    70E-1   ->   1
ctmx129 comparetotmag   8      0.7E+1   ->   1
ctmx130 comparetotmag   8      70E-1   ->   1

ctmx140 comparetotmag   8.0    9.0     ->  -1
ctmx141 comparetotmag   8.0    9       ->  -1
ctmx142 comparetotmag   8      9.0     ->  -1
ctmx143 comparetotmag   8E+0   9.0     ->  -1
ctmx144 comparetotmag   80E-1  9.0     ->  -1
ctmx145 comparetotmag   0.8E+1 9       ->  -1
ctmx146 comparetotmag   80E-1  9       ->  -1
ctmx147 comparetotmag   8.0    9E+0    ->  -1
ctmx148 comparetotmag   8.0    90E-1   ->  -1
ctmx149 comparetotmag   8      0.9E+1  ->  -1
ctmx150 comparetotmag   8      90E-1   ->  -1

-- and again, with sign changes -+ ..
ctmx200 comparetotmag  -7.0    7.0     ->   0
ctmx201 comparetotmag  -7.0    7       ->  -1
ctmx202 comparetotmag  -7      7.0     ->   1
ctmx203 comparetotmag  -7E+0   7.0     ->   1
ctmx204 comparetotmag  -70E-1  7.0     ->   0
ctmx205 comparetotmag  -0.7E+1 7       ->   0
ctmx206 comparetotmag  -70E-1  7       ->  -1
ctmx207 comparetotmag  -7.0    7E+0    ->  -1
ctmx208 comparetotmag  -7.0    70E-1   ->   0
ctmx209 comparetotmag  -7      0.7E+1  ->   0
ctmx210 comparetotmag  -7      70E-1   ->   1

ctmx220 comparetotmag  -8.0    7.0     ->   1
ctmx221 comparetotmag  -8.0    7       ->   1
ctmx222 comparetotmag  -8      7.0     ->   1
ctmx223 comparetotmag  -8E+0   7.0     ->   1
ctmx224 comparetotmag  -80E-1  7.0     ->   1
ctmx225 comparetotmag  -0.8E+1 7       ->   1
ctmx226 comparetotmag  -80E-1  7       ->   1
ctmx227 comparetotmag  -8.0    7E+0    ->   1
ctmx228 comparetotmag  -8.0    70E-1   ->   1
ctmx229 comparetotmag  -8      0.7E+1  ->   1
ctmx230 comparetotmag  -8      70E-1   ->   1

ctmx240 comparetotmag  -8.0    9.0     ->  -1
ctmx241 comparetotmag  -8.0    9       ->  -1
ctmx242 comparetotmag  -8      9.0     ->  -1
ctmx243 comparetotmag  -8E+0   9.0     ->  -1
ctmx244 comparetotmag  -80E-1  9.0     ->  -1
ctmx245 comparetotmag  -0.8E+1 9       ->  -1
ctmx246 comparetotmag  -80E-1  9       ->  -1
ctmx247 comparetotmag  -8.0    9E+0    ->  -1
ctmx248 comparetotmag  -8.0    90E-1   ->  -1
ctmx249 comparetotmag  -8      0.9E+1  ->  -1
ctmx250 comparetotmag  -8      90E-1   ->  -1

-- and again, with sign changes +- ..
ctmx300 comparetotmag   7.0    -7.0     ->   0
ctmx301 comparetotmag   7.0    -7       ->  -1
ctmx302 comparetotmag   7      -7.0     ->   1
ctmx303 comparetotmag   7E+0   -7.0     ->   1
ctmx304 comparetotmag   70E-1  -7.0     ->   0
ctmx305 comparetotmag   .7E+1  -7       ->   0
ctmx306 comparetotmag   70E-1  -7       ->  -1
ctmx307 comparetotmag   7.0    -7E+0    ->  -1
ctmx308 comparetotmag   7.0    -70E-1   ->   0
ctmx309 comparetotmag   7      -.7E+1   ->   0
ctmx310 comparetotmag   7      -70E-1   ->   1

ctmx320 comparetotmag   8.0    -7.0     ->   1
ctmx321 comparetotmag   8.0    -7       ->   1
ctmx322 comparetotmag   8      -7.0     ->   1
ctmx323 comparetotmag   8E+0   -7.0     ->   1
ctmx324 comparetotmag   80E-1  -7.0     ->   1
ctmx325 comparetotmag   .8E+1  -7       ->   1
ctmx326 comparetotmag   80E-1  -7       ->   1
ctmx327 comparetotmag   8.0    -7E+0    ->   1
ctmx328 comparetotmag   8.0    -70E-1   ->   1
ctmx329 comparetotmag   8      -.7E+1   ->   1
ctmx330 comparetotmag   8      -70E-1   ->   1

ctmx340 comparetotmag   8.0    -9.0     ->  -1
ctmx341 comparetotmag   8.0    -9       ->  -1
ctmx342 comparetotmag   8      -9.0     ->  -1
ctmx343 comparetotmag   8E+0   -9.0     ->  -1
ctmx344 comparetotmag   80E-1  -9.0     ->  -1
ctmx345 comparetotmag   .8E+1  -9       ->  -1
ctmx346 comparetotmag   80E-1  -9       ->  -1
ctmx347 comparetotmag   8.0    -9E+0    ->  -1
ctmx348 comparetotmag   8.0    -90E-1   ->  -1
ctmx349 comparetotmag   8      -.9E+1   ->  -1
ctmx350 comparetotmag   8      -90E-1   ->  -1

-- and again, with sign changes -- ..
ctmx400 comparetotmag   -7.0    -7.0     ->   0
ctmx401 comparetotmag   -7.0    -7       ->  -1
ctmx402 comparetotmag   -7      -7.0     ->   1
ctmx403 comparetotmag   -7E+0   -7.0     ->   1
ctmx404 comparetotmag   -70E-1  -7.0     ->   0
ctmx405 comparetotmag   -.7E+1  -7       ->   0
ctmx406 comparetotmag   -70E-1  -7       ->  -1
ctmx407 comparetotmag   -7.0    -7E+0    ->  -1
ctmx408 comparetotmag   -7.0    -70E-1   ->   0
ctmx409 comparetotmag   -7      -.7E+1   ->   0
ctmx410 comparetotmag   -7      -70E-1   ->   1

ctmx420 comparetotmag   -8.0    -7.0     ->   1
ctmx421 comparetotmag   -8.0    -7       ->   1
ctmx422 comparetotmag   -8      -7.0     ->   1
ctmx423 comparetotmag   -8E+0   -7.0     ->   1
ctmx424 comparetotmag   -80E-1  -7.0     ->   1
ctmx425 comparetotmag   -.8E+1  -7       ->   1
ctmx426 comparetotmag   -80E-1  -7       ->   1
ctmx427 comparetotmag   -8.0    -7E+0    ->   1
ctmx428 comparetotmag   -8.0    -70E-1   ->   1
ctmx429 comparetotmag   -8      -.7E+1   ->   1
ctmx430 comparetotmag   -8      -70E-1   ->   1

ctmx440 comparetotmag   -8.0    -9.0     ->  -1
ctmx441 comparetotmag   -8.0    -9       ->  -1
ctmx442 comparetotmag   -8      -9.0     ->  -1
ctmx443 comparetotmag   -8E+0   -9.0     ->  -1
ctmx444 comparetotmag   -80E-1  -9.0     ->  -1
ctmx445 comparetotmag   -.8E+1  -9       ->  -1
ctmx446 comparetotmag   -80E-1  -9       ->  -1
ctmx447 comparetotmag   -8.0    -9E+0    ->  -1
ctmx448 comparetotmag   -8.0    -90E-1   ->  -1
ctmx449 comparetotmag   -8      -.9E+1   ->  -1
ctmx450 comparetotmag   -8      -90E-1   ->  -1


-- testcases that subtract to lots of zeros at boundaries [pgr]
precision: 40
ctmx470 comparetotmag 123.4560000000000000E789 123.456E789  ->  -1
ctmx471 comparetotmag 123.456000000000000E-89 123.456E-89  ->  -1
ctmx472 comparetotmag 123.45600000000000E789 123.456E789  ->  -1
ctmx473 comparetotmag 123.4560000000000E-89 123.456E-89  ->  -1
ctmx474 comparetotmag 123.456000000000E789 123.456E789  ->  -1
ctmx475 comparetotmag 123.45600000000E-89 123.456E-89  ->  -1
ctmx476 comparetotmag 123.4560000000E789 123.456E789  ->  -1
ctmx477 comparetotmag 123.456000000E-89 123.456E-89  ->  -1
ctmx478 comparetotmag 123.45600000E789 123.456E789  ->  -1
ctmx479 comparetotmag 123.4560000E-89 123.456E-89  ->  -1
ctmx480 comparetotmag 123.456000E789 123.456E789  ->  -1
ctmx481 comparetotmag 123.45600E-89 123.456E-89  ->  -1
ctmx482 comparetotmag 123.4560E789 123.456E789  ->  -1
ctmx483 comparetotmag 123.456E-89 123.456E-89  ->   0
ctmx484 comparetotmag 123.456E-89 123.4560000000000000E-89  ->   1
ctmx485 comparetotmag 123.456E789 123.456000000000000E789  ->   1
ctmx486 comparetotmag 123.456E-89 123.45600000000000E-89  ->   1
ctmx487 comparetotmag 123.456E789 123.4560000000000E789  ->   1
ctmx488 comparetotmag 123.456E-89 123.456000000000E-89  ->   1
ctmx489 comparetotmag 123.456E789 123.45600000000E789  ->   1
ctmx490 comparetotmag 123.456E-89 123.4560000000E-89  ->   1
ctmx491 comparetotmag 123.456E789 123.456000000E789  ->   1
ctmx492 comparetotmag 123.456E-89 123.45600000E-89  ->   1
ctmx493 comparetotmag 123.456E789 123.4560000E789  ->   1
ctmx494 comparetotmag 123.456E-89 123.456000E-89  ->   1
ctmx495 comparetotmag 123.456E789 123.45600E789  ->   1
ctmx496 comparetotmag 123.456E-89 123.4560E-89  ->   1
ctmx497 comparetotmag 123.456E789 123.456E789  ->   0

-- wide-ranging, around precision; signs equal
precision: 9
ctmx500 comparetotmag    1     1E-15     ->   1
ctmx501 comparetotmag    1     1E-14     ->   1
ctmx502 comparetotmag    1     1E-13     ->   1
ctmx503 comparetotmag    1     1E-12     ->   1
ctmx504 comparetotmag    1     1E-11     ->   1
ctmx505 comparetotmag    1     1E-10     ->   1
ctmx506 comparetotmag    1     1E-9      ->   1
ctmx507 comparetotmag    1     1E-8      ->   1
ctmx508 comparetotmag    1     1E-7      ->   1
ctmx509 comparetotmag    1     1E-6      ->   1
ctmx510 comparetotmag    1     1E-5      ->   1
ctmx511 comparetotmag    1     1E-4      ->   1
ctmx512 comparetotmag    1     1E-3      ->   1
ctmx513 comparetotmag    1     1E-2      ->   1
ctmx514 comparetotmag    1     1E-1      ->   1
ctmx515 comparetotmag    1     1E-0      ->   0
ctmx516 comparetotmag    1     1E+1      ->  -1
ctmx517 comparetotmag    1     1E+2      ->  -1
ctmx518 comparetotmag    1     1E+3      ->  -1
ctmx519 comparetotmag    1     1E+4      ->  -1
ctmx521 comparetotmag    1     1E+5      ->  -1
ctmx522 comparetotmag    1     1E+6      ->  -1
ctmx523 comparetotmag    1     1E+7      ->  -1
ctmx524 comparetotmag    1     1E+8      ->  -1
ctmx525 comparetotmag    1     1E+9      ->  -1
ctmx526 comparetotmag    1     1E+10     ->  -1
ctmx527 comparetotmag    1     1E+11     ->  -1
ctmx528 comparetotmag    1     1E+12     ->  -1
ctmx529 comparetotmag    1     1E+13     ->  -1
ctmx530 comparetotmag    1     1E+14     ->  -1
ctmx531 comparetotmag    1     1E+15     ->  -1
-- LR swap
ctmx540 comparetotmag    1E-15  1        ->  -1
ctmx541 comparetotmag    1E-14  1        ->  -1
ctmx542 comparetotmag    1E-13  1        ->  -1
ctmx543 comparetotmag    1E-12  1        ->  -1
ctmx544 comparetotmag    1E-11  1        ->  -1
ctmx545 comparetotmag    1E-10  1        ->  -1
ctmx546 comparetotmag    1E-9   1        ->  -1
ctmx547 comparetotmag    1E-8   1        ->  -1
ctmx548 comparetotmag    1E-7   1        ->  -1
ctmx549 comparetotmag    1E-6   1        ->  -1
ctmx550 comparetotmag    1E-5   1        ->  -1
ctmx551 comparetotmag    1E-4   1        ->  -1
ctmx552 comparetotmag    1E-3   1        ->  -1
ctmx553 comparetotmag    1E-2   1        ->  -1
ctmx554 comparetotmag    1E-1   1        ->  -1
ctmx555 comparetotmag    1E-0   1        ->   0
ctmx556 comparetotmag    1E+1   1        ->   1
ctmx557 comparetotmag    1E+2   1        ->   1
ctmx558 comparetotmag    1E+3   1        ->   1
ctmx559 comparetotmag    1E+4   1        ->   1
ctmx561 comparetotmag    1E+5   1        ->   1
ctmx562 comparetotmag    1E+6   1        ->   1
ctmx563 comparetotmag    1E+7   1        ->   1
ctmx564 comparetotmag    1E+8   1        ->   1
ctmx565 comparetotmag    1E+9   1        ->   1
ctmx566 comparetotmag    1E+10  1        ->   1
ctmx567 comparetotmag    1E+11  1        ->   1
ctmx568 comparetotmag    1E+12  1        ->   1
ctmx569 comparetotmag    1E+13  1        ->   1
ctmx570 comparetotmag    1E+14  1        ->   1
ctmx571 comparetotmag    1E+15  1        ->   1
-- similar with an useful coefficient, one side only
ctmx580 comparetotmag  0.000000987654321     1E-15     ->   1
ctmx581 comparetotmag  0.000000987654321     1E-14     ->   1
ctmx582 comparetotmag  0.000000987654321     1E-13     ->   1
ctmx583 comparetotmag  0.000000987654321     1E-12     ->   1
ctmx584 comparetotmag  0.000000987654321     1E-11     ->   1
ctmx585 comparetotmag  0.000000987654321     1E-10     ->   1
ctmx586 comparetotmag  0.000000987654321     1E-9      ->   1
ctmx587 comparetotmag  0.000000987654321     1E-8      ->   1
ctmx588 comparetotmag  0.000000987654321     1E-7      ->   1
ctmx589 comparetotmag  0.000000987654321     1E-6      ->  -1
ctmx590 comparetotmag  0.000000987654321     1E-5      ->  -1
ctmx591 comparetotmag  0.000000987654321     1E-4      ->  -1
ctmx592 comparetotmag  0.000000987654321     1E-3      ->  -1
ctmx593 comparetotmag  0.000000987654321     1E-2      ->  -1
ctmx594 comparetotmag  0.000000987654321     1E-1      ->  -1
ctmx595 comparetotmag  0.000000987654321     1E-0      ->  -1
ctmx596 comparetotmag  0.000000987654321     1E+1      ->  -1
ctmx597 comparetotmag  0.000000987654321     1E+2      ->  -1
ctmx598 comparetotmag  0.000000987654321     1E+3      ->  -1
ctmx599 comparetotmag  0.000000987654321     1E+4      ->  -1

-- check some unit-y traps
precision: 20
ctmx600 comparetotmag   12            12.2345  ->  -1
ctmx601 comparetotmag   12.0          12.2345  ->  -1
ctmx602 comparetotmag   12.00         12.2345  ->  -1
ctmx603 comparetotmag   12.000        12.2345  ->  -1
ctmx604 comparetotmag   12.0000       12.2345  ->  -1
ctmx605 comparetotmag   12.00000      12.2345  ->  -1
ctmx606 comparetotmag   12.000000     12.2345  ->  -1
ctmx607 comparetotmag   12.0000000    12.2345  ->  -1
ctmx608 comparetotmag   12.00000000   12.2345  ->  -1
ctmx609 comparetotmag   12.000000000  12.2345  ->  -1
ctmx610 comparetotmag   12.1234 12             ->   1
ctmx611 comparetotmag   12.1234 12.0           ->   1
ctmx612 comparetotmag   12.1234 12.00          ->   1
ctmx613 comparetotmag   12.1234 12.000         ->   1
ctmx614 comparetotmag   12.1234 12.0000        ->   1
ctmx615 comparetotmag   12.1234 12.00000       ->   1
ctmx616 comparetotmag   12.1234 12.000000      ->   1
ctmx617 comparetotmag   12.1234 12.0000000     ->   1
ctmx618 comparetotmag   12.1234 12.00000000    ->   1
ctmx619 comparetotmag   12.1234 12.000000000   ->   1
ctmx620 comparetotmag  -12           -12.2345  ->  -1
ctmx621 comparetotmag  -12.0         -12.2345  ->  -1
ctmx622 comparetotmag  -12.00        -12.2345  ->  -1
ctmx623 comparetotmag  -12.000       -12.2345  ->  -1
ctmx624 comparetotmag  -12.0000      -12.2345  ->  -1
ctmx625 comparetotmag  -12.00000     -12.2345  ->  -1
ctmx626 comparetotmag  -12.000000    -12.2345  ->  -1
ctmx627 comparetotmag  -12.0000000   -12.2345  ->  -1
ctmx628 comparetotmag  -12.00000000  -12.2345  ->  -1
ctmx629 comparetotmag  -12.000000000 -12.2345  ->  -1
ctmx630 comparetotmag  -12.1234 -12            ->   1
ctmx631 comparetotmag  -12.1234 -12.0          ->   1
ctmx632 comparetotmag  -12.1234 -12.00         ->   1
ctmx633 comparetotmag  -12.1234 -12.000        ->   1
ctmx634 comparetotmag  -12.1234 -12.0000       ->   1
ctmx635 comparetotmag  -12.1234 -12.00000      ->   1
ctmx636 comparetotmag  -12.1234 -12.000000     ->   1
ctmx637 comparetotmag  -12.1234 -12.0000000    ->   1
ctmx638 comparetotmag  -12.1234 -12.00000000   ->   1
ctmx639 comparetotmag  -12.1234 -12.000000000  ->   1
precision: 9

-- extended zeros
ctmx640 comparetotmag   0     0    ->   0
ctmx641 comparetotmag   0    -0    ->   0
ctmx642 comparetotmag   0    -0.0  ->   1
ctmx643 comparetotmag   0     0.0  ->   1
ctmx644 comparetotmag  -0     0    ->   0
ctmx645 comparetotmag  -0    -0    ->   0
ctmx646 comparetotmag  -0    -0.0  ->   1
ctmx647 comparetotmag  -0     0.0  ->   1
ctmx648 comparetotmag   0.0   0    ->  -1
ctmx649 comparetotmag   0.0  -0    ->  -1
ctmx650 comparetotmag   0.0  -0.0  ->   0
ctmx651 comparetotmag   0.0   0.0  ->   0
ctmx652 comparetotmag  -0.0   0    ->  -1
ctmx653 comparetotmag  -0.0  -0    ->  -1
ctmx654 comparetotmag  -0.0  -0.0  ->   0
ctmx655 comparetotmag  -0.0   0.0  ->   0

ctmx656 comparetotmag  -0E1   0.0  ->   1
ctmx657 comparetotmag  -0E2   0.0  ->   1
ctmx658 comparetotmag   0E1   0.0  ->   1
ctmx659 comparetotmag   0E2   0.0  ->   1
ctmx660 comparetotmag  -0E1   0    ->   1
ctmx661 comparetotmag  -0E2   0    ->   1
ctmx662 comparetotmag   0E1   0    ->   1
ctmx663 comparetotmag   0E2   0    ->   1
ctmx664 comparetotmag  -0E1  -0E1  ->   0
ctmx665 comparetotmag  -0E2  -0E1  ->   1
ctmx666 comparetotmag   0E1  -0E1  ->   0
ctmx667 comparetotmag   0E2  -0E1  ->   1
ctmx668 comparetotmag  -0E1  -0E2  ->  -1
ctmx669 comparetotmag  -0E2  -0E2  ->   0
ctmx670 comparetotmag   0E1  -0E2  ->  -1
ctmx671 comparetotmag   0E2  -0E2  ->   0
ctmx672 comparetotmag  -0E1   0E1  ->   0
ctmx673 comparetotmag  -0E2   0E1  ->   1
ctmx674 comparetotmag   0E1   0E1  ->   0
ctmx675 comparetotmag   0E2   0E1  ->   1
ctmx676 comparetotmag  -0E1   0E2  ->  -1
ctmx677 comparetotmag  -0E2   0E2  ->   0
ctmx678 comparetotmag   0E1   0E2  ->  -1
ctmx679 comparetotmag   0E2   0E2  ->   0

-- trailing zeros; unit-y
precision: 20
ctmx680 comparetotmag   12    12            ->   0
ctmx681 comparetotmag   12    12.0          ->   1
ctmx682 comparetotmag   12    12.00         ->   1
ctmx683 comparetotmag   12    12.000        ->   1
ctmx684 comparetotmag   12    12.0000       ->   1
ctmx685 comparetotmag   12    12.00000      ->   1
ctmx686 comparetotmag   12    12.000000     ->   1
ctmx687 comparetotmag   12    12.0000000    ->   1
ctmx688 comparetotmag   12    12.00000000   ->   1
ctmx689 comparetotmag   12    12.000000000  ->   1
ctmx690 comparetotmag   12              12  ->   0
ctmx691 comparetotmag   12.0            12  ->  -1
ctmx692 comparetotmag   12.00           12  ->  -1
ctmx693 comparetotmag   12.000          12  ->  -1
ctmx694 comparetotmag   12.0000         12  ->  -1
ctmx695 comparetotmag   12.00000        12  ->  -1
ctmx696 comparetotmag   12.000000       12  ->  -1
ctmx697 comparetotmag   12.0000000      12  ->  -1
ctmx698 comparetotmag   12.00000000     12  ->  -1
ctmx699 comparetotmag   12.000000000    12  ->  -1

-- long operand checks
maxexponent: 999
minexponent: -999
precision: 9
ctmx701 comparetotmag 12345678000  1  ->   1
ctmx702 comparetotmag 1 12345678000   ->  -1
ctmx703 comparetotmag 1234567800   1  ->   1
ctmx704 comparetotmag 1 1234567800    ->  -1
ctmx705 comparetotmag 1234567890   1  ->   1
ctmx706 comparetotmag 1 1234567890    ->  -1
ctmx707 comparetotmag 1234567891   1  ->   1
ctmx708 comparetotmag 1 1234567891    ->  -1
ctmx709 comparetotmag 12345678901  1  ->   1
ctmx710 comparetotmag 1 12345678901   ->  -1
ctmx711 comparetotmag 1234567896   1  ->   1
ctmx712 comparetotmag 1 1234567896    ->  -1
ctmx713 comparetotmag -1234567891  1  ->   1
ctmx714 comparetotmag 1 -1234567891   ->  -1
ctmx715 comparetotmag -12345678901 1  ->   1
ctmx716 comparetotmag 1 -12345678901  ->  -1
ctmx717 comparetotmag -1234567896  1  ->   1
ctmx718 comparetotmag 1 -1234567896   ->  -1

precision: 15
-- same with plenty of precision
ctmx721 comparetotmag 12345678000 1  ->   1
ctmx722 comparetotmag 1 12345678000  ->  -1
ctmx723 comparetotmag 1234567800  1  ->   1
ctmx724 comparetotmag 1 1234567800   ->  -1
ctmx725 comparetotmag 1234567890  1  ->   1
ctmx726 comparetotmag 1 1234567890   ->  -1
ctmx727 comparetotmag 1234567891  1  ->   1
ctmx728 comparetotmag 1 1234567891   ->  -1
ctmx729 comparetotmag 12345678901 1  ->   1
ctmx730 comparetotmag 1 12345678901  ->  -1
ctmx731 comparetotmag 1234567896  1  ->   1
ctmx732 comparetotmag 1 1234567896   ->  -1

-- residue cases
precision: 5
ctmx740 comparetotmag  1  0.9999999   ->   1
ctmx741 comparetotmag  1  0.999999    ->   1
ctmx742 comparetotmag  1  0.99999     ->   1
ctmx743 comparetotmag  1  1.0000      ->   1
ctmx744 comparetotmag  1  1.00001     ->  -1
ctmx745 comparetotmag  1  1.000001    ->  -1
ctmx746 comparetotmag  1  1.0000001   ->  -1
ctmx750 comparetotmag  0.9999999  1   ->  -1
ctmx751 comparetotmag  0.999999   1   ->  -1
ctmx752 comparetotmag  0.99999    1   ->  -1
ctmx753 comparetotmag  1.0000     1   ->  -1
ctmx754 comparetotmag  1.00001    1   ->   1
ctmx755 comparetotmag  1.000001   1   ->   1
ctmx756 comparetotmag  1.0000001  1   ->   1

-- a selection of longies
ctmx760 comparetotmag -36852134.84194296250843579428931 -5830629.8347085025808756560357940  ->   1
ctmx761 comparetotmag -36852134.84194296250843579428931 -36852134.84194296250843579428931   ->   0
ctmx762 comparetotmag -36852134.94194296250843579428931 -36852134.84194296250843579428931   ->   1
ctmx763 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931   ->  -1
-- precisions above or below the difference should have no effect
precision:   11
ctmx764 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931   ->  -1
precision:   10
ctmx765 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931   ->  -1
precision:    9
ctmx766 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931   ->  -1
precision:    8
ctmx767 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931   ->  -1
precision:    7
ctmx768 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931   ->  -1
precision:    6
ctmx769 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931   ->  -1
precision:    5
ctmx770 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931   ->  -1
precision:    4
ctmx771 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931   ->  -1
precision:    3
ctmx772 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931   ->  -1
precision:    2
ctmx773 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931   ->  -1
precision:    1
ctmx774 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931   ->  -1

-- Specials
precision:   9
ctmx780 comparetotmag  Inf  -Inf   ->  0
ctmx781 comparetotmag  Inf  -1000  ->  1
ctmx782 comparetotmag  Inf  -1     ->  1
ctmx783 comparetotmag  Inf  -0     ->  1
ctmx784 comparetotmag  Inf   0     ->  1
ctmx785 comparetotmag  Inf   1     ->  1
ctmx786 comparetotmag  Inf   1000  ->  1
ctmx787 comparetotmag  Inf   Inf   ->  0
ctmx788 comparetotmag -1000  Inf   -> -1
ctmx789 comparetotmag -Inf   Inf   ->  0
ctmx790 comparetotmag -1     Inf   -> -1
ctmx791 comparetotmag -0     Inf   -> -1
ctmx792 comparetotmag  0     Inf   -> -1
ctmx793 comparetotmag  1     Inf   -> -1
ctmx794 comparetotmag  1000  Inf   -> -1
ctmx795 comparetotmag  Inf   Inf   ->  0

ctmx800 comparetotmag -Inf  -Inf   ->  0
ctmx801 comparetotmag -Inf  -1000  ->  1
ctmx802 comparetotmag -Inf  -1     ->  1
ctmx803 comparetotmag -Inf  -0     ->  1
ctmx804 comparetotmag -Inf   0     ->  1
ctmx805 comparetotmag -Inf   1     ->  1
ctmx806 comparetotmag -Inf   1000  ->  1
ctmx807 comparetotmag -Inf   Inf   ->  0
ctmx808 comparetotmag -Inf  -Inf   ->  0
ctmx809 comparetotmag -1000 -Inf   -> -1
ctmx810 comparetotmag -1    -Inf   -> -1
ctmx811 comparetotmag -0    -Inf   -> -1
ctmx812 comparetotmag  0    -Inf   -> -1
ctmx813 comparetotmag  1    -Inf   -> -1
ctmx814 comparetotmag  1000 -Inf   -> -1
ctmx815 comparetotmag  Inf  -Inf   ->  0

ctmx821 comparetotmag  NaN -Inf    ->  1
ctmx822 comparetotmag  NaN -1000   ->  1
ctmx823 comparetotmag  NaN -1      ->  1
ctmx824 comparetotmag  NaN -0      ->  1
ctmx825 comparetotmag  NaN  0      ->  1
ctmx826 comparetotmag  NaN  1      ->  1
ctmx827 comparetotmag  NaN  1000   ->  1
ctmx828 comparetotmag  NaN  Inf    ->  1
ctmx829 comparetotmag  NaN  NaN    ->  0
ctmx830 comparetotmag -Inf  NaN    ->  -1
ctmx831 comparetotmag -1000 NaN    ->  -1
ctmx832 comparetotmag -1    NaN    ->  -1
ctmx833 comparetotmag -0    NaN    ->  -1
ctmx834 comparetotmag  0    NaN    ->  -1
ctmx835 comparetotmag  1    NaN    ->  -1
ctmx836 comparetotmag  1000 NaN    ->  -1
ctmx837 comparetotmag  Inf  NaN    ->  -1
ctmx838 comparetotmag -NaN -NaN    ->  0
ctmx839 comparetotmag +NaN -NaN    ->  0
ctmx840 comparetotmag -NaN +NaN    ->  0

ctmx841 comparetotmag  sNaN -sNaN  ->  0
ctmx842 comparetotmag  sNaN -NaN   ->  -1
ctmx843 comparetotmag  sNaN -Inf   ->  1
ctmx844 comparetotmag  sNaN -1000  ->  1
ctmx845 comparetotmag  sNaN -1     ->  1
ctmx846 comparetotmag  sNaN -0     ->  1
ctmx847 comparetotmag  sNaN  0     ->  1
ctmx848 comparetotmag  sNaN  1     ->  1
ctmx849 comparetotmag  sNaN  1000  ->  1
ctmx850 comparetotmag  sNaN  NaN   ->  -1
ctmx851 comparetotmag  sNaN sNaN   ->  0

ctmx852 comparetotmag -sNaN sNaN   ->  0
ctmx853 comparetotmag -NaN  sNaN   ->  1
ctmx854 comparetotmag -Inf  sNaN   ->  -1
ctmx855 comparetotmag -1000 sNaN   ->  -1
ctmx856 comparetotmag -1    sNaN   ->  -1
ctmx857 comparetotmag -0    sNaN   ->  -1
ctmx858 comparetotmag  0    sNaN   ->  -1
ctmx859 comparetotmag  1    sNaN   ->  -1
ctmx860 comparetotmag  1000 sNaN   ->  -1
ctmx861 comparetotmag  Inf  sNaN   ->  -1
ctmx862 comparetotmag  NaN  sNaN   ->  1
ctmx863 comparetotmag  sNaN sNaN   ->  0

ctmx871 comparetotmag  -sNaN -sNaN  ->  0
ctmx872 comparetotmag  -sNaN -NaN   ->  -1
ctmx873 comparetotmag  -sNaN -Inf   ->  1
ctmx874 comparetotmag  -sNaN -1000  ->  1
ctmx875 comparetotmag  -sNaN -1     ->  1
ctmx876 comparetotmag  -sNaN -0     ->  1
ctmx877 comparetotmag  -sNaN  0     ->  1
ctmx878 comparetotmag  -sNaN  1     ->  1
ctmx879 comparetotmag  -sNaN  1000  ->  1
ctmx880 comparetotmag  -sNaN  NaN   ->  -1
ctmx881 comparetotmag  -sNaN sNaN   ->  0

ctmx882 comparetotmag -sNaN -sNaN   ->  0
ctmx883 comparetotmag -NaN  -sNaN   ->  1
ctmx884 comparetotmag -Inf  -sNaN   ->  -1
ctmx885 comparetotmag -1000 -sNaN   ->  -1
ctmx886 comparetotmag -1    -sNaN   ->  -1
ctmx887 comparetotmag -0    -sNaN   ->  -1
ctmx888 comparetotmag  0    -sNaN   ->  -1
ctmx889 comparetotmag  1    -sNaN   ->  -1
ctmx890 comparetotmag  1000 -sNaN   ->  -1
ctmx891 comparetotmag  Inf  -sNaN   ->  -1
ctmx892 comparetotmag  NaN  -sNaN   ->  1
ctmx893 comparetotmag  sNaN -sNaN   ->  0

-- NaNs with payload
ctmx960 comparetotmag  NaN9 -Inf   ->  1
ctmx961 comparetotmag  NaN8  999   ->  1
ctmx962 comparetotmag  NaN77 Inf   ->  1
ctmx963 comparetotmag -NaN67 NaN5  ->  1
ctmx964 comparetotmag -Inf  -NaN4  ->  -1
ctmx965 comparetotmag -999  -NaN33 ->  -1
ctmx966 comparetotmag  Inf   NaN2  ->  -1

ctmx970 comparetotmag -NaN41 -NaN42 -> -1
ctmx971 comparetotmag +NaN41 -NaN42 -> -1
ctmx972 comparetotmag -NaN41 +NaN42 -> -1
ctmx973 comparetotmag +NaN41 +NaN42 -> -1
ctmx974 comparetotmag -NaN42 -NaN01 ->  1
ctmx975 comparetotmag +NaN42 -NaN01 ->  1
ctmx976 comparetotmag -NaN42 +NaN01 ->  1
ctmx977 comparetotmag +NaN42 +NaN01 ->  1

ctmx980 comparetotmag -sNaN771 -sNaN772 -> -1
ctmx981 comparetotmag +sNaN771 -sNaN772 -> -1
ctmx982 comparetotmag -sNaN771 +sNaN772 -> -1
ctmx983 comparetotmag +sNaN771 +sNaN772 -> -1
ctmx984 comparetotmag -sNaN772 -sNaN771 ->  1
ctmx985 comparetotmag +sNaN772 -sNaN771 ->  1
ctmx986 comparetotmag -sNaN772 +sNaN771 ->  1
ctmx987 comparetotmag +sNaN772 +sNaN771 ->  1

ctmx991 comparetotmag -sNaN99 -Inf    ->  1
ctmx992 comparetotmag  sNaN98 -11     ->  1
ctmx993 comparetotmag  sNaN97  NaN    -> -1
ctmx994 comparetotmag  sNaN16 sNaN94  -> -1
ctmx995 comparetotmag  NaN85  sNaN83  ->  1
ctmx996 comparetotmag -Inf    sNaN92  -> -1
ctmx997 comparetotmag  088    sNaN81  -> -1
ctmx998 comparetotmag  Inf    sNaN90  -> -1
ctmx999 comparetotmag  NaN   -sNaN89  ->  1

-- overflow and underflow tests .. subnormal results now allowed
maxExponent: 999999999
minexponent: -999999999
ctmx1080 comparetotmag +1.23456789012345E-0 9E+999999999  ->  -1
ctmx1081 comparetotmag 9E+999999999 +1.23456789012345E-0  ->   1
ctmx1082 comparetotmag +0.100 9E-999999999                ->   1
ctmx1083 comparetotmag 9E-999999999 +0.100                ->  -1
ctmx1085 comparetotmag -1.23456789012345E-0 9E+999999999  ->  -1
ctmx1086 comparetotmag 9E+999999999 -1.23456789012345E-0  ->   1
ctmx1087 comparetotmag -0.100 9E-999999999                ->   1
ctmx1088 comparetotmag 9E-999999999 -0.100                ->  -1

ctmx1089 comparetotmag 1e-599999999 1e-400000001    ->  -1
ctmx1090 comparetotmag 1e-599999999 1e-400000000    ->  -1
ctmx1091 comparetotmag 1e-600000000 1e-400000000    ->  -1
ctmx1092 comparetotmag 9e-999999998 0.01            ->  -1
ctmx1093 comparetotmag 9e-999999998 0.1             ->  -1
ctmx1094 comparetotmag 0.01 9e-999999998            ->   1
ctmx1095 comparetotmag 1e599999999 1e400000001      ->   1
ctmx1096 comparetotmag 1e599999999 1e400000000      ->   1
ctmx1097 comparetotmag 1e600000000 1e400000000      ->   1
ctmx1098 comparetotmag 9e999999998 100              ->   1
ctmx1099 comparetotmag 9e999999998 10               ->   1
ctmx1100 comparetotmag 100  9e999999998             ->  -1
-- signs
ctmx1101 comparetotmag  1e+777777777  1e+411111111  ->   1
ctmx1102 comparetotmag  1e+777777777 -1e+411111111  ->   1
ctmx1103 comparetotmag -1e+777777777  1e+411111111  ->   1
ctmx1104 comparetotmag -1e+777777777 -1e+411111111  ->   1
ctmx1105 comparetotmag  1e-777777777  1e-411111111  ->  -1
ctmx1106 comparetotmag  1e-777777777 -1e-411111111  ->  -1
ctmx1107 comparetotmag -1e-777777777  1e-411111111  ->  -1
ctmx1108 comparetotmag -1e-777777777 -1e-411111111  ->  -1

-- spread zeros
ctmx1110 comparetotmag   0E-383  0        ->  -1
ctmx1111 comparetotmag   0E-383 -0        ->  -1
ctmx1112 comparetotmag  -0E-383  0        ->  -1
ctmx1113 comparetotmag  -0E-383 -0        ->  -1
ctmx1114 comparetotmag   0E-383  0E+384   ->  -1
ctmx1115 comparetotmag   0E-383 -0E+384   ->  -1
ctmx1116 comparetotmag  -0E-383  0E+384   ->  -1
ctmx1117 comparetotmag  -0E-383 -0E+384   ->  -1
ctmx1118 comparetotmag   0       0E+384   ->  -1
ctmx1119 comparetotmag   0      -0E+384   ->  -1
ctmx1120 comparetotmag  -0       0E+384   ->  -1
ctmx1121 comparetotmag  -0      -0E+384   ->  -1

ctmx1130 comparetotmag   0E+384  0        ->   1
ctmx1131 comparetotmag   0E+384 -0        ->   1
ctmx1132 comparetotmag  -0E+384  0        ->   1
ctmx1133 comparetotmag  -0E+384 -0        ->   1
ctmx1134 comparetotmag   0E+384  0E-383   ->   1
ctmx1135 comparetotmag   0E+384 -0E-383   ->   1
ctmx1136 comparetotmag  -0E+384  0E-383   ->   1
ctmx1137 comparetotmag  -0E+384 -0E-383   ->   1
ctmx1138 comparetotmag   0       0E-383   ->   1
ctmx1139 comparetotmag   0      -0E-383   ->   1
ctmx1140 comparetotmag  -0       0E-383   ->   1
ctmx1141 comparetotmag  -0      -0E-383   ->   1

-- Null tests
ctmx9990 comparetotmag 10  # -> NaN Invalid_operation
ctmx9991 comparetotmag  # 10 -> NaN Invalid_operation

Added test/dectest/copy.decTest.













































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
------------------------------------------------------------------------
-- copy.decTest -- quiet copy                                         --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

-- Sanity check
cpyx001 copy       +7.50  -> 7.50

-- Infinities
cpyx011 copy  Infinity    -> Infinity
cpyx012 copy  -Infinity   -> -Infinity

-- NaNs, 0 payload
cpyx021 copy         NaN  -> NaN
cpyx022 copy        -NaN  -> -NaN
cpyx023 copy        sNaN  -> sNaN
cpyx024 copy       -sNaN  -> -sNaN

-- NaNs, non-0 payload
cpyx031 copy       NaN10  -> NaN10
cpyx032 copy      -NaN10  -> -NaN10
cpyx033 copy      sNaN10  -> sNaN10
cpyx034 copy     -sNaN10  -> -sNaN10
cpyx035 copy       NaN7   -> NaN7
cpyx036 copy      -NaN7   -> -NaN7
cpyx037 copy      sNaN101 -> sNaN101
cpyx038 copy     -sNaN101 -> -sNaN101

-- finites
cpyx101 copy          7   -> 7
cpyx102 copy         -7   -> -7
cpyx103 copy         75   -> 75
cpyx104 copy        -75   -> -75
cpyx105 copy       7.50   -> 7.50
cpyx106 copy      -7.50   -> -7.50
cpyx107 copy       7.500  -> 7.500
cpyx108 copy      -7.500  -> -7.500

-- zeros
cpyx111 copy          0   -> 0
cpyx112 copy         -0   -> -0
cpyx113 copy       0E+4   -> 0E+4
cpyx114 copy      -0E+4   -> -0E+4
cpyx115 copy     0.0000   -> 0.0000
cpyx116 copy    -0.0000   -> -0.0000
cpyx117 copy      0E-141  -> 0E-141
cpyx118 copy     -0E-141  -> -0E-141

-- full coefficients, alternating bits
cpyx121 copy   268268268        -> 268268268
cpyx122 copy  -268268268        -> -268268268
cpyx123 copy   134134134        -> 134134134
cpyx124 copy  -134134134        -> -134134134

-- Nmax, Nmin, Ntiny
cpyx131 copy  9.99999999E+999   -> 9.99999999E+999
cpyx132 copy  1E-999            -> 1E-999
cpyx133 copy  1.00000000E-999   -> 1.00000000E-999
cpyx134 copy  1E-1007           -> 1E-1007

cpyx135 copy  -1E-1007          -> -1E-1007
cpyx136 copy  -1.00000000E-999  -> -1.00000000E-999
cpyx137 copy  -1E-999           -> -1E-999
cpyx138 copy  -9.99999999E+999  -> -9.99999999E+999

Added test/dectest/copyabs.decTest.













































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
------------------------------------------------------------------------
-- copyAbs.decTest -- quiet copy and set sign to zero                 --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

-- Sanity check
cpax001 copyabs       +7.50  -> 7.50

-- Infinities
cpax011 copyabs  Infinity    -> Infinity
cpax012 copyabs  -Infinity   -> Infinity

-- NaNs, 0 payload
cpax021 copyabs         NaN  -> NaN
cpax022 copyabs        -NaN  -> NaN
cpax023 copyabs        sNaN  -> sNaN
cpax024 copyabs       -sNaN  -> sNaN

-- NaNs, non-0 payload
cpax031 copyabs       NaN10  -> NaN10
cpax032 copyabs      -NaN15  -> NaN15
cpax033 copyabs      sNaN15  -> sNaN15
cpax034 copyabs     -sNaN10  -> sNaN10
cpax035 copyabs       NaN7   -> NaN7
cpax036 copyabs      -NaN7   -> NaN7
cpax037 copyabs      sNaN101 -> sNaN101
cpax038 copyabs     -sNaN101 -> sNaN101

-- finites
cpax101 copyabs          7   -> 7
cpax102 copyabs         -7   -> 7
cpax103 copyabs         75   -> 75
cpax104 copyabs        -75   -> 75
cpax105 copyabs       7.10   -> 7.10
cpax106 copyabs      -7.10   -> 7.10
cpax107 copyabs       7.500  -> 7.500
cpax108 copyabs      -7.500  -> 7.500

-- zeros
cpax111 copyabs          0   -> 0
cpax112 copyabs         -0   -> 0
cpax113 copyabs       0E+6   -> 0E+6
cpax114 copyabs      -0E+6   -> 0E+6
cpax115 copyabs     0.0000   -> 0.0000
cpax116 copyabs    -0.0000   -> 0.0000
cpax117 copyabs      0E-141  -> 0E-141
cpax118 copyabs     -0E-141  -> 0E-141

-- full coefficients, alternating bits
cpax121 copyabs   268268268        -> 268268268
cpax122 copyabs  -268268268        -> 268268268
cpax123 copyabs   134134134        -> 134134134
cpax124 copyabs  -134134134        -> 134134134

-- Nmax, Nmin, Ntiny
cpax131 copyabs  9.99999999E+999   -> 9.99999999E+999
cpax132 copyabs  1E-999            -> 1E-999
cpax133 copyabs  1.00000000E-999   -> 1.00000000E-999
cpax134 copyabs  1E-1007           -> 1E-1007

cpax135 copyabs  -1E-1007          -> 1E-1007
cpax136 copyabs  -1.00000000E-999  -> 1.00000000E-999
cpax137 copyabs  -1E-999           -> 1E-999
cpax199 copyabs  -9.99999999E+999  -> 9.99999999E+999

Added test/dectest/copynegate.decTest.













































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
------------------------------------------------------------------------
-- copyNegate.decTest -- quiet copy and negate                        --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

-- Sanity check
cpnx001 copynegate       +7.50  -> -7.50

-- Infinities
cpnx011 copynegate  Infinity    -> -Infinity
cpnx012 copynegate  -Infinity   -> Infinity

-- NaNs, 0 payload
cpnx021 copynegate         NaN  -> -NaN
cpnx022 copynegate        -NaN  -> NaN
cpnx023 copynegate        sNaN  -> -sNaN
cpnx024 copynegate       -sNaN  -> sNaN

-- NaNs, non-0 payload
cpnx031 copynegate       NaN13  -> -NaN13
cpnx032 copynegate      -NaN13  -> NaN13
cpnx033 copynegate      sNaN13  -> -sNaN13
cpnx034 copynegate     -sNaN13  -> sNaN13
cpnx035 copynegate       NaN70  -> -NaN70
cpnx036 copynegate      -NaN70  -> NaN70
cpnx037 copynegate      sNaN101 -> -sNaN101
cpnx038 copynegate     -sNaN101 -> sNaN101

-- finites
cpnx101 copynegate          7   -> -7
cpnx102 copynegate         -7   -> 7
cpnx103 copynegate         75   -> -75
cpnx104 copynegate        -75   -> 75
cpnx105 copynegate       7.50   -> -7.50
cpnx106 copynegate      -7.50   -> 7.50
cpnx107 copynegate       7.500  -> -7.500
cpnx108 copynegate      -7.500  -> 7.500

-- zeros
cpnx111 copynegate          0   -> -0
cpnx112 copynegate         -0   -> 0
cpnx113 copynegate       0E+4   -> -0E+4
cpnx114 copynegate      -0E+4   -> 0E+4
cpnx115 copynegate     0.0000   -> -0.0000
cpnx116 copynegate    -0.0000   -> 0.0000
cpnx117 copynegate      0E-141  -> -0E-141
cpnx118 copynegate     -0E-141  -> 0E-141

-- full coefficients, alternating bits
cpnx121 copynegate  268268268         -> -268268268
cpnx122 copynegate  -268268268        -> 268268268
cpnx123 copynegate  134134134         -> -134134134
cpnx124 copynegate  -134134134        -> 134134134

-- Nmax, Nmin, Ntiny
cpnx131 copynegate  9.99999999E+999   -> -9.99999999E+999
cpnx132 copynegate  1E-999                     -> -1E-999
cpnx133 copynegate  1.00000000E-999   -> -1.00000000E-999
cpnx134 copynegate  1E-1007                    -> -1E-1007

cpnx135 copynegate  -1E-1007                   -> 1E-1007
cpnx136 copynegate  -1.00000000E-999  -> 1.00000000E-999
cpnx137 copynegate  -1E-999                    -> 1E-999
cpnx138 copynegate  -9.99999999E+999  -> 9.99999999E+999

Added test/dectest/copysign.decTest.



































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
------------------------------------------------------------------------
-- copysign.decTest -- quiet copy with sign from rhs                  --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

-- Sanity check, and examples from decArith
cpsx001 copysign   +7.50       11  -> 7.50
cpsx002 copysign   '1.50'   '7.33' -> 1.50
cpsx003 copysign  '-1.50'   '7.33' -> 1.50
cpsx004 copysign   '1.50'  '-7.33' -> -1.50
cpsx005 copysign  '-1.50'  '-7.33' -> -1.50

-- Infinities
cpsx011 copysign  Infinity       11 -> Infinity
cpsx012 copysign  -Infinity      11 -> Infinity

-- NaNs, 0 payload
cpsx021 copysign         NaN     11 -> NaN
cpsx022 copysign        -NaN     11 -> NaN
cpsx023 copysign        sNaN     11 -> sNaN
cpsx024 copysign       -sNaN     11 -> sNaN

-- NaNs, non-0 payload
cpsx031 copysign       NaN10     11 -> NaN10
cpsx032 copysign      -NaN10     11 -> NaN10
cpsx033 copysign      sNaN10     11 -> sNaN10
cpsx034 copysign     -sNaN10     11 -> sNaN10
cpsx035 copysign       NaN7      11 -> NaN7
cpsx036 copysign      -NaN7      11 -> NaN7
cpsx037 copysign      sNaN101    11 -> sNaN101
cpsx038 copysign     -sNaN101    11 -> sNaN101

-- finites
cpsx101 copysign          7      11 -> 7
cpsx102 copysign         -7      11 -> 7
cpsx103 copysign         75      11 -> 75
cpsx104 copysign        -75      11 -> 75
cpsx105 copysign       7.50      11 -> 7.50
cpsx106 copysign      -7.50      11 -> 7.50
cpsx107 copysign       7.500     11 -> 7.500
cpsx108 copysign      -7.500     11 -> 7.500

-- zeros
cpsx111 copysign          0      11 -> 0
cpsx112 copysign         -0      11 -> 0
cpsx113 copysign       0E+4      11 -> 0E+4
cpsx114 copysign      -0E+4      11 -> 0E+4
cpsx115 copysign     0.0000      11 -> 0.0000
cpsx116 copysign    -0.0000      11 -> 0.0000
cpsx117 copysign      0E-141     11 -> 0E-141
cpsx118 copysign     -0E-141     11 -> 0E-141

-- full coefficients, alternating bits
cpsx121 copysign   268268268           11 -> 268268268
cpsx122 copysign  -268268268           11 -> 268268268
cpsx123 copysign   134134134           11 -> 134134134
cpsx124 copysign  -134134134           11 -> 134134134

-- Nmax, Nmin, Ntiny
cpsx131 copysign  9.99999999E+999      11 -> 9.99999999E+999
cpsx132 copysign  1E-999               11 -> 1E-999
cpsx133 copysign  1.00000000E-999      11 -> 1.00000000E-999
cpsx134 copysign  1E-1007              11 -> 1E-1007

cpsx135 copysign  -1E-1007             11 -> 1E-1007
cpsx136 copysign  -1.00000000E-999     11 -> 1.00000000E-999
cpsx137 copysign  -1E-999              11 -> 1E-999
cpsx138 copysign  -9.99999999E+999     11 -> 9.99999999E+999

-- repeat with negative RHS

-- Infinities
cpsx211 copysign  Infinity       -34 -> -Infinity
cpsx212 copysign  -Infinity      -34 -> -Infinity

-- NaNs, 0 payload
cpsx221 copysign         NaN     -34 -> -NaN
cpsx222 copysign        -NaN     -34 -> -NaN
cpsx223 copysign        sNaN     -34 -> -sNaN
cpsx224 copysign       -sNaN     -34 -> -sNaN

-- NaNs, non-0 payload
cpsx231 copysign       NaN10     -34 -> -NaN10
cpsx232 copysign      -NaN10     -34 -> -NaN10
cpsx233 copysign      sNaN10     -34 -> -sNaN10
cpsx234 copysign     -sNaN10     -34 -> -sNaN10
cpsx235 copysign       NaN7      -34 -> -NaN7
cpsx236 copysign      -NaN7      -34 -> -NaN7
cpsx237 copysign      sNaN101    -34 -> -sNaN101
cpsx238 copysign     -sNaN101    -34 -> -sNaN101

-- finites
cpsx301 copysign          7      -34 -> -7
cpsx302 copysign         -7      -34 -> -7
cpsx303 copysign         75      -34 -> -75
cpsx304 copysign        -75      -34 -> -75
cpsx305 copysign       7.50      -34 -> -7.50
cpsx306 copysign      -7.50      -34 -> -7.50
cpsx307 copysign       7.500     -34 -> -7.500
cpsx308 copysign      -7.500     -34 -> -7.500

-- zeros
cpsx311 copysign          0      -34 -> -0
cpsx312 copysign         -0      -34 -> -0
cpsx313 copysign       0E+4      -34 -> -0E+4
cpsx314 copysign      -0E+4      -34 -> -0E+4
cpsx315 copysign     0.0000      -34 -> -0.0000
cpsx316 copysign    -0.0000      -34 -> -0.0000
cpsx317 copysign      0E-141     -34 -> -0E-141
cpsx318 copysign     -0E-141     -34 -> -0E-141

-- full coefficients, alternating bits
cpsx321 copysign   268268268          -18 -> -268268268
cpsx322 copysign  -268268268          -18 -> -268268268
cpsx323 copysign   134134134          -18 -> -134134134
cpsx324 copysign  -134134134          -18 -> -134134134

-- Nmax, Nmin, Ntiny
cpsx331 copysign  9.99999999E+999     -18 -> -9.99999999E+999
cpsx332 copysign  1E-999              -18 -> -1E-999
cpsx333 copysign  1.00000000E-999     -18 -> -1.00000000E-999
cpsx334 copysign  1E-1007             -18 -> -1E-1007

cpsx335 copysign  -1E-1007            -18 -> -1E-1007
cpsx336 copysign  -1.00000000E-999    -18 -> -1.00000000E-999
cpsx337 copysign  -1E-999             -18 -> -1E-999
cpsx338 copysign  -9.99999999E+999    -18 -> -9.99999999E+999

-- Other kinds of RHS
cpsx401 copysign          701    -34 -> -701
cpsx402 copysign         -720    -34 -> -720
cpsx403 copysign          701    -0  -> -701
cpsx404 copysign         -720    -0  -> -720
cpsx405 copysign          701    +0  ->  701
cpsx406 copysign         -720    +0  ->  720
cpsx407 copysign          701    +34 ->  701
cpsx408 copysign         -720    +34 ->  720

cpsx413 copysign          701    -Inf  -> -701
cpsx414 copysign         -720    -Inf  -> -720
cpsx415 copysign          701    +Inf  ->  701
cpsx416 copysign         -720    +Inf  ->  720

cpsx420 copysign          701    -NaN  -> -701
cpsx421 copysign         -720    -NaN  -> -720
cpsx422 copysign          701    +NaN  ->  701
cpsx423 copysign         -720    +NaN  ->  720
cpsx425 copysign         -720    +NaN8 ->  720

cpsx426 copysign          701    -sNaN  -> -701
cpsx427 copysign         -720    -sNaN  -> -720
cpsx428 copysign          701    +sNaN  ->  701
cpsx429 copysign         -720    +sNaN  ->  720
cpsx430 copysign         -720    +sNaN3 ->  720

Added test/dectest/ddAbs.decTest.





























































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
------------------------------------------------------------------------
-- ddAbs.decTest -- decDouble absolute value, heeding sNaN            --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

ddabs001 abs '1'      -> '1'
ddabs002 abs '-1'     -> '1'
ddabs003 abs '1.00'   -> '1.00'
ddabs004 abs '-1.00'  -> '1.00'
ddabs005 abs '0'      -> '0'
ddabs006 abs '0.00'   -> '0.00'
ddabs007 abs '00.0'   -> '0.0'
ddabs008 abs '00.00'  -> '0.00'
ddabs009 abs '00'     -> '0'

ddabs010 abs '-2'     -> '2'
ddabs011 abs '2'      -> '2'
ddabs012 abs '-2.00'  -> '2.00'
ddabs013 abs '2.00'   -> '2.00'
ddabs014 abs '-0'     -> '0'
ddabs015 abs '-0.00'  -> '0.00'
ddabs016 abs '-00.0'  -> '0.0'
ddabs017 abs '-00.00' -> '0.00'
ddabs018 abs '-00'    -> '0'

ddabs020 abs '-2000000' -> '2000000'
ddabs021 abs '2000000'  -> '2000000'

ddabs030 abs '+0.1'            -> '0.1'
ddabs031 abs '-0.1'            -> '0.1'
ddabs032 abs '+0.01'           -> '0.01'
ddabs033 abs '-0.01'           -> '0.01'
ddabs034 abs '+0.001'          -> '0.001'
ddabs035 abs '-0.001'          -> '0.001'
ddabs036 abs '+0.000001'       -> '0.000001'
ddabs037 abs '-0.000001'       -> '0.000001'
ddabs038 abs '+0.000000000001' -> '1E-12'
ddabs039 abs '-0.000000000001' -> '1E-12'

-- examples from decArith
ddabs040 abs '2.1'     ->  '2.1'
ddabs041 abs '-100'    ->  '100'
ddabs042 abs '101.5'   ->  '101.5'
ddabs043 abs '-101.5'  ->  '101.5'

-- more fixed, potential LHS swaps/overlays if done by subtract 0
ddabs060 abs '-56267E-10'  -> '0.0000056267'
ddabs061 abs '-56267E-5'   -> '0.56267'
ddabs062 abs '-56267E-2'   -> '562.67'
ddabs063 abs '-56267E-1'   -> '5626.7'
ddabs065 abs '-56267E-0'   -> '56267'

-- subnormals and underflow

-- long operand tests
ddabs321 abs 1234567890123456  -> 1234567890123456
ddabs322 abs 12345678000  -> 12345678000
ddabs323 abs 1234567800   -> 1234567800
ddabs324 abs 1234567890   -> 1234567890
ddabs325 abs 1234567891   -> 1234567891
ddabs326 abs 12345678901  -> 12345678901
ddabs327 abs 1234567896   -> 1234567896

-- zeros
ddabs111 abs          0   -> 0
ddabs112 abs         -0   -> 0
ddabs113 abs       0E+6   -> 0E+6
ddabs114 abs      -0E+6   -> 0E+6
ddabs115 abs     0.0000   -> 0.0000
ddabs116 abs    -0.0000   -> 0.0000
ddabs117 abs      0E-141  -> 0E-141
ddabs118 abs     -0E-141  -> 0E-141

-- full coefficients, alternating bits
ddabs121 abs  2682682682682682         -> 2682682682682682
ddabs122 abs  -2682682682682682        -> 2682682682682682
ddabs123 abs  1341341341341341         -> 1341341341341341
ddabs124 abs  -1341341341341341        -> 1341341341341341

-- Nmax, Nmin, Ntiny
ddabs131 abs  9.999999999999999E+384   -> 9.999999999999999E+384
ddabs132 abs  1E-383                   -> 1E-383
ddabs133 abs  1.000000000000000E-383   -> 1.000000000000000E-383
ddabs134 abs  1E-398                   -> 1E-398 Subnormal

ddabs135 abs  -1E-398                  -> 1E-398 Subnormal
ddabs136 abs  -1.000000000000000E-383  -> 1.000000000000000E-383
ddabs137 abs  -1E-383                  -> 1E-383
ddabs138 abs  -9.999999999999999E+384  -> 9.999999999999999E+384

-- specials
ddabs520 abs 'Inf'    -> 'Infinity'
ddabs521 abs '-Inf'   -> 'Infinity'
ddabs522 abs   NaN    ->  NaN
ddabs523 abs  sNaN    ->  NaN   Invalid_operation
ddabs524 abs   NaN22  ->  NaN22
ddabs525 abs  sNaN33  ->  NaN33 Invalid_operation
ddabs526 abs  -NaN22  -> -NaN22
ddabs527 abs -sNaN33  -> -NaN33 Invalid_operation

-- Null tests
ddabs900 abs  # -> NaN Invalid_operation

Added test/dectest/ddAdd.decTest.





















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
------------------------------------------------------------------------
-- ddAdd.decTest -- decDouble addition                                --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests are for decDoubles only; all arguments are
-- representable in a decDouble
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- [first group are 'quick confidence check']
ddadd001 add 1       1       ->  2
ddadd002 add 2       3       ->  5
ddadd003 add '5.75'  '3.3'   ->  9.05
ddadd004 add '5'     '-3'    ->  2
ddadd005 add '-5'    '-3'    ->  -8
ddadd006 add '-7'    '2.5'   ->  -4.5
ddadd007 add '0.7'   '0.3'   ->  1.0
ddadd008 add '1.25'  '1.25'  ->  2.50
ddadd009 add '1.23456789'  '1.00000000' -> '2.23456789'
ddadd010 add '1.23456789'  '1.00000011' -> '2.23456800'

--             1234567890123456      1234567890123456
ddadd011 add '0.4444444444444446'  '0.5555555555555555' -> '1.000000000000000' Inexact Rounded
ddadd012 add '0.4444444444444445'  '0.5555555555555555' -> '1.000000000000000' Rounded
ddadd013 add '0.4444444444444444'  '0.5555555555555555' -> '0.9999999999999999'
ddadd014 add   '4444444444444444' '0.49'   -> '4444444444444444' Inexact Rounded
ddadd015 add   '4444444444444444' '0.499'  -> '4444444444444444' Inexact Rounded
ddadd016 add   '4444444444444444' '0.4999' -> '4444444444444444' Inexact Rounded
ddadd017 add   '4444444444444444' '0.5000' -> '4444444444444444' Inexact Rounded
ddadd018 add   '4444444444444444' '0.5001' -> '4444444444444445' Inexact Rounded
ddadd019 add   '4444444444444444' '0.501'  -> '4444444444444445' Inexact Rounded
ddadd020 add   '4444444444444444' '0.51'   -> '4444444444444445' Inexact Rounded

ddadd021 add 0 1 -> 1
ddadd022 add 1 1 -> 2
ddadd023 add 2 1 -> 3
ddadd024 add 3 1 -> 4
ddadd025 add 4 1 -> 5
ddadd026 add 5 1 -> 6
ddadd027 add 6 1 -> 7
ddadd028 add 7 1 -> 8
ddadd029 add 8 1 -> 9
ddadd030 add 9 1 -> 10

-- some carrying effects
ddadd031 add '0.9998'  '0.0000' -> '0.9998'
ddadd032 add '0.9998'  '0.0001' -> '0.9999'
ddadd033 add '0.9998'  '0.0002' -> '1.0000'
ddadd034 add '0.9998'  '0.0003' -> '1.0001'

ddadd035 add '70'  '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
ddadd036 add '700'  '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
ddadd037 add '7000'  '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
ddadd038 add '70000'  '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
ddadd039 add '700000'  '10000e+16' -> '1.000000000000007E+20' Rounded

-- symmetry:
ddadd040 add '10000e+16'  '70' -> '1.000000000000000E+20' Inexact Rounded
ddadd041 add '10000e+16'  '700' -> '1.000000000000000E+20' Inexact Rounded
ddadd042 add '10000e+16'  '7000' -> '1.000000000000000E+20' Inexact Rounded
ddadd044 add '10000e+16'  '70000' -> '1.000000000000001E+20' Inexact Rounded
ddadd045 add '10000e+16'  '700000' -> '1.000000000000007E+20' Rounded

-- same, without rounding
ddadd046 add '10000e+9'  '7' -> '10000000000007'
ddadd047 add '10000e+9'  '70' -> '10000000000070'
ddadd048 add '10000e+9'  '700' -> '10000000000700'
ddadd049 add '10000e+9'  '7000' -> '10000000007000'
ddadd050 add '10000e+9'  '70000' -> '10000000070000'
ddadd051 add '10000e+9'  '700000' -> '10000000700000'
ddadd052 add '10000e+9'  '7000000' -> '10000007000000'

-- examples from decarith
ddadd053 add '12' '7.00' -> '19.00'
ddadd054 add '1.3' '-1.07' -> '0.23'
ddadd055 add '1.3' '-1.30' -> '0.00'
ddadd056 add '1.3' '-2.07' -> '-0.77'
ddadd057 add '1E+2' '1E+4' -> '1.01E+4'

-- leading zero preservation
ddadd061 add 1 '0.0001' -> '1.0001'
ddadd062 add 1 '0.00001' -> '1.00001'
ddadd063 add 1 '0.000001' -> '1.000001'
ddadd064 add 1 '0.0000001' -> '1.0000001'
ddadd065 add 1 '0.00000001' -> '1.00000001'

-- some funny zeros [in case of bad signum]
ddadd070 add 1  0    -> 1
ddadd071 add 1 0.    -> 1
ddadd072 add 1  .0   -> 1.0
ddadd073 add 1 0.0   -> 1.0
ddadd074 add 1 0.00  -> 1.00
ddadd075 add  0  1   -> 1
ddadd076 add 0.  1   -> 1
ddadd077 add  .0 1   -> 1.0
ddadd078 add 0.0 1   -> 1.0
ddadd079 add 0.00 1  -> 1.00

-- some carries
ddadd080 add 999999998 1  -> 999999999
ddadd081 add 999999999 1  -> 1000000000
ddadd082 add  99999999 1  -> 100000000
ddadd083 add   9999999 1  -> 10000000
ddadd084 add    999999 1  -> 1000000
ddadd085 add     99999 1  -> 100000
ddadd086 add      9999 1  -> 10000
ddadd087 add       999 1  -> 1000
ddadd088 add        99 1  -> 100
ddadd089 add         9 1  -> 10


-- more LHS swaps
ddadd090 add '-56267E-10'   0 ->  '-0.0000056267'
ddadd091 add '-56267E-6'    0 ->  '-0.056267'
ddadd092 add '-56267E-5'    0 ->  '-0.56267'
ddadd093 add '-56267E-4'    0 ->  '-5.6267'
ddadd094 add '-56267E-3'    0 ->  '-56.267'
ddadd095 add '-56267E-2'    0 ->  '-562.67'
ddadd096 add '-56267E-1'    0 ->  '-5626.7'
ddadd097 add '-56267E-0'    0 ->  '-56267'
ddadd098 add '-5E-10'       0 ->  '-5E-10'
ddadd099 add '-5E-7'        0 ->  '-5E-7'
ddadd100 add '-5E-6'        0 ->  '-0.000005'
ddadd101 add '-5E-5'        0 ->  '-0.00005'
ddadd102 add '-5E-4'        0 ->  '-0.0005'
ddadd103 add '-5E-1'        0 ->  '-0.5'
ddadd104 add '-5E0'         0 ->  '-5'
ddadd105 add '-5E1'         0 ->  '-50'
ddadd106 add '-5E5'         0 ->  '-500000'
ddadd107 add '-5E15'        0 ->  '-5000000000000000'
ddadd108 add '-5E16'        0 ->  '-5.000000000000000E+16'  Rounded
ddadd109 add '-5E17'        0 ->  '-5.000000000000000E+17'  Rounded
ddadd110 add '-5E18'        0 ->  '-5.000000000000000E+18'  Rounded
ddadd111 add '-5E100'       0 ->  '-5.000000000000000E+100' Rounded

-- more RHS swaps
ddadd113 add 0  '-56267E-10' ->  '-0.0000056267'
ddadd114 add 0  '-56267E-6'  ->  '-0.056267'
ddadd116 add 0  '-56267E-5'  ->  '-0.56267'
ddadd117 add 0  '-56267E-4'  ->  '-5.6267'
ddadd119 add 0  '-56267E-3'  ->  '-56.267'
ddadd120 add 0  '-56267E-2'  ->  '-562.67'
ddadd121 add 0  '-56267E-1'  ->  '-5626.7'
ddadd122 add 0  '-56267E-0'  ->  '-56267'
ddadd123 add 0  '-5E-10'     ->  '-5E-10'
ddadd124 add 0  '-5E-7'      ->  '-5E-7'
ddadd125 add 0  '-5E-6'      ->  '-0.000005'
ddadd126 add 0  '-5E-5'      ->  '-0.00005'
ddadd127 add 0  '-5E-4'      ->  '-0.0005'
ddadd128 add 0  '-5E-1'      ->  '-0.5'
ddadd129 add 0  '-5E0'       ->  '-5'
ddadd130 add 0  '-5E1'       ->  '-50'
ddadd131 add 0  '-5E5'       ->  '-500000'
ddadd132 add 0  '-5E15'      ->  '-5000000000000000'
ddadd133 add 0  '-5E16'      ->  '-5.000000000000000E+16'   Rounded
ddadd134 add 0  '-5E17'      ->  '-5.000000000000000E+17'   Rounded
ddadd135 add 0  '-5E18'      ->  '-5.000000000000000E+18'   Rounded
ddadd136 add 0  '-5E100'     ->  '-5.000000000000000E+100'  Rounded

-- related
ddadd137 add  1  '0E-19'      ->  '1.000000000000000'  Rounded
ddadd138 add -1  '0E-19'      ->  '-1.000000000000000' Rounded
ddadd139 add '0E-19' 1        ->  '1.000000000000000'  Rounded
ddadd140 add '0E-19' -1       ->  '-1.000000000000000' Rounded
ddadd141 add 1E+11   0.0000   ->  '100000000000.0000'
ddadd142 add 1E+11   0.00000  ->  '100000000000.0000'  Rounded
ddadd143 add 0.000   1E+12    ->  '1000000000000.000'
ddadd144 add 0.0000  1E+12    ->  '1000000000000.000'  Rounded

-- [some of the next group are really constructor tests]
ddadd146 add '00.0'  0       ->  '0.0'
ddadd147 add '0.00'  0       ->  '0.00'
ddadd148 add  0      '0.00'  ->  '0.00'
ddadd149 add  0      '00.0'  ->  '0.0'
ddadd150 add '00.0'  '0.00'  ->  '0.00'
ddadd151 add '0.00'  '00.0'  ->  '0.00'
ddadd152 add '3'     '.3'    ->  '3.3'
ddadd153 add '3.'    '.3'    ->  '3.3'
ddadd154 add '3.0'   '.3'    ->  '3.3'
ddadd155 add '3.00'  '.3'    ->  '3.30'
ddadd156 add '3'     '3'     ->  '6'
ddadd157 add '3'     '+3'    ->  '6'
ddadd158 add '3'     '-3'    ->  '0'
ddadd159 add '0.3'   '-0.3'  ->  '0.0'
ddadd160 add '0.03'  '-0.03' ->  '0.00'

-- try borderline precision, with carries, etc.
ddadd161 add '1E+12' '-1'    -> '999999999999'
ddadd162 add '1E+12'  '1.11' -> '1000000000001.11'
ddadd163 add '1.11'  '1E+12' -> '1000000000001.11'
ddadd164 add '-1'    '1E+12' -> '999999999999'
ddadd165 add '7E+12' '-1'    -> '6999999999999'
ddadd166 add '7E+12'  '1.11' -> '7000000000001.11'
ddadd167 add '1.11'  '7E+12' -> '7000000000001.11'
ddadd168 add '-1'    '7E+12' -> '6999999999999'

rounding: half_up
--           1.234567890123456      1234567890123456      1 234567890123456
ddadd170 add '4.444444444444444'  '0.5555555555555567' -> '5.000000000000001' Inexact Rounded
ddadd171 add '4.444444444444444'  '0.5555555555555566' -> '5.000000000000001' Inexact Rounded
ddadd172 add '4.444444444444444'  '0.5555555555555565' -> '5.000000000000001' Inexact Rounded
ddadd173 add '4.444444444444444'  '0.5555555555555564' -> '5.000000000000000' Inexact Rounded
ddadd174 add '4.444444444444444'  '0.5555555555555553' -> '4.999999999999999' Inexact Rounded
ddadd175 add '4.444444444444444'  '0.5555555555555552' -> '4.999999999999999' Inexact Rounded
ddadd176 add '4.444444444444444'  '0.5555555555555551' -> '4.999999999999999' Inexact Rounded
ddadd177 add '4.444444444444444'  '0.5555555555555550' -> '4.999999999999999' Rounded
ddadd178 add '4.444444444444444'  '0.5555555555555545' -> '4.999999999999999' Inexact Rounded
ddadd179 add '4.444444444444444'  '0.5555555555555544' -> '4.999999999999998' Inexact Rounded
ddadd180 add '4.444444444444444'  '0.5555555555555543' -> '4.999999999999998' Inexact Rounded
ddadd181 add '4.444444444444444'  '0.5555555555555542' -> '4.999999999999998' Inexact Rounded
ddadd182 add '4.444444444444444'  '0.5555555555555541' -> '4.999999999999998' Inexact Rounded
ddadd183 add '4.444444444444444'  '0.5555555555555540' -> '4.999999999999998' Rounded

-- and some more, including residue effects and different roundings
rounding: half_up
ddadd200 add '1234560123456789' 0             -> '1234560123456789'
ddadd201 add '1234560123456789' 0.000000001   -> '1234560123456789' Inexact Rounded
ddadd202 add '1234560123456789' 0.000001      -> '1234560123456789' Inexact Rounded
ddadd203 add '1234560123456789' 0.1           -> '1234560123456789' Inexact Rounded
ddadd204 add '1234560123456789' 0.4           -> '1234560123456789' Inexact Rounded
ddadd205 add '1234560123456789' 0.49          -> '1234560123456789' Inexact Rounded
ddadd206 add '1234560123456789' 0.499999      -> '1234560123456789' Inexact Rounded
ddadd207 add '1234560123456789' 0.499999999   -> '1234560123456789' Inexact Rounded
ddadd208 add '1234560123456789' 0.5           -> '1234560123456790' Inexact Rounded
ddadd209 add '1234560123456789' 0.500000001   -> '1234560123456790' Inexact Rounded
ddadd210 add '1234560123456789' 0.500001      -> '1234560123456790' Inexact Rounded
ddadd211 add '1234560123456789' 0.51          -> '1234560123456790' Inexact Rounded
ddadd212 add '1234560123456789' 0.6           -> '1234560123456790' Inexact Rounded
ddadd213 add '1234560123456789' 0.9           -> '1234560123456790' Inexact Rounded
ddadd214 add '1234560123456789' 0.99999       -> '1234560123456790' Inexact Rounded
ddadd215 add '1234560123456789' 0.999999999   -> '1234560123456790' Inexact Rounded
ddadd216 add '1234560123456789' 1             -> '1234560123456790'
ddadd217 add '1234560123456789' 1.000000001   -> '1234560123456790' Inexact Rounded
ddadd218 add '1234560123456789' 1.00001       -> '1234560123456790' Inexact Rounded
ddadd219 add '1234560123456789' 1.1           -> '1234560123456790' Inexact Rounded

rounding: half_even
ddadd220 add '1234560123456789' 0             -> '1234560123456789'
ddadd221 add '1234560123456789' 0.000000001   -> '1234560123456789' Inexact Rounded
ddadd222 add '1234560123456789' 0.000001      -> '1234560123456789' Inexact Rounded
ddadd223 add '1234560123456789' 0.1           -> '1234560123456789' Inexact Rounded
ddadd224 add '1234560123456789' 0.4           -> '1234560123456789' Inexact Rounded
ddadd225 add '1234560123456789' 0.49          -> '1234560123456789' Inexact Rounded
ddadd226 add '1234560123456789' 0.499999      -> '1234560123456789' Inexact Rounded
ddadd227 add '1234560123456789' 0.499999999   -> '1234560123456789' Inexact Rounded
ddadd228 add '1234560123456789' 0.5           -> '1234560123456790' Inexact Rounded
ddadd229 add '1234560123456789' 0.500000001   -> '1234560123456790' Inexact Rounded
ddadd230 add '1234560123456789' 0.500001      -> '1234560123456790' Inexact Rounded
ddadd231 add '1234560123456789' 0.51          -> '1234560123456790' Inexact Rounded
ddadd232 add '1234560123456789' 0.6           -> '1234560123456790' Inexact Rounded
ddadd233 add '1234560123456789' 0.9           -> '1234560123456790' Inexact Rounded
ddadd234 add '1234560123456789' 0.99999       -> '1234560123456790' Inexact Rounded
ddadd235 add '1234560123456789' 0.999999999   -> '1234560123456790' Inexact Rounded
ddadd236 add '1234560123456789' 1             -> '1234560123456790'
ddadd237 add '1234560123456789' 1.00000001    -> '1234560123456790' Inexact Rounded
ddadd238 add '1234560123456789' 1.00001       -> '1234560123456790' Inexact Rounded
ddadd239 add '1234560123456789' 1.1           -> '1234560123456790' Inexact Rounded
-- critical few with even bottom digit...
ddadd240 add '1234560123456788' 0.499999999   -> '1234560123456788' Inexact Rounded
ddadd241 add '1234560123456788' 0.5           -> '1234560123456788' Inexact Rounded
ddadd242 add '1234560123456788' 0.500000001   -> '1234560123456789' Inexact Rounded

rounding: down
ddadd250 add '1234560123456789' 0             -> '1234560123456789'
ddadd251 add '1234560123456789' 0.000000001   -> '1234560123456789' Inexact Rounded
ddadd252 add '1234560123456789' 0.000001      -> '1234560123456789' Inexact Rounded
ddadd253 add '1234560123456789' 0.1           -> '1234560123456789' Inexact Rounded
ddadd254 add '1234560123456789' 0.4           -> '1234560123456789' Inexact Rounded
ddadd255 add '1234560123456789' 0.49          -> '1234560123456789' Inexact Rounded
ddadd256 add '1234560123456789' 0.499999      -> '1234560123456789' Inexact Rounded
ddadd257 add '1234560123456789' 0.499999999   -> '1234560123456789' Inexact Rounded
ddadd258 add '1234560123456789' 0.5           -> '1234560123456789' Inexact Rounded
ddadd259 add '1234560123456789' 0.500000001   -> '1234560123456789' Inexact Rounded
ddadd260 add '1234560123456789' 0.500001      -> '1234560123456789' Inexact Rounded
ddadd261 add '1234560123456789' 0.51          -> '1234560123456789' Inexact Rounded
ddadd262 add '1234560123456789' 0.6           -> '1234560123456789' Inexact Rounded
ddadd263 add '1234560123456789' 0.9           -> '1234560123456789' Inexact Rounded
ddadd264 add '1234560123456789' 0.99999       -> '1234560123456789' Inexact Rounded
ddadd265 add '1234560123456789' 0.999999999   -> '1234560123456789' Inexact Rounded
ddadd266 add '1234560123456789' 1             -> '1234560123456790'
ddadd267 add '1234560123456789' 1.00000001    -> '1234560123456790' Inexact Rounded
ddadd268 add '1234560123456789' 1.00001       -> '1234560123456790' Inexact Rounded
ddadd269 add '1234560123456789' 1.1           -> '1234560123456790' Inexact Rounded

-- 1 in last place tests
rounding: half_up
ddadd301 add  -1   1      ->   0
ddadd302 add   0   1      ->   1
ddadd303 add   1   1      ->   2
ddadd304 add  12   1      ->  13
ddadd305 add  98   1      ->  99
ddadd306 add  99   1      -> 100
ddadd307 add 100   1      -> 101
ddadd308 add 101   1      -> 102
ddadd309 add  -1  -1      ->  -2
ddadd310 add   0  -1      ->  -1
ddadd311 add   1  -1      ->   0
ddadd312 add  12  -1      ->  11
ddadd313 add  98  -1      ->  97
ddadd314 add  99  -1      ->  98
ddadd315 add 100  -1      ->  99
ddadd316 add 101  -1      -> 100

ddadd321 add -0.01  0.01    ->  0.00
ddadd322 add  0.00  0.01    ->  0.01
ddadd323 add  0.01  0.01    ->  0.02
ddadd324 add  0.12  0.01    ->  0.13
ddadd325 add  0.98  0.01    ->  0.99
ddadd326 add  0.99  0.01    ->  1.00
ddadd327 add  1.00  0.01    ->  1.01
ddadd328 add  1.01  0.01    ->  1.02
ddadd329 add -0.01 -0.01    -> -0.02
ddadd330 add  0.00 -0.01    -> -0.01
ddadd331 add  0.01 -0.01    ->  0.00
ddadd332 add  0.12 -0.01    ->  0.11
ddadd333 add  0.98 -0.01    ->  0.97
ddadd334 add  0.99 -0.01    ->  0.98
ddadd335 add  1.00 -0.01    ->  0.99
ddadd336 add  1.01 -0.01    ->  1.00

-- some more cases where adding 0 affects the coefficient
ddadd340 add 1E+3    0    ->         1000
ddadd341 add 1E+15   0    ->    1000000000000000
ddadd342 add 1E+16   0    ->   1.000000000000000E+16  Rounded
ddadd343 add 1E+20   0    ->   1.000000000000000E+20  Rounded
-- which simply follow from these cases ...
ddadd344 add 1E+3    1    ->         1001
ddadd345 add 1E+15   1    ->    1000000000000001
ddadd346 add 1E+16   1    ->   1.000000000000000E+16  Inexact Rounded
ddadd347 add 1E+20   1    ->   1.000000000000000E+20  Inexact Rounded
ddadd348 add 1E+3    7    ->         1007
ddadd349 add 1E+15   7    ->    1000000000000007
ddadd350 add 1E+16   7    ->   1.000000000000001E+16  Inexact Rounded
ddadd351 add 1E+20   7    ->   1.000000000000000E+20  Inexact Rounded

-- tryzeros cases
rounding:    half_up
ddadd360  add 0E+50 10000E+1  -> 1.0000E+5
ddadd361  add 0E-50 10000E+1  -> 100000.0000000000 Rounded
ddadd362  add 10000E+1 0E-50  -> 100000.0000000000 Rounded
ddadd363  add 10000E+1 10000E-50  -> 100000.0000000000 Rounded Inexact
ddadd364  add 9.999999999999999E+384 -9.999999999999999E+384 -> 0E+369

-- a curiosity from JSR 13 testing
rounding:    half_down
ddadd370 add  999999999999999 815 -> 1000000000000814
ddadd371 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
rounding:    half_up
ddadd372 add  999999999999999 815 -> 1000000000000814
ddadd373 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
rounding:    half_even
ddadd374 add  999999999999999 815 -> 1000000000000814
ddadd375 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact

-- operands folded
ddadd380 add   1E+384  1E+384  ->  2.000000000000000E+384  Clamped
ddadd381 add   1E+380  1E+380  ->  2.00000000000E+380      Clamped
ddadd382 add   1E+376  1E+376  ->  2.0000000E+376          Clamped
ddadd383 add   1E+372  1E+372  ->  2.000E+372              Clamped
ddadd384 add   1E+370  1E+370  ->  2.0E+370                Clamped
ddadd385 add   1E+369  1E+369  ->  2E+369
ddadd386 add   1E+368  1E+368  ->  2E+368

-- ulp replacement tests
ddadd400 add   1   77e-14      ->  1.00000000000077
ddadd401 add   1   77e-15      ->  1.000000000000077
ddadd402 add   1   77e-16      ->  1.000000000000008 Inexact Rounded
ddadd403 add   1   77e-17      ->  1.000000000000001 Inexact Rounded
ddadd404 add   1   77e-18      ->  1.000000000000000 Inexact Rounded
ddadd405 add   1   77e-19      ->  1.000000000000000 Inexact Rounded
ddadd406 add   1   77e-299     ->  1.000000000000000 Inexact Rounded

ddadd410 add  10   77e-14      ->  10.00000000000077
ddadd411 add  10   77e-15      ->  10.00000000000008 Inexact Rounded
ddadd412 add  10   77e-16      ->  10.00000000000001 Inexact Rounded
ddadd413 add  10   77e-17      ->  10.00000000000000 Inexact Rounded
ddadd414 add  10   77e-18      ->  10.00000000000000 Inexact Rounded
ddadd415 add  10   77e-19      ->  10.00000000000000 Inexact Rounded
ddadd416 add  10   77e-299     ->  10.00000000000000 Inexact Rounded

ddadd420 add  77e-14       1   ->  1.00000000000077
ddadd421 add  77e-15       1   ->  1.000000000000077
ddadd422 add  77e-16       1   ->  1.000000000000008 Inexact Rounded
ddadd423 add  77e-17       1   ->  1.000000000000001 Inexact Rounded
ddadd424 add  77e-18       1   ->  1.000000000000000 Inexact Rounded
ddadd425 add  77e-19       1   ->  1.000000000000000 Inexact Rounded
ddadd426 add  77e-299      1   ->  1.000000000000000 Inexact Rounded

ddadd430 add  77e-14      10   ->  10.00000000000077
ddadd431 add  77e-15      10   ->  10.00000000000008 Inexact Rounded
ddadd432 add  77e-16      10   ->  10.00000000000001 Inexact Rounded
ddadd433 add  77e-17      10   ->  10.00000000000000 Inexact Rounded
ddadd434 add  77e-18      10   ->  10.00000000000000 Inexact Rounded
ddadd435 add  77e-19      10   ->  10.00000000000000 Inexact Rounded
ddadd436 add  77e-299     10   ->  10.00000000000000 Inexact Rounded

-- negative ulps
ddadd6440 add   1   -77e-14      ->  0.99999999999923
ddadd6441 add   1   -77e-15      ->  0.999999999999923
ddadd6442 add   1   -77e-16      ->  0.9999999999999923
ddadd6443 add   1   -77e-17      ->  0.9999999999999992 Inexact Rounded
ddadd6444 add   1   -77e-18      ->  0.9999999999999999 Inexact Rounded
ddadd6445 add   1   -77e-19      ->  1.000000000000000 Inexact Rounded
ddadd6446 add   1   -77e-99      ->  1.000000000000000 Inexact Rounded

ddadd6450 add  10   -77e-14      ->   9.99999999999923
ddadd6451 add  10   -77e-15      ->   9.999999999999923
ddadd6452 add  10   -77e-16      ->   9.999999999999992 Inexact Rounded
ddadd6453 add  10   -77e-17      ->   9.999999999999999 Inexact Rounded
ddadd6454 add  10   -77e-18      ->  10.00000000000000 Inexact Rounded
ddadd6455 add  10   -77e-19      ->  10.00000000000000 Inexact Rounded
ddadd6456 add  10   -77e-99      ->  10.00000000000000 Inexact Rounded

ddadd6460 add  -77e-14       1   ->  0.99999999999923
ddadd6461 add  -77e-15       1   ->  0.999999999999923
ddadd6462 add  -77e-16       1   ->  0.9999999999999923
ddadd6463 add  -77e-17       1   ->  0.9999999999999992 Inexact Rounded
ddadd6464 add  -77e-18       1   ->  0.9999999999999999 Inexact Rounded
ddadd6465 add  -77e-19       1   ->  1.000000000000000 Inexact Rounded
ddadd6466 add  -77e-99       1   ->  1.000000000000000 Inexact Rounded

ddadd6470 add  -77e-14      10   ->   9.99999999999923
ddadd6471 add  -77e-15      10   ->   9.999999999999923
ddadd6472 add  -77e-16      10   ->   9.999999999999992 Inexact Rounded
ddadd6473 add  -77e-17      10   ->   9.999999999999999 Inexact Rounded
ddadd6474 add  -77e-18      10   ->  10.00000000000000 Inexact Rounded
ddadd6475 add  -77e-19      10   ->  10.00000000000000 Inexact Rounded
ddadd6476 add  -77e-99      10   ->  10.00000000000000 Inexact Rounded

-- negative ulps
ddadd6480 add  -1    77e-14      ->  -0.99999999999923
ddadd6481 add  -1    77e-15      ->  -0.999999999999923
ddadd6482 add  -1    77e-16      ->  -0.9999999999999923
ddadd6483 add  -1    77e-17      ->  -0.9999999999999992 Inexact Rounded
ddadd6484 add  -1    77e-18      ->  -0.9999999999999999 Inexact Rounded
ddadd6485 add  -1    77e-19      ->  -1.000000000000000 Inexact Rounded
ddadd6486 add  -1    77e-99      ->  -1.000000000000000 Inexact Rounded

ddadd6490 add -10    77e-14      ->   -9.99999999999923
ddadd6491 add -10    77e-15      ->   -9.999999999999923
ddadd6492 add -10    77e-16      ->   -9.999999999999992 Inexact Rounded
ddadd6493 add -10    77e-17      ->   -9.999999999999999 Inexact Rounded
ddadd6494 add -10    77e-18      ->  -10.00000000000000 Inexact Rounded
ddadd6495 add -10    77e-19      ->  -10.00000000000000 Inexact Rounded
ddadd6496 add -10    77e-99      ->  -10.00000000000000 Inexact Rounded

ddadd6500 add   77e-14      -1   ->  -0.99999999999923
ddadd6501 add   77e-15      -1   ->  -0.999999999999923
ddadd6502 add   77e-16      -1   ->  -0.9999999999999923
ddadd6503 add   77e-17      -1   ->  -0.9999999999999992 Inexact Rounded
ddadd6504 add   77e-18      -1   ->  -0.9999999999999999 Inexact Rounded
ddadd6505 add   77e-19      -1   ->  -1.000000000000000 Inexact Rounded
ddadd6506 add   77e-99      -1   ->  -1.000000000000000 Inexact Rounded

ddadd6510 add   77e-14      -10  ->   -9.99999999999923
ddadd6511 add   77e-15      -10  ->   -9.999999999999923
ddadd6512 add   77e-16      -10  ->   -9.999999999999992 Inexact Rounded
ddadd6513 add   77e-17      -10  ->   -9.999999999999999 Inexact Rounded
ddadd6514 add   77e-18      -10  ->  -10.00000000000000 Inexact Rounded
ddadd6515 add   77e-19      -10  ->  -10.00000000000000 Inexact Rounded
ddadd6516 add   77e-99      -10  ->  -10.00000000000000 Inexact Rounded

-- and some more residue effects and different roundings
rounding: half_up
ddadd6540 add '6543210123456789' 0             -> '6543210123456789'
ddadd6541 add '6543210123456789' 0.000000001   -> '6543210123456789' Inexact Rounded
ddadd6542 add '6543210123456789' 0.000001      -> '6543210123456789' Inexact Rounded
ddadd6543 add '6543210123456789' 0.1           -> '6543210123456789' Inexact Rounded
ddadd6544 add '6543210123456789' 0.4           -> '6543210123456789' Inexact Rounded
ddadd6545 add '6543210123456789' 0.49          -> '6543210123456789' Inexact Rounded
ddadd6546 add '6543210123456789' 0.499999      -> '6543210123456789' Inexact Rounded
ddadd6547 add '6543210123456789' 0.499999999   -> '6543210123456789' Inexact Rounded
ddadd6548 add '6543210123456789' 0.5           -> '6543210123456790' Inexact Rounded
ddadd6549 add '6543210123456789' 0.500000001   -> '6543210123456790' Inexact Rounded
ddadd6550 add '6543210123456789' 0.500001      -> '6543210123456790' Inexact Rounded
ddadd6551 add '6543210123456789' 0.51          -> '6543210123456790' Inexact Rounded
ddadd6552 add '6543210123456789' 0.6           -> '6543210123456790' Inexact Rounded
ddadd6553 add '6543210123456789' 0.9           -> '6543210123456790' Inexact Rounded
ddadd6554 add '6543210123456789' 0.99999       -> '6543210123456790' Inexact Rounded
ddadd6555 add '6543210123456789' 0.999999999   -> '6543210123456790' Inexact Rounded
ddadd6556 add '6543210123456789' 1             -> '6543210123456790'
ddadd6557 add '6543210123456789' 1.000000001   -> '6543210123456790' Inexact Rounded
ddadd6558 add '6543210123456789' 1.00001       -> '6543210123456790' Inexact Rounded
ddadd6559 add '6543210123456789' 1.1           -> '6543210123456790' Inexact Rounded

rounding: half_even
ddadd6560 add '6543210123456789' 0             -> '6543210123456789'
ddadd6561 add '6543210123456789' 0.000000001   -> '6543210123456789' Inexact Rounded
ddadd6562 add '6543210123456789' 0.000001      -> '6543210123456789' Inexact Rounded
ddadd6563 add '6543210123456789' 0.1           -> '6543210123456789' Inexact Rounded
ddadd6564 add '6543210123456789' 0.4           -> '6543210123456789' Inexact Rounded
ddadd6565 add '6543210123456789' 0.49          -> '6543210123456789' Inexact Rounded
ddadd6566 add '6543210123456789' 0.499999      -> '6543210123456789' Inexact Rounded
ddadd6567 add '6543210123456789' 0.499999999   -> '6543210123456789' Inexact Rounded
ddadd6568 add '6543210123456789' 0.5           -> '6543210123456790' Inexact Rounded
ddadd6569 add '6543210123456789' 0.500000001   -> '6543210123456790' Inexact Rounded
ddadd6570 add '6543210123456789' 0.500001      -> '6543210123456790' Inexact Rounded
ddadd6571 add '6543210123456789' 0.51          -> '6543210123456790' Inexact Rounded
ddadd6572 add '6543210123456789' 0.6           -> '6543210123456790' Inexact Rounded
ddadd6573 add '6543210123456789' 0.9           -> '6543210123456790' Inexact Rounded
ddadd6574 add '6543210123456789' 0.99999       -> '6543210123456790' Inexact Rounded
ddadd6575 add '6543210123456789' 0.999999999   -> '6543210123456790' Inexact Rounded
ddadd6576 add '6543210123456789' 1             -> '6543210123456790'
ddadd6577 add '6543210123456789' 1.00000001    -> '6543210123456790' Inexact Rounded
ddadd6578 add '6543210123456789' 1.00001       -> '6543210123456790' Inexact Rounded
ddadd6579 add '6543210123456789' 1.1           -> '6543210123456790' Inexact Rounded

-- critical few with even bottom digit...
ddadd7540 add '6543210123456788' 0.499999999   -> '6543210123456788' Inexact Rounded
ddadd7541 add '6543210123456788' 0.5           -> '6543210123456788' Inexact Rounded
ddadd7542 add '6543210123456788' 0.500000001   -> '6543210123456789' Inexact Rounded

rounding: down
ddadd7550 add '6543210123456789' 0             -> '6543210123456789'
ddadd7551 add '6543210123456789' 0.000000001   -> '6543210123456789' Inexact Rounded
ddadd7552 add '6543210123456789' 0.000001      -> '6543210123456789' Inexact Rounded
ddadd7553 add '6543210123456789' 0.1           -> '6543210123456789' Inexact Rounded
ddadd7554 add '6543210123456789' 0.4           -> '6543210123456789' Inexact Rounded
ddadd7555 add '6543210123456789' 0.49          -> '6543210123456789' Inexact Rounded
ddadd7556 add '6543210123456789' 0.499999      -> '6543210123456789' Inexact Rounded
ddadd7557 add '6543210123456789' 0.499999999   -> '6543210123456789' Inexact Rounded
ddadd7558 add '6543210123456789' 0.5           -> '6543210123456789' Inexact Rounded
ddadd7559 add '6543210123456789' 0.500000001   -> '6543210123456789' Inexact Rounded
ddadd7560 add '6543210123456789' 0.500001      -> '6543210123456789' Inexact Rounded
ddadd7561 add '6543210123456789' 0.51          -> '6543210123456789' Inexact Rounded
ddadd7562 add '6543210123456789' 0.6           -> '6543210123456789' Inexact Rounded
ddadd7563 add '6543210123456789' 0.9           -> '6543210123456789' Inexact Rounded
ddadd7564 add '6543210123456789' 0.99999       -> '6543210123456789' Inexact Rounded
ddadd7565 add '6543210123456789' 0.999999999   -> '6543210123456789' Inexact Rounded
ddadd7566 add '6543210123456789' 1             -> '6543210123456790'
ddadd7567 add '6543210123456789' 1.00000001    -> '6543210123456790' Inexact Rounded
ddadd7568 add '6543210123456789' 1.00001       -> '6543210123456790' Inexact Rounded
ddadd7569 add '6543210123456789' 1.1           -> '6543210123456790' Inexact Rounded

-- verify a query
rounding:     down
ddadd7661 add 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
ddadd7662 add      0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
ddadd7663 add 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
ddadd7664 add      0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded

-- more zeros, etc.
rounding: half_even

ddadd7701 add 5.00 1.00E-3 -> 5.00100
ddadd7702 add 00.00 0.000  -> 0.000
ddadd7703 add 00.00 0E-3   -> 0.000
ddadd7704 add 0E-3  00.00  -> 0.000

ddadd7710 add 0E+3  00.00  -> 0.00
ddadd7711 add 0E+3  00.0   -> 0.0
ddadd7712 add 0E+3  00.    -> 0
ddadd7713 add 0E+3  00.E+1 -> 0E+1
ddadd7714 add 0E+3  00.E+2 -> 0E+2
ddadd7715 add 0E+3  00.E+3 -> 0E+3
ddadd7716 add 0E+3  00.E+4 -> 0E+3
ddadd7717 add 0E+3  00.E+5 -> 0E+3
ddadd7718 add 0E+3  -00.0   -> 0.0
ddadd7719 add 0E+3  -00.    -> 0
ddadd7731 add 0E+3  -00.E+1 -> 0E+1

ddadd7720 add 00.00  0E+3  -> 0.00
ddadd7721 add 00.0   0E+3  -> 0.0
ddadd7722 add 00.    0E+3  -> 0
ddadd7723 add 00.E+1 0E+3  -> 0E+1
ddadd7724 add 00.E+2 0E+3  -> 0E+2
ddadd7725 add 00.E+3 0E+3  -> 0E+3
ddadd7726 add 00.E+4 0E+3  -> 0E+3
ddadd7727 add 00.E+5 0E+3  -> 0E+3
ddadd7728 add -00.00 0E+3  -> 0.00
ddadd7729 add -00.0  0E+3  -> 0.0
ddadd7730 add -00.   0E+3  -> 0

ddadd7732 add  0     0     ->  0
ddadd7733 add  0    -0     ->  0
ddadd7734 add -0     0     ->  0
ddadd7735 add -0    -0     -> -0     -- IEEE 854 special case

ddadd7736 add  1    -1     ->  0
ddadd7737 add -1    -1     -> -2
ddadd7738 add  1     1     ->  2
ddadd7739 add -1     1     ->  0

ddadd7741 add  0    -1     -> -1
ddadd7742 add -0    -1     -> -1
ddadd7743 add  0     1     ->  1
ddadd7744 add -0     1     ->  1
ddadd7745 add -1     0     -> -1
ddadd7746 add -1    -0     -> -1
ddadd7747 add  1     0     ->  1
ddadd7748 add  1    -0     ->  1

ddadd7751 add  0.0  -1     -> -1.0
ddadd7752 add -0.0  -1     -> -1.0
ddadd7753 add  0.0   1     ->  1.0
ddadd7754 add -0.0   1     ->  1.0
ddadd7755 add -1.0   0     -> -1.0
ddadd7756 add -1.0  -0     -> -1.0
ddadd7757 add  1.0   0     ->  1.0
ddadd7758 add  1.0  -0     ->  1.0

ddadd7761 add  0    -1.0   -> -1.0
ddadd7762 add -0    -1.0   -> -1.0
ddadd7763 add  0     1.0   ->  1.0
ddadd7764 add -0     1.0   ->  1.0
ddadd7765 add -1     0.0   -> -1.0
ddadd7766 add -1    -0.0   -> -1.0
ddadd7767 add  1     0.0   ->  1.0
ddadd7768 add  1    -0.0   ->  1.0

ddadd7771 add  0.0  -1.0   -> -1.0
ddadd7772 add -0.0  -1.0   -> -1.0
ddadd7773 add  0.0   1.0   ->  1.0
ddadd7774 add -0.0   1.0   ->  1.0
ddadd7775 add -1.0   0.0   -> -1.0
ddadd7776 add -1.0  -0.0   -> -1.0
ddadd7777 add  1.0   0.0   ->  1.0
ddadd7778 add  1.0  -0.0   ->  1.0

-- Specials
ddadd7780 add -Inf  -Inf   -> -Infinity
ddadd7781 add -Inf  -1000  -> -Infinity
ddadd7782 add -Inf  -1     -> -Infinity
ddadd7783 add -Inf  -0     -> -Infinity
ddadd7784 add -Inf   0     -> -Infinity
ddadd7785 add -Inf   1     -> -Infinity
ddadd7786 add -Inf   1000  -> -Infinity
ddadd7787 add -1000 -Inf   -> -Infinity
ddadd7788 add -Inf  -Inf   -> -Infinity
ddadd7789 add -1    -Inf   -> -Infinity
ddadd7790 add -0    -Inf   -> -Infinity
ddadd7791 add  0    -Inf   -> -Infinity
ddadd7792 add  1    -Inf   -> -Infinity
ddadd7793 add  1000 -Inf   -> -Infinity
ddadd7794 add  Inf  -Inf   ->  NaN  Invalid_operation

ddadd7800 add  Inf  -Inf   ->  NaN  Invalid_operation
ddadd7801 add  Inf  -1000  ->  Infinity
ddadd7802 add  Inf  -1     ->  Infinity
ddadd7803 add  Inf  -0     ->  Infinity
ddadd7804 add  Inf   0     ->  Infinity
ddadd7805 add  Inf   1     ->  Infinity
ddadd7806 add  Inf   1000  ->  Infinity
ddadd7807 add  Inf   Inf   ->  Infinity
ddadd7808 add -1000  Inf   ->  Infinity
ddadd7809 add -Inf   Inf   ->  NaN  Invalid_operation
ddadd7810 add -1     Inf   ->  Infinity
ddadd7811 add -0     Inf   ->  Infinity
ddadd7812 add  0     Inf   ->  Infinity
ddadd7813 add  1     Inf   ->  Infinity
ddadd7814 add  1000  Inf   ->  Infinity
ddadd7815 add  Inf   Inf   ->  Infinity

ddadd7821 add  NaN -Inf    ->  NaN
ddadd7822 add  NaN -1000   ->  NaN
ddadd7823 add  NaN -1      ->  NaN
ddadd7824 add  NaN -0      ->  NaN
ddadd7825 add  NaN  0      ->  NaN
ddadd7826 add  NaN  1      ->  NaN
ddadd7827 add  NaN  1000   ->  NaN
ddadd7828 add  NaN  Inf    ->  NaN
ddadd7829 add  NaN  NaN    ->  NaN
ddadd7830 add -Inf  NaN    ->  NaN
ddadd7831 add -1000 NaN    ->  NaN
ddadd7832 add -1    NaN    ->  NaN
ddadd7833 add -0    NaN    ->  NaN
ddadd7834 add  0    NaN    ->  NaN
ddadd7835 add  1    NaN    ->  NaN
ddadd7836 add  1000 NaN    ->  NaN
ddadd7837 add  Inf  NaN    ->  NaN

ddadd7841 add  sNaN -Inf   ->  NaN  Invalid_operation
ddadd7842 add  sNaN -1000  ->  NaN  Invalid_operation
ddadd7843 add  sNaN -1     ->  NaN  Invalid_operation
ddadd7844 add  sNaN -0     ->  NaN  Invalid_operation
ddadd7845 add  sNaN  0     ->  NaN  Invalid_operation
ddadd7846 add  sNaN  1     ->  NaN  Invalid_operation
ddadd7847 add  sNaN  1000  ->  NaN  Invalid_operation
ddadd7848 add  sNaN  NaN   ->  NaN  Invalid_operation
ddadd7849 add  sNaN sNaN   ->  NaN  Invalid_operation
ddadd7850 add  NaN  sNaN   ->  NaN  Invalid_operation
ddadd7851 add -Inf  sNaN   ->  NaN  Invalid_operation
ddadd7852 add -1000 sNaN   ->  NaN  Invalid_operation
ddadd7853 add -1    sNaN   ->  NaN  Invalid_operation
ddadd7854 add -0    sNaN   ->  NaN  Invalid_operation
ddadd7855 add  0    sNaN   ->  NaN  Invalid_operation
ddadd7856 add  1    sNaN   ->  NaN  Invalid_operation
ddadd7857 add  1000 sNaN   ->  NaN  Invalid_operation
ddadd7858 add  Inf  sNaN   ->  NaN  Invalid_operation
ddadd7859 add  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddadd7861 add  NaN1   -Inf    ->  NaN1
ddadd7862 add +NaN2   -1000   ->  NaN2
ddadd7863 add  NaN3    1000   ->  NaN3
ddadd7864 add  NaN4    Inf    ->  NaN4
ddadd7865 add  NaN5   +NaN6   ->  NaN5
ddadd7866 add -Inf     NaN7   ->  NaN7
ddadd7867 add -1000    NaN8   ->  NaN8
ddadd7868 add  1000    NaN9   ->  NaN9
ddadd7869 add  Inf    +NaN10  ->  NaN10
ddadd7871 add  sNaN11  -Inf   ->  NaN11  Invalid_operation
ddadd7872 add  sNaN12  -1000  ->  NaN12  Invalid_operation
ddadd7873 add  sNaN13   1000  ->  NaN13  Invalid_operation
ddadd7874 add  sNaN14   NaN17 ->  NaN14  Invalid_operation
ddadd7875 add  sNaN15  sNaN18 ->  NaN15  Invalid_operation
ddadd7876 add  NaN16   sNaN19 ->  NaN19  Invalid_operation
ddadd7877 add -Inf    +sNaN20 ->  NaN20  Invalid_operation
ddadd7878 add -1000    sNaN21 ->  NaN21  Invalid_operation
ddadd7879 add  1000    sNaN22 ->  NaN22  Invalid_operation
ddadd7880 add  Inf     sNaN23 ->  NaN23  Invalid_operation
ddadd7881 add +NaN25  +sNaN24 ->  NaN24  Invalid_operation
ddadd7882 add -NaN26    NaN28 -> -NaN26
ddadd7883 add -sNaN27  sNaN29 -> -NaN27  Invalid_operation
ddadd7884 add  1000    -NaN30 -> -NaN30
ddadd7885 add  1000   -sNaN31 -> -NaN31  Invalid_operation

-- Here we explore near the boundary of rounding a subnormal to Nmin
ddadd7575 add  1E-383 -1E-398 ->  9.99999999999999E-384  Subnormal
ddadd7576 add -1E-383 +1E-398 -> -9.99999999999999E-384  Subnormal

-- check overflow edge case
--               1234567890123456
ddadd7972 apply   9.999999999999999E+384         -> 9.999999999999999E+384
ddadd7973 add     9.999999999999999E+384  1      -> 9.999999999999999E+384 Inexact Rounded
ddadd7974 add      9999999999999999E+369  1      -> 9.999999999999999E+384 Inexact Rounded
ddadd7975 add      9999999999999999E+369  1E+369  -> Infinity Overflow Inexact Rounded
ddadd7976 add      9999999999999999E+369  9E+368  -> Infinity Overflow Inexact Rounded
ddadd7977 add      9999999999999999E+369  8E+368  -> Infinity Overflow Inexact Rounded
ddadd7978 add      9999999999999999E+369  7E+368  -> Infinity Overflow Inexact Rounded
ddadd7979 add      9999999999999999E+369  6E+368  -> Infinity Overflow Inexact Rounded
ddadd7980 add      9999999999999999E+369  5E+368  -> Infinity Overflow Inexact Rounded
ddadd7981 add      9999999999999999E+369  4E+368  -> 9.999999999999999E+384 Inexact Rounded
ddadd7982 add      9999999999999999E+369  3E+368  -> 9.999999999999999E+384 Inexact Rounded
ddadd7983 add      9999999999999999E+369  2E+368  -> 9.999999999999999E+384 Inexact Rounded
ddadd7984 add      9999999999999999E+369  1E+368  -> 9.999999999999999E+384 Inexact Rounded

ddadd7985 apply  -9.999999999999999E+384         -> -9.999999999999999E+384
ddadd7986 add    -9.999999999999999E+384 -1      -> -9.999999999999999E+384 Inexact Rounded
ddadd7987 add     -9999999999999999E+369 -1      -> -9.999999999999999E+384 Inexact Rounded
ddadd7988 add     -9999999999999999E+369 -1E+369  -> -Infinity Overflow Inexact Rounded
ddadd7989 add     -9999999999999999E+369 -9E+368  -> -Infinity Overflow Inexact Rounded
ddadd7990 add     -9999999999999999E+369 -8E+368  -> -Infinity Overflow Inexact Rounded
ddadd7991 add     -9999999999999999E+369 -7E+368  -> -Infinity Overflow Inexact Rounded
ddadd7992 add     -9999999999999999E+369 -6E+368  -> -Infinity Overflow Inexact Rounded
ddadd7993 add     -9999999999999999E+369 -5E+368  -> -Infinity Overflow Inexact Rounded
ddadd7994 add     -9999999999999999E+369 -4E+368  -> -9.999999999999999E+384 Inexact Rounded
ddadd7995 add     -9999999999999999E+369 -3E+368  -> -9.999999999999999E+384 Inexact Rounded
ddadd7996 add     -9999999999999999E+369 -2E+368  -> -9.999999999999999E+384 Inexact Rounded
ddadd7997 add     -9999999999999999E+369 -1E+368  -> -9.999999999999999E+384 Inexact Rounded

-- And for round down full and subnormal results
rounding:     down
ddadd71100 add 1e+2 -1e-383    -> 99.99999999999999 Rounded Inexact
ddadd71101 add 1e+1 -1e-383    -> 9.999999999999999  Rounded Inexact
ddadd71103 add   +1 -1e-383    -> 0.9999999999999999  Rounded Inexact
ddadd71104 add 1e-1 -1e-383    -> 0.09999999999999999  Rounded Inexact
ddadd71105 add 1e-2 -1e-383    -> 0.009999999999999999  Rounded Inexact
ddadd71106 add 1e-3 -1e-383    -> 0.0009999999999999999  Rounded Inexact
ddadd71107 add 1e-4 -1e-383    -> 0.00009999999999999999  Rounded Inexact
ddadd71108 add 1e-5 -1e-383    -> 0.000009999999999999999  Rounded Inexact
ddadd71109 add 1e-6 -1e-383    -> 9.999999999999999E-7  Rounded Inexact

rounding:     ceiling
ddadd71110 add -1e+2 +1e-383   -> -99.99999999999999 Rounded Inexact
ddadd71111 add -1e+1 +1e-383   -> -9.999999999999999  Rounded Inexact
ddadd71113 add    -1 +1e-383   -> -0.9999999999999999  Rounded Inexact
ddadd71114 add -1e-1 +1e-383   -> -0.09999999999999999  Rounded Inexact
ddadd71115 add -1e-2 +1e-383   -> -0.009999999999999999  Rounded Inexact
ddadd71116 add -1e-3 +1e-383   -> -0.0009999999999999999  Rounded Inexact
ddadd71117 add -1e-4 +1e-383   -> -0.00009999999999999999  Rounded Inexact
ddadd71118 add -1e-5 +1e-383   -> -0.000009999999999999999  Rounded Inexact
ddadd71119 add -1e-6 +1e-383   -> -9.999999999999999E-7  Rounded Inexact

-- tests based on Gunnar Degnbol's edge case
rounding:     half_even

ddadd71300 add 1E16  -0.5                 ->  1.000000000000000E+16 Inexact Rounded
ddadd71310 add 1E16  -0.51                ->  9999999999999999      Inexact Rounded
ddadd71311 add 1E16  -0.501               ->  9999999999999999      Inexact Rounded
ddadd71312 add 1E16  -0.5001              ->  9999999999999999      Inexact Rounded
ddadd71313 add 1E16  -0.50001             ->  9999999999999999      Inexact Rounded
ddadd71314 add 1E16  -0.500001            ->  9999999999999999      Inexact Rounded
ddadd71315 add 1E16  -0.5000001           ->  9999999999999999      Inexact Rounded
ddadd71316 add 1E16  -0.50000001          ->  9999999999999999      Inexact Rounded
ddadd71317 add 1E16  -0.500000001         ->  9999999999999999      Inexact Rounded
ddadd71318 add 1E16  -0.5000000001        ->  9999999999999999      Inexact Rounded
ddadd71319 add 1E16  -0.50000000001       ->  9999999999999999      Inexact Rounded
ddadd71320 add 1E16  -0.500000000001      ->  9999999999999999      Inexact Rounded
ddadd71321 add 1E16  -0.5000000000001     ->  9999999999999999      Inexact Rounded
ddadd71322 add 1E16  -0.50000000000001    ->  9999999999999999      Inexact Rounded
ddadd71323 add 1E16  -0.500000000000001   ->  9999999999999999      Inexact Rounded
ddadd71324 add 1E16  -0.5000000000000001  ->  9999999999999999      Inexact Rounded
ddadd71325 add 1E16  -0.5000000000000000  ->  1.000000000000000E+16 Inexact Rounded
ddadd71326 add 1E16  -0.500000000000000   ->  1.000000000000000E+16 Inexact Rounded
ddadd71327 add 1E16  -0.50000000000000    ->  1.000000000000000E+16 Inexact Rounded
ddadd71328 add 1E16  -0.5000000000000     ->  1.000000000000000E+16 Inexact Rounded
ddadd71329 add 1E16  -0.500000000000      ->  1.000000000000000E+16 Inexact Rounded
ddadd71330 add 1E16  -0.50000000000       ->  1.000000000000000E+16 Inexact Rounded
ddadd71331 add 1E16  -0.5000000000        ->  1.000000000000000E+16 Inexact Rounded
ddadd71332 add 1E16  -0.500000000         ->  1.000000000000000E+16 Inexact Rounded
ddadd71333 add 1E16  -0.50000000          ->  1.000000000000000E+16 Inexact Rounded
ddadd71334 add 1E16  -0.5000000           ->  1.000000000000000E+16 Inexact Rounded
ddadd71335 add 1E16  -0.500000            ->  1.000000000000000E+16 Inexact Rounded
ddadd71336 add 1E16  -0.50000             ->  1.000000000000000E+16 Inexact Rounded
ddadd71337 add 1E16  -0.5000              ->  1.000000000000000E+16 Inexact Rounded
ddadd71338 add 1E16  -0.500               ->  1.000000000000000E+16 Inexact Rounded
ddadd71339 add 1E16  -0.50                ->  1.000000000000000E+16 Inexact Rounded

ddadd71340 add 1E16  -5000000.000010001   ->  9999999995000000      Inexact Rounded
ddadd71341 add 1E16  -5000000.000000001   ->  9999999995000000      Inexact Rounded

ddadd71349 add 9999999999999999 0.4                 ->  9999999999999999      Inexact Rounded
ddadd71350 add 9999999999999999 0.49                ->  9999999999999999      Inexact Rounded
ddadd71351 add 9999999999999999 0.499               ->  9999999999999999      Inexact Rounded
ddadd71352 add 9999999999999999 0.4999              ->  9999999999999999      Inexact Rounded
ddadd71353 add 9999999999999999 0.49999             ->  9999999999999999      Inexact Rounded
ddadd71354 add 9999999999999999 0.499999            ->  9999999999999999      Inexact Rounded
ddadd71355 add 9999999999999999 0.4999999           ->  9999999999999999      Inexact Rounded
ddadd71356 add 9999999999999999 0.49999999          ->  9999999999999999      Inexact Rounded
ddadd71357 add 9999999999999999 0.499999999         ->  9999999999999999      Inexact Rounded
ddadd71358 add 9999999999999999 0.4999999999        ->  9999999999999999      Inexact Rounded
ddadd71359 add 9999999999999999 0.49999999999       ->  9999999999999999      Inexact Rounded
ddadd71360 add 9999999999999999 0.499999999999      ->  9999999999999999      Inexact Rounded
ddadd71361 add 9999999999999999 0.4999999999999     ->  9999999999999999      Inexact Rounded
ddadd71362 add 9999999999999999 0.49999999999999    ->  9999999999999999      Inexact Rounded
ddadd71363 add 9999999999999999 0.499999999999999   ->  9999999999999999      Inexact Rounded
ddadd71364 add 9999999999999999 0.4999999999999999  ->  9999999999999999      Inexact Rounded
ddadd71365 add 9999999999999999 0.5000000000000000  ->  1.000000000000000E+16 Inexact Rounded
ddadd71367 add 9999999999999999 0.500000000000000   ->  1.000000000000000E+16 Inexact Rounded
ddadd71368 add 9999999999999999 0.50000000000000    ->  1.000000000000000E+16 Inexact Rounded
ddadd71369 add 9999999999999999 0.5000000000000     ->  1.000000000000000E+16 Inexact Rounded
ddadd71370 add 9999999999999999 0.500000000000      ->  1.000000000000000E+16 Inexact Rounded
ddadd71371 add 9999999999999999 0.50000000000       ->  1.000000000000000E+16 Inexact Rounded
ddadd71372 add 9999999999999999 0.5000000000        ->  1.000000000000000E+16 Inexact Rounded
ddadd71373 add 9999999999999999 0.500000000         ->  1.000000000000000E+16 Inexact Rounded
ddadd71374 add 9999999999999999 0.50000000          ->  1.000000000000000E+16 Inexact Rounded
ddadd71375 add 9999999999999999 0.5000000           ->  1.000000000000000E+16 Inexact Rounded
ddadd71376 add 9999999999999999 0.500000            ->  1.000000000000000E+16 Inexact Rounded
ddadd71377 add 9999999999999999 0.50000             ->  1.000000000000000E+16 Inexact Rounded
ddadd71378 add 9999999999999999 0.5000              ->  1.000000000000000E+16 Inexact Rounded
ddadd71379 add 9999999999999999 0.500               ->  1.000000000000000E+16 Inexact Rounded
ddadd71380 add 9999999999999999 0.50                ->  1.000000000000000E+16 Inexact Rounded
ddadd71381 add 9999999999999999 0.5                 ->  1.000000000000000E+16 Inexact Rounded
ddadd71382 add 9999999999999999 0.5000000000000001  ->  1.000000000000000E+16 Inexact Rounded
ddadd71383 add 9999999999999999 0.500000000000001   ->  1.000000000000000E+16 Inexact Rounded
ddadd71384 add 9999999999999999 0.50000000000001    ->  1.000000000000000E+16 Inexact Rounded
ddadd71385 add 9999999999999999 0.5000000000001     ->  1.000000000000000E+16 Inexact Rounded
ddadd71386 add 9999999999999999 0.500000000001      ->  1.000000000000000E+16 Inexact Rounded
ddadd71387 add 9999999999999999 0.50000000001       ->  1.000000000000000E+16 Inexact Rounded
ddadd71388 add 9999999999999999 0.5000000001        ->  1.000000000000000E+16 Inexact Rounded
ddadd71389 add 9999999999999999 0.500000001         ->  1.000000000000000E+16 Inexact Rounded
ddadd71390 add 9999999999999999 0.50000001          ->  1.000000000000000E+16 Inexact Rounded
ddadd71391 add 9999999999999999 0.5000001           ->  1.000000000000000E+16 Inexact Rounded
ddadd71392 add 9999999999999999 0.500001            ->  1.000000000000000E+16 Inexact Rounded
ddadd71393 add 9999999999999999 0.50001             ->  1.000000000000000E+16 Inexact Rounded
ddadd71394 add 9999999999999999 0.5001              ->  1.000000000000000E+16 Inexact Rounded
ddadd71395 add 9999999999999999 0.501               ->  1.000000000000000E+16 Inexact Rounded
ddadd71396 add 9999999999999999 0.51                ->  1.000000000000000E+16 Inexact Rounded

-- More GD edge cases, where difference between the unadjusted
-- exponents is larger than the maximum precision and one side is 0
ddadd71420 add  0 1.123456789012345     -> 1.123456789012345
ddadd71421 add  0 1.123456789012345E-1  -> 0.1123456789012345
ddadd71422 add  0 1.123456789012345E-2  -> 0.01123456789012345
ddadd71423 add  0 1.123456789012345E-3  -> 0.001123456789012345
ddadd71424 add  0 1.123456789012345E-4  -> 0.0001123456789012345
ddadd71425 add  0 1.123456789012345E-5  -> 0.00001123456789012345
ddadd71426 add  0 1.123456789012345E-6  -> 0.000001123456789012345
ddadd71427 add  0 1.123456789012345E-7  -> 1.123456789012345E-7
ddadd71428 add  0 1.123456789012345E-8  -> 1.123456789012345E-8
ddadd71429 add  0 1.123456789012345E-9  -> 1.123456789012345E-9
ddadd71430 add  0 1.123456789012345E-10 -> 1.123456789012345E-10
ddadd71431 add  0 1.123456789012345E-11 -> 1.123456789012345E-11
ddadd71432 add  0 1.123456789012345E-12 -> 1.123456789012345E-12
ddadd71433 add  0 1.123456789012345E-13 -> 1.123456789012345E-13
ddadd71434 add  0 1.123456789012345E-14 -> 1.123456789012345E-14
ddadd71435 add  0 1.123456789012345E-15 -> 1.123456789012345E-15
ddadd71436 add  0 1.123456789012345E-16 -> 1.123456789012345E-16
ddadd71437 add  0 1.123456789012345E-17 -> 1.123456789012345E-17
ddadd71438 add  0 1.123456789012345E-18 -> 1.123456789012345E-18
ddadd71439 add  0 1.123456789012345E-19 -> 1.123456789012345E-19

-- same, reversed 0
ddadd71440 add 1.123456789012345     0 -> 1.123456789012345
ddadd71441 add 1.123456789012345E-1  0 -> 0.1123456789012345
ddadd71442 add 1.123456789012345E-2  0 -> 0.01123456789012345
ddadd71443 add 1.123456789012345E-3  0 -> 0.001123456789012345
ddadd71444 add 1.123456789012345E-4  0 -> 0.0001123456789012345
ddadd71445 add 1.123456789012345E-5  0 -> 0.00001123456789012345
ddadd71446 add 1.123456789012345E-6  0 -> 0.000001123456789012345
ddadd71447 add 1.123456789012345E-7  0 -> 1.123456789012345E-7
ddadd71448 add 1.123456789012345E-8  0 -> 1.123456789012345E-8
ddadd71449 add 1.123456789012345E-9  0 -> 1.123456789012345E-9
ddadd71450 add 1.123456789012345E-10 0 -> 1.123456789012345E-10
ddadd71451 add 1.123456789012345E-11 0 -> 1.123456789012345E-11
ddadd71452 add 1.123456789012345E-12 0 -> 1.123456789012345E-12
ddadd71453 add 1.123456789012345E-13 0 -> 1.123456789012345E-13
ddadd71454 add 1.123456789012345E-14 0 -> 1.123456789012345E-14
ddadd71455 add 1.123456789012345E-15 0 -> 1.123456789012345E-15
ddadd71456 add 1.123456789012345E-16 0 -> 1.123456789012345E-16
ddadd71457 add 1.123456789012345E-17 0 -> 1.123456789012345E-17
ddadd71458 add 1.123456789012345E-18 0 -> 1.123456789012345E-18
ddadd71459 add 1.123456789012345E-19 0 -> 1.123456789012345E-19

-- same, Es on the 0
ddadd71460 add 1.123456789012345  0E-0   -> 1.123456789012345
ddadd71461 add 1.123456789012345  0E-1   -> 1.123456789012345
ddadd71462 add 1.123456789012345  0E-2   -> 1.123456789012345
ddadd71463 add 1.123456789012345  0E-3   -> 1.123456789012345
ddadd71464 add 1.123456789012345  0E-4   -> 1.123456789012345
ddadd71465 add 1.123456789012345  0E-5   -> 1.123456789012345
ddadd71466 add 1.123456789012345  0E-6   -> 1.123456789012345
ddadd71467 add 1.123456789012345  0E-7   -> 1.123456789012345
ddadd71468 add 1.123456789012345  0E-8   -> 1.123456789012345
ddadd71469 add 1.123456789012345  0E-9   -> 1.123456789012345
ddadd71470 add 1.123456789012345  0E-10  -> 1.123456789012345
ddadd71471 add 1.123456789012345  0E-11  -> 1.123456789012345
ddadd71472 add 1.123456789012345  0E-12  -> 1.123456789012345
ddadd71473 add 1.123456789012345  0E-13  -> 1.123456789012345
ddadd71474 add 1.123456789012345  0E-14  -> 1.123456789012345
ddadd71475 add 1.123456789012345  0E-15  -> 1.123456789012345
-- next four flag Rounded because the 0 extends the result
ddadd71476 add 1.123456789012345  0E-16  -> 1.123456789012345 Rounded
ddadd71477 add 1.123456789012345  0E-17  -> 1.123456789012345 Rounded
ddadd71478 add 1.123456789012345  0E-18  -> 1.123456789012345 Rounded
ddadd71479 add 1.123456789012345  0E-19  -> 1.123456789012345 Rounded

-- sum of two opposite-sign operands is exactly 0 and floor => -0
rounding:    half_up
-- exact zeros from zeros
ddadd71500 add  0        0E-19  ->  0E-19
ddadd71501 add -0        0E-19  ->  0E-19
ddadd71502 add  0       -0E-19  ->  0E-19
ddadd71503 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddadd71511 add -11      11    ->  0
ddadd71512 add  11     -11    ->  0

rounding:    half_down
-- exact zeros from zeros
ddadd71520 add  0        0E-19  ->  0E-19
ddadd71521 add -0        0E-19  ->  0E-19
ddadd71522 add  0       -0E-19  ->  0E-19
ddadd71523 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddadd71531 add -11      11    ->  0
ddadd71532 add  11     -11    ->  0

rounding:    half_even
-- exact zeros from zeros
ddadd71540 add  0        0E-19  ->  0E-19
ddadd71541 add -0        0E-19  ->  0E-19
ddadd71542 add  0       -0E-19  ->  0E-19
ddadd71543 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddadd71551 add -11      11    ->  0
ddadd71552 add  11     -11    ->  0

rounding:    up
-- exact zeros from zeros
ddadd71560 add  0        0E-19  ->  0E-19
ddadd71561 add -0        0E-19  ->  0E-19
ddadd71562 add  0       -0E-19  ->  0E-19
ddadd71563 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddadd71571 add -11      11    ->  0
ddadd71572 add  11     -11    ->  0

rounding:    down
-- exact zeros from zeros
ddadd71580 add  0        0E-19  ->  0E-19
ddadd71581 add -0        0E-19  ->  0E-19
ddadd71582 add  0       -0E-19  ->  0E-19
ddadd71583 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddadd71591 add -11      11    ->  0
ddadd71592 add  11     -11    ->  0

rounding:    ceiling
-- exact zeros from zeros
ddadd71600 add  0        0E-19  ->  0E-19
ddadd71601 add -0        0E-19  ->  0E-19
ddadd71602 add  0       -0E-19  ->  0E-19
ddadd71603 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddadd71611 add -11      11    ->  0
ddadd71612 add  11     -11    ->  0

-- and the extra-special ugly case; unusual minuses marked by -- *
rounding:    floor
-- exact zeros from zeros
ddadd71620 add  0        0E-19  ->  0E-19
ddadd71621 add -0        0E-19  -> -0E-19           -- *
ddadd71622 add  0       -0E-19  -> -0E-19           -- *
ddadd71623 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddadd71631 add -11      11    ->  -0                -- *
ddadd71632 add  11     -11    ->  -0                -- *

-- Examples from SQL proposal (Krishna Kulkarni)
ddadd71701 add 130E-2    120E-2    -> 2.50
ddadd71702 add 130E-2    12E-1     -> 2.50
ddadd71703 add 130E-2    1E0       -> 2.30
ddadd71704 add 1E2       1E4       -> 1.01E+4
ddadd71705 add 130E-2   -120E-2 -> 0.10
ddadd71706 add 130E-2   -12E-1  -> 0.10
ddadd71707 add 130E-2   -1E0    -> 0.30
ddadd71708 add 1E2      -1E4    -> -9.9E+3

-- Gappy coefficients; check residue handling even with full coefficient gap
rounding: half_even

ddadd75001 add 1234567890123456 1      -> 1234567890123457
ddadd75002 add 1234567890123456 0.6    -> 1234567890123457  Inexact Rounded
ddadd75003 add 1234567890123456 0.06   -> 1234567890123456  Inexact Rounded
ddadd75004 add 1234567890123456 6E-3   -> 1234567890123456  Inexact Rounded
ddadd75005 add 1234567890123456 6E-4   -> 1234567890123456  Inexact Rounded
ddadd75006 add 1234567890123456 6E-5   -> 1234567890123456  Inexact Rounded
ddadd75007 add 1234567890123456 6E-6   -> 1234567890123456  Inexact Rounded
ddadd75008 add 1234567890123456 6E-7   -> 1234567890123456  Inexact Rounded
ddadd75009 add 1234567890123456 6E-8   -> 1234567890123456  Inexact Rounded
ddadd75010 add 1234567890123456 6E-9   -> 1234567890123456  Inexact Rounded
ddadd75011 add 1234567890123456 6E-10  -> 1234567890123456  Inexact Rounded
ddadd75012 add 1234567890123456 6E-11  -> 1234567890123456  Inexact Rounded
ddadd75013 add 1234567890123456 6E-12  -> 1234567890123456  Inexact Rounded
ddadd75014 add 1234567890123456 6E-13  -> 1234567890123456  Inexact Rounded
ddadd75015 add 1234567890123456 6E-14  -> 1234567890123456  Inexact Rounded
ddadd75016 add 1234567890123456 6E-15  -> 1234567890123456  Inexact Rounded
ddadd75017 add 1234567890123456 6E-16  -> 1234567890123456  Inexact Rounded
ddadd75018 add 1234567890123456 6E-17  -> 1234567890123456  Inexact Rounded
ddadd75019 add 1234567890123456 6E-18  -> 1234567890123456  Inexact Rounded
ddadd75020 add 1234567890123456 6E-19  -> 1234567890123456  Inexact Rounded
ddadd75021 add 1234567890123456 6E-20  -> 1234567890123456  Inexact Rounded

-- widening second argument at gap
ddadd75030 add 12345678 1                       -> 12345679
ddadd75031 add 12345678 0.1                     -> 12345678.1
ddadd75032 add 12345678 0.12                    -> 12345678.12
ddadd75033 add 12345678 0.123                   -> 12345678.123
ddadd75034 add 12345678 0.1234                  -> 12345678.1234
ddadd75035 add 12345678 0.12345                 -> 12345678.12345
ddadd75036 add 12345678 0.123456                -> 12345678.123456
ddadd75037 add 12345678 0.1234567               -> 12345678.1234567
ddadd75038 add 12345678 0.12345678              -> 12345678.12345678
ddadd75039 add 12345678 0.123456789             -> 12345678.12345679 Inexact Rounded
ddadd75040 add 12345678 0.123456785             -> 12345678.12345678 Inexact Rounded
ddadd75041 add 12345678 0.1234567850            -> 12345678.12345678 Inexact Rounded
ddadd75042 add 12345678 0.1234567851            -> 12345678.12345679 Inexact Rounded
ddadd75043 add 12345678 0.12345678501           -> 12345678.12345679 Inexact Rounded
ddadd75044 add 12345678 0.123456785001          -> 12345678.12345679 Inexact Rounded
ddadd75045 add 12345678 0.1234567850001         -> 12345678.12345679 Inexact Rounded
ddadd75046 add 12345678 0.12345678500001        -> 12345678.12345679 Inexact Rounded
ddadd75047 add 12345678 0.123456785000001       -> 12345678.12345679 Inexact Rounded
ddadd75048 add 12345678 0.1234567850000001      -> 12345678.12345679 Inexact Rounded
ddadd75049 add 12345678 0.1234567850000000      -> 12345678.12345678 Inexact Rounded
--                               90123456
rounding: half_even
ddadd75050 add 12345678 0.0234567750000000      -> 12345678.02345678 Inexact Rounded
ddadd75051 add 12345678 0.0034567750000000      -> 12345678.00345678 Inexact Rounded
ddadd75052 add 12345678 0.0004567750000000      -> 12345678.00045678 Inexact Rounded
ddadd75053 add 12345678 0.0000567750000000      -> 12345678.00005678 Inexact Rounded
ddadd75054 add 12345678 0.0000067750000000      -> 12345678.00000678 Inexact Rounded
ddadd75055 add 12345678 0.0000007750000000      -> 12345678.00000078 Inexact Rounded
ddadd75056 add 12345678 0.0000000750000000      -> 12345678.00000008 Inexact Rounded
ddadd75057 add 12345678 0.0000000050000000      -> 12345678.00000000 Inexact Rounded
ddadd75060 add 12345678 0.0234567750000001      -> 12345678.02345678 Inexact Rounded
ddadd75061 add 12345678 0.0034567750000001      -> 12345678.00345678 Inexact Rounded
ddadd75062 add 12345678 0.0004567750000001      -> 12345678.00045678 Inexact Rounded
ddadd75063 add 12345678 0.0000567750000001      -> 12345678.00005678 Inexact Rounded
ddadd75064 add 12345678 0.0000067750000001      -> 12345678.00000678 Inexact Rounded
ddadd75065 add 12345678 0.0000007750000001      -> 12345678.00000078 Inexact Rounded
ddadd75066 add 12345678 0.0000000750000001      -> 12345678.00000008 Inexact Rounded
ddadd75067 add 12345678 0.0000000050000001      -> 12345678.00000001 Inexact Rounded
-- far-out residues (full coefficient gap is 16+15 digits)
rounding: up
ddadd75070 add 12345678 1E-8                    -> 12345678.00000001
ddadd75071 add 12345678 1E-9                    -> 12345678.00000001 Inexact Rounded
ddadd75072 add 12345678 1E-10                   -> 12345678.00000001 Inexact Rounded
ddadd75073 add 12345678 1E-11                   -> 12345678.00000001 Inexact Rounded
ddadd75074 add 12345678 1E-12                   -> 12345678.00000001 Inexact Rounded
ddadd75075 add 12345678 1E-13                   -> 12345678.00000001 Inexact Rounded
ddadd75076 add 12345678 1E-14                   -> 12345678.00000001 Inexact Rounded
ddadd75077 add 12345678 1E-15                   -> 12345678.00000001 Inexact Rounded
ddadd75078 add 12345678 1E-16                   -> 12345678.00000001 Inexact Rounded
ddadd75079 add 12345678 1E-17                   -> 12345678.00000001 Inexact Rounded
ddadd75080 add 12345678 1E-18                   -> 12345678.00000001 Inexact Rounded
ddadd75081 add 12345678 1E-19                   -> 12345678.00000001 Inexact Rounded
ddadd75082 add 12345678 1E-20                   -> 12345678.00000001 Inexact Rounded
ddadd75083 add 12345678 1E-25                   -> 12345678.00000001 Inexact Rounded
ddadd75084 add 12345678 1E-30                   -> 12345678.00000001 Inexact Rounded
ddadd75085 add 12345678 1E-31                   -> 12345678.00000001 Inexact Rounded
ddadd75086 add 12345678 1E-32                   -> 12345678.00000001 Inexact Rounded
ddadd75087 add 12345678 1E-33                   -> 12345678.00000001 Inexact Rounded
ddadd75088 add 12345678 1E-34                   -> 12345678.00000001 Inexact Rounded
ddadd75089 add 12345678 1E-35                   -> 12345678.00000001 Inexact Rounded

-- Punit's
ddadd75100 add 1.000 -200.000                   -> -199.000

-- Rounding swathe
rounding: half_even
ddadd81100 add  .2300    12345678901234.00    ->  12345678901234.23  Rounded
ddadd81101 add  .2301    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81102 add  .2310    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81103 add  .2350    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81104 add  .2351    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81105 add  .2450    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81106 add  .2451    12345678901234.00    ->  12345678901234.25  Inexact Rounded
ddadd81107 add  .2360    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81108 add  .2370    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81109 add  .2399    12345678901234.00    ->  12345678901234.24  Inexact Rounded

rounding: half_up
ddadd81200 add  .2300    12345678901234.00    ->  12345678901234.23  Rounded
ddadd81201 add  .2301    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81202 add  .2310    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81203 add  .2350    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81204 add  .2351    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81205 add  .2450    12345678901234.00    ->  12345678901234.25  Inexact Rounded
ddadd81206 add  .2451    12345678901234.00    ->  12345678901234.25  Inexact Rounded
ddadd81207 add  .2360    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81208 add  .2370    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81209 add  .2399    12345678901234.00    ->  12345678901234.24  Inexact Rounded

rounding: half_down
ddadd81300 add  .2300    12345678901234.00    ->  12345678901234.23  Rounded
ddadd81301 add  .2301    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81302 add  .2310    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81303 add  .2350    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81304 add  .2351    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81305 add  .2450    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81306 add  .2451    12345678901234.00    ->  12345678901234.25  Inexact Rounded
ddadd81307 add  .2360    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81308 add  .2370    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81309 add  .2399    12345678901234.00    ->  12345678901234.24  Inexact Rounded

rounding: up
ddadd81400 add  .2300    12345678901234.00    ->  12345678901234.23  Rounded
ddadd81401 add  .2301    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81402 add  .2310    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81403 add  .2350    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81404 add  .2351    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81405 add  .2450    12345678901234.00    ->  12345678901234.25  Inexact Rounded
ddadd81406 add  .2451    12345678901234.00    ->  12345678901234.25  Inexact Rounded
ddadd81407 add  .2360    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81408 add  .2370    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81409 add  .2399    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81411 add -.2399   -12345678901234.00    -> -12345678901234.24  Inexact Rounded

rounding: down
ddadd81500 add  .2300    12345678901234.00    ->  12345678901234.23  Rounded
ddadd81501 add  .2301    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81502 add  .2310    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81503 add  .2350    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81504 add  .2351    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81505 add  .2450    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81506 add  .2451    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81507 add  .2360    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81508 add  .2370    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81509 add  .2399    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81511 add -.2399   -12345678901234.00    -> -12345678901234.23  Inexact Rounded

rounding: ceiling
ddadd81600 add  .2300    12345678901234.00    ->  12345678901234.23  Rounded
ddadd81601 add  .2301    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81602 add  .2310    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81603 add  .2350    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81604 add  .2351    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81605 add  .2450    12345678901234.00    ->  12345678901234.25  Inexact Rounded
ddadd81606 add  .2451    12345678901234.00    ->  12345678901234.25  Inexact Rounded
ddadd81607 add  .2360    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81608 add  .2370    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81609 add  .2399    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81611 add -.2399   -12345678901234.00    -> -12345678901234.23  Inexact Rounded

rounding: floor
ddadd81700 add  .2300    12345678901234.00    ->  12345678901234.23  Rounded
ddadd81701 add  .2301    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81702 add  .2310    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81703 add  .2350    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81704 add  .2351    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81705 add  .2450    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81706 add  .2451    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd81707 add  .2360    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81708 add  .2370    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81709 add  .2399    12345678901234.00    ->  12345678901234.23  Inexact Rounded
ddadd81711 add -.2399   -12345678901234.00    -> -12345678901234.24  Inexact Rounded

rounding: 05up
ddadd81800 add  .2000    12345678901234.00    ->  12345678901234.20  Rounded
ddadd81801 add  .2001    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81802 add  .2010    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81803 add  .2050    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81804 add  .2051    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81807 add  .2060    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81808 add  .2070    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81809 add  .2099    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81811 add -.2099   -12345678901234.00    -> -12345678901234.21  Inexact Rounded

ddadd81900 add  .2100    12345678901234.00    ->  12345678901234.21  Rounded
ddadd81901 add  .2101    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81902 add  .2110    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81903 add  .2150    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81904 add  .2151    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81907 add  .2160    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81908 add  .2170    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81909 add  .2199    12345678901234.00    ->  12345678901234.21  Inexact Rounded
ddadd81911 add -.2199   -12345678901234.00    -> -12345678901234.21  Inexact Rounded

ddadd82000 add  .2400    12345678901234.00    ->  12345678901234.24  Rounded
ddadd82001 add  .2401    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd82002 add  .2410    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd82003 add  .2450    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd82004 add  .2451    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd82007 add  .2460    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd82008 add  .2470    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd82009 add  .2499    12345678901234.00    ->  12345678901234.24  Inexact Rounded
ddadd82011 add -.2499   -12345678901234.00    -> -12345678901234.24  Inexact Rounded

ddadd82100 add  .2500    12345678901234.00    ->  12345678901234.25  Rounded
ddadd82101 add  .2501    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82102 add  .2510    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82103 add  .2550    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82104 add  .2551    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82107 add  .2560    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82108 add  .2570    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82109 add  .2599    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82111 add -.2599   -12345678901234.00    -> -12345678901234.26  Inexact Rounded

ddadd82200 add  .2600    12345678901234.00    ->  12345678901234.26  Rounded
ddadd82201 add  .2601    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82202 add  .2610    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82203 add  .2650    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82204 add  .2651    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82207 add  .2660    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82208 add  .2670    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82209 add  .2699    12345678901234.00    ->  12345678901234.26  Inexact Rounded
ddadd82211 add -.2699   -12345678901234.00    -> -12345678901234.26  Inexact Rounded

ddadd82300 add  .2900    12345678901234.00    ->  12345678901234.29  Rounded
ddadd82301 add  .2901    12345678901234.00    ->  12345678901234.29  Inexact Rounded
ddadd82302 add  .2910    12345678901234.00    ->  12345678901234.29  Inexact Rounded
ddadd82303 add  .2950    12345678901234.00    ->  12345678901234.29  Inexact Rounded
ddadd82304 add  .2951    12345678901234.00    ->  12345678901234.29  Inexact Rounded
ddadd82307 add  .2960    12345678901234.00    ->  12345678901234.29  Inexact Rounded
ddadd82308 add  .2970    12345678901234.00    ->  12345678901234.29  Inexact Rounded
ddadd82309 add  .2999    12345678901234.00    ->  12345678901234.29  Inexact Rounded
ddadd82311 add -.2999   -12345678901234.00    -> -12345678901234.29  Inexact Rounded

-- Null tests
ddadd9990 add 10  # -> NaN Invalid_operation
ddadd9991 add  # 10 -> NaN Invalid_operation

Added test/dectest/ddAnd.decTest.























































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
------------------------------------------------------------------------
-- ddAnd.decTest -- digitwise logical AND for decDoubles              --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check (truth table)
ddand001 and             0    0 ->    0
ddand002 and             0    1 ->    0
ddand003 and             1    0 ->    0
ddand004 and             1    1 ->    1
ddand005 and          1100 1010 -> 1000
-- and at msd and msd-1
--           1234567890123456 1234567890123456      1234567890123456
ddand006 and 0000000000000000 0000000000000000 ->                  0
ddand007 and 0000000000000000 1000000000000000 ->                  0
ddand008 and 1000000000000000 0000000000000000 ->                  0
ddand009 and 1000000000000000 1000000000000000 ->   1000000000000000
ddand010 and 0000000000000000 0000000000000000 ->                  0
ddand011 and 0000000000000000 0100000000000000 ->                  0
ddand012 and 0100000000000000 0000000000000000 ->                  0
ddand013 and 0100000000000000 0100000000000000 ->    100000000000000

-- Various lengths
--           1234567890123456 1234567890123456      1234567890123456
ddand021 and 1111111111111111 1111111111111111  ->  1111111111111111
ddand024 and 1111111111111111  111111111111111  ->   111111111111111
ddand025 and 1111111111111111   11111111111111  ->    11111111111111
ddand026 and 1111111111111111    1111111111111  ->     1111111111111
ddand027 and 1111111111111111     111111111111  ->      111111111111
ddand028 and 1111111111111111      11111111111  ->       11111111111
ddand029 and 1111111111111111       1111111111  ->        1111111111
ddand030 and 1111111111111111        111111111  ->         111111111
ddand031 and 1111111111111111         11111111  ->          11111111
ddand032 and 1111111111111111          1111111  ->           1111111
ddand033 and 1111111111111111           111111  ->            111111
ddand034 and 1111111111111111            11111  ->             11111
ddand035 and 1111111111111111             1111  ->              1111
ddand036 and 1111111111111111              111  ->               111
ddand037 and 1111111111111111               11  ->                11
ddand038 and 1111111111111111                1  ->                 1
ddand039 and 1111111111111111                0  ->                 0

ddand040 and 1111111111111111    1111111111111111 ->  1111111111111111
ddand041 and  111111111111111    1111111111111111 ->   111111111111111
ddand042 and  111111111111111    1111111111111111 ->   111111111111111
ddand043 and   11111111111111    1111111111111111 ->    11111111111111
ddand044 and    1111111111111    1111111111111111 ->     1111111111111
ddand045 and     111111111111    1111111111111111 ->      111111111111
ddand046 and      11111111111    1111111111111111 ->       11111111111
ddand047 and       1111111111    1111111111111111 ->        1111111111
ddand048 and        111111111    1111111111111111 ->         111111111
ddand049 and         11111111    1111111111111111 ->          11111111
ddand050 and          1111111    1111111111111111 ->           1111111
ddand051 and           111111    1111111111111111 ->            111111
ddand052 and            11111    1111111111111111 ->             11111
ddand053 and             1111    1111111111111111 ->              1111
ddand054 and              111    1111111111111111 ->               111
ddand055 and               11    1111111111111111 ->                11
ddand056 and                1    1111111111111111 ->                 1
ddand057 and                0    1111111111111111 ->                 0

ddand150 and 1111111111  1  ->  1
ddand151 and  111111111  1  ->  1
ddand152 and   11111111  1  ->  1
ddand153 and    1111111  1  ->  1
ddand154 and     111111  1  ->  1
ddand155 and      11111  1  ->  1
ddand156 and       1111  1  ->  1
ddand157 and        111  1  ->  1
ddand158 and         11  1  ->  1
ddand159 and          1  1  ->  1

ddand160 and 1111111111  0  ->  0
ddand161 and  111111111  0  ->  0
ddand162 and   11111111  0  ->  0
ddand163 and    1111111  0  ->  0
ddand164 and     111111  0  ->  0
ddand165 and      11111  0  ->  0
ddand166 and       1111  0  ->  0
ddand167 and        111  0  ->  0
ddand168 and         11  0  ->  0
ddand169 and          1  0  ->  0

ddand170 and 1  1111111111  ->  1
ddand171 and 1   111111111  ->  1
ddand172 and 1    11111111  ->  1
ddand173 and 1     1111111  ->  1
ddand174 and 1      111111  ->  1
ddand175 and 1       11111  ->  1
ddand176 and 1        1111  ->  1
ddand177 and 1         111  ->  1
ddand178 and 1          11  ->  1
ddand179 and 1           1  ->  1

ddand180 and 0  1111111111  ->  0
ddand181 and 0   111111111  ->  0
ddand182 and 0    11111111  ->  0
ddand183 and 0     1111111  ->  0
ddand184 and 0      111111  ->  0
ddand185 and 0       11111  ->  0
ddand186 and 0        1111  ->  0
ddand187 and 0         111  ->  0
ddand188 and 0          11  ->  0
ddand189 and 0           1  ->  0

ddand090 and 011111111  111111111  ->   11111111
ddand091 and 101111111  111111111  ->  101111111
ddand092 and 110111111  111111111  ->  110111111
ddand093 and 111011111  111111111  ->  111011111
ddand094 and 111101111  111111111  ->  111101111
ddand095 and 111110111  111111111  ->  111110111
ddand096 and 111111011  111111111  ->  111111011
ddand097 and 111111101  111111111  ->  111111101
ddand098 and 111111110  111111111  ->  111111110

ddand100 and 111111111  011111111  ->   11111111
ddand101 and 111111111  101111111  ->  101111111
ddand102 and 111111111  110111111  ->  110111111
ddand103 and 111111111  111011111  ->  111011111
ddand104 and 111111111  111101111  ->  111101111
ddand105 and 111111111  111110111  ->  111110111
ddand106 and 111111111  111111011  ->  111111011
ddand107 and 111111111  111111101  ->  111111101
ddand108 and 111111111  111111110  ->  111111110

-- non-0/1 should not be accepted, nor should signs
ddand220 and 111111112  111111111  ->  NaN Invalid_operation
ddand221 and 333333333  333333333  ->  NaN Invalid_operation
ddand222 and 555555555  555555555  ->  NaN Invalid_operation
ddand223 and 777777777  777777777  ->  NaN Invalid_operation
ddand224 and 999999999  999999999  ->  NaN Invalid_operation
ddand225 and 222222222  999999999  ->  NaN Invalid_operation
ddand226 and 444444444  999999999  ->  NaN Invalid_operation
ddand227 and 666666666  999999999  ->  NaN Invalid_operation
ddand228 and 888888888  999999999  ->  NaN Invalid_operation
ddand229 and 999999999  222222222  ->  NaN Invalid_operation
ddand230 and 999999999  444444444  ->  NaN Invalid_operation
ddand231 and 999999999  666666666  ->  NaN Invalid_operation
ddand232 and 999999999  888888888  ->  NaN Invalid_operation
-- a few randoms
ddand240 and  567468689 -934981942 ->  NaN Invalid_operation
ddand241 and  567367689  934981942 ->  NaN Invalid_operation
ddand242 and -631917772 -706014634 ->  NaN Invalid_operation
ddand243 and -756253257  138579234 ->  NaN Invalid_operation
ddand244 and  835590149  567435400 ->  NaN Invalid_operation
-- test MSD
ddand250 and  2000000000000000 1000000000000000 ->  NaN Invalid_operation
ddand251 and  7000000000000000 1000000000000000 ->  NaN Invalid_operation
ddand252 and  8000000000000000 1000000000000000 ->  NaN Invalid_operation
ddand253 and  9000000000000000 1000000000000000 ->  NaN Invalid_operation
ddand254 and  2000000000000000 0000000000000000 ->  NaN Invalid_operation
ddand255 and  7000000000000000 0000000000000000 ->  NaN Invalid_operation
ddand256 and  8000000000000000 0000000000000000 ->  NaN Invalid_operation
ddand257 and  9000000000000000 0000000000000000 ->  NaN Invalid_operation
ddand258 and  1000000000000000 2000000000000000 ->  NaN Invalid_operation
ddand259 and  1000000000000000 7000000000000000 ->  NaN Invalid_operation
ddand260 and  1000000000000000 8000000000000000 ->  NaN Invalid_operation
ddand261 and  1000000000000000 9000000000000000 ->  NaN Invalid_operation
ddand262 and  0000000000000000 2000000000000000 ->  NaN Invalid_operation
ddand263 and  0000000000000000 7000000000000000 ->  NaN Invalid_operation
ddand264 and  0000000000000000 8000000000000000 ->  NaN Invalid_operation
ddand265 and  0000000000000000 9000000000000000 ->  NaN Invalid_operation
-- test MSD-1
ddand270 and  0200001000000000 1000100000000010 ->  NaN Invalid_operation
ddand271 and  0700000100000000 1000010000000100 ->  NaN Invalid_operation
ddand272 and  0800000010000000 1000001000001000 ->  NaN Invalid_operation
ddand273 and  0900000001000000 1000000100010000 ->  NaN Invalid_operation
ddand274 and  1000000000100000 0200000010100000 ->  NaN Invalid_operation
ddand275 and  1000000000010000 0700000001000000 ->  NaN Invalid_operation
ddand276 and  1000000000001000 0800000010100000 ->  NaN Invalid_operation
ddand277 and  1000000000000100 0900000000010000 ->  NaN Invalid_operation
-- test LSD
ddand280 and  0010000000000002 1000000100000001 ->  NaN Invalid_operation
ddand281 and  0001000000000007 1000001000000011 ->  NaN Invalid_operation
ddand282 and  0000100000000008 1000010000000001 ->  NaN Invalid_operation
ddand283 and  0000010000000009 1000100000000001 ->  NaN Invalid_operation
ddand284 and  1000001000000000 0001000000000002 ->  NaN Invalid_operation
ddand285 and  1000000100000000 0010000000000007 ->  NaN Invalid_operation
ddand286 and  1000000010000000 0100000000000008 ->  NaN Invalid_operation
ddand287 and  1000000001000000 1000000000000009 ->  NaN Invalid_operation
-- test Middie
ddand288 and  0010000020000000 1000001000000000 ->  NaN Invalid_operation
ddand289 and  0001000070000001 1000000100000000 ->  NaN Invalid_operation
ddand290 and  0000100080000010 1000000010000000 ->  NaN Invalid_operation
ddand291 and  0000010090000100 1000000001000000 ->  NaN Invalid_operation
ddand292 and  1000001000001000 0000000020100000 ->  NaN Invalid_operation
ddand293 and  1000000100010000 0000000070010000 ->  NaN Invalid_operation
ddand294 and  1000000010100000 0000000080001000 ->  NaN Invalid_operation
ddand295 and  1000000001000000 0000000090000100 ->  NaN Invalid_operation
-- signs
ddand296 and -1000000001000000 -0000010000000100 ->  NaN Invalid_operation
ddand297 and -1000000001000000  0000000010000100 ->  NaN Invalid_operation
ddand298 and  1000000001000000 -0000001000000100 ->  NaN Invalid_operation
ddand299 and  1000000001000000  0000000011000100 ->  1000000

-- Nmax, Nmin, Ntiny-like
ddand331 and  2   9.99999999E+199     -> NaN Invalid_operation
ddand332 and  3   1E-199              -> NaN Invalid_operation
ddand333 and  4   1.00000000E-199     -> NaN Invalid_operation
ddand334 and  5   1E-100              -> NaN Invalid_operation
ddand335 and  6   -1E-100             -> NaN Invalid_operation
ddand336 and  7   -1.00000000E-199    -> NaN Invalid_operation
ddand337 and  8   -1E-199             -> NaN Invalid_operation
ddand338 and  9   -9.99999999E+199    -> NaN Invalid_operation
ddand341 and  9.99999999E+199     -18 -> NaN Invalid_operation
ddand342 and  1E-199               01 -> NaN Invalid_operation
ddand343 and  1.00000000E-199     -18 -> NaN Invalid_operation
ddand344 and  1E-100               18 -> NaN Invalid_operation
ddand345 and  -1E-100             -10 -> NaN Invalid_operation
ddand346 and  -1.00000000E-199     18 -> NaN Invalid_operation
ddand347 and  -1E-199              10 -> NaN Invalid_operation
ddand348 and  -9.99999999E+199    -18 -> NaN Invalid_operation

-- A few other non-integers
ddand361 and  1.0                  1  -> NaN Invalid_operation
ddand362 and  1E+1                 1  -> NaN Invalid_operation
ddand363 and  0.0                  1  -> NaN Invalid_operation
ddand364 and  0E+1                 1  -> NaN Invalid_operation
ddand365 and  9.9                  1  -> NaN Invalid_operation
ddand366 and  9E+1                 1  -> NaN Invalid_operation
ddand371 and  0 1.0                   -> NaN Invalid_operation
ddand372 and  0 1E+1                  -> NaN Invalid_operation
ddand373 and  0 0.0                   -> NaN Invalid_operation
ddand374 and  0 0E+1                  -> NaN Invalid_operation
ddand375 and  0 9.9                   -> NaN Invalid_operation
ddand376 and  0 9E+1                  -> NaN Invalid_operation

-- All Specials are in error
ddand780 and -Inf  -Inf   -> NaN Invalid_operation
ddand781 and -Inf  -1000  -> NaN Invalid_operation
ddand782 and -Inf  -1     -> NaN Invalid_operation
ddand783 and -Inf  -0     -> NaN Invalid_operation
ddand784 and -Inf   0     -> NaN Invalid_operation
ddand785 and -Inf   1     -> NaN Invalid_operation
ddand786 and -Inf   1000  -> NaN Invalid_operation
ddand787 and -1000 -Inf   -> NaN Invalid_operation
ddand788 and -Inf  -Inf   -> NaN Invalid_operation
ddand789 and -1    -Inf   -> NaN Invalid_operation
ddand790 and -0    -Inf   -> NaN Invalid_operation
ddand791 and  0    -Inf   -> NaN Invalid_operation
ddand792 and  1    -Inf   -> NaN Invalid_operation
ddand793 and  1000 -Inf   -> NaN Invalid_operation
ddand794 and  Inf  -Inf   -> NaN Invalid_operation

ddand800 and  Inf  -Inf   -> NaN Invalid_operation
ddand801 and  Inf  -1000  -> NaN Invalid_operation
ddand802 and  Inf  -1     -> NaN Invalid_operation
ddand803 and  Inf  -0     -> NaN Invalid_operation
ddand804 and  Inf   0     -> NaN Invalid_operation
ddand805 and  Inf   1     -> NaN Invalid_operation
ddand806 and  Inf   1000  -> NaN Invalid_operation
ddand807 and  Inf   Inf   -> NaN Invalid_operation
ddand808 and -1000  Inf   -> NaN Invalid_operation
ddand809 and -Inf   Inf   -> NaN Invalid_operation
ddand810 and -1     Inf   -> NaN Invalid_operation
ddand811 and -0     Inf   -> NaN Invalid_operation
ddand812 and  0     Inf   -> NaN Invalid_operation
ddand813 and  1     Inf   -> NaN Invalid_operation
ddand814 and  1000  Inf   -> NaN Invalid_operation
ddand815 and  Inf   Inf   -> NaN Invalid_operation

ddand821 and  NaN -Inf    -> NaN Invalid_operation
ddand822 and  NaN -1000   -> NaN Invalid_operation
ddand823 and  NaN -1      -> NaN Invalid_operation
ddand824 and  NaN -0      -> NaN Invalid_operation
ddand825 and  NaN  0      -> NaN Invalid_operation
ddand826 and  NaN  1      -> NaN Invalid_operation
ddand827 and  NaN  1000   -> NaN Invalid_operation
ddand828 and  NaN  Inf    -> NaN Invalid_operation
ddand829 and  NaN  NaN    -> NaN Invalid_operation
ddand830 and -Inf  NaN    -> NaN Invalid_operation
ddand831 and -1000 NaN    -> NaN Invalid_operation
ddand832 and -1    NaN    -> NaN Invalid_operation
ddand833 and -0    NaN    -> NaN Invalid_operation
ddand834 and  0    NaN    -> NaN Invalid_operation
ddand835 and  1    NaN    -> NaN Invalid_operation
ddand836 and  1000 NaN    -> NaN Invalid_operation
ddand837 and  Inf  NaN    -> NaN Invalid_operation

ddand841 and  sNaN -Inf   ->  NaN  Invalid_operation
ddand842 and  sNaN -1000  ->  NaN  Invalid_operation
ddand843 and  sNaN -1     ->  NaN  Invalid_operation
ddand844 and  sNaN -0     ->  NaN  Invalid_operation
ddand845 and  sNaN  0     ->  NaN  Invalid_operation
ddand846 and  sNaN  1     ->  NaN  Invalid_operation
ddand847 and  sNaN  1000  ->  NaN  Invalid_operation
ddand848 and  sNaN  NaN   ->  NaN  Invalid_operation
ddand849 and  sNaN sNaN   ->  NaN  Invalid_operation
ddand850 and  NaN  sNaN   ->  NaN  Invalid_operation
ddand851 and -Inf  sNaN   ->  NaN  Invalid_operation
ddand852 and -1000 sNaN   ->  NaN  Invalid_operation
ddand853 and -1    sNaN   ->  NaN  Invalid_operation
ddand854 and -0    sNaN   ->  NaN  Invalid_operation
ddand855 and  0    sNaN   ->  NaN  Invalid_operation
ddand856 and  1    sNaN   ->  NaN  Invalid_operation
ddand857 and  1000 sNaN   ->  NaN  Invalid_operation
ddand858 and  Inf  sNaN   ->  NaN  Invalid_operation
ddand859 and  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddand861 and  NaN1   -Inf    -> NaN Invalid_operation
ddand862 and +NaN2   -1000   -> NaN Invalid_operation
ddand863 and  NaN3    1000   -> NaN Invalid_operation
ddand864 and  NaN4    Inf    -> NaN Invalid_operation
ddand865 and  NaN5   +NaN6   -> NaN Invalid_operation
ddand866 and -Inf     NaN7   -> NaN Invalid_operation
ddand867 and -1000    NaN8   -> NaN Invalid_operation
ddand868 and  1000    NaN9   -> NaN Invalid_operation
ddand869 and  Inf    +NaN10  -> NaN Invalid_operation
ddand871 and  sNaN11  -Inf   -> NaN Invalid_operation
ddand872 and  sNaN12  -1000  -> NaN Invalid_operation
ddand873 and  sNaN13   1000  -> NaN Invalid_operation
ddand874 and  sNaN14   NaN17 -> NaN Invalid_operation
ddand875 and  sNaN15  sNaN18 -> NaN Invalid_operation
ddand876 and  NaN16   sNaN19 -> NaN Invalid_operation
ddand877 and -Inf    +sNaN20 -> NaN Invalid_operation
ddand878 and -1000    sNaN21 -> NaN Invalid_operation
ddand879 and  1000    sNaN22 -> NaN Invalid_operation
ddand880 and  Inf     sNaN23 -> NaN Invalid_operation
ddand881 and +NaN25  +sNaN24 -> NaN Invalid_operation
ddand882 and -NaN26    NaN28 -> NaN Invalid_operation
ddand883 and -sNaN27  sNaN29 -> NaN Invalid_operation
ddand884 and  1000    -NaN30 -> NaN Invalid_operation
ddand885 and  1000   -sNaN31 -> NaN Invalid_operation

Added test/dectest/ddBase.decTest.

















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
------------------------------------------------------------------------
-- ddBase.decTest -- base decDouble <--> string conversions           --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This file tests base conversions from string to a decimal number
-- and back to a string (in Scientific form)

-- Note that unlike other operations the operand is subject to rounding
-- to conform to emax and precision settings (that is, numbers will
-- conform to rules and exponent will be in permitted range).  The
-- 'left hand side', therefore, may have numbers that cannot be
-- represented in a decDouble.  Some testcases go to the limit of the
-- next-wider format, and hence these testcases may also be used to
-- test narrowing and widening operations.

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

ddbas001 toSci       0 -> 0
ddbas002 toSci       1 -> 1
ddbas003 toSci     1.0 -> 1.0
ddbas004 toSci    1.00 -> 1.00
ddbas005 toSci      10 -> 10
ddbas006 toSci    1000 -> 1000
ddbas007 toSci    10.0 -> 10.0
ddbas008 toSci    10.1 -> 10.1
ddbas009 toSci    10.4 -> 10.4
ddbas010 toSci    10.5 -> 10.5
ddbas011 toSci    10.6 -> 10.6
ddbas012 toSci    10.9 -> 10.9
ddbas013 toSci    11.0 -> 11.0
ddbas014 toSci  1.234 -> 1.234
ddbas015 toSci  0.123 -> 0.123
ddbas016 toSci  0.012 -> 0.012
ddbas017 toSci  -0    -> -0
ddbas018 toSci  -0.0  -> -0.0
ddbas019 toSci -00.00 -> -0.00

ddbas021 toSci     -1 -> -1
ddbas022 toSci   -1.0 -> -1.0
ddbas023 toSci   -0.1 -> -0.1
ddbas024 toSci   -9.1 -> -9.1
ddbas025 toSci   -9.11 -> -9.11
ddbas026 toSci   -9.119 -> -9.119
ddbas027 toSci   -9.999 -> -9.999

ddbas030 toSci  '123456789.123456'   -> '123456789.123456'
ddbas031 toSci  '123456789.000000'   -> '123456789.000000'
ddbas032 toSci   '123456789123456'   -> '123456789123456'
ddbas033 toSci   '0.0000123456789'   -> '0.0000123456789'
ddbas034 toSci  '0.00000123456789'   -> '0.00000123456789'
ddbas035 toSci '0.000000123456789'   -> '1.23456789E-7'
ddbas036 toSci '0.0000000123456789'  -> '1.23456789E-8'

ddbas037 toSci '0.123456789012344'   -> '0.123456789012344'
ddbas038 toSci '0.123456789012345'   -> '0.123456789012345'

-- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
ddbsn001 toSci -9.999999999999999E+384 -> -9.999999999999999E+384
ddbsn002 toSci -1E-383 -> -1E-383
ddbsn003 toSci -1E-398 -> -1E-398 Subnormal
ddbsn004 toSci -0 -> -0
ddbsn005 toSci +0 ->  0
ddbsn006 toSci +1E-398 ->  1E-398 Subnormal
ddbsn007 toSci +1E-383 ->  1E-383
ddbsn008 toSci +9.999999999999999E+384 ->  9.999999999999999E+384

-- String [many more examples are implicitly tested elsewhere]
-- strings without E cannot generate E in result
ddbas040 toSci "12"        -> '12'
ddbas041 toSci "-76"       -> '-76'
ddbas042 toSci "12.76"     -> '12.76'
ddbas043 toSci "+12.76"    -> '12.76'
ddbas044 toSci "012.76"    -> '12.76'
ddbas045 toSci "+0.003"    -> '0.003'
ddbas046 toSci "17."       -> '17'
ddbas047 toSci ".5"        -> '0.5'
ddbas048 toSci "044"       -> '44'
ddbas049 toSci "0044"      -> '44'
ddbas050 toSci "0.0005"      -> '0.0005'
ddbas051 toSci "00.00005"    -> '0.00005'
ddbas052 toSci "0.000005"    -> '0.000005'
ddbas053 toSci "0.0000050"   -> '0.0000050'
ddbas054 toSci "0.0000005"   -> '5E-7'
ddbas055 toSci "0.00000005"  -> '5E-8'
ddbas056 toSci "12345678.543210" -> '12345678.543210'
ddbas057 toSci "2345678.543210" -> '2345678.543210'
ddbas058 toSci "345678.543210" -> '345678.543210'
ddbas059 toSci "0345678.54321" -> '345678.54321'
ddbas060 toSci "345678.5432" -> '345678.5432'
ddbas061 toSci "+345678.5432" -> '345678.5432'
ddbas062 toSci "+0345678.5432" -> '345678.5432'
ddbas063 toSci "+00345678.5432" -> '345678.5432'
ddbas064 toSci "-345678.5432"  -> '-345678.5432'
ddbas065 toSci "-0345678.5432"  -> '-345678.5432'
ddbas066 toSci "-00345678.5432"  -> '-345678.5432'
-- examples
ddbas067 toSci "5E-6"        -> '0.000005'
ddbas068 toSci "50E-7"       -> '0.0000050'
ddbas069 toSci "5E-7"        -> '5E-7'

-- [No exotics as no Unicode]

-- rounded with dots in all (including edge) places
ddbas071 toSci  .1234567890123456123  -> 0.1234567890123456 Inexact Rounded
ddbas072 toSci  1.234567890123456123  -> 1.234567890123456 Inexact Rounded
ddbas073 toSci  12.34567890123456123  -> 12.34567890123456 Inexact Rounded
ddbas074 toSci  123.4567890123456123  -> 123.4567890123456 Inexact Rounded
ddbas075 toSci  1234.567890123456123  -> 1234.567890123456 Inexact Rounded
ddbas076 toSci  12345.67890123456123  -> 12345.67890123456 Inexact Rounded
ddbas077 toSci  123456.7890123456123  -> 123456.7890123456 Inexact Rounded
ddbas078 toSci  1234567.890123456123  -> 1234567.890123456 Inexact Rounded
ddbas079 toSci  12345678.90123456123  -> 12345678.90123456 Inexact Rounded
ddbas080 toSci  123456789.0123456123  -> 123456789.0123456 Inexact Rounded
ddbas081 toSci  1234567890.123456123  -> 1234567890.123456 Inexact Rounded
ddbas082 toSci  12345678901.23456123  -> 12345678901.23456 Inexact Rounded
ddbas083 toSci  123456789012.3456123  -> 123456789012.3456 Inexact Rounded
ddbas084 toSci  1234567890123.456123  -> 1234567890123.456 Inexact Rounded
ddbas085 toSci  12345678901234.56123  -> 12345678901234.56 Inexact Rounded
ddbas086 toSci  123456789012345.6123  -> 123456789012345.6 Inexact Rounded
ddbas087 toSci  1234567890123456.123  -> 1234567890123456  Inexact Rounded
ddbas088 toSci  12345678901234561.23  -> 1.234567890123456E+16 Inexact Rounded
ddbas089 toSci  123456789012345612.3  -> 1.234567890123456E+17 Inexact Rounded
ddbas090 toSci  1234567890123456123.  -> 1.234567890123456E+18 Inexact Rounded


-- Numbers with E
ddbas130 toSci "0.000E-1"  -> '0.0000'
ddbas131 toSci "0.000E-2"  -> '0.00000'
ddbas132 toSci "0.000E-3"  -> '0.000000'
ddbas133 toSci "0.000E-4"  -> '0E-7'
ddbas134 toSci "0.00E-2"   -> '0.0000'
ddbas135 toSci "0.00E-3"   -> '0.00000'
ddbas136 toSci "0.00E-4"   -> '0.000000'
ddbas137 toSci "0.00E-5"   -> '0E-7'
ddbas138 toSci "+0E+9"     -> '0E+9'
ddbas139 toSci "-0E+9"     -> '-0E+9'
ddbas140 toSci "1E+9"      -> '1E+9'
ddbas141 toSci "1e+09"     -> '1E+9'
ddbas142 toSci "1E+90"     -> '1E+90'
ddbas143 toSci "+1E+009"   -> '1E+9'
ddbas144 toSci "0E+9"      -> '0E+9'
ddbas145 toSci "1E+9"      -> '1E+9'
ddbas146 toSci "1E+09"     -> '1E+9'
ddbas147 toSci "1e+90"     -> '1E+90'
ddbas148 toSci "1E+009"    -> '1E+9'
ddbas149 toSci "000E+9"    -> '0E+9'
ddbas150 toSci "1E9"       -> '1E+9'
ddbas151 toSci "1e09"      -> '1E+9'
ddbas152 toSci "1E90"      -> '1E+90'
ddbas153 toSci "1E009"     -> '1E+9'
ddbas154 toSci "0E9"       -> '0E+9'
ddbas155 toSci "0.000e+0"  -> '0.000'
ddbas156 toSci "0.000E-1"  -> '0.0000'
ddbas157 toSci "4E+9"      -> '4E+9'
ddbas158 toSci "44E+9"     -> '4.4E+10'
ddbas159 toSci "0.73e-7"   -> '7.3E-8'
ddbas160 toSci "00E+9"     -> '0E+9'
ddbas161 toSci "00E-9"     -> '0E-9'
ddbas162 toSci "10E+9"     -> '1.0E+10'
ddbas163 toSci "10E+09"    -> '1.0E+10'
ddbas164 toSci "10e+90"    -> '1.0E+91'
ddbas165 toSci "10E+009"   -> '1.0E+10'
ddbas166 toSci "100e+9"    -> '1.00E+11'
ddbas167 toSci "100e+09"   -> '1.00E+11'
ddbas168 toSci "100E+90"   -> '1.00E+92'
ddbas169 toSci "100e+009"  -> '1.00E+11'

ddbas170 toSci "1.265"     -> '1.265'
ddbas171 toSci "1.265E-20" -> '1.265E-20'
ddbas172 toSci "1.265E-8"  -> '1.265E-8'
ddbas173 toSci "1.265E-4"  -> '0.0001265'
ddbas174 toSci "1.265E-3"  -> '0.001265'
ddbas175 toSci "1.265E-2"  -> '0.01265'
ddbas176 toSci "1.265E-1"  -> '0.1265'
ddbas177 toSci "1.265E-0"  -> '1.265'
ddbas178 toSci "1.265E+1"  -> '12.65'
ddbas179 toSci "1.265E+2"  -> '126.5'
ddbas180 toSci "1.265E+3"  -> '1265'
ddbas181 toSci "1.265E+4"  -> '1.265E+4'
ddbas182 toSci "1.265E+8"  -> '1.265E+8'
ddbas183 toSci "1.265E+20" -> '1.265E+20'

ddbas190 toSci "12.65"     -> '12.65'
ddbas191 toSci "12.65E-20" -> '1.265E-19'
ddbas192 toSci "12.65E-8"  -> '1.265E-7'
ddbas193 toSci "12.65E-4"  -> '0.001265'
ddbas194 toSci "12.65E-3"  -> '0.01265'
ddbas195 toSci "12.65E-2"  -> '0.1265'
ddbas196 toSci "12.65E-1"  -> '1.265'
ddbas197 toSci "12.65E-0"  -> '12.65'
ddbas198 toSci "12.65E+1"  -> '126.5'
ddbas199 toSci "12.65E+2"  -> '1265'
ddbas200 toSci "12.65E+3"  -> '1.265E+4'
ddbas201 toSci "12.65E+4"  -> '1.265E+5'
ddbas202 toSci "12.65E+8"  -> '1.265E+9'
ddbas203 toSci "12.65E+20" -> '1.265E+21'

ddbas210 toSci "126.5"     -> '126.5'
ddbas211 toSci "126.5E-20" -> '1.265E-18'
ddbas212 toSci "126.5E-8"  -> '0.000001265'
ddbas213 toSci "126.5E-4"  -> '0.01265'
ddbas214 toSci "126.5E-3"  -> '0.1265'
ddbas215 toSci "126.5E-2"  -> '1.265'
ddbas216 toSci "126.5E-1"  -> '12.65'
ddbas217 toSci "126.5E-0"  -> '126.5'
ddbas218 toSci "126.5E+1"  -> '1265'
ddbas219 toSci "126.5E+2"  -> '1.265E+4'
ddbas220 toSci "126.5E+3"  -> '1.265E+5'
ddbas221 toSci "126.5E+4"  -> '1.265E+6'
ddbas222 toSci "126.5E+8"  -> '1.265E+10'
ddbas223 toSci "126.5E+20" -> '1.265E+22'

ddbas230 toSci "1265"     -> '1265'
ddbas231 toSci "1265E-20" -> '1.265E-17'
ddbas232 toSci "1265E-8"  -> '0.00001265'
ddbas233 toSci "1265E-4"  -> '0.1265'
ddbas234 toSci "1265E-3"  -> '1.265'
ddbas235 toSci "1265E-2"  -> '12.65'
ddbas236 toSci "1265E-1"  -> '126.5'
ddbas237 toSci "1265E-0"  -> '1265'
ddbas238 toSci "1265E+1"  -> '1.265E+4'
ddbas239 toSci "1265E+2"  -> '1.265E+5'
ddbas240 toSci "1265E+3"  -> '1.265E+6'
ddbas241 toSci "1265E+4"  -> '1.265E+7'
ddbas242 toSci "1265E+8"  -> '1.265E+11'
ddbas243 toSci "1265E+20" -> '1.265E+23'
ddbas244 toSci "1265E-9"  -> '0.000001265'
ddbas245 toSci "1265E-10" -> '1.265E-7'
ddbas246 toSci "1265E-11" -> '1.265E-8'
ddbas247 toSci "1265E-12" -> '1.265E-9'

ddbas250 toSci "0.1265"     -> '0.1265'
ddbas251 toSci "0.1265E-20" -> '1.265E-21'
ddbas252 toSci "0.1265E-8"  -> '1.265E-9'
ddbas253 toSci "0.1265E-4"  -> '0.00001265'
ddbas254 toSci "0.1265E-3"  -> '0.0001265'
ddbas255 toSci "0.1265E-2"  -> '0.001265'
ddbas256 toSci "0.1265E-1"  -> '0.01265'
ddbas257 toSci "0.1265E-0"  -> '0.1265'
ddbas258 toSci "0.1265E+1"  -> '1.265'
ddbas259 toSci "0.1265E+2"  -> '12.65'
ddbas260 toSci "0.1265E+3"  -> '126.5'
ddbas261 toSci "0.1265E+4"  -> '1265'
ddbas262 toSci "0.1265E+8"  -> '1.265E+7'
ddbas263 toSci "0.1265E+20" -> '1.265E+19'

-- some more negative zeros [systematic tests below]
ddbas290 toSci "-0.000E-1"  -> '-0.0000'
ddbas291 toSci "-0.000E-2"  -> '-0.00000'
ddbas292 toSci "-0.000E-3"  -> '-0.000000'
ddbas293 toSci "-0.000E-4"  -> '-0E-7'
ddbas294 toSci "-0.00E-2"   -> '-0.0000'
ddbas295 toSci "-0.00E-3"   -> '-0.00000'
ddbas296 toSci "-0.0E-2"    -> '-0.000'
ddbas297 toSci "-0.0E-3"    -> '-0.0000'
ddbas298 toSci "-0E-2"      -> '-0.00'
ddbas299 toSci "-0E-3"      -> '-0.000'

-- Engineering notation tests
ddbas301  toSci 10e12  -> 1.0E+13
ddbas302  toEng 10e12  -> 10E+12
ddbas303  toSci 10e11  -> 1.0E+12
ddbas304  toEng 10e11  -> 1.0E+12
ddbas305  toSci 10e10  -> 1.0E+11
ddbas306  toEng 10e10  -> 100E+9
ddbas307  toSci 10e9   -> 1.0E+10
ddbas308  toEng 10e9   -> 10E+9
ddbas309  toSci 10e8   -> 1.0E+9
ddbas310  toEng 10e8   -> 1.0E+9
ddbas311  toSci 10e7   -> 1.0E+8
ddbas312  toEng 10e7   -> 100E+6
ddbas313  toSci 10e6   -> 1.0E+7
ddbas314  toEng 10e6   -> 10E+6
ddbas315  toSci 10e5   -> 1.0E+6
ddbas316  toEng 10e5   -> 1.0E+6
ddbas317  toSci 10e4   -> 1.0E+5
ddbas318  toEng 10e4   -> 100E+3
ddbas319  toSci 10e3   -> 1.0E+4
ddbas320  toEng 10e3   -> 10E+3
ddbas321  toSci 10e2   -> 1.0E+3
ddbas322  toEng 10e2   -> 1.0E+3
ddbas323  toSci 10e1   -> 1.0E+2
ddbas324  toEng 10e1   -> 100
ddbas325  toSci 10e0   -> 10
ddbas326  toEng 10e0   -> 10
ddbas327  toSci 10e-1  -> 1.0
ddbas328  toEng 10e-1  -> 1.0
ddbas329  toSci 10e-2  -> 0.10
ddbas330  toEng 10e-2  -> 0.10
ddbas331  toSci 10e-3  -> 0.010
ddbas332  toEng 10e-3  -> 0.010
ddbas333  toSci 10e-4  -> 0.0010
ddbas334  toEng 10e-4  -> 0.0010
ddbas335  toSci 10e-5  -> 0.00010
ddbas336  toEng 10e-5  -> 0.00010
ddbas337  toSci 10e-6  -> 0.000010
ddbas338  toEng 10e-6  -> 0.000010
ddbas339  toSci 10e-7  -> 0.0000010
ddbas340  toEng 10e-7  -> 0.0000010
ddbas341  toSci 10e-8  -> 1.0E-7
ddbas342  toEng 10e-8  -> 100E-9
ddbas343  toSci 10e-9  -> 1.0E-8
ddbas344  toEng 10e-9  -> 10E-9
ddbas345  toSci 10e-10 -> 1.0E-9
ddbas346  toEng 10e-10 -> 1.0E-9
ddbas347  toSci 10e-11 -> 1.0E-10
ddbas348  toEng 10e-11 -> 100E-12
ddbas349  toSci 10e-12 -> 1.0E-11
ddbas350  toEng 10e-12 -> 10E-12
ddbas351  toSci 10e-13 -> 1.0E-12
ddbas352  toEng 10e-13 -> 1.0E-12

ddbas361  toSci 7E12  -> 7E+12
ddbas362  toEng 7E12  -> 7E+12
ddbas363  toSci 7E11  -> 7E+11
ddbas364  toEng 7E11  -> 700E+9
ddbas365  toSci 7E10  -> 7E+10
ddbas366  toEng 7E10  -> 70E+9
ddbas367  toSci 7E9   -> 7E+9
ddbas368  toEng 7E9   -> 7E+9
ddbas369  toSci 7E8   -> 7E+8
ddbas370  toEng 7E8   -> 700E+6
ddbas371  toSci 7E7   -> 7E+7
ddbas372  toEng 7E7   -> 70E+6
ddbas373  toSci 7E6   -> 7E+6
ddbas374  toEng 7E6   -> 7E+6
ddbas375  toSci 7E5   -> 7E+5
ddbas376  toEng 7E5   -> 700E+3
ddbas377  toSci 7E4   -> 7E+4
ddbas378  toEng 7E4   -> 70E+3
ddbas379  toSci 7E3   -> 7E+3
ddbas380  toEng 7E3   -> 7E+3
ddbas381  toSci 7E2   -> 7E+2
ddbas382  toEng 7E2   -> 700
ddbas383  toSci 7E1   -> 7E+1
ddbas384  toEng 7E1   -> 70
ddbas385  toSci 7E0   -> 7
ddbas386  toEng 7E0   -> 7
ddbas387  toSci 7E-1  -> 0.7
ddbas388  toEng 7E-1  -> 0.7
ddbas389  toSci 7E-2  -> 0.07
ddbas390  toEng 7E-2  -> 0.07
ddbas391  toSci 7E-3  -> 0.007
ddbas392  toEng 7E-3  -> 0.007
ddbas393  toSci 7E-4  -> 0.0007
ddbas394  toEng 7E-4  -> 0.0007
ddbas395  toSci 7E-5  -> 0.00007
ddbas396  toEng 7E-5  -> 0.00007
ddbas397  toSci 7E-6  -> 0.000007
ddbas398  toEng 7E-6  -> 0.000007
ddbas399  toSci 7E-7  -> 7E-7
ddbas400  toEng 7E-7  -> 700E-9
ddbas401  toSci 7E-8  -> 7E-8
ddbas402  toEng 7E-8  -> 70E-9
ddbas403  toSci 7E-9  -> 7E-9
ddbas404  toEng 7E-9  -> 7E-9
ddbas405  toSci 7E-10 -> 7E-10
ddbas406  toEng 7E-10 -> 700E-12
ddbas407  toSci 7E-11 -> 7E-11
ddbas408  toEng 7E-11 -> 70E-12
ddbas409  toSci 7E-12 -> 7E-12
ddbas410  toEng 7E-12 -> 7E-12
ddbas411  toSci 7E-13 -> 7E-13
ddbas412  toEng 7E-13 -> 700E-15

-- Exacts remain exact up to precision ..
rounding:  half_up
ddbas420  toSci    100 -> 100
ddbas421  toEng    100 -> 100
ddbas422  toSci   1000 -> 1000
ddbas423  toEng   1000 -> 1000
ddbas424  toSci  999.9 ->  999.9
ddbas425  toEng  999.9 ->  999.9
ddbas426  toSci 1000.0 -> 1000.0
ddbas427  toEng 1000.0 -> 1000.0
ddbas428  toSci 1000.1 -> 1000.1
ddbas429  toEng 1000.1 -> 1000.1
ddbas430  toSci 10000 -> 10000
ddbas431  toEng 10000 -> 10000
ddbas432  toSci 100000 -> 100000
ddbas433  toEng 100000 -> 100000
ddbas434  toSci 1000000 -> 1000000
ddbas435  toEng 1000000 -> 1000000
ddbas436  toSci 10000000 -> 10000000
ddbas437  toEng 10000000 -> 10000000
ddbas438  toSci 100000000 -> 100000000
ddbas439  toEng 1000000000000000 -> 1000000000000000
ddbas440  toSci 10000000000000000    -> 1.000000000000000E+16   Rounded
ddbas441  toEng 10000000000000000    -> 10.00000000000000E+15   Rounded
ddbas442  toSci 10000000000000001    -> 1.000000000000000E+16   Rounded Inexact
ddbas443  toEng 10000000000000001    -> 10.00000000000000E+15   Rounded Inexact
ddbas444  toSci 10000000000000003    -> 1.000000000000000E+16   Rounded Inexact
ddbas445  toEng 10000000000000003    -> 10.00000000000000E+15   Rounded Inexact
ddbas446  toSci 10000000000000005    -> 1.000000000000001E+16   Rounded Inexact
ddbas447  toEng 10000000000000005    -> 10.00000000000001E+15   Rounded Inexact
ddbas448  toSci 100000000000000050   -> 1.000000000000001E+17   Rounded Inexact
ddbas449  toEng 100000000000000050   -> 100.0000000000001E+15   Rounded Inexact
ddbas450  toSci 10000000000000009    -> 1.000000000000001E+16   Rounded Inexact
ddbas451  toEng 10000000000000009    -> 10.00000000000001E+15   Rounded Inexact
ddbas452  toSci 100000000000000000   -> 1.000000000000000E+17   Rounded
ddbas453  toEng 100000000000000000   -> 100.0000000000000E+15   Rounded
ddbas454  toSci 100000000000000003   -> 1.000000000000000E+17   Rounded Inexact
ddbas455  toEng 100000000000000003   -> 100.0000000000000E+15   Rounded Inexact
ddbas456  toSci 100000000000000005   -> 1.000000000000000E+17   Rounded Inexact
ddbas457  toEng 100000000000000005   -> 100.0000000000000E+15   Rounded Inexact
ddbas458  toSci 100000000000000009   -> 1.000000000000000E+17   Rounded Inexact
ddbas459  toEng 100000000000000009   -> 100.0000000000000E+15   Rounded Inexact
ddbas460  toSci 1000000000000000000  -> 1.000000000000000E+18   Rounded
ddbas461  toEng 1000000000000000000  -> 1.000000000000000E+18   Rounded
ddbas462  toSci 1000000000000000300  -> 1.000000000000000E+18   Rounded Inexact
ddbas463  toEng 1000000000000000300  -> 1.000000000000000E+18   Rounded Inexact
ddbas464  toSci 1000000000000000500  -> 1.000000000000001E+18   Rounded Inexact
ddbas465  toEng 1000000000000000500  -> 1.000000000000001E+18   Rounded Inexact
ddbas466  toSci 1000000000000000900  -> 1.000000000000001E+18   Rounded Inexact
ddbas467  toEng 1000000000000000900  -> 1.000000000000001E+18   Rounded Inexact
ddbas468  toSci 10000000000000000000 -> 1.000000000000000E+19   Rounded
ddbas469  toEng 10000000000000000000 -> 10.00000000000000E+18   Rounded
ddbas470  toSci 10000000000000003000 -> 1.000000000000000E+19   Rounded Inexact
ddbas471  toEng 10000000000000003000 -> 10.00000000000000E+18   Rounded Inexact
ddbas472  toSci 10000000000000005000 -> 1.000000000000001E+19   Rounded Inexact
ddbas473  toEng 10000000000000005000 -> 10.00000000000001E+18   Rounded Inexact
ddbas474  toSci 10000000000000009000 -> 1.000000000000001E+19   Rounded Inexact
ddbas475  toEng 10000000000000009000 -> 10.00000000000001E+18   Rounded Inexact

-- check rounding modes heeded
rounding:  ceiling
ddbsr401  toSci  1.1111111111123450    ->  1.111111111112345  Rounded
ddbsr402  toSci  1.11111111111234549   ->  1.111111111112346  Rounded Inexact
ddbsr403  toSci  1.11111111111234550   ->  1.111111111112346  Rounded Inexact
ddbsr404  toSci  1.11111111111234551   ->  1.111111111112346  Rounded Inexact
rounding:  up
ddbsr405  toSci  1.1111111111123450    ->  1.111111111112345  Rounded
ddbsr406  toSci  1.11111111111234549   ->  1.111111111112346  Rounded Inexact
ddbsr407  toSci  1.11111111111234550   ->  1.111111111112346  Rounded Inexact
ddbsr408  toSci  1.11111111111234551   ->  1.111111111112346  Rounded Inexact
rounding:  floor
ddbsr410  toSci  1.1111111111123450    ->  1.111111111112345  Rounded
ddbsr411  toSci  1.11111111111234549   ->  1.111111111112345  Rounded Inexact
ddbsr412  toSci  1.11111111111234550   ->  1.111111111112345  Rounded Inexact
ddbsr413  toSci  1.11111111111234551   ->  1.111111111112345  Rounded Inexact
rounding:  half_down
ddbsr415  toSci  1.1111111111123450    ->  1.111111111112345  Rounded
ddbsr416  toSci  1.11111111111234549   ->  1.111111111112345  Rounded Inexact
ddbsr417  toSci  1.11111111111234550   ->  1.111111111112345  Rounded Inexact
ddbsr418  toSci  1.11111111111234650   ->  1.111111111112346  Rounded Inexact
ddbsr419  toSci  1.11111111111234551   ->  1.111111111112346  Rounded Inexact
rounding:  half_even
ddbsr421  toSci  1.1111111111123450    ->  1.111111111112345  Rounded
ddbsr422  toSci  1.11111111111234549   ->  1.111111111112345  Rounded Inexact
ddbsr423  toSci  1.11111111111234550   ->  1.111111111112346  Rounded Inexact
ddbsr424  toSci  1.11111111111234650   ->  1.111111111112346  Rounded Inexact
ddbsr425  toSci  1.11111111111234551   ->  1.111111111112346  Rounded Inexact
rounding:  down
ddbsr426  toSci  1.1111111111123450    ->  1.111111111112345  Rounded
ddbsr427  toSci  1.11111111111234549   ->  1.111111111112345  Rounded Inexact
ddbsr428  toSci  1.11111111111234550   ->  1.111111111112345  Rounded Inexact
ddbsr429  toSci  1.11111111111234551   ->  1.111111111112345  Rounded Inexact
rounding:  half_up
ddbsr431  toSci  1.1111111111123450    ->  1.111111111112345  Rounded
ddbsr432  toSci  1.11111111111234549   ->  1.111111111112345  Rounded Inexact
ddbsr433  toSci  1.11111111111234550   ->  1.111111111112346  Rounded Inexact
ddbsr434  toSci  1.11111111111234650   ->  1.111111111112347  Rounded Inexact
ddbsr435  toSci  1.11111111111234551   ->  1.111111111112346  Rounded Inexact
-- negatives
rounding:  ceiling
ddbsr501  toSci -1.1111111111123450    -> -1.111111111112345  Rounded
ddbsr502  toSci -1.11111111111234549   -> -1.111111111112345  Rounded Inexact
ddbsr503  toSci -1.11111111111234550   -> -1.111111111112345  Rounded Inexact
ddbsr504  toSci -1.11111111111234551   -> -1.111111111112345  Rounded Inexact
rounding:  up
ddbsr505  toSci -1.1111111111123450    -> -1.111111111112345  Rounded
ddbsr506  toSci -1.11111111111234549   -> -1.111111111112346  Rounded Inexact
ddbsr507  toSci -1.11111111111234550   -> -1.111111111112346  Rounded Inexact
ddbsr508  toSci -1.11111111111234551   -> -1.111111111112346  Rounded Inexact
rounding:  floor
ddbsr510  toSci -1.1111111111123450    -> -1.111111111112345  Rounded
ddbsr511  toSci -1.11111111111234549   -> -1.111111111112346  Rounded Inexact
ddbsr512  toSci -1.11111111111234550   -> -1.111111111112346  Rounded Inexact
ddbsr513  toSci -1.11111111111234551   -> -1.111111111112346  Rounded Inexact
rounding:  half_down
ddbsr515  toSci -1.1111111111123450    -> -1.111111111112345  Rounded
ddbsr516  toSci -1.11111111111234549   -> -1.111111111112345  Rounded Inexact
ddbsr517  toSci -1.11111111111234550   -> -1.111111111112345  Rounded Inexact
ddbsr518  toSci -1.11111111111234650   -> -1.111111111112346  Rounded Inexact
ddbsr519  toSci -1.11111111111234551   -> -1.111111111112346  Rounded Inexact
rounding:  half_even
ddbsr521  toSci -1.1111111111123450    -> -1.111111111112345  Rounded
ddbsr522  toSci -1.11111111111234549   -> -1.111111111112345  Rounded Inexact
ddbsr523  toSci -1.11111111111234550   -> -1.111111111112346  Rounded Inexact
ddbsr524  toSci -1.11111111111234650   -> -1.111111111112346  Rounded Inexact
ddbsr525  toSci -1.11111111111234551   -> -1.111111111112346  Rounded Inexact
rounding:  down
ddbsr526  toSci -1.1111111111123450    -> -1.111111111112345  Rounded
ddbsr527  toSci -1.11111111111234549   -> -1.111111111112345  Rounded Inexact
ddbsr528  toSci -1.11111111111234550   -> -1.111111111112345  Rounded Inexact
ddbsr529  toSci -1.11111111111234551   -> -1.111111111112345  Rounded Inexact
rounding:  half_up
ddbsr531  toSci -1.1111111111123450    -> -1.111111111112345  Rounded
ddbsr532  toSci -1.11111111111234549   -> -1.111111111112345  Rounded Inexact
ddbsr533  toSci -1.11111111111234550   -> -1.111111111112346  Rounded Inexact
ddbsr534  toSci -1.11111111111234650   -> -1.111111111112347  Rounded Inexact
ddbsr535  toSci -1.11111111111234551   -> -1.111111111112346  Rounded Inexact

rounding:    half_even

-- The 'baddies' tests from DiagBigDecimal, plus some new ones
ddbas500 toSci '1..2'            -> NaN Conversion_syntax
ddbas501 toSci '.'               -> NaN Conversion_syntax
ddbas502 toSci '..'              -> NaN Conversion_syntax
ddbas503 toSci '++1'             -> NaN Conversion_syntax
ddbas504 toSci '--1'             -> NaN Conversion_syntax
ddbas505 toSci '-+1'             -> NaN Conversion_syntax
ddbas506 toSci '+-1'             -> NaN Conversion_syntax
ddbas507 toSci '12e'             -> NaN Conversion_syntax
ddbas508 toSci '12e++'           -> NaN Conversion_syntax
ddbas509 toSci '12f4'            -> NaN Conversion_syntax
ddbas510 toSci ' +1'             -> NaN Conversion_syntax
ddbas511 toSci '+ 1'             -> NaN Conversion_syntax
ddbas512 toSci '12 '             -> NaN Conversion_syntax
ddbas513 toSci ' + 1'            -> NaN Conversion_syntax
ddbas514 toSci ' - 1 '           -> NaN Conversion_syntax
ddbas515 toSci 'x'               -> NaN Conversion_syntax
ddbas516 toSci '-1-'             -> NaN Conversion_syntax
ddbas517 toSci '12-'             -> NaN Conversion_syntax
ddbas518 toSci '3+'              -> NaN Conversion_syntax
ddbas519 toSci ''                -> NaN Conversion_syntax
ddbas520 toSci '1e-'             -> NaN Conversion_syntax
ddbas521 toSci '7e99999a'        -> NaN Conversion_syntax
ddbas522 toSci '7e123567890x'    -> NaN Conversion_syntax
ddbas523 toSci '7e12356789012x'  -> NaN Conversion_syntax
ddbas524 toSci ''                -> NaN Conversion_syntax
ddbas525 toSci 'e100'            -> NaN Conversion_syntax
ddbas526 toSci '\u0e5a'          -> NaN Conversion_syntax
ddbas527 toSci '\u0b65'          -> NaN Conversion_syntax
ddbas528 toSci '123,65'          -> NaN Conversion_syntax
ddbas529 toSci '1.34.5'          -> NaN Conversion_syntax
ddbas530 toSci '.123.5'          -> NaN Conversion_syntax
ddbas531 toSci '01.35.'          -> NaN Conversion_syntax
ddbas532 toSci '01.35-'          -> NaN Conversion_syntax
ddbas533 toSci '0000..'          -> NaN Conversion_syntax
ddbas534 toSci '.0000.'          -> NaN Conversion_syntax
ddbas535 toSci '00..00'          -> NaN Conversion_syntax
ddbas536 toSci '111e*123'        -> NaN Conversion_syntax
ddbas537 toSci '111e123-'        -> NaN Conversion_syntax
ddbas538 toSci '111e+12+'        -> NaN Conversion_syntax
ddbas539 toSci '111e1-3-'        -> NaN Conversion_syntax
ddbas540 toSci '111e1*23'        -> NaN Conversion_syntax
ddbas541 toSci '111e1e+3'        -> NaN Conversion_syntax
ddbas542 toSci '1e1.0'           -> NaN Conversion_syntax
ddbas543 toSci '1e123e'          -> NaN Conversion_syntax
ddbas544 toSci 'ten'             -> NaN Conversion_syntax
ddbas545 toSci 'ONE'             -> NaN Conversion_syntax
ddbas546 toSci '1e.1'            -> NaN Conversion_syntax
ddbas547 toSci '1e1.'            -> NaN Conversion_syntax
ddbas548 toSci '1ee'             -> NaN Conversion_syntax
ddbas549 toSci 'e+1'             -> NaN Conversion_syntax
ddbas550 toSci '1.23.4'          -> NaN Conversion_syntax
ddbas551 toSci '1.2.1'           -> NaN Conversion_syntax
ddbas552 toSci '1E+1.2'          -> NaN Conversion_syntax
ddbas553 toSci '1E+1.2.3'        -> NaN Conversion_syntax
ddbas554 toSci '1E++1'           -> NaN Conversion_syntax
ddbas555 toSci '1E--1'           -> NaN Conversion_syntax
ddbas556 toSci '1E+-1'           -> NaN Conversion_syntax
ddbas557 toSci '1E-+1'           -> NaN Conversion_syntax
ddbas558 toSci '1E''1'           -> NaN Conversion_syntax
ddbas559 toSci "1E""1"           -> NaN Conversion_syntax
ddbas560 toSci "1E"""""          -> NaN Conversion_syntax
-- Near-specials
ddbas561 toSci "qNaN"            -> NaN Conversion_syntax
ddbas562 toSci "NaNq"            -> NaN Conversion_syntax
ddbas563 toSci "NaNs"            -> NaN Conversion_syntax
ddbas564 toSci "Infi"            -> NaN Conversion_syntax
ddbas565 toSci "Infin"           -> NaN Conversion_syntax
ddbas566 toSci "Infini"          -> NaN Conversion_syntax
ddbas567 toSci "Infinit"         -> NaN Conversion_syntax
ddbas568 toSci "-Infinit"        -> NaN Conversion_syntax
ddbas569 toSci "0Inf"            -> NaN Conversion_syntax
ddbas570 toSci "9Inf"            -> NaN Conversion_syntax
ddbas571 toSci "-0Inf"           -> NaN Conversion_syntax
ddbas572 toSci "-9Inf"           -> NaN Conversion_syntax
ddbas573 toSci "-sNa"            -> NaN Conversion_syntax
ddbas574 toSci "xNaN"            -> NaN Conversion_syntax
ddbas575 toSci "0sNaN"           -> NaN Conversion_syntax

-- some baddies with dots and Es and dots and specials
ddbas576 toSci  'e+1'            ->  NaN Conversion_syntax
ddbas577 toSci  '.e+1'           ->  NaN Conversion_syntax
ddbas578 toSci  '+.e+1'          ->  NaN Conversion_syntax
ddbas579 toSci  '-.e+'           ->  NaN Conversion_syntax
ddbas580 toSci  '-.e'            ->  NaN Conversion_syntax
ddbas581 toSci  'E+1'            ->  NaN Conversion_syntax
ddbas582 toSci  '.E+1'           ->  NaN Conversion_syntax
ddbas583 toSci  '+.E+1'          ->  NaN Conversion_syntax
ddbas584 toSci  '-.E+'           ->  NaN Conversion_syntax
ddbas585 toSci  '-.E'            ->  NaN Conversion_syntax

ddbas586 toSci  '.NaN'           ->  NaN Conversion_syntax
ddbas587 toSci  '-.NaN'          ->  NaN Conversion_syntax
ddbas588 toSci  '+.sNaN'         ->  NaN Conversion_syntax
ddbas589 toSci  '+.Inf'          ->  NaN Conversion_syntax
ddbas590 toSci  '.Infinity'      ->  NaN Conversion_syntax

-- Zeros
ddbas601 toSci 0.000000000       -> 0E-9
ddbas602 toSci 0.00000000        -> 0E-8
ddbas603 toSci 0.0000000         -> 0E-7
ddbas604 toSci 0.000000          -> 0.000000
ddbas605 toSci 0.00000           -> 0.00000
ddbas606 toSci 0.0000            -> 0.0000
ddbas607 toSci 0.000             -> 0.000
ddbas608 toSci 0.00              -> 0.00
ddbas609 toSci 0.0               -> 0.0
ddbas610 toSci  .0               -> 0.0
ddbas611 toSci 0.                -> 0
ddbas612 toSci -.0               -> -0.0
ddbas613 toSci -0.               -> -0
ddbas614 toSci -0.0              -> -0.0
ddbas615 toSci -0.00             -> -0.00
ddbas616 toSci -0.000            -> -0.000
ddbas617 toSci -0.0000           -> -0.0000
ddbas618 toSci -0.00000          -> -0.00000
ddbas619 toSci -0.000000         -> -0.000000
ddbas620 toSci -0.0000000        -> -0E-7
ddbas621 toSci -0.00000000       -> -0E-8
ddbas622 toSci -0.000000000      -> -0E-9

ddbas630 toSci  0.00E+0          -> 0.00
ddbas631 toSci  0.00E+1          -> 0.0
ddbas632 toSci  0.00E+2          -> 0
ddbas633 toSci  0.00E+3          -> 0E+1
ddbas634 toSci  0.00E+4          -> 0E+2
ddbas635 toSci  0.00E+5          -> 0E+3
ddbas636 toSci  0.00E+6          -> 0E+4
ddbas637 toSci  0.00E+7          -> 0E+5
ddbas638 toSci  0.00E+8          -> 0E+6
ddbas639 toSci  0.00E+9          -> 0E+7

ddbas640 toSci  0.0E+0           -> 0.0
ddbas641 toSci  0.0E+1           -> 0
ddbas642 toSci  0.0E+2           -> 0E+1
ddbas643 toSci  0.0E+3           -> 0E+2
ddbas644 toSci  0.0E+4           -> 0E+3
ddbas645 toSci  0.0E+5           -> 0E+4
ddbas646 toSci  0.0E+6           -> 0E+5
ddbas647 toSci  0.0E+7           -> 0E+6
ddbas648 toSci  0.0E+8           -> 0E+7
ddbas649 toSci  0.0E+9           -> 0E+8

ddbas650 toSci  0E+0             -> 0
ddbas651 toSci  0E+1             -> 0E+1
ddbas652 toSci  0E+2             -> 0E+2
ddbas653 toSci  0E+3             -> 0E+3
ddbas654 toSci  0E+4             -> 0E+4
ddbas655 toSci  0E+5             -> 0E+5
ddbas656 toSci  0E+6             -> 0E+6
ddbas657 toSci  0E+7             -> 0E+7
ddbas658 toSci  0E+8             -> 0E+8
ddbas659 toSci  0E+9             -> 0E+9

ddbas660 toSci  0.0E-0           -> 0.0
ddbas661 toSci  0.0E-1           -> 0.00
ddbas662 toSci  0.0E-2           -> 0.000
ddbas663 toSci  0.0E-3           -> 0.0000
ddbas664 toSci  0.0E-4           -> 0.00000
ddbas665 toSci  0.0E-5           -> 0.000000
ddbas666 toSci  0.0E-6           -> 0E-7
ddbas667 toSci  0.0E-7           -> 0E-8
ddbas668 toSci  0.0E-8           -> 0E-9
ddbas669 toSci  0.0E-9           -> 0E-10

ddbas670 toSci  0.00E-0          -> 0.00
ddbas671 toSci  0.00E-1          -> 0.000
ddbas672 toSci  0.00E-2          -> 0.0000
ddbas673 toSci  0.00E-3          -> 0.00000
ddbas674 toSci  0.00E-4          -> 0.000000
ddbas675 toSci  0.00E-5          -> 0E-7
ddbas676 toSci  0.00E-6          -> 0E-8
ddbas677 toSci  0.00E-7          -> 0E-9
ddbas678 toSci  0.00E-8          -> 0E-10
ddbas679 toSci  0.00E-9          -> 0E-11

ddbas680 toSci  000000.          ->  0
ddbas681 toSci   00000.          ->  0
ddbas682 toSci    0000.          ->  0
ddbas683 toSci     000.          ->  0
ddbas684 toSci      00.          ->  0
ddbas685 toSci       0.          ->  0
ddbas686 toSci  +00000.          ->  0
ddbas687 toSci  -00000.          -> -0
ddbas688 toSci  +0.              ->  0
ddbas689 toSci  -0.              -> -0

-- Specials
ddbas700 toSci "NaN"             -> NaN
ddbas701 toSci "nan"             -> NaN
ddbas702 toSci "nAn"             -> NaN
ddbas703 toSci "NAN"             -> NaN
ddbas704 toSci "+NaN"            -> NaN
ddbas705 toSci "+nan"            -> NaN
ddbas706 toSci "+nAn"            -> NaN
ddbas707 toSci "+NAN"            -> NaN
ddbas708 toSci "-NaN"            -> -NaN
ddbas709 toSci "-nan"            -> -NaN
ddbas710 toSci "-nAn"            -> -NaN
ddbas711 toSci "-NAN"            -> -NaN
ddbas712 toSci 'NaN0'            -> NaN
ddbas713 toSci 'NaN1'            -> NaN1
ddbas714 toSci 'NaN12'           -> NaN12
ddbas715 toSci 'NaN123'          -> NaN123
ddbas716 toSci 'NaN1234'         -> NaN1234
ddbas717 toSci 'NaN01'           -> NaN1
ddbas718 toSci 'NaN012'          -> NaN12
ddbas719 toSci 'NaN0123'         -> NaN123
ddbas720 toSci 'NaN01234'        -> NaN1234
ddbas721 toSci 'NaN001'          -> NaN1
ddbas722 toSci 'NaN0012'         -> NaN12
ddbas723 toSci 'NaN00123'        -> NaN123
ddbas724 toSci 'NaN001234'       -> NaN1234
ddbas725 toSci 'NaN1234567890123456' -> NaN Conversion_syntax
ddbas726 toSci 'NaN123e+1'       -> NaN Conversion_syntax
ddbas727 toSci 'NaN12.45'        -> NaN Conversion_syntax
ddbas728 toSci 'NaN-12'          -> NaN Conversion_syntax
ddbas729 toSci 'NaN+12'          -> NaN Conversion_syntax

ddbas730 toSci "sNaN"            -> sNaN
ddbas731 toSci "snan"            -> sNaN
ddbas732 toSci "SnAn"            -> sNaN
ddbas733 toSci "SNAN"            -> sNaN
ddbas734 toSci "+sNaN"           -> sNaN
ddbas735 toSci "+snan"           -> sNaN
ddbas736 toSci "+SnAn"           -> sNaN
ddbas737 toSci "+SNAN"           -> sNaN
ddbas738 toSci "-sNaN"           -> -sNaN
ddbas739 toSci "-snan"           -> -sNaN
ddbas740 toSci "-SnAn"           -> -sNaN
ddbas741 toSci "-SNAN"           -> -sNaN
ddbas742 toSci 'sNaN0000'        -> sNaN
ddbas743 toSci 'sNaN7'           -> sNaN7
ddbas744 toSci 'sNaN007234'      -> sNaN7234
ddbas745 toSci 'sNaN7234561234567890' -> NaN Conversion_syntax
ddbas746 toSci 'sNaN72.45'       -> NaN Conversion_syntax
ddbas747 toSci 'sNaN-72'         -> NaN Conversion_syntax

ddbas748 toSci "Inf"             -> Infinity
ddbas749 toSci "inf"             -> Infinity
ddbas750 toSci "iNf"             -> Infinity
ddbas751 toSci "INF"             -> Infinity
ddbas752 toSci "+Inf"            -> Infinity
ddbas753 toSci "+inf"            -> Infinity
ddbas754 toSci "+iNf"            -> Infinity
ddbas755 toSci "+INF"            -> Infinity
ddbas756 toSci "-Inf"            -> -Infinity
ddbas757 toSci "-inf"            -> -Infinity
ddbas758 toSci "-iNf"            -> -Infinity
ddbas759 toSci "-INF"            -> -Infinity

ddbas760 toSci "Infinity"        -> Infinity
ddbas761 toSci "infinity"        -> Infinity
ddbas762 toSci "iNfInItY"        -> Infinity
ddbas763 toSci "INFINITY"        -> Infinity
ddbas764 toSci "+Infinity"       -> Infinity
ddbas765 toSci "+infinity"       -> Infinity
ddbas766 toSci "+iNfInItY"       -> Infinity
ddbas767 toSci "+INFINITY"       -> Infinity
ddbas768 toSci "-Infinity"       -> -Infinity
ddbas769 toSci "-infinity"       -> -Infinity
ddbas770 toSci "-iNfInItY"       -> -Infinity
ddbas771 toSci "-INFINITY"       -> -Infinity

-- Specials and zeros for toEng
ddbast772 toEng "NaN"              -> NaN
ddbast773 toEng "-Infinity"        -> -Infinity
ddbast774 toEng "-sNaN"            -> -sNaN
ddbast775 toEng "-NaN"             -> -NaN
ddbast776 toEng "+Infinity"        -> Infinity
ddbast778 toEng "+sNaN"            -> sNaN
ddbast779 toEng "+NaN"             -> NaN
ddbast780 toEng "INFINITY"         -> Infinity
ddbast781 toEng "SNAN"             -> sNaN
ddbast782 toEng "NAN"              -> NaN
ddbast783 toEng "infinity"         -> Infinity
ddbast784 toEng "snan"             -> sNaN
ddbast785 toEng "nan"              -> NaN
ddbast786 toEng "InFINITY"         -> Infinity
ddbast787 toEng "SnAN"             -> sNaN
ddbast788 toEng "nAN"              -> NaN
ddbast789 toEng "iNfinity"         -> Infinity
ddbast790 toEng "sNan"             -> sNaN
ddbast791 toEng "Nan"              -> NaN
ddbast792 toEng "Infinity"         -> Infinity
ddbast793 toEng "sNaN"             -> sNaN

-- Zero toEng, etc.
ddbast800 toEng 0e+1              -> "0.00E+3"  -- doc example

ddbast801 toEng 0.000000000       -> 0E-9
ddbast802 toEng 0.00000000        -> 0.00E-6
ddbast803 toEng 0.0000000         -> 0.0E-6
ddbast804 toEng 0.000000          -> 0.000000
ddbast805 toEng 0.00000           -> 0.00000
ddbast806 toEng 0.0000            -> 0.0000
ddbast807 toEng 0.000             -> 0.000
ddbast808 toEng 0.00              -> 0.00
ddbast809 toEng 0.0               -> 0.0
ddbast810 toEng  .0               -> 0.0
ddbast811 toEng 0.                -> 0
ddbast812 toEng -.0               -> -0.0
ddbast813 toEng -0.               -> -0
ddbast814 toEng -0.0              -> -0.0
ddbast815 toEng -0.00             -> -0.00
ddbast816 toEng -0.000            -> -0.000
ddbast817 toEng -0.0000           -> -0.0000
ddbast818 toEng -0.00000          -> -0.00000
ddbast819 toEng -0.000000         -> -0.000000
ddbast820 toEng -0.0000000        -> -0.0E-6
ddbast821 toEng -0.00000000       -> -0.00E-6
ddbast822 toEng -0.000000000      -> -0E-9

ddbast830 toEng  0.00E+0          -> 0.00
ddbast831 toEng  0.00E+1          -> 0.0
ddbast832 toEng  0.00E+2          -> 0
ddbast833 toEng  0.00E+3          -> 0.00E+3
ddbast834 toEng  0.00E+4          -> 0.0E+3
ddbast835 toEng  0.00E+5          -> 0E+3
ddbast836 toEng  0.00E+6          -> 0.00E+6
ddbast837 toEng  0.00E+7          -> 0.0E+6
ddbast838 toEng  0.00E+8          -> 0E+6
ddbast839 toEng  0.00E+9          -> 0.00E+9

ddbast840 toEng  0.0E+0           -> 0.0
ddbast841 toEng  0.0E+1           -> 0
ddbast842 toEng  0.0E+2           -> 0.00E+3
ddbast843 toEng  0.0E+3           -> 0.0E+3
ddbast844 toEng  0.0E+4           -> 0E+3
ddbast845 toEng  0.0E+5           -> 0.00E+6
ddbast846 toEng  0.0E+6           -> 0.0E+6
ddbast847 toEng  0.0E+7           -> 0E+6
ddbast848 toEng  0.0E+8           -> 0.00E+9
ddbast849 toEng  0.0E+9           -> 0.0E+9

ddbast850 toEng  0E+0             -> 0
ddbast851 toEng  0E+1             -> 0.00E+3
ddbast852 toEng  0E+2             -> 0.0E+3
ddbast853 toEng  0E+3             -> 0E+3
ddbast854 toEng  0E+4             -> 0.00E+6
ddbast855 toEng  0E+5             -> 0.0E+6
ddbast856 toEng  0E+6             -> 0E+6
ddbast857 toEng  0E+7             -> 0.00E+9
ddbast858 toEng  0E+8             -> 0.0E+9
ddbast859 toEng  0E+9             -> 0E+9

ddbast860 toEng  0.0E-0           -> 0.0
ddbast861 toEng  0.0E-1           -> 0.00
ddbast862 toEng  0.0E-2           -> 0.000
ddbast863 toEng  0.0E-3           -> 0.0000
ddbast864 toEng  0.0E-4           -> 0.00000
ddbast865 toEng  0.0E-5           -> 0.000000
ddbast866 toEng  0.0E-6           -> 0.0E-6
ddbast867 toEng  0.0E-7           -> 0.00E-6
ddbast868 toEng  0.0E-8           -> 0E-9
ddbast869 toEng  0.0E-9           -> 0.0E-9

ddbast870 toEng  0.00E-0          -> 0.00
ddbast871 toEng  0.00E-1          -> 0.000
ddbast872 toEng  0.00E-2          -> 0.0000
ddbast873 toEng  0.00E-3          -> 0.00000
ddbast874 toEng  0.00E-4          -> 0.000000
ddbast875 toEng  0.00E-5          -> 0.0E-6
ddbast876 toEng  0.00E-6          -> 0.00E-6
ddbast877 toEng  0.00E-7          -> 0E-9
ddbast878 toEng  0.00E-8          -> 0.0E-9
ddbast879 toEng  0.00E-9          -> 0.00E-9

-- long input strings
ddbas801 tosci '01234567890123456' -> 1234567890123456
ddbas802 tosci '001234567890123456' -> 1234567890123456
ddbas803 tosci '0001234567890123456' -> 1234567890123456
ddbas804 tosci '00001234567890123456' -> 1234567890123456
ddbas805 tosci '000001234567890123456' -> 1234567890123456
ddbas806 tosci '0000001234567890123456' -> 1234567890123456
ddbas807 tosci '00000001234567890123456' -> 1234567890123456
ddbas808 tosci '000000001234567890123456' -> 1234567890123456
ddbas809 tosci '0000000001234567890123456' -> 1234567890123456
ddbas810 tosci '00000000001234567890123456' -> 1234567890123456

ddbas811 tosci '0.1234567890123456' -> 0.1234567890123456
ddbas812 tosci '0.01234567890123456' -> 0.01234567890123456
ddbas813 tosci '0.001234567890123456' -> 0.001234567890123456
ddbas814 tosci '0.0001234567890123456' -> 0.0001234567890123456
ddbas815 tosci '0.00001234567890123456' -> 0.00001234567890123456
ddbas816 tosci '0.000001234567890123456' -> 0.000001234567890123456
ddbas817 tosci '0.0000001234567890123456' -> 1.234567890123456E-7
ddbas818 tosci '0.00000001234567890123456' -> 1.234567890123456E-8
ddbas819 tosci '0.000000001234567890123456' -> 1.234567890123456E-9
ddbas820 tosci '0.0000000001234567890123456' -> 1.234567890123456E-10

ddbas821 tosci '12345678901234567890' -> 1.234567890123457E+19 Inexact Rounded
ddbas822 tosci '123456789012345678901' -> 1.234567890123457E+20 Inexact Rounded
ddbas823 tosci '1234567890123456789012' -> 1.234567890123457E+21 Inexact Rounded
ddbas824 tosci '12345678901234567890123' -> 1.234567890123457E+22 Inexact Rounded
ddbas825 tosci '123456789012345678901234' -> 1.234567890123457E+23 Inexact Rounded
ddbas826 tosci '1234567890123456789012345' -> 1.234567890123457E+24 Inexact Rounded
ddbas827 tosci '12345678901234567890123456' -> 1.234567890123457E+25 Inexact Rounded
ddbas828 tosci '123456789012345678901234567' -> 1.234567890123457E+26 Inexact Rounded
ddbas829 tosci '1234567890123456789012345678' -> 1.234567890123457E+27 Inexact Rounded

-- subnormals and overflows
ddbas906 toSci '99e999999999'       -> Infinity Overflow  Inexact Rounded
ddbas907 toSci '999e999999999'      -> Infinity Overflow  Inexact Rounded
ddbas908 toSci '0.9e-999999999'     -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas909 toSci '0.09e-999999999'    -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas910 toSci '0.1e1000000000'     -> Infinity Overflow  Inexact Rounded
ddbas911 toSci '10e-1000000000'     -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas912 toSci '0.9e9999999999'     -> Infinity Overflow  Inexact Rounded
ddbas913 toSci '99e-9999999999'     -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas914 toSci '111e9999999999'     -> Infinity Overflow  Inexact Rounded
ddbas915 toSci '1111e-9999999999'   -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas916 toSci '1111e-99999999999'  -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas917 toSci '7e1000000000'       -> Infinity Overflow  Inexact Rounded
-- negatives the same
ddbas918 toSci '-99e999999999'      -> -Infinity Overflow  Inexact Rounded
ddbas919 toSci '-999e999999999'     -> -Infinity Overflow  Inexact Rounded
ddbas920 toSci '-0.9e-999999999'    -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas921 toSci '-0.09e-999999999'   -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas922 toSci '-0.1e1000000000'    -> -Infinity Overflow  Inexact Rounded
ddbas923 toSci '-10e-1000000000'    -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas924 toSci '-0.9e9999999999'    -> -Infinity Overflow  Inexact Rounded
ddbas925 toSci '-99e-9999999999'    -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas926 toSci '-111e9999999999'    -> -Infinity Overflow  Inexact Rounded
ddbas927 toSci '-1111e-9999999999'  -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas928 toSci '-1111e-99999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas929 toSci '-7e1000000000'      -> -Infinity Overflow  Inexact Rounded

-- overflow results at different rounding modes
rounding:  ceiling
ddbas930 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
ddbas931 toSci '-7e10000'  -> -9.999999999999999E+384 Overflow  Inexact Rounded
rounding:  up
ddbas932 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
ddbas933 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded
rounding:  down
ddbas934 toSci  '7e10000'  ->  9.999999999999999E+384 Overflow  Inexact Rounded
ddbas935 toSci '-7e10000'  -> -9.999999999999999E+384 Overflow  Inexact Rounded
rounding:  floor
ddbas936 toSci  '7e10000'  ->  9.999999999999999E+384 Overflow  Inexact Rounded
ddbas937 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded

rounding:  half_up
ddbas938 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
ddbas939 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded
rounding:  half_even
ddbas940 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
ddbas941 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded
rounding:  half_down
ddbas942 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
ddbas943 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded

rounding:  half_even

-- Now check 854/754r some subnormals and underflow to 0
ddbem400 toSci  1.0000E-383     -> 1.0000E-383
ddbem401 toSci  0.1E-394        -> 1E-395       Subnormal
ddbem402 toSci  0.1000E-394     -> 1.000E-395   Subnormal
ddbem403 toSci  0.0100E-394     -> 1.00E-396    Subnormal
ddbem404 toSci  0.0010E-394     -> 1.0E-397     Subnormal
ddbem405 toSci  0.0001E-394     -> 1E-398       Subnormal
ddbem406 toSci  0.00010E-394    -> 1E-398     Subnormal Rounded
ddbem407 toSci  0.00013E-394    -> 1E-398     Underflow Subnormal Inexact Rounded
ddbem408 toSci  0.00015E-394    -> 2E-398     Underflow Subnormal Inexact Rounded
ddbem409 toSci  0.00017E-394    -> 2E-398     Underflow Subnormal Inexact Rounded
ddbem410 toSci  0.00023E-394    -> 2E-398     Underflow Subnormal Inexact Rounded
ddbem411 toSci  0.00025E-394    -> 2E-398     Underflow Subnormal Inexact Rounded
ddbem412 toSci  0.00027E-394    -> 3E-398     Underflow Subnormal Inexact Rounded
ddbem413 toSci  0.000149E-394   -> 1E-398     Underflow Subnormal Inexact Rounded
ddbem414 toSci  0.000150E-394   -> 2E-398     Underflow Subnormal Inexact Rounded
ddbem415 toSci  0.000151E-394   -> 2E-398     Underflow Subnormal Inexact Rounded
ddbem416 toSci  0.000249E-394   -> 2E-398     Underflow Subnormal Inexact Rounded
ddbem417 toSci  0.000250E-394   -> 2E-398     Underflow Subnormal Inexact Rounded
ddbem418 toSci  0.000251E-394   -> 3E-398     Underflow Subnormal Inexact Rounded
ddbem419 toSci  0.00009E-394    -> 1E-398     Underflow Subnormal Inexact Rounded
ddbem420 toSci  0.00005E-394    -> 0E-398     Underflow Subnormal Inexact Rounded Clamped
ddbem421 toSci  0.00003E-394    -> 0E-398     Underflow Subnormal Inexact Rounded Clamped
ddbem422 toSci  0.000009E-394   -> 0E-398     Underflow Subnormal Inexact Rounded Clamped
ddbem423 toSci  0.000005E-394   -> 0E-398     Underflow Subnormal Inexact Rounded Clamped
ddbem424 toSci  0.000003E-394   -> 0E-398     Underflow Subnormal Inexact Rounded Clamped

ddbem425 toSci  0.001049E-394   -> 1.0E-397   Underflow Subnormal Inexact Rounded
ddbem426 toSci  0.001050E-394   -> 1.0E-397   Underflow Subnormal Inexact Rounded
ddbem427 toSci  0.001051E-394   -> 1.1E-397   Underflow Subnormal Inexact Rounded
ddbem428 toSci  0.001149E-394   -> 1.1E-397   Underflow Subnormal Inexact Rounded
ddbem429 toSci  0.001150E-394   -> 1.2E-397   Underflow Subnormal Inexact Rounded
ddbem430 toSci  0.001151E-394   -> 1.2E-397   Underflow Subnormal Inexact Rounded

ddbem432 toSci  0.010049E-394   -> 1.00E-396  Underflow Subnormal Inexact Rounded
ddbem433 toSci  0.010050E-394   -> 1.00E-396  Underflow Subnormal Inexact Rounded
ddbem434 toSci  0.010051E-394   -> 1.01E-396  Underflow Subnormal Inexact Rounded
ddbem435 toSci  0.010149E-394   -> 1.01E-396  Underflow Subnormal Inexact Rounded
ddbem436 toSci  0.010150E-394   -> 1.02E-396  Underflow Subnormal Inexact Rounded
ddbem437 toSci  0.010151E-394   -> 1.02E-396  Underflow Subnormal Inexact Rounded

ddbem440 toSci  0.10103E-394    -> 1.010E-395 Underflow Subnormal Inexact Rounded
ddbem441 toSci  0.10105E-394    -> 1.010E-395 Underflow Subnormal Inexact Rounded
ddbem442 toSci  0.10107E-394    -> 1.011E-395 Underflow Subnormal Inexact Rounded
ddbem443 toSci  0.10113E-394    -> 1.011E-395 Underflow Subnormal Inexact Rounded
ddbem444 toSci  0.10115E-394    -> 1.012E-395 Underflow Subnormal Inexact Rounded
ddbem445 toSci  0.10117E-394    -> 1.012E-395 Underflow Subnormal Inexact Rounded

ddbem450 toSci  1.10730E-395   -> 1.107E-395 Underflow Subnormal Inexact Rounded
ddbem451 toSci  1.10750E-395   -> 1.108E-395 Underflow Subnormal Inexact Rounded
ddbem452 toSci  1.10770E-395   -> 1.108E-395 Underflow Subnormal Inexact Rounded
ddbem453 toSci  1.10830E-395   -> 1.108E-395 Underflow Subnormal Inexact Rounded
ddbem454 toSci  1.10850E-395   -> 1.108E-395 Underflow Subnormal Inexact Rounded
ddbem455 toSci  1.10870E-395   -> 1.109E-395 Underflow Subnormal Inexact Rounded

-- make sure sign OK
ddbem456 toSci  -0.10103E-394   -> -1.010E-395 Underflow Subnormal Inexact Rounded
ddbem457 toSci  -0.10105E-394   -> -1.010E-395 Underflow Subnormal Inexact Rounded
ddbem458 toSci  -0.10107E-394   -> -1.011E-395 Underflow Subnormal Inexact Rounded
ddbem459 toSci  -0.10113E-394   -> -1.011E-395 Underflow Subnormal Inexact Rounded
ddbem460 toSci  -0.10115E-394   -> -1.012E-395 Underflow Subnormal Inexact Rounded
ddbem461 toSci  -0.10117E-394   -> -1.012E-395 Underflow Subnormal Inexact Rounded

-- '999s' cases
ddbem464 toSci  999999E-395         -> 9.99999E-390 Subnormal
ddbem465 toSci  99999.0E-394        -> 9.99990E-390 Subnormal
ddbem466 toSci  99999.E-394         -> 9.9999E-390  Subnormal
ddbem467 toSci  9999.9E-394         -> 9.9999E-391  Subnormal
ddbem468 toSci  999.99E-394         -> 9.9999E-392  Subnormal
ddbem469 toSci  99.999E-394         -> 9.9999E-393  Subnormal
ddbem470 toSci  9.9999E-394         -> 9.9999E-394  Subnormal
ddbem471 toSci  0.99999E-394        -> 1.0000E-394 Underflow Subnormal Inexact Rounded
ddbem472 toSci  0.099999E-394       -> 1.000E-395 Underflow Subnormal Inexact Rounded
ddbem473 toSci  0.0099999E-394      -> 1.00E-396  Underflow Subnormal Inexact Rounded
ddbem474 toSci  0.00099999E-394     -> 1.0E-397   Underflow Subnormal Inexact Rounded
ddbem475 toSci  0.000099999E-394    -> 1E-398     Underflow Subnormal Inexact Rounded
ddbem476 toSci  0.0000099999E-394   -> 0E-398     Underflow Subnormal Inexact Rounded Clamped
ddbem477 toSci  0.00000099999E-394  -> 0E-398     Underflow Subnormal Inexact Rounded Clamped
ddbem478 toSci  0.000000099999E-394 -> 0E-398     Underflow Subnormal Inexact Rounded Clamped

-- Exponents with insignificant leading zeros
ddbas1001 toSci  1e999999999 -> Infinity Overflow Inexact Rounded
ddbas1002 toSci  1e0999999999 -> Infinity Overflow Inexact Rounded
ddbas1003 toSci  1e00999999999 -> Infinity Overflow Inexact Rounded
ddbas1004 toSci  1e000999999999 -> Infinity Overflow Inexact Rounded
ddbas1005 toSci  1e000000000000999999999 -> Infinity Overflow Inexact Rounded
ddbas1006 toSci  1e000000000001000000007 -> Infinity Overflow Inexact Rounded
ddbas1007 toSci  1e-999999999 -> 0E-398             Underflow Subnormal Inexact Rounded Clamped
ddbas1008 toSci  1e-0999999999 -> 0E-398            Underflow Subnormal Inexact Rounded Clamped
ddbas1009 toSci  1e-00999999999 -> 0E-398           Underflow Subnormal Inexact Rounded Clamped
ddbas1010 toSci  1e-000999999999 -> 0E-398          Underflow Subnormal Inexact Rounded Clamped
ddbas1011 toSci  1e-000000000000999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
ddbas1012 toSci  1e-000000000001000000007 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped

-- check for double-rounded subnormals
ddbas1041 toSci     1.1111111111152444E-384 ->  1.11111111111524E-384 Inexact Rounded Subnormal Underflow
ddbas1042 toSci     1.1111111111152445E-384 ->  1.11111111111524E-384 Inexact Rounded Subnormal Underflow
ddbas1043 toSci     1.1111111111152446E-384 ->  1.11111111111524E-384 Inexact Rounded Subnormal Underflow

-- clamped zeros [see also clamp.decTest]
ddbas1075 toSci   0e+10000  ->  0E+369  Clamped
ddbas1076 toSci   0e-10000  ->  0E-398  Clamped
ddbas1077 toSci  -0e+10000  -> -0E+369  Clamped
ddbas1078 toSci  -0e-10000  -> -0E-398  Clamped

-- extreme values from next-wider
ddbas1101 toSci -9.99999999999999999999999999999999E+6144 -> -Infinity Overflow Inexact Rounded
ddbas1102 toSci -1E-6143 -> -0E-398 Inexact Rounded Subnormal Underflow Clamped
ddbas1103 toSci -1E-6176 -> -0E-398 Inexact Rounded Subnormal Underflow Clamped
ddbas1104 toSci -0 -> -0
ddbas1105 toSci +0 ->  0
ddbas1106 toSci +1E-6176 ->  0E-398 Inexact Rounded Subnormal Underflow Clamped
ddbas1107 toSci +1E-6173 ->  0E-398 Inexact Rounded Subnormal Underflow Clamped
ddbas1108 toSci +9.99999999999999999999999999999999E+6144 ->  Infinity Overflow Inexact Rounded

Added test/dectest/ddCanonical.decTest.











































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
------------------------------------------------------------------------
-- ddCanonical.decTest -- test decDouble canonical results            --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This file tests that copy operations leave uncanonical operands
-- unchanged, and vice versa
-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Uncanonical declets are: abc, where:
--   a=1,2,3
--   b=6,7,e,f
--   c=e,f

-- assert some standard (canonical) values; this tests that FromString
-- produces canonical results (many more in decimalNN)
ddcan001 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff
ddcan002 apply 0                      -> #2238000000000000
ddcan003 apply 1                      -> #2238000000000001
ddcan004 apply -1                     -> #a238000000000001
ddcan005 apply Infinity               -> #7800000000000000
ddcan006 apply -Infinity              -> #f800000000000000
ddcan007 apply -NaN                   -> #fc00000000000000
ddcan008 apply -sNaN                  -> #fe00000000000000
ddcan009 apply NaN999999999999999     -> #7c00ff3fcff3fcff
ddcan010 apply sNaN999999999999999    -> #7e00ff3fcff3fcff
decan011 apply  9999999999999999      -> #6e38ff3fcff3fcff
ddcan012 apply 7.50                   -> #22300000000003d0
ddcan013 apply 9.99                   -> #22300000000000ff

-- Base tests for canonical encodings (individual operator
-- propagation is tested later)

-- Finites: declets in coefficient
ddcan021 canonical  #77fcff3fcff3fcff  -> #77fcff3fcff3fcff
ddcan022 canonical  #77fcff3fcff3fcff  -> #77fcff3fcff3fcff
ddcan023 canonical  #77ffff3fcff3fcff  -> #77fcff3fcff3fcff
ddcan024 canonical  #77ffff3fcff3fcff  -> #77fcff3fcff3fcff
ddcan025 canonical  #77fcffffcff3fcff  -> #77fcff3fcff3fcff
ddcan026 canonical  #77fcffffcff3fcff  -> #77fcff3fcff3fcff
ddcan027 canonical  #77fcff3ffff3fcff  -> #77fcff3fcff3fcff
ddcan028 canonical  #77fcff3ffff3fcff  -> #77fcff3fcff3fcff
ddcan030 canonical  #77fcff3fcffffcff  -> #77fcff3fcff3fcff
ddcan031 canonical  #77fcff3fcffffcff  -> #77fcff3fcff3fcff
ddcan032 canonical  #77fcff3fcff3ffff  -> #77fcff3fcff3fcff
ddcan033 canonical  #77fcff3fcff3ffff  -> #77fcff3fcff3fcff
ddcan035 canonical  #77fcff3fdff3fcff  -> #77fcff3fcff3fcff
ddcan036 canonical  #77fcff3feff3fcff  -> #77fcff3fcff3fcff

-- NaN: declets in payload
ddcan100 canonical  NaN999999999999999 -> #7c00ff3fcff3fcff
ddcan101 canonical  #7c00ff3fcff3fcff  -> #7c00ff3fcff3fcff
ddcan102 canonical  #7c03ff3fcff3fcff  -> #7c00ff3fcff3fcff
ddcan103 canonical  #7c00ffffcff3fcff  -> #7c00ff3fcff3fcff
ddcan104 canonical  #7c00ff3ffff3fcff  -> #7c00ff3fcff3fcff
ddcan105 canonical  #7c00ff3fcffffcff  -> #7c00ff3fcff3fcff
ddcan106 canonical  #7c00ff3fcff3ffff  -> #7c00ff3fcff3fcff
ddcan107 canonical  #7c00ff3fcff3ffff  -> #7c00ff3fcff3fcff
-- NaN: exponent continuation bits [excluding sNaN selector]
ddcan110 canonical  #7c00ff3fcff3fcff  -> #7c00ff3fcff3fcff
ddcan112 canonical  #7d00ff3fcff3fcff  -> #7c00ff3fcff3fcff
ddcan113 canonical  #7c80ff3fcff3fcff  -> #7c00ff3fcff3fcff
ddcan114 canonical  #7c40ff3fcff3fcff  -> #7c00ff3fcff3fcff
ddcan115 canonical  #7c20ff3fcff3fcff  -> #7c00ff3fcff3fcff
ddcan116 canonical  #7c10ff3fcff3fcff  -> #7c00ff3fcff3fcff
ddcan117 canonical  #7c08ff3fcff3fcff  -> #7c00ff3fcff3fcff
ddcan118 canonical  #7c04ff3fcff3fcff  -> #7c00ff3fcff3fcff

-- sNaN: declets in payload
ddcan120 canonical sNaN999999999999999 -> #7e00ff3fcff3fcff
ddcan121 canonical  #7e00ff3fcff3fcff  -> #7e00ff3fcff3fcff
ddcan122 canonical  #7e03ff3fcff3fcff  -> #7e00ff3fcff3fcff
ddcan123 canonical  #7e00ffffcff3fcff  -> #7e00ff3fcff3fcff
ddcan124 canonical  #7e00ff3ffff3fcff  -> #7e00ff3fcff3fcff
ddcan125 canonical  #7e00ff3fcffffcff  -> #7e00ff3fcff3fcff
ddcan126 canonical  #7e00ff3fcff3ffff  -> #7e00ff3fcff3fcff
ddcan127 canonical  #7e00ff3fcff3ffff  -> #7e00ff3fcff3fcff
-- sNaN: exponent continuation bits [excluding sNaN selector]
ddcan130 canonical  #7e00ff3fcff3fcff  -> #7e00ff3fcff3fcff
ddcan132 canonical  #7f00ff3fcff3fcff  -> #7e00ff3fcff3fcff
ddcan133 canonical  #7e80ff3fcff3fcff  -> #7e00ff3fcff3fcff
ddcan134 canonical  #7e40ff3fcff3fcff  -> #7e00ff3fcff3fcff
ddcan135 canonical  #7e20ff3fcff3fcff  -> #7e00ff3fcff3fcff
ddcan136 canonical  #7e10ff3fcff3fcff  -> #7e00ff3fcff3fcff
ddcan137 canonical  #7e08ff3fcff3fcff  -> #7e00ff3fcff3fcff
ddcan138 canonical  #7e04ff3fcff3fcff  -> #7e00ff3fcff3fcff

-- Inf: exponent continuation bits
ddcan140 canonical  #7800000000000000  -> #7800000000000000
ddcan141 canonical  #7900000000000000  -> #7800000000000000
ddcan142 canonical  #7a00000000000000  -> #7800000000000000
ddcan143 canonical  #7880000000000000  -> #7800000000000000
ddcan144 canonical  #7840000000000000  -> #7800000000000000
ddcan145 canonical  #7820000000000000  -> #7800000000000000
ddcan146 canonical  #7810000000000000  -> #7800000000000000
ddcan147 canonical  #7808000000000000  -> #7800000000000000
ddcan148 canonical  #7804000000000000  -> #7800000000000000

-- Inf: coefficient continuation bits (first, last, and a few others)
ddcan150 canonical  #7800000000000000  -> #7800000000000000
ddcan151 canonical  #7802000000000000  -> #7800000000000000
ddcan152 canonical  #7800000000000001  -> #7800000000000000
ddcan153 canonical  #7801000000000000  -> #7800000000000000
ddcan154 canonical  #7800200000000000  -> #7800000000000000
ddcan155 canonical  #7800080000000000  -> #7800000000000000
ddcan156 canonical  #7800002000000000  -> #7800000000000000
ddcan157 canonical  #7800000400000000  -> #7800000000000000
ddcan158 canonical  #7800000040000000  -> #7800000000000000
ddcan159 canonical  #7800000008000000  -> #7800000000000000
ddcan160 canonical  #7800000000400000  -> #7800000000000000
ddcan161 canonical  #7800000000020000  -> #7800000000000000
ddcan162 canonical  #7800000000008000  -> #7800000000000000
ddcan163 canonical  #7800000000000200  -> #7800000000000000
ddcan164 canonical  #7800000000000040  -> #7800000000000000
ddcan165 canonical  #7800000000000008  -> #7800000000000000


-- Now the operators -- trying to check paths that might fail to
-- canonicalize propagated operands

----- Add:
-- Finites: neutral 0
ddcan202 add  0E+384 #77ffff3fcff3fcff        -> #77fcff3fcff3fcff
ddcan203 add         #77fcffffcff3fcff 0E+384 -> #77fcff3fcff3fcff
-- tiny zero
ddcan204 add  0E-398 #77ffff3fcff3fcff        -> #77fcff3fcff3fcff Rounded
ddcan205 add         #77fcffffcff3fcff 0E-398 -> #77fcff3fcff3fcff Rounded
-- tiny non zero
ddcan206 add -1E-398 #77ffff3fcff3fcff         -> #77fcff3fcff3fcff Inexact Rounded
ddcan207 add         #77ffff3fcff3fcff -1E-398 -> #77fcff3fcff3fcff Inexact Rounded
-- NaN: declets in payload
ddcan211 add  0  #7c03ff3fcff3fcff      -> #7c00ff3fcff3fcff
ddcan212 add     #7c03ff3fcff3fcff  0   -> #7c00ff3fcff3fcff
-- NaN: exponent continuation bits [excluding sNaN selector]
ddcan213 add  0  #7c40ff3fcff3fcff      -> #7c00ff3fcff3fcff
ddcan214 add     #7c40ff3fcff3fcff  0   -> #7c00ff3fcff3fcff
-- sNaN: declets in payload
ddcan215 add  0  #7e00ffffcff3fcff      -> #7c00ff3fcff3fcff Invalid_operation
ddcan216 add     #7e00ffffcff3fcff  0   -> #7c00ff3fcff3fcff Invalid_operation
-- sNaN: exponent continuation bits [excluding sNaN selector]
ddcan217 add  0  #7e80ff3fcff3fcff      -> #7c00ff3fcff3fcff Invalid_operation
ddcan218 add     #7e80ff3fcff3fcff  0   -> #7c00ff3fcff3fcff Invalid_operation
-- Inf: exponent continuation bits
ddcan220 add  0  #7880000000000000      -> #7800000000000000
ddcan221 add     #7880000000000000  0   -> #7800000000000000
-- Inf: coefficient continuation bits
ddcan222 add  0  #7802000000000000     -> #7800000000000000
ddcan223 add     #7802000000000000  0  -> #7800000000000000
ddcan224 add  0  #7800000000000001     -> #7800000000000000
ddcan225 add     #7800000000000001  0  -> #7800000000000000
ddcan226 add  0  #7800002000000000     -> #7800000000000000
ddcan227 add     #7800002000000000  0  -> #7800000000000000

----- Class: [does not return encoded]

----- Compare:
ddcan231 compare -Inf   1     ->  #a238000000000001
ddcan232 compare -Inf  -Inf   ->  #2238000000000000
ddcan233 compare  1    -Inf   ->  #2238000000000001
ddcan234 compare  #7c00ff3ffff3fcff -1000  ->  #7c00ff3fcff3fcff
ddcan235 compare  #7e00ff3ffff3fcff -1000  ->  #7c00ff3fcff3fcff  Invalid_operation

----- CompareSig:
ddcan241 comparesig -Inf   1     ->  #a238000000000001
ddcan242 comparesig -Inf  -Inf   ->  #2238000000000000
ddcan243 comparesig  1    -Inf   ->  #2238000000000001
ddcan244 comparesig  #7c00ff3ffff3fcff -1000  ->  #7c00ff3fcff3fcff  Invalid_operation
ddcan245 comparesig  #7e00ff3ffff3fcff -1000  ->  #7c00ff3fcff3fcff  Invalid_operation

----- Copy: [does not usually canonicalize]
-- finites
ddcan250 copy  #77ffff3fcff3fcff  -> #77ffff3fcff3fcff
ddcan251 copy  #77fcff3fdff3fcff  -> #77fcff3fdff3fcff
-- NaNs
ddcan252 copy  #7c03ff3fcff3fcff  -> #7c03ff3fcff3fcff
ddcan253 copy  #7c00ff3fcff3ffff  -> #7c00ff3fcff3ffff
ddcan254 copy  #7d00ff3fcff3fcff  -> #7d00ff3fcff3fcff
ddcan255 copy  #7c04ff3fcff3fcff  -> #7c04ff3fcff3fcff
-- sNaN
ddcan256 copy  #7e00ff3fcffffcff  -> #7e00ff3fcffffcff
ddcan257 copy  #7e40ff3fcff3fcff  -> #7e40ff3fcff3fcff
-- Inf
ddcan258 copy  #7a00000000000000  -> #7a00000000000000
ddcan259 copy  #7800200000000000  -> #7800200000000000

----- CopyAbs: [does not usually canonicalize]
-- finites
ddcan260 copyabs  #f7ffff3fcff3fcff  -> #77ffff3fcff3fcff
ddcan261 copyabs  #f7fcff3fdff3fcff  -> #77fcff3fdff3fcff
-- NaNs
ddcan262 copyabs  #fc03ff3fcff3fcff  -> #7c03ff3fcff3fcff
ddcan263 copyabs  #fc00ff3fcff3ffff  -> #7c00ff3fcff3ffff
ddcan264 copyabs  #fd00ff3fcff3fcff  -> #7d00ff3fcff3fcff
ddcan265 copyabs  #fc04ff3fcff3fcff  -> #7c04ff3fcff3fcff
-- sNaN
ddcan266 copyabs  #fe00ff3fcffffcff  -> #7e00ff3fcffffcff
ddcan267 copyabs  #fe40ff3fcff3fcff  -> #7e40ff3fcff3fcff
-- Inf
ddcan268 copyabs  #fa00000000000000  -> #7a00000000000000
ddcan269 copyabs  #f800200000000000  -> #7800200000000000

----- CopyNegate: [does not usually canonicalize]
-- finites
ddcan270 copynegate  #77ffff3fcff3fcff  -> #f7ffff3fcff3fcff
ddcan271 copynegate  #77fcff3fdff3fcff  -> #f7fcff3fdff3fcff
-- NaNs
ddcan272 copynegate  #7c03ff3fcff3fcff  -> #fc03ff3fcff3fcff
ddcan273 copynegate  #7c00ff3fcff3ffff  -> #fc00ff3fcff3ffff
ddcan274 copynegate  #7d00ff3fcff3fcff  -> #fd00ff3fcff3fcff
ddcan275 copynegate  #7c04ff3fcff3fcff  -> #fc04ff3fcff3fcff
-- sNaN
ddcan276 copynegate  #7e00ff3fcffffcff  -> #fe00ff3fcffffcff
ddcan277 copynegate  #7e40ff3fcff3fcff  -> #fe40ff3fcff3fcff
-- Inf
ddcan278 copynegate  #7a00000000000000  -> #fa00000000000000
ddcan279 copynegate  #7800200000000000  -> #f800200000000000

----- CopySign: [does not usually canonicalize]
-- finites
ddcan280 copysign  #77ffff3fcff3fcff -1 -> #f7ffff3fcff3fcff
ddcan281 copysign  #77fcff3fdff3fcff  1 -> #77fcff3fdff3fcff
-- NaNs
ddcan282 copysign  #7c03ff3fcff3fcff -1 -> #fc03ff3fcff3fcff
ddcan283 copysign  #7c00ff3fcff3ffff  1 -> #7c00ff3fcff3ffff
ddcan284 copysign  #7d00ff3fcff3fcff -1 -> #fd00ff3fcff3fcff
ddcan285 copysign  #7c04ff3fcff3fcff  1 -> #7c04ff3fcff3fcff
-- sNaN
ddcan286 copysign  #7e00ff3fcffffcff -1 -> #fe00ff3fcffffcff
ddcan287 copysign  #7e40ff3fcff3fcff  1 -> #7e40ff3fcff3fcff
-- Inf
ddcan288 copysign  #7a00000000000000 -1 -> #fa00000000000000
ddcan289 copysign  #7800200000000000  1 -> #7800200000000000

----- Multiply:
-- Finites: neutral 0
ddcan302 multiply  1      #77ffff3fcff3fcff        -> #77fcff3fcff3fcff
ddcan303 multiply         #77fcffffcff3fcff  1     -> #77fcff3fcff3fcff
-- negative
ddcan306 multiply -1      #77ffff3fcff3fcff        -> #f7fcff3fcff3fcff
ddcan307 multiply         #77fcffffcff3fcff -1     -> #f7fcff3fcff3fcff
-- NaN: declets in payload
ddcan311 multiply  1  #7c03ff3fcff3fcff      -> #7c00ff3fcff3fcff
ddcan312 multiply     #7c03ff3fcff3fcff  1   -> #7c00ff3fcff3fcff
-- NaN: exponent continuation bits [excluding sNaN selector]
ddcan313 multiply  1  #7c40ff3fcff3fcff      -> #7c00ff3fcff3fcff
ddcan314 multiply     #7c40ff3fcff3fcff  1   -> #7c00ff3fcff3fcff
-- sNaN: declets in payload
ddcan315 multiply  1  #7e00ffffcff3fcff      -> #7c00ff3fcff3fcff Invalid_operation
ddcan316 multiply     #7e00ffffcff3fcff  1   -> #7c00ff3fcff3fcff Invalid_operation
-- sNaN: exponent continuation bits [excluding sNaN selector]
ddcan317 multiply  1  #7e80ff3fcff3fcff      -> #7c00ff3fcff3fcff Invalid_operation
ddcan318 multiply     #7e80ff3fcff3fcff  1   -> #7c00ff3fcff3fcff Invalid_operation
-- Inf: exponent continuation bits
ddcan320 multiply  1  #7880000000000000      -> #7800000000000000
ddcan321 multiply     #7880000000000000  1   -> #7800000000000000
-- Inf: coefficient continuation bits
ddcan322 multiply  1  #7802000000000000     -> #7800000000000000
ddcan323 multiply     #7802000000000000  1  -> #7800000000000000
ddcan324 multiply  1  #7800000000000001     -> #7800000000000000
ddcan325 multiply     #7800000000000001  1  -> #7800000000000000
ddcan326 multiply  1  #7800002000000000     -> #7800000000000000
ddcan327 multiply     #7800002000000000  1  -> #7800000000000000

----- Quantize:
ddcan401 quantize  #6e38ff3ffff3fcff 1    -> #6e38ff3fcff3fcff
ddcan402 quantize  #6e38ff3fcff3fdff 0    -> #6e38ff3fcff3fcff
ddcan403 quantize  #7880000000000000 Inf  -> #7800000000000000
ddcan404 quantize  #7802000000000000 -Inf -> #7800000000000000
ddcan410 quantize  #7c03ff3fcff3fcff  1   -> #7c00ff3fcff3fcff
ddcan411 quantize  #7c03ff3fcff3fcff  1   -> #7c00ff3fcff3fcff
ddcan412 quantize  #7c40ff3fcff3fcff  1   -> #7c00ff3fcff3fcff
ddcan413 quantize  #7c40ff3fcff3fcff  1   -> #7c00ff3fcff3fcff
ddcan414 quantize  #7e00ffffcff3fcff  1   -> #7c00ff3fcff3fcff Invalid_operation
ddcan415 quantize  #7e00ffffcff3fcff  1   -> #7c00ff3fcff3fcff Invalid_operation
ddcan416 quantize  #7e80ff3fcff3fcff  1   -> #7c00ff3fcff3fcff Invalid_operation
ddcan417 quantize  #7e80ff3fcff3fcff  1   -> #7c00ff3fcff3fcff Invalid_operation

----- Subtract:
-- Finites: neutral 0
ddcan502 subtract  0E+384 #77ffff3fcff3fcff        -> #f7fcff3fcff3fcff
ddcan503 subtract         #77fcffffcff3fcff 0E+384 -> #77fcff3fcff3fcff
-- tiny zero
ddcan504 subtract  0E-398 #77ffff3fcff3fcff        -> #f7fcff3fcff3fcff Rounded
ddcan505 subtract         #77fcffffcff3fcff 0E-398 -> #77fcff3fcff3fcff Rounded
-- tiny non zero
ddcan506 subtract -1E-398 #77ffff3fcff3fcff         -> #f7fcff3fcff3fcff Inexact Rounded
ddcan507 subtract         #77ffff3fcff3fcff -1E-398 -> #77fcff3fcff3fcff Inexact Rounded
-- NaN: declets in payload
ddcan511 subtract  0  #7c03ff3fcff3fcff      -> #7c00ff3fcff3fcff
ddcan512 subtract     #7c03ff3fcff3fcff  0   -> #7c00ff3fcff3fcff
-- NaN: exponent continuation bits [excluding sNaN selector]
ddcan513 subtract  0  #7c40ff3fcff3fcff      -> #7c00ff3fcff3fcff
ddcan514 subtract     #7c40ff3fcff3fcff  0   -> #7c00ff3fcff3fcff
-- sNaN: declets in payload
ddcan515 subtract  0  #7e00ffffcff3fcff      -> #7c00ff3fcff3fcff Invalid_operation
ddcan516 subtract     #7e00ffffcff3fcff  0   -> #7c00ff3fcff3fcff Invalid_operation
-- sNaN: exponent continuation bits [excluding sNaN selector]
ddcan517 subtract  0  #7e80ff3fcff3fcff      -> #7c00ff3fcff3fcff Invalid_operation
ddcan518 subtract     #7e80ff3fcff3fcff  0   -> #7c00ff3fcff3fcff Invalid_operation
-- Inf: exponent continuation bits
ddcan520 subtract  0  #7880000000000000      -> #f800000000000000
ddcan521 subtract     #7880000000000000  0   -> #7800000000000000
-- Inf: coefficient continuation bits
ddcan522 subtract  0  #7802000000000000     -> #f800000000000000
ddcan523 subtract     #7802000000000000  0  -> #7800000000000000
ddcan524 subtract  0  #7800000000000001     -> #f800000000000000
ddcan525 subtract     #7800000000000001  0  -> #7800000000000000
ddcan526 subtract  0  #7800002000000000     -> #f800000000000000
ddcan527 subtract     #7800002000000000  0  -> #7800000000000000

----- ToIntegral:
ddcan601 tointegralx  #6e38ff3ffff3fcff -> #6e38ff3fcff3fcff
ddcan602 tointegralx  #6e38ff3fcff3fdff -> #6e38ff3fcff3fcff
ddcan603 tointegralx  #7880000000000000 -> #7800000000000000
ddcan604 tointegralx  #7802000000000000 -> #7800000000000000
ddcan610 tointegralx  #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
ddcan611 tointegralx  #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
ddcan612 tointegralx  #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
ddcan613 tointegralx  #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
ddcan614 tointegralx  #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
ddcan615 tointegralx  #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
ddcan616 tointegralx  #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
ddcan617 tointegralx  #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-- uncanonical 3999, 39.99, 3.99, 0.399, and negatives
ddcan618 tointegralx  #2238000000000fff -> #2238000000000cff
ddcan619 tointegralx  #2230000000000fff -> #2238000000000040 Inexact Rounded
ddcan620 tointegralx  #222c000000000fff -> #2238000000000004 Inexact Rounded
ddcan621 tointegralx  #2228000000000fff -> #2238000000000000 Inexact Rounded
ddcan622 tointegralx  #a238000000000fff -> #a238000000000cff
ddcan623 tointegralx  #a230000000000fff -> #a238000000000040 Inexact Rounded
ddcan624 tointegralx  #a22c000000000fff -> #a238000000000004 Inexact Rounded
ddcan625 tointegralx  #a228000000000fff -> #a238000000000000 Inexact Rounded



Added test/dectest/ddClass.decTest.

























































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
------------------------------------------------------------------------
-- ddClass.decTest -- decDouble Class operations                      --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- [New 2006.11.27]
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

ddcla001  class    0                        -> +Zero
ddcla002  class    0.00                     -> +Zero
ddcla003  class    0E+5                     -> +Zero
ddcla004  class    1E-396                   -> +Subnormal
ddcla005  class  0.1E-383                   -> +Subnormal
ddcla006  class  0.999999999999999E-383     -> +Subnormal
ddcla007  class  1.000000000000000E-383     -> +Normal
ddcla008  class   1E-383                    -> +Normal
ddcla009  class   1E-100                    -> +Normal
ddcla010  class   1E-10                     -> +Normal
ddcla012  class   1E-1                      -> +Normal
ddcla013  class   1                         -> +Normal
ddcla014  class   2.50                      -> +Normal
ddcla015  class   100.100                   -> +Normal
ddcla016  class   1E+30                     -> +Normal
ddcla017  class   1E+384                    -> +Normal
ddcla018  class   9.999999999999999E+384    -> +Normal
ddcla019  class   Inf                       -> +Infinity

ddcla021  class   -0                        -> -Zero
ddcla022  class   -0.00                     -> -Zero
ddcla023  class   -0E+5                     -> -Zero
ddcla024  class   -1E-396                   -> -Subnormal
ddcla025  class  -0.1E-383                  -> -Subnormal
ddcla026  class  -0.999999999999999E-383    -> -Subnormal
ddcla027  class  -1.000000000000000E-383    -> -Normal
ddcla028  class  -1E-383                    -> -Normal
ddcla029  class  -1E-100                    -> -Normal
ddcla030  class  -1E-10                     -> -Normal
ddcla032  class  -1E-1                      -> -Normal
ddcla033  class  -1                         -> -Normal
ddcla034  class  -2.50                      -> -Normal
ddcla035  class  -100.100                   -> -Normal
ddcla036  class  -1E+30                     -> -Normal
ddcla037  class  -1E+384                    -> -Normal
ddcla038  class  -9.999999999999999E+384    -> -Normal
ddcla039  class  -Inf                       -> -Infinity

ddcla041  class   NaN                       -> NaN
ddcla042  class  -NaN                       -> NaN
ddcla043  class  +NaN12345                  -> NaN
ddcla044  class   sNaN                      -> sNaN
ddcla045  class  -sNaN                      -> sNaN
ddcla046  class  +sNaN12345                 -> sNaN



Added test/dectest/ddCompare.decTest.

















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
------------------------------------------------------------------------
-- ddCompare.decTest -- decDouble comparison that allows quiet NaNs   --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Note that we cannot assume add/subtract tests cover paths adequately,
-- here, because the code might be quite different (comparison cannot
-- overflow or underflow, so actual subtractions are not necessary).

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks
ddcom001 compare  -2  -2  -> 0
ddcom002 compare  -2  -1  -> -1
ddcom003 compare  -2   0  -> -1
ddcom004 compare  -2   1  -> -1
ddcom005 compare  -2   2  -> -1
ddcom006 compare  -1  -2  -> 1
ddcom007 compare  -1  -1  -> 0
ddcom008 compare  -1   0  -> -1
ddcom009 compare  -1   1  -> -1
ddcom010 compare  -1   2  -> -1
ddcom011 compare   0  -2  -> 1
ddcom012 compare   0  -1  -> 1
ddcom013 compare   0   0  -> 0
ddcom014 compare   0   1  -> -1
ddcom015 compare   0   2  -> -1
ddcom016 compare   1  -2  -> 1
ddcom017 compare   1  -1  -> 1
ddcom018 compare   1   0  -> 1
ddcom019 compare   1   1  -> 0
ddcom020 compare   1   2  -> -1
ddcom021 compare   2  -2  -> 1
ddcom022 compare   2  -1  -> 1
ddcom023 compare   2   0  -> 1
ddcom025 compare   2   1  -> 1
ddcom026 compare   2   2  -> 0

ddcom031 compare  -20  -20  -> 0
ddcom032 compare  -20  -10  -> -1
ddcom033 compare  -20   00  -> -1
ddcom034 compare  -20   10  -> -1
ddcom035 compare  -20   20  -> -1
ddcom036 compare  -10  -20  -> 1
ddcom037 compare  -10  -10  -> 0
ddcom038 compare  -10   00  -> -1
ddcom039 compare  -10   10  -> -1
ddcom040 compare  -10   20  -> -1
ddcom041 compare   00  -20  -> 1
ddcom042 compare   00  -10  -> 1
ddcom043 compare   00   00  -> 0
ddcom044 compare   00   10  -> -1
ddcom045 compare   00   20  -> -1
ddcom046 compare   10  -20  -> 1
ddcom047 compare   10  -10  -> 1
ddcom048 compare   10   00  -> 1
ddcom049 compare   10   10  -> 0
ddcom050 compare   10   20  -> -1
ddcom051 compare   20  -20  -> 1
ddcom052 compare   20  -10  -> 1
ddcom053 compare   20   00  -> 1
ddcom055 compare   20   10  -> 1
ddcom056 compare   20   20  -> 0

ddcom061 compare  -2.0  -2.0  -> 0
ddcom062 compare  -2.0  -1.0  -> -1
ddcom063 compare  -2.0   0.0  -> -1
ddcom064 compare  -2.0   1.0  -> -1
ddcom065 compare  -2.0   2.0  -> -1
ddcom066 compare  -1.0  -2.0  -> 1
ddcom067 compare  -1.0  -1.0  -> 0
ddcom068 compare  -1.0   0.0  -> -1
ddcom069 compare  -1.0   1.0  -> -1
ddcom070 compare  -1.0   2.0  -> -1
ddcom071 compare   0.0  -2.0  -> 1
ddcom072 compare   0.0  -1.0  -> 1
ddcom073 compare   0.0   0.0  -> 0
ddcom074 compare   0.0   1.0  -> -1
ddcom075 compare   0.0   2.0  -> -1
ddcom076 compare   1.0  -2.0  -> 1
ddcom077 compare   1.0  -1.0  -> 1
ddcom078 compare   1.0   0.0  -> 1
ddcom079 compare   1.0   1.0  -> 0
ddcom080 compare   1.0   2.0  -> -1
ddcom081 compare   2.0  -2.0  -> 1
ddcom082 compare   2.0  -1.0  -> 1
ddcom083 compare   2.0   0.0  -> 1
ddcom085 compare   2.0   1.0  -> 1
ddcom086 compare   2.0   2.0  -> 0
ddcom087 compare   1.0   0.1  -> 1
ddcom088 compare   0.1   1.0  -> -1

-- now some cases which might overflow if subtract were used
ddcom095 compare  9.999999999999999E+384 9.999999999999999E+384  -> 0
ddcom096 compare -9.999999999999999E+384 9.999999999999999E+384  -> -1
ddcom097 compare  9.999999999999999E+384 -9.999999999999999E+384 -> 1
ddcom098 compare -9.999999999999999E+384 -9.999999999999999E+384 -> 0

-- some differing length/exponent cases
ddcom100 compare   7.0    7.0    -> 0
ddcom101 compare   7.0    7      -> 0
ddcom102 compare   7      7.0    -> 0
ddcom103 compare   7E+0   7.0    -> 0
ddcom104 compare   70E-1  7.0    -> 0
ddcom105 compare   0.7E+1 7      -> 0
ddcom106 compare   70E-1  7      -> 0
ddcom107 compare   7.0    7E+0   -> 0
ddcom108 compare   7.0    70E-1  -> 0
ddcom109 compare   7      0.7E+1 -> 0
ddcom110 compare   7      70E-1  -> 0

ddcom120 compare   8.0    7.0    -> 1
ddcom121 compare   8.0    7      -> 1
ddcom122 compare   8      7.0    -> 1
ddcom123 compare   8E+0   7.0    -> 1
ddcom124 compare   80E-1  7.0    -> 1
ddcom125 compare   0.8E+1 7      -> 1
ddcom126 compare   80E-1  7      -> 1
ddcom127 compare   8.0    7E+0   -> 1
ddcom128 compare   8.0    70E-1  -> 1
ddcom129 compare   8      0.7E+1  -> 1
ddcom130 compare   8      70E-1  -> 1

ddcom140 compare   8.0    9.0    -> -1
ddcom141 compare   8.0    9      -> -1
ddcom142 compare   8      9.0    -> -1
ddcom143 compare   8E+0   9.0    -> -1
ddcom144 compare   80E-1  9.0    -> -1
ddcom145 compare   0.8E+1 9      -> -1
ddcom146 compare   80E-1  9      -> -1
ddcom147 compare   8.0    9E+0   -> -1
ddcom148 compare   8.0    90E-1  -> -1
ddcom149 compare   8      0.9E+1 -> -1
ddcom150 compare   8      90E-1  -> -1

-- and again, with sign changes -+ ..
ddcom200 compare  -7.0    7.0    -> -1
ddcom201 compare  -7.0    7      -> -1
ddcom202 compare  -7      7.0    -> -1
ddcom203 compare  -7E+0   7.0    -> -1
ddcom204 compare  -70E-1  7.0    -> -1
ddcom205 compare  -0.7E+1 7      -> -1
ddcom206 compare  -70E-1  7      -> -1
ddcom207 compare  -7.0    7E+0   -> -1
ddcom208 compare  -7.0    70E-1  -> -1
ddcom209 compare  -7      0.7E+1 -> -1
ddcom210 compare  -7      70E-1  -> -1

ddcom220 compare  -8.0    7.0    -> -1
ddcom221 compare  -8.0    7      -> -1
ddcom222 compare  -8      7.0    -> -1
ddcom223 compare  -8E+0   7.0    -> -1
ddcom224 compare  -80E-1  7.0    -> -1
ddcom225 compare  -0.8E+1 7      -> -1
ddcom226 compare  -80E-1  7      -> -1
ddcom227 compare  -8.0    7E+0   -> -1
ddcom228 compare  -8.0    70E-1  -> -1
ddcom229 compare  -8      0.7E+1 -> -1
ddcom230 compare  -8      70E-1  -> -1

ddcom240 compare  -8.0    9.0    -> -1
ddcom241 compare  -8.0    9      -> -1
ddcom242 compare  -8      9.0    -> -1
ddcom243 compare  -8E+0   9.0    -> -1
ddcom244 compare  -80E-1  9.0    -> -1
ddcom245 compare  -0.8E+1 9      -> -1
ddcom246 compare  -80E-1  9      -> -1
ddcom247 compare  -8.0    9E+0   -> -1
ddcom248 compare  -8.0    90E-1  -> -1
ddcom249 compare  -8      0.9E+1 -> -1
ddcom250 compare  -8      90E-1  -> -1

-- and again, with sign changes +- ..
ddcom300 compare   7.0    -7.0    -> 1
ddcom301 compare   7.0    -7      -> 1
ddcom302 compare   7      -7.0    -> 1
ddcom303 compare   7E+0   -7.0    -> 1
ddcom304 compare   70E-1  -7.0    -> 1
ddcom305 compare   .7E+1  -7      -> 1
ddcom306 compare   70E-1  -7      -> 1
ddcom307 compare   7.0    -7E+0   -> 1
ddcom308 compare   7.0    -70E-1  -> 1
ddcom309 compare   7      -.7E+1  -> 1
ddcom310 compare   7      -70E-1  -> 1

ddcom320 compare   8.0    -7.0    -> 1
ddcom321 compare   8.0    -7      -> 1
ddcom322 compare   8      -7.0    -> 1
ddcom323 compare   8E+0   -7.0    -> 1
ddcom324 compare   80E-1  -7.0    -> 1
ddcom325 compare   .8E+1  -7      -> 1
ddcom326 compare   80E-1  -7      -> 1
ddcom327 compare   8.0    -7E+0   -> 1
ddcom328 compare   8.0    -70E-1  -> 1
ddcom329 compare   8      -.7E+1  -> 1
ddcom330 compare   8      -70E-1  -> 1

ddcom340 compare   8.0    -9.0    -> 1
ddcom341 compare   8.0    -9      -> 1
ddcom342 compare   8      -9.0    -> 1
ddcom343 compare   8E+0   -9.0    -> 1
ddcom344 compare   80E-1  -9.0    -> 1
ddcom345 compare   .8E+1  -9      -> 1
ddcom346 compare   80E-1  -9      -> 1
ddcom347 compare   8.0    -9E+0   -> 1
ddcom348 compare   8.0    -90E-1  -> 1
ddcom349 compare   8      -.9E+1  -> 1
ddcom350 compare   8      -90E-1  -> 1

-- and again, with sign changes -- ..
ddcom400 compare   -7.0    -7.0    -> 0
ddcom401 compare   -7.0    -7      -> 0
ddcom402 compare   -7      -7.0    -> 0
ddcom403 compare   -7E+0   -7.0    -> 0
ddcom404 compare   -70E-1  -7.0    -> 0
ddcom405 compare   -.7E+1  -7      -> 0
ddcom406 compare   -70E-1  -7      -> 0
ddcom407 compare   -7.0    -7E+0   -> 0
ddcom408 compare   -7.0    -70E-1  -> 0
ddcom409 compare   -7      -.7E+1  -> 0
ddcom410 compare   -7      -70E-1  -> 0

ddcom420 compare   -8.0    -7.0    -> -1
ddcom421 compare   -8.0    -7      -> -1
ddcom422 compare   -8      -7.0    -> -1
ddcom423 compare   -8E+0   -7.0    -> -1
ddcom424 compare   -80E-1  -7.0    -> -1
ddcom425 compare   -.8E+1  -7      -> -1
ddcom426 compare   -80E-1  -7      -> -1
ddcom427 compare   -8.0    -7E+0   -> -1
ddcom428 compare   -8.0    -70E-1  -> -1
ddcom429 compare   -8      -.7E+1  -> -1
ddcom430 compare   -8      -70E-1  -> -1

ddcom440 compare   -8.0    -9.0    -> 1
ddcom441 compare   -8.0    -9      -> 1
ddcom442 compare   -8      -9.0    -> 1
ddcom443 compare   -8E+0   -9.0    -> 1
ddcom444 compare   -80E-1  -9.0    -> 1
ddcom445 compare   -.8E+1  -9      -> 1
ddcom446 compare   -80E-1  -9      -> 1
ddcom447 compare   -8.0    -9E+0   -> 1
ddcom448 compare   -8.0    -90E-1  -> 1
ddcom449 compare   -8      -.9E+1  -> 1
ddcom450 compare   -8      -90E-1  -> 1

-- misalignment traps for little-endian
ddcom451 compare      1.0       0.1  -> 1
ddcom452 compare      0.1       1.0  -> -1
ddcom453 compare     10.0       0.1  -> 1
ddcom454 compare      0.1      10.0  -> -1
ddcom455 compare      100       1.0  -> 1
ddcom456 compare      1.0       100  -> -1
ddcom457 compare     1000      10.0  -> 1
ddcom458 compare     10.0      1000  -> -1
ddcom459 compare    10000     100.0  -> 1
ddcom460 compare    100.0     10000  -> -1
ddcom461 compare   100000    1000.0  -> 1
ddcom462 compare   1000.0    100000  -> -1
ddcom463 compare  1000000   10000.0  -> 1
ddcom464 compare  10000.0   1000000  -> -1

-- testcases that subtract to lots of zeros at boundaries [pgr]
ddcom473 compare 123.4560000000000E-89 123.456E-89 -> 0
ddcom474 compare 123.456000000000E+89 123.456E+89 -> 0
ddcom475 compare 123.45600000000E-89 123.456E-89 -> 0
ddcom476 compare 123.4560000000E+89 123.456E+89 -> 0
ddcom477 compare 123.456000000E-89 123.456E-89 -> 0
ddcom478 compare 123.45600000E+89 123.456E+89 -> 0
ddcom479 compare 123.4560000E-89 123.456E-89 -> 0
ddcom480 compare 123.456000E+89 123.456E+89 -> 0
ddcom481 compare 123.45600E-89 123.456E-89 -> 0
ddcom482 compare 123.4560E+89 123.456E+89 -> 0
ddcom483 compare 123.456E-89 123.456E-89 -> 0
ddcom487 compare 123.456E+89 123.4560000000000E+89 -> 0
ddcom488 compare 123.456E-89 123.456000000000E-89 -> 0
ddcom489 compare 123.456E+89 123.45600000000E+89 -> 0
ddcom490 compare 123.456E-89 123.4560000000E-89 -> 0
ddcom491 compare 123.456E+89 123.456000000E+89 -> 0
ddcom492 compare 123.456E-89 123.45600000E-89 -> 0
ddcom493 compare 123.456E+89 123.4560000E+89 -> 0
ddcom494 compare 123.456E-89 123.456000E-89 -> 0
ddcom495 compare 123.456E+89 123.45600E+89 -> 0
ddcom496 compare 123.456E-89 123.4560E-89 -> 0
ddcom497 compare 123.456E+89 123.456E+89 -> 0

-- wide-ranging, around precision; signs equal
ddcom500 compare    1     1E-15    -> 1
ddcom501 compare    1     1E-14    -> 1
ddcom502 compare    1     1E-13    -> 1
ddcom503 compare    1     1E-12    -> 1
ddcom504 compare    1     1E-11    -> 1
ddcom505 compare    1     1E-10    -> 1
ddcom506 compare    1     1E-9     -> 1
ddcom507 compare    1     1E-8     -> 1
ddcom508 compare    1     1E-7     -> 1
ddcom509 compare    1     1E-6     -> 1
ddcom510 compare    1     1E-5     -> 1
ddcom511 compare    1     1E-4     -> 1
ddcom512 compare    1     1E-3     -> 1
ddcom513 compare    1     1E-2     -> 1
ddcom514 compare    1     1E-1     -> 1
ddcom515 compare    1     1E-0     -> 0
ddcom516 compare    1     1E+1     -> -1
ddcom517 compare    1     1E+2     -> -1
ddcom518 compare    1     1E+3     -> -1
ddcom519 compare    1     1E+4     -> -1
ddcom521 compare    1     1E+5     -> -1
ddcom522 compare    1     1E+6     -> -1
ddcom523 compare    1     1E+7     -> -1
ddcom524 compare    1     1E+8     -> -1
ddcom525 compare    1     1E+9     -> -1
ddcom526 compare    1     1E+10    -> -1
ddcom527 compare    1     1E+11    -> -1
ddcom528 compare    1     1E+12    -> -1
ddcom529 compare    1     1E+13    -> -1
ddcom530 compare    1     1E+14    -> -1
ddcom531 compare    1     1E+15    -> -1
-- LR swap
ddcom540 compare    1E-15  1       -> -1
ddcom541 compare    1E-14  1       -> -1
ddcom542 compare    1E-13  1       -> -1
ddcom543 compare    1E-12  1       -> -1
ddcom544 compare    1E-11  1       -> -1
ddcom545 compare    1E-10  1       -> -1
ddcom546 compare    1E-9   1       -> -1
ddcom547 compare    1E-8   1       -> -1
ddcom548 compare    1E-7   1       -> -1
ddcom549 compare    1E-6   1       -> -1
ddcom550 compare    1E-5   1       -> -1
ddcom551 compare    1E-4   1       -> -1
ddcom552 compare    1E-3   1       -> -1
ddcom553 compare    1E-2   1       -> -1
ddcom554 compare    1E-1   1       -> -1
ddcom555 compare    1E-0   1       ->  0
ddcom556 compare    1E+1   1       ->  1
ddcom557 compare    1E+2   1       ->  1
ddcom558 compare    1E+3   1       ->  1
ddcom559 compare    1E+4   1       ->  1
ddcom561 compare    1E+5   1       ->  1
ddcom562 compare    1E+6   1       ->  1
ddcom563 compare    1E+7   1       ->  1
ddcom564 compare    1E+8   1       ->  1
ddcom565 compare    1E+9   1       ->  1
ddcom566 compare    1E+10  1       ->  1
ddcom567 compare    1E+11  1       ->  1
ddcom568 compare    1E+12  1       ->  1
ddcom569 compare    1E+13  1       ->  1
ddcom570 compare    1E+14  1       ->  1
ddcom571 compare    1E+15  1       ->  1
-- similar with a useful coefficient, one side only
ddcom580 compare  0.000000987654321     1E-15    -> 1
ddcom581 compare  0.000000987654321     1E-14    -> 1
ddcom582 compare  0.000000987654321     1E-13    -> 1
ddcom583 compare  0.000000987654321     1E-12    -> 1
ddcom584 compare  0.000000987654321     1E-11    -> 1
ddcom585 compare  0.000000987654321     1E-10    -> 1
ddcom586 compare  0.000000987654321     1E-9     -> 1
ddcom587 compare  0.000000987654321     1E-8     -> 1
ddcom588 compare  0.000000987654321     1E-7     -> 1
ddcom589 compare  0.000000987654321     1E-6     -> -1
ddcom590 compare  0.000000987654321     1E-5     -> -1
ddcom591 compare  0.000000987654321     1E-4     -> -1
ddcom592 compare  0.000000987654321     1E-3     -> -1
ddcom593 compare  0.000000987654321     1E-2     -> -1
ddcom594 compare  0.000000987654321     1E-1     -> -1
ddcom595 compare  0.000000987654321     1E-0     -> -1
ddcom596 compare  0.000000987654321     1E+1     -> -1
ddcom597 compare  0.000000987654321     1E+2     -> -1
ddcom598 compare  0.000000987654321     1E+3     -> -1
ddcom599 compare  0.000000987654321     1E+4     -> -1

-- check some unit-y traps
ddcom600 compare   12            12.2345 -> -1
ddcom601 compare   12.0          12.2345 -> -1
ddcom602 compare   12.00         12.2345 -> -1
ddcom603 compare   12.000        12.2345 -> -1
ddcom604 compare   12.0000       12.2345 -> -1
ddcom605 compare   12.00000      12.2345 -> -1
ddcom606 compare   12.000000     12.2345 -> -1
ddcom607 compare   12.0000000    12.2345 -> -1
ddcom608 compare   12.00000000   12.2345 -> -1
ddcom609 compare   12.000000000  12.2345 -> -1
ddcom610 compare   12.1234 12            ->  1
ddcom611 compare   12.1234 12.0          ->  1
ddcom612 compare   12.1234 12.00         ->  1
ddcom613 compare   12.1234 12.000        ->  1
ddcom614 compare   12.1234 12.0000       ->  1
ddcom615 compare   12.1234 12.00000      ->  1
ddcom616 compare   12.1234 12.000000     ->  1
ddcom617 compare   12.1234 12.0000000    ->  1
ddcom618 compare   12.1234 12.00000000   ->  1
ddcom619 compare   12.1234 12.000000000  ->  1
ddcom620 compare  -12           -12.2345 ->  1
ddcom621 compare  -12.0         -12.2345 ->  1
ddcom622 compare  -12.00        -12.2345 ->  1
ddcom623 compare  -12.000       -12.2345 ->  1
ddcom624 compare  -12.0000      -12.2345 ->  1
ddcom625 compare  -12.00000     -12.2345 ->  1
ddcom626 compare  -12.000000    -12.2345 ->  1
ddcom627 compare  -12.0000000   -12.2345 ->  1
ddcom628 compare  -12.00000000  -12.2345 ->  1
ddcom629 compare  -12.000000000 -12.2345 ->  1
ddcom630 compare  -12.1234 -12           -> -1
ddcom631 compare  -12.1234 -12.0         -> -1
ddcom632 compare  -12.1234 -12.00        -> -1
ddcom633 compare  -12.1234 -12.000       -> -1
ddcom634 compare  -12.1234 -12.0000      -> -1
ddcom635 compare  -12.1234 -12.00000     -> -1
ddcom636 compare  -12.1234 -12.000000    -> -1
ddcom637 compare  -12.1234 -12.0000000   -> -1
ddcom638 compare  -12.1234 -12.00000000  -> -1
ddcom639 compare  -12.1234 -12.000000000 -> -1

-- extended zeros
ddcom640 compare   0     0   -> 0
ddcom641 compare   0    -0   -> 0
ddcom642 compare   0    -0.0 -> 0
ddcom643 compare   0     0.0 -> 0
ddcom644 compare  -0     0   -> 0
ddcom645 compare  -0    -0   -> 0
ddcom646 compare  -0    -0.0 -> 0
ddcom647 compare  -0     0.0 -> 0
ddcom648 compare   0.0   0   -> 0
ddcom649 compare   0.0  -0   -> 0
ddcom650 compare   0.0  -0.0 -> 0
ddcom651 compare   0.0   0.0 -> 0
ddcom652 compare  -0.0   0   -> 0
ddcom653 compare  -0.0  -0   -> 0
ddcom654 compare  -0.0  -0.0 -> 0
ddcom655 compare  -0.0   0.0 -> 0

ddcom656 compare  -0E1   0.0 -> 0
ddcom657 compare  -0E2   0.0 -> 0
ddcom658 compare   0E1   0.0 -> 0
ddcom659 compare   0E2   0.0 -> 0
ddcom660 compare  -0E1   0   -> 0
ddcom661 compare  -0E2   0   -> 0
ddcom662 compare   0E1   0   -> 0
ddcom663 compare   0E2   0   -> 0
ddcom664 compare  -0E1  -0E1 -> 0
ddcom665 compare  -0E2  -0E1 -> 0
ddcom666 compare   0E1  -0E1 -> 0
ddcom667 compare   0E2  -0E1 -> 0
ddcom668 compare  -0E1  -0E2 -> 0
ddcom669 compare  -0E2  -0E2 -> 0
ddcom670 compare   0E1  -0E2 -> 0
ddcom671 compare   0E2  -0E2 -> 0
ddcom672 compare  -0E1   0E1 -> 0
ddcom673 compare  -0E2   0E1 -> 0
ddcom674 compare   0E1   0E1 -> 0
ddcom675 compare   0E2   0E1 -> 0
ddcom676 compare  -0E1   0E2 -> 0
ddcom677 compare  -0E2   0E2 -> 0
ddcom678 compare   0E1   0E2 -> 0
ddcom679 compare   0E2   0E2 -> 0

-- trailing zeros; unit-y
ddcom680 compare   12    12           -> 0
ddcom681 compare   12    12.0         -> 0
ddcom682 compare   12    12.00        -> 0
ddcom683 compare   12    12.000       -> 0
ddcom684 compare   12    12.0000      -> 0
ddcom685 compare   12    12.00000     -> 0
ddcom686 compare   12    12.000000    -> 0
ddcom687 compare   12    12.0000000   -> 0
ddcom688 compare   12    12.00000000  -> 0
ddcom689 compare   12    12.000000000 -> 0
ddcom690 compare   12              12 -> 0
ddcom691 compare   12.0            12 -> 0
ddcom692 compare   12.00           12 -> 0
ddcom693 compare   12.000          12 -> 0
ddcom694 compare   12.0000         12 -> 0
ddcom695 compare   12.00000        12 -> 0
ddcom696 compare   12.000000       12 -> 0
ddcom697 compare   12.0000000      12 -> 0
ddcom698 compare   12.00000000     12 -> 0
ddcom699 compare   12.000000000    12 -> 0

-- first, second, & last digit
ddcom700 compare   1234567890123456 1234567890123455 -> 1
ddcom701 compare   1234567890123456 1234567890123456 -> 0
ddcom702 compare   1234567890123456 1234567890123457 -> -1
ddcom703 compare   1234567890123456 0234567890123456 -> 1
ddcom704 compare   1234567890123456 1234567890123456 -> 0
ddcom705 compare   1234567890123456 2234567890123456 -> -1
ddcom706 compare   1134567890123456 1034567890123456 -> 1
ddcom707 compare   1134567890123456 1134567890123456 -> 0
ddcom708 compare   1134567890123456 1234567890123456 -> -1

-- miscellaneous
ddcom721 compare 12345678000 1 -> 1
ddcom722 compare 1 12345678000 -> -1
ddcom723 compare 1234567800  1 -> 1
ddcom724 compare 1 1234567800  -> -1
ddcom725 compare 1234567890  1 -> 1
ddcom726 compare 1 1234567890  -> -1
ddcom727 compare 1234567891  1 -> 1
ddcom728 compare 1 1234567891  -> -1
ddcom729 compare 12345678901 1 -> 1
ddcom730 compare 1 12345678901 -> -1
ddcom731 compare 1234567896  1 -> 1
ddcom732 compare 1 1234567896  -> -1

-- residue cases at lower precision
ddcom740 compare  1  0.9999999  -> 1
ddcom741 compare  1  0.999999   -> 1
ddcom742 compare  1  0.99999    -> 1
ddcom743 compare  1  1.0000     -> 0
ddcom744 compare  1  1.00001    -> -1
ddcom745 compare  1  1.000001   -> -1
ddcom746 compare  1  1.0000001  -> -1
ddcom750 compare  0.9999999  1  -> -1
ddcom751 compare  0.999999   1  -> -1
ddcom752 compare  0.99999    1  -> -1
ddcom753 compare  1.0000     1  -> 0
ddcom754 compare  1.00001    1  -> 1
ddcom755 compare  1.000001   1  -> 1
ddcom756 compare  1.0000001  1  -> 1

-- Specials
ddcom780 compare  Inf  -Inf   ->  1
ddcom781 compare  Inf  -1000  ->  1
ddcom782 compare  Inf  -1     ->  1
ddcom783 compare  Inf  -0     ->  1
ddcom784 compare  Inf   0     ->  1
ddcom785 compare  Inf   1     ->  1
ddcom786 compare  Inf   1000  ->  1
ddcom787 compare  Inf   Inf   ->  0
ddcom788 compare -1000  Inf   -> -1
ddcom789 compare -Inf   Inf   -> -1
ddcom790 compare -1     Inf   -> -1
ddcom791 compare -0     Inf   -> -1
ddcom792 compare  0     Inf   -> -1
ddcom793 compare  1     Inf   -> -1
ddcom794 compare  1000  Inf   -> -1
ddcom795 compare  Inf   Inf   ->  0

ddcom800 compare -Inf  -Inf   ->  0
ddcom801 compare -Inf  -1000  -> -1
ddcom802 compare -Inf  -1     -> -1
ddcom803 compare -Inf  -0     -> -1
ddcom804 compare -Inf   0     -> -1
ddcom805 compare -Inf   1     -> -1
ddcom806 compare -Inf   1000  -> -1
ddcom807 compare -Inf   Inf   -> -1
ddcom808 compare -Inf  -Inf   ->  0
ddcom809 compare -1000 -Inf   ->  1
ddcom810 compare -1    -Inf   ->  1
ddcom811 compare -0    -Inf   ->  1
ddcom812 compare  0    -Inf   ->  1
ddcom813 compare  1    -Inf   ->  1
ddcom814 compare  1000 -Inf   ->  1
ddcom815 compare  Inf  -Inf   ->  1

ddcom821 compare  NaN -Inf    ->  NaN
ddcom822 compare  NaN -1000   ->  NaN
ddcom823 compare  NaN -1      ->  NaN
ddcom824 compare  NaN -0      ->  NaN
ddcom825 compare  NaN  0      ->  NaN
ddcom826 compare  NaN  1      ->  NaN
ddcom827 compare  NaN  1000   ->  NaN
ddcom828 compare  NaN  Inf    ->  NaN
ddcom829 compare  NaN  NaN    ->  NaN
ddcom830 compare -Inf  NaN    ->  NaN
ddcom831 compare -1000 NaN    ->  NaN
ddcom832 compare -1    NaN    ->  NaN
ddcom833 compare -0    NaN    ->  NaN
ddcom834 compare  0    NaN    ->  NaN
ddcom835 compare  1    NaN    ->  NaN
ddcom836 compare  1000 NaN    ->  NaN
ddcom837 compare  Inf  NaN    ->  NaN
ddcom838 compare -NaN -NaN    -> -NaN
ddcom839 compare +NaN -NaN    ->  NaN
ddcom840 compare -NaN +NaN    -> -NaN

ddcom841 compare  sNaN -Inf   ->  NaN  Invalid_operation
ddcom842 compare  sNaN -1000  ->  NaN  Invalid_operation
ddcom843 compare  sNaN -1     ->  NaN  Invalid_operation
ddcom844 compare  sNaN -0     ->  NaN  Invalid_operation
ddcom845 compare  sNaN  0     ->  NaN  Invalid_operation
ddcom846 compare  sNaN  1     ->  NaN  Invalid_operation
ddcom847 compare  sNaN  1000  ->  NaN  Invalid_operation
ddcom848 compare  sNaN  NaN   ->  NaN  Invalid_operation
ddcom849 compare  sNaN sNaN   ->  NaN  Invalid_operation
ddcom850 compare  NaN  sNaN   ->  NaN  Invalid_operation
ddcom851 compare -Inf  sNaN   ->  NaN  Invalid_operation
ddcom852 compare -1000 sNaN   ->  NaN  Invalid_operation
ddcom853 compare -1    sNaN   ->  NaN  Invalid_operation
ddcom854 compare -0    sNaN   ->  NaN  Invalid_operation
ddcom855 compare  0    sNaN   ->  NaN  Invalid_operation
ddcom856 compare  1    sNaN   ->  NaN  Invalid_operation
ddcom857 compare  1000 sNaN   ->  NaN  Invalid_operation
ddcom858 compare  Inf  sNaN   ->  NaN  Invalid_operation
ddcom859 compare  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddcom860 compare  NaN9 -Inf   ->  NaN9
ddcom861 compare  NaN8  999   ->  NaN8
ddcom862 compare  NaN77 Inf   ->  NaN77
ddcom863 compare -NaN67 NaN5  -> -NaN67
ddcom864 compare -Inf  -NaN4  -> -NaN4
ddcom865 compare -999  -NaN33 -> -NaN33
ddcom866 compare  Inf   NaN2  ->  NaN2
ddcom867 compare -NaN41 -NaN42 -> -NaN41
ddcom868 compare +NaN41 -NaN42 ->  NaN41
ddcom869 compare -NaN41 +NaN42 -> -NaN41
ddcom870 compare +NaN41 +NaN42 ->  NaN41

ddcom871 compare -sNaN99 -Inf    -> -NaN99 Invalid_operation
ddcom872 compare  sNaN98 -11     ->  NaN98 Invalid_operation
ddcom873 compare  sNaN97  NaN    ->  NaN97 Invalid_operation
ddcom874 compare  sNaN16 sNaN94  ->  NaN16 Invalid_operation
ddcom875 compare  NaN85  sNaN83  ->  NaN83 Invalid_operation
ddcom876 compare -Inf    sNaN92  ->  NaN92 Invalid_operation
ddcom877 compare  088    sNaN81  ->  NaN81 Invalid_operation
ddcom878 compare  Inf    sNaN90  ->  NaN90 Invalid_operation
ddcom879 compare  NaN   -sNaN89  -> -NaN89 Invalid_operation

-- wide range
ddcom880 compare +1.23456789012345E-0 9E+384 -> -1
ddcom881 compare 9E+384 +1.23456789012345E-0 ->  1
ddcom882 compare +0.100 9E-383               ->  1
ddcom883 compare 9E-383 +0.100               -> -1
ddcom885 compare -1.23456789012345E-0 9E+384 -> -1
ddcom886 compare 9E+384 -1.23456789012345E-0 ->  1
ddcom887 compare -0.100 9E-383               -> -1
ddcom888 compare 9E-383 -0.100               ->  1

-- spread zeros
ddcom900 compare   0E-383  0       ->  0
ddcom901 compare   0E-383 -0       ->  0
ddcom902 compare  -0E-383  0       ->  0
ddcom903 compare  -0E-383 -0       ->  0
ddcom904 compare   0E-383  0E+384  ->  0
ddcom905 compare   0E-383 -0E+384  ->  0
ddcom906 compare  -0E-383  0E+384  ->  0
ddcom907 compare  -0E-383 -0E+384  ->  0
ddcom908 compare   0       0E+384  ->  0
ddcom909 compare   0      -0E+384  ->  0
ddcom910 compare  -0       0E+384  ->  0
ddcom911 compare  -0      -0E+384  ->  0
ddcom930 compare   0E+384  0       ->  0
ddcom931 compare   0E+384 -0       ->  0
ddcom932 compare  -0E+384  0       ->  0
ddcom933 compare  -0E+384 -0       ->  0
ddcom934 compare   0E+384  0E-383  ->  0
ddcom935 compare   0E+384 -0E-383  ->  0
ddcom936 compare  -0E+384  0E-383  ->  0
ddcom937 compare  -0E+384 -0E-383  ->  0
ddcom938 compare   0       0E-383  ->  0
ddcom939 compare   0      -0E-383  ->  0
ddcom940 compare  -0       0E-383  ->  0
ddcom941 compare  -0      -0E-383  ->  0

-- signs
ddcom961 compare  1e+77  1e+11 ->  1
ddcom962 compare  1e+77 -1e+11 ->  1
ddcom963 compare -1e+77  1e+11 -> -1
ddcom964 compare -1e+77 -1e+11 -> -1
ddcom965 compare  1e-77  1e-11 -> -1
ddcom966 compare  1e-77 -1e-11 ->  1
ddcom967 compare -1e-77  1e-11 -> -1
ddcom968 compare -1e-77 -1e-11 ->  1

-- full alignment range, both ways
ddcomp1001 compare 1 1.000000000000000  -> 0
ddcomp1002 compare 1 1.00000000000000   -> 0
ddcomp1003 compare 1 1.0000000000000    -> 0
ddcomp1004 compare 1 1.000000000000     -> 0
ddcomp1005 compare 1 1.00000000000      -> 0
ddcomp1006 compare 1 1.0000000000       -> 0
ddcomp1007 compare 1 1.000000000        -> 0
ddcomp1008 compare 1 1.00000000         -> 0
ddcomp1009 compare 1 1.0000000          -> 0
ddcomp1010 compare 1 1.000000           -> 0
ddcomp1011 compare 1 1.00000            -> 0
ddcomp1012 compare 1 1.0000             -> 0
ddcomp1013 compare 1 1.000              -> 0
ddcomp1014 compare 1 1.00               -> 0
ddcomp1015 compare 1 1.0                -> 0
ddcomp1021 compare 1.000000000000000  1 -> 0
ddcomp1022 compare 1.00000000000000   1 -> 0
ddcomp1023 compare 1.0000000000000    1 -> 0
ddcomp1024 compare 1.000000000000     1 -> 0
ddcomp1025 compare 1.00000000000      1 -> 0
ddcomp1026 compare 1.0000000000       1 -> 0
ddcomp1027 compare 1.000000000        1 -> 0
ddcomp1028 compare 1.00000000         1 -> 0
ddcomp1029 compare 1.0000000          1 -> 0
ddcomp1030 compare 1.000000           1 -> 0
ddcomp1031 compare 1.00000            1 -> 0
ddcomp1032 compare 1.0000             1 -> 0
ddcomp1033 compare 1.000              1 -> 0
ddcomp1034 compare 1.00               1 -> 0
ddcomp1035 compare 1.0                1 -> 0

-- check MSD always detected non-zero
ddcomp1040 compare 0 0.000000000000000  -> 0
ddcomp1041 compare 0 1.000000000000000  -> -1
ddcomp1042 compare 0 2.000000000000000  -> -1
ddcomp1043 compare 0 3.000000000000000  -> -1
ddcomp1044 compare 0 4.000000000000000  -> -1
ddcomp1045 compare 0 5.000000000000000  -> -1
ddcomp1046 compare 0 6.000000000000000  -> -1
ddcomp1047 compare 0 7.000000000000000  -> -1
ddcomp1048 compare 0 8.000000000000000  -> -1
ddcomp1049 compare 0 9.000000000000000  -> -1
ddcomp1050 compare 0.000000000000000  0 -> 0
ddcomp1051 compare 1.000000000000000  0 -> 1
ddcomp1052 compare 2.000000000000000  0 -> 1
ddcomp1053 compare 3.000000000000000  0 -> 1
ddcomp1054 compare 4.000000000000000  0 -> 1
ddcomp1055 compare 5.000000000000000  0 -> 1
ddcomp1056 compare 6.000000000000000  0 -> 1
ddcomp1057 compare 7.000000000000000  0 -> 1
ddcomp1058 compare 8.000000000000000  0 -> 1
ddcomp1059 compare 9.000000000000000  0 -> 1

-- Null tests
ddcom9990 compare 10  # -> NaN Invalid_operation
ddcom9991 compare  # 10 -> NaN Invalid_operation

Added test/dectest/ddCompareSig.decTest.















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
------------------------------------------------------------------------
-- ddCompareSig.decTest -- decDouble comparison; all NaNs signal      --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Note that we cannot assume add/subtract tests cover paths adequately,
-- here, because the code might be quite different (comparison cannot
-- overflow or underflow, so actual subtractions are not necessary).

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks
ddcms001 comparesig  -2  -2  -> 0
ddcms002 comparesig  -2  -1  -> -1
ddcms003 comparesig  -2   0  -> -1
ddcms004 comparesig  -2   1  -> -1
ddcms005 comparesig  -2   2  -> -1
ddcms006 comparesig  -1  -2  -> 1
ddcms007 comparesig  -1  -1  -> 0
ddcms008 comparesig  -1   0  -> -1
ddcms009 comparesig  -1   1  -> -1
ddcms010 comparesig  -1   2  -> -1
ddcms011 comparesig   0  -2  -> 1
ddcms012 comparesig   0  -1  -> 1
ddcms013 comparesig   0   0  -> 0
ddcms014 comparesig   0   1  -> -1
ddcms015 comparesig   0   2  -> -1
ddcms016 comparesig   1  -2  -> 1
ddcms017 comparesig   1  -1  -> 1
ddcms018 comparesig   1   0  -> 1
ddcms019 comparesig   1   1  -> 0
ddcms020 comparesig   1   2  -> -1
ddcms021 comparesig   2  -2  -> 1
ddcms022 comparesig   2  -1  -> 1
ddcms023 comparesig   2   0  -> 1
ddcms025 comparesig   2   1  -> 1
ddcms026 comparesig   2   2  -> 0

ddcms031 comparesig  -20  -20  -> 0
ddcms032 comparesig  -20  -10  -> -1
ddcms033 comparesig  -20   00  -> -1
ddcms034 comparesig  -20   10  -> -1
ddcms035 comparesig  -20   20  -> -1
ddcms036 comparesig  -10  -20  -> 1
ddcms037 comparesig  -10  -10  -> 0
ddcms038 comparesig  -10   00  -> -1
ddcms039 comparesig  -10   10  -> -1
ddcms040 comparesig  -10   20  -> -1
ddcms041 comparesig   00  -20  -> 1
ddcms042 comparesig   00  -10  -> 1
ddcms043 comparesig   00   00  -> 0
ddcms044 comparesig   00   10  -> -1
ddcms045 comparesig   00   20  -> -1
ddcms046 comparesig   10  -20  -> 1
ddcms047 comparesig   10  -10  -> 1
ddcms048 comparesig   10   00  -> 1
ddcms049 comparesig   10   10  -> 0
ddcms050 comparesig   10   20  -> -1
ddcms051 comparesig   20  -20  -> 1
ddcms052 comparesig   20  -10  -> 1
ddcms053 comparesig   20   00  -> 1
ddcms055 comparesig   20   10  -> 1
ddcms056 comparesig   20   20  -> 0

ddcms061 comparesig  -2.0  -2.0  -> 0
ddcms062 comparesig  -2.0  -1.0  -> -1
ddcms063 comparesig  -2.0   0.0  -> -1
ddcms064 comparesig  -2.0   1.0  -> -1
ddcms065 comparesig  -2.0   2.0  -> -1
ddcms066 comparesig  -1.0  -2.0  -> 1
ddcms067 comparesig  -1.0  -1.0  -> 0
ddcms068 comparesig  -1.0   0.0  -> -1
ddcms069 comparesig  -1.0   1.0  -> -1
ddcms070 comparesig  -1.0   2.0  -> -1
ddcms071 comparesig   0.0  -2.0  -> 1
ddcms072 comparesig   0.0  -1.0  -> 1
ddcms073 comparesig   0.0   0.0  -> 0
ddcms074 comparesig   0.0   1.0  -> -1
ddcms075 comparesig   0.0   2.0  -> -1
ddcms076 comparesig   1.0  -2.0  -> 1
ddcms077 comparesig   1.0  -1.0  -> 1
ddcms078 comparesig   1.0   0.0  -> 1
ddcms079 comparesig   1.0   1.0  -> 0
ddcms080 comparesig   1.0   2.0  -> -1
ddcms081 comparesig   2.0  -2.0  -> 1
ddcms082 comparesig   2.0  -1.0  -> 1
ddcms083 comparesig   2.0   0.0  -> 1
ddcms085 comparesig   2.0   1.0  -> 1
ddcms086 comparesig   2.0   2.0  -> 0

-- now some cases which might overflow if subtract were used
ddcms090 comparesig  9.999999999999999E+384 9.999999999999999E+384  -> 0
ddcms091 comparesig -9.999999999999999E+384 9.999999999999999E+384  -> -1
ddcms092 comparesig  9.999999999999999E+384 -9.999999999999999E+384 -> 1
ddcms093 comparesig -9.999999999999999E+384 -9.999999999999999E+384 -> 0

-- some differing length/exponent cases
ddcms100 comparesig   7.0    7.0    -> 0
ddcms101 comparesig   7.0    7      -> 0
ddcms102 comparesig   7      7.0    -> 0
ddcms103 comparesig   7E+0   7.0    -> 0
ddcms104 comparesig   70E-1  7.0    -> 0
ddcms105 comparesig   0.7E+1 7      -> 0
ddcms106 comparesig   70E-1  7      -> 0
ddcms107 comparesig   7.0    7E+0   -> 0
ddcms108 comparesig   7.0    70E-1  -> 0
ddcms109 comparesig   7      0.7E+1 -> 0
ddcms110 comparesig   7      70E-1  -> 0

ddcms120 comparesig   8.0    7.0    -> 1
ddcms121 comparesig   8.0    7      -> 1
ddcms122 comparesig   8      7.0    -> 1
ddcms123 comparesig   8E+0   7.0    -> 1
ddcms124 comparesig   80E-1  7.0    -> 1
ddcms125 comparesig   0.8E+1 7      -> 1
ddcms126 comparesig   80E-1  7      -> 1
ddcms127 comparesig   8.0    7E+0   -> 1
ddcms128 comparesig   8.0    70E-1  -> 1
ddcms129 comparesig   8      0.7E+1  -> 1
ddcms130 comparesig   8      70E-1  -> 1

ddcms140 comparesig   8.0    9.0    -> -1
ddcms141 comparesig   8.0    9      -> -1
ddcms142 comparesig   8      9.0    -> -1
ddcms143 comparesig   8E+0   9.0    -> -1
ddcms144 comparesig   80E-1  9.0    -> -1
ddcms145 comparesig   0.8E+1 9      -> -1
ddcms146 comparesig   80E-1  9      -> -1
ddcms147 comparesig   8.0    9E+0   -> -1
ddcms148 comparesig   8.0    90E-1  -> -1
ddcms149 comparesig   8      0.9E+1 -> -1
ddcms150 comparesig   8      90E-1  -> -1

-- and again, with sign changes -+ ..
ddcms200 comparesig  -7.0    7.0    -> -1
ddcms201 comparesig  -7.0    7      -> -1
ddcms202 comparesig  -7      7.0    -> -1
ddcms203 comparesig  -7E+0   7.0    -> -1
ddcms204 comparesig  -70E-1  7.0    -> -1
ddcms205 comparesig  -0.7E+1 7      -> -1
ddcms206 comparesig  -70E-1  7      -> -1
ddcms207 comparesig  -7.0    7E+0   -> -1
ddcms208 comparesig  -7.0    70E-1  -> -1
ddcms209 comparesig  -7      0.7E+1 -> -1
ddcms210 comparesig  -7      70E-1  -> -1

ddcms220 comparesig  -8.0    7.0    -> -1
ddcms221 comparesig  -8.0    7      -> -1
ddcms222 comparesig  -8      7.0    -> -1
ddcms223 comparesig  -8E+0   7.0    -> -1
ddcms224 comparesig  -80E-1  7.0    -> -1
ddcms225 comparesig  -0.8E+1 7      -> -1
ddcms226 comparesig  -80E-1  7      -> -1
ddcms227 comparesig  -8.0    7E+0   -> -1
ddcms228 comparesig  -8.0    70E-1  -> -1
ddcms229 comparesig  -8      0.7E+1 -> -1
ddcms230 comparesig  -8      70E-1  -> -1

ddcms240 comparesig  -8.0    9.0    -> -1
ddcms241 comparesig  -8.0    9      -> -1
ddcms242 comparesig  -8      9.0    -> -1
ddcms243 comparesig  -8E+0   9.0    -> -1
ddcms244 comparesig  -80E-1  9.0    -> -1
ddcms245 comparesig  -0.8E+1 9      -> -1
ddcms246 comparesig  -80E-1  9      -> -1
ddcms247 comparesig  -8.0    9E+0   -> -1
ddcms248 comparesig  -8.0    90E-1  -> -1
ddcms249 comparesig  -8      0.9E+1 -> -1
ddcms250 comparesig  -8      90E-1  -> -1

-- and again, with sign changes +- ..
ddcms300 comparesig   7.0    -7.0    -> 1
ddcms301 comparesig   7.0    -7      -> 1
ddcms302 comparesig   7      -7.0    -> 1
ddcms303 comparesig   7E+0   -7.0    -> 1
ddcms304 comparesig   70E-1  -7.0    -> 1
ddcms305 comparesig   .7E+1  -7      -> 1
ddcms306 comparesig   70E-1  -7      -> 1
ddcms307 comparesig   7.0    -7E+0   -> 1
ddcms308 comparesig   7.0    -70E-1  -> 1
ddcms309 comparesig   7      -.7E+1  -> 1
ddcms310 comparesig   7      -70E-1  -> 1

ddcms320 comparesig   8.0    -7.0    -> 1
ddcms321 comparesig   8.0    -7      -> 1
ddcms322 comparesig   8      -7.0    -> 1
ddcms323 comparesig   8E+0   -7.0    -> 1
ddcms324 comparesig   80E-1  -7.0    -> 1
ddcms325 comparesig   .8E+1  -7      -> 1
ddcms326 comparesig   80E-1  -7      -> 1
ddcms327 comparesig   8.0    -7E+0   -> 1
ddcms328 comparesig   8.0    -70E-1  -> 1
ddcms329 comparesig   8      -.7E+1  -> 1
ddcms330 comparesig   8      -70E-1  -> 1

ddcms340 comparesig   8.0    -9.0    -> 1
ddcms341 comparesig   8.0    -9      -> 1
ddcms342 comparesig   8      -9.0    -> 1
ddcms343 comparesig   8E+0   -9.0    -> 1
ddcms344 comparesig   80E-1  -9.0    -> 1
ddcms345 comparesig   .8E+1  -9      -> 1
ddcms346 comparesig   80E-1  -9      -> 1
ddcms347 comparesig   8.0    -9E+0   -> 1
ddcms348 comparesig   8.0    -90E-1  -> 1
ddcms349 comparesig   8      -.9E+1  -> 1
ddcms350 comparesig   8      -90E-1  -> 1

-- and again, with sign changes -- ..
ddcms400 comparesig   -7.0    -7.0    -> 0
ddcms401 comparesig   -7.0    -7      -> 0
ddcms402 comparesig   -7      -7.0    -> 0
ddcms403 comparesig   -7E+0   -7.0    -> 0
ddcms404 comparesig   -70E-1  -7.0    -> 0
ddcms405 comparesig   -.7E+1  -7      -> 0
ddcms406 comparesig   -70E-1  -7      -> 0
ddcms407 comparesig   -7.0    -7E+0   -> 0
ddcms408 comparesig   -7.0    -70E-1  -> 0
ddcms409 comparesig   -7      -.7E+1  -> 0
ddcms410 comparesig   -7      -70E-1  -> 0

ddcms420 comparesig   -8.0    -7.0    -> -1
ddcms421 comparesig   -8.0    -7      -> -1
ddcms422 comparesig   -8      -7.0    -> -1
ddcms423 comparesig   -8E+0   -7.0    -> -1
ddcms424 comparesig   -80E-1  -7.0    -> -1
ddcms425 comparesig   -.8E+1  -7      -> -1
ddcms426 comparesig   -80E-1  -7      -> -1
ddcms427 comparesig   -8.0    -7E+0   -> -1
ddcms428 comparesig   -8.0    -70E-1  -> -1
ddcms429 comparesig   -8      -.7E+1  -> -1
ddcms430 comparesig   -8      -70E-1  -> -1

ddcms440 comparesig   -8.0    -9.0    -> 1
ddcms441 comparesig   -8.0    -9      -> 1
ddcms442 comparesig   -8      -9.0    -> 1
ddcms443 comparesig   -8E+0   -9.0    -> 1
ddcms444 comparesig   -80E-1  -9.0    -> 1
ddcms445 comparesig   -.8E+1  -9      -> 1
ddcms446 comparesig   -80E-1  -9      -> 1
ddcms447 comparesig   -8.0    -9E+0   -> 1
ddcms448 comparesig   -8.0    -90E-1  -> 1
ddcms449 comparesig   -8      -.9E+1  -> 1
ddcms450 comparesig   -8      -90E-1  -> 1


-- testcases that subtract to lots of zeros at boundaries [pgr]
ddcms473 comparesig 123.4560000000000E-89 123.456E-89 -> 0
ddcms474 comparesig 123.456000000000E+89 123.456E+89 -> 0
ddcms475 comparesig 123.45600000000E-89 123.456E-89 -> 0
ddcms476 comparesig 123.4560000000E+89 123.456E+89 -> 0
ddcms477 comparesig 123.456000000E-89 123.456E-89 -> 0
ddcms478 comparesig 123.45600000E+89 123.456E+89 -> 0
ddcms479 comparesig 123.4560000E-89 123.456E-89 -> 0
ddcms480 comparesig 123.456000E+89 123.456E+89 -> 0
ddcms481 comparesig 123.45600E-89 123.456E-89 -> 0
ddcms482 comparesig 123.4560E+89 123.456E+89 -> 0
ddcms483 comparesig 123.456E-89 123.456E-89 -> 0
ddcms487 comparesig 123.456E+89 123.4560000000000E+89 -> 0
ddcms488 comparesig 123.456E-89 123.456000000000E-89 -> 0
ddcms489 comparesig 123.456E+89 123.45600000000E+89 -> 0
ddcms490 comparesig 123.456E-89 123.4560000000E-89 -> 0
ddcms491 comparesig 123.456E+89 123.456000000E+89 -> 0
ddcms492 comparesig 123.456E-89 123.45600000E-89 -> 0
ddcms493 comparesig 123.456E+89 123.4560000E+89 -> 0
ddcms494 comparesig 123.456E-89 123.456000E-89 -> 0
ddcms495 comparesig 123.456E+89 123.45600E+89 -> 0
ddcms496 comparesig 123.456E-89 123.4560E-89 -> 0
ddcms497 comparesig 123.456E+89 123.456E+89 -> 0

-- wide-ranging, around precision; signs equal
ddcms500 comparesig    1     1E-15    -> 1
ddcms501 comparesig    1     1E-14    -> 1
ddcms502 comparesig    1     1E-13    -> 1
ddcms503 comparesig    1     1E-12    -> 1
ddcms504 comparesig    1     1E-11    -> 1
ddcms505 comparesig    1     1E-10    -> 1
ddcms506 comparesig    1     1E-9     -> 1
ddcms507 comparesig    1     1E-8     -> 1
ddcms508 comparesig    1     1E-7     -> 1
ddcms509 comparesig    1     1E-6     -> 1
ddcms510 comparesig    1     1E-5     -> 1
ddcms511 comparesig    1     1E-4     -> 1
ddcms512 comparesig    1     1E-3     -> 1
ddcms513 comparesig    1     1E-2     -> 1
ddcms514 comparesig    1     1E-1     -> 1
ddcms515 comparesig    1     1E-0     -> 0
ddcms516 comparesig    1     1E+1     -> -1
ddcms517 comparesig    1     1E+2     -> -1
ddcms518 comparesig    1     1E+3     -> -1
ddcms519 comparesig    1     1E+4     -> -1
ddcms521 comparesig    1     1E+5     -> -1
ddcms522 comparesig    1     1E+6     -> -1
ddcms523 comparesig    1     1E+7     -> -1
ddcms524 comparesig    1     1E+8     -> -1
ddcms525 comparesig    1     1E+9     -> -1
ddcms526 comparesig    1     1E+10    -> -1
ddcms527 comparesig    1     1E+11    -> -1
ddcms528 comparesig    1     1E+12    -> -1
ddcms529 comparesig    1     1E+13    -> -1
ddcms530 comparesig    1     1E+14    -> -1
ddcms531 comparesig    1     1E+15    -> -1
-- LR swap
ddcms540 comparesig    1E-15  1       -> -1
ddcms541 comparesig    1E-14  1       -> -1
ddcms542 comparesig    1E-13  1       -> -1
ddcms543 comparesig    1E-12  1       -> -1
ddcms544 comparesig    1E-11  1       -> -1
ddcms545 comparesig    1E-10  1       -> -1
ddcms546 comparesig    1E-9   1       -> -1
ddcms547 comparesig    1E-8   1       -> -1
ddcms548 comparesig    1E-7   1       -> -1
ddcms549 comparesig    1E-6   1       -> -1
ddcms550 comparesig    1E-5   1       -> -1
ddcms551 comparesig    1E-4   1       -> -1
ddcms552 comparesig    1E-3   1       -> -1
ddcms553 comparesig    1E-2   1       -> -1
ddcms554 comparesig    1E-1   1       -> -1
ddcms555 comparesig    1E-0   1       ->  0
ddcms556 comparesig    1E+1   1       ->  1
ddcms557 comparesig    1E+2   1       ->  1
ddcms558 comparesig    1E+3   1       ->  1
ddcms559 comparesig    1E+4   1       ->  1
ddcms561 comparesig    1E+5   1       ->  1
ddcms562 comparesig    1E+6   1       ->  1
ddcms563 comparesig    1E+7   1       ->  1
ddcms564 comparesig    1E+8   1       ->  1
ddcms565 comparesig    1E+9   1       ->  1
ddcms566 comparesig    1E+10  1       ->  1
ddcms567 comparesig    1E+11  1       ->  1
ddcms568 comparesig    1E+12  1       ->  1
ddcms569 comparesig    1E+13  1       ->  1
ddcms570 comparesig    1E+14  1       ->  1
ddcms571 comparesig    1E+15  1       ->  1
-- similar with a useful coefficient, one side only
ddcms580 comparesig  0.000000987654321     1E-15    -> 1
ddcms581 comparesig  0.000000987654321     1E-14    -> 1
ddcms582 comparesig  0.000000987654321     1E-13    -> 1
ddcms583 comparesig  0.000000987654321     1E-12    -> 1
ddcms584 comparesig  0.000000987654321     1E-11    -> 1
ddcms585 comparesig  0.000000987654321     1E-10    -> 1
ddcms586 comparesig  0.000000987654321     1E-9     -> 1
ddcms587 comparesig  0.000000987654321     1E-8     -> 1
ddcms588 comparesig  0.000000987654321     1E-7     -> 1
ddcms589 comparesig  0.000000987654321     1E-6     -> -1
ddcms590 comparesig  0.000000987654321     1E-5     -> -1
ddcms591 comparesig  0.000000987654321     1E-4     -> -1
ddcms592 comparesig  0.000000987654321     1E-3     -> -1
ddcms593 comparesig  0.000000987654321     1E-2     -> -1
ddcms594 comparesig  0.000000987654321     1E-1     -> -1
ddcms595 comparesig  0.000000987654321     1E-0     -> -1
ddcms596 comparesig  0.000000987654321     1E+1     -> -1
ddcms597 comparesig  0.000000987654321     1E+2     -> -1
ddcms598 comparesig  0.000000987654321     1E+3     -> -1
ddcms599 comparesig  0.000000987654321     1E+4     -> -1

-- check some unit-y traps
ddcms600 comparesig   12            12.2345 -> -1
ddcms601 comparesig   12.0          12.2345 -> -1
ddcms602 comparesig   12.00         12.2345 -> -1
ddcms603 comparesig   12.000        12.2345 -> -1
ddcms604 comparesig   12.0000       12.2345 -> -1
ddcms605 comparesig   12.00000      12.2345 -> -1
ddcms606 comparesig   12.000000     12.2345 -> -1
ddcms607 comparesig   12.0000000    12.2345 -> -1
ddcms608 comparesig   12.00000000   12.2345 -> -1
ddcms609 comparesig   12.000000000  12.2345 -> -1
ddcms610 comparesig   12.1234 12            ->  1
ddcms611 comparesig   12.1234 12.0          ->  1
ddcms612 comparesig   12.1234 12.00         ->  1
ddcms613 comparesig   12.1234 12.000        ->  1
ddcms614 comparesig   12.1234 12.0000       ->  1
ddcms615 comparesig   12.1234 12.00000      ->  1
ddcms616 comparesig   12.1234 12.000000     ->  1
ddcms617 comparesig   12.1234 12.0000000    ->  1
ddcms618 comparesig   12.1234 12.00000000   ->  1
ddcms619 comparesig   12.1234 12.000000000  ->  1
ddcms620 comparesig  -12           -12.2345 ->  1
ddcms621 comparesig  -12.0         -12.2345 ->  1
ddcms622 comparesig  -12.00        -12.2345 ->  1
ddcms623 comparesig  -12.000       -12.2345 ->  1
ddcms624 comparesig  -12.0000      -12.2345 ->  1
ddcms625 comparesig  -12.00000     -12.2345 ->  1
ddcms626 comparesig  -12.000000    -12.2345 ->  1
ddcms627 comparesig  -12.0000000   -12.2345 ->  1
ddcms628 comparesig  -12.00000000  -12.2345 ->  1
ddcms629 comparesig  -12.000000000 -12.2345 ->  1
ddcms630 comparesig  -12.1234 -12           -> -1
ddcms631 comparesig  -12.1234 -12.0         -> -1
ddcms632 comparesig  -12.1234 -12.00        -> -1
ddcms633 comparesig  -12.1234 -12.000       -> -1
ddcms634 comparesig  -12.1234 -12.0000      -> -1
ddcms635 comparesig  -12.1234 -12.00000     -> -1
ddcms636 comparesig  -12.1234 -12.000000    -> -1
ddcms637 comparesig  -12.1234 -12.0000000   -> -1
ddcms638 comparesig  -12.1234 -12.00000000  -> -1
ddcms639 comparesig  -12.1234 -12.000000000 -> -1

-- extended zeros
ddcms640 comparesig   0     0   -> 0
ddcms641 comparesig   0    -0   -> 0
ddcms642 comparesig   0    -0.0 -> 0
ddcms643 comparesig   0     0.0 -> 0
ddcms644 comparesig  -0     0   -> 0
ddcms645 comparesig  -0    -0   -> 0
ddcms646 comparesig  -0    -0.0 -> 0
ddcms647 comparesig  -0     0.0 -> 0
ddcms648 comparesig   0.0   0   -> 0
ddcms649 comparesig   0.0  -0   -> 0
ddcms650 comparesig   0.0  -0.0 -> 0
ddcms651 comparesig   0.0   0.0 -> 0
ddcms652 comparesig  -0.0   0   -> 0
ddcms653 comparesig  -0.0  -0   -> 0
ddcms654 comparesig  -0.0  -0.0 -> 0
ddcms655 comparesig  -0.0   0.0 -> 0

ddcms656 comparesig  -0E1   0.0 -> 0
ddcms657 comparesig  -0E2   0.0 -> 0
ddcms658 comparesig   0E1   0.0 -> 0
ddcms659 comparesig   0E2   0.0 -> 0
ddcms660 comparesig  -0E1   0   -> 0
ddcms661 comparesig  -0E2   0   -> 0
ddcms662 comparesig   0E1   0   -> 0
ddcms663 comparesig   0E2   0   -> 0
ddcms664 comparesig  -0E1  -0E1 -> 0
ddcms665 comparesig  -0E2  -0E1 -> 0
ddcms666 comparesig   0E1  -0E1 -> 0
ddcms667 comparesig   0E2  -0E1 -> 0
ddcms668 comparesig  -0E1  -0E2 -> 0
ddcms669 comparesig  -0E2  -0E2 -> 0
ddcms670 comparesig   0E1  -0E2 -> 0
ddcms671 comparesig   0E2  -0E2 -> 0
ddcms672 comparesig  -0E1   0E1 -> 0
ddcms673 comparesig  -0E2   0E1 -> 0
ddcms674 comparesig   0E1   0E1 -> 0
ddcms675 comparesig   0E2   0E1 -> 0
ddcms676 comparesig  -0E1   0E2 -> 0
ddcms677 comparesig  -0E2   0E2 -> 0
ddcms678 comparesig   0E1   0E2 -> 0
ddcms679 comparesig   0E2   0E2 -> 0

-- trailing zeros; unit-y
ddcms680 comparesig   12    12           -> 0
ddcms681 comparesig   12    12.0         -> 0
ddcms682 comparesig   12    12.00        -> 0
ddcms683 comparesig   12    12.000       -> 0
ddcms684 comparesig   12    12.0000      -> 0
ddcms685 comparesig   12    12.00000     -> 0
ddcms686 comparesig   12    12.000000    -> 0
ddcms687 comparesig   12    12.0000000   -> 0
ddcms688 comparesig   12    12.00000000  -> 0
ddcms689 comparesig   12    12.000000000 -> 0
ddcms690 comparesig   12              12 -> 0
ddcms691 comparesig   12.0            12 -> 0
ddcms692 comparesig   12.00           12 -> 0
ddcms693 comparesig   12.000          12 -> 0
ddcms694 comparesig   12.0000         12 -> 0
ddcms695 comparesig   12.00000        12 -> 0
ddcms696 comparesig   12.000000       12 -> 0
ddcms697 comparesig   12.0000000      12 -> 0
ddcms698 comparesig   12.00000000     12 -> 0
ddcms699 comparesig   12.000000000    12 -> 0

-- first, second, & last digit
ddcms700 comparesig   1234567890123456 1234567890123455 -> 1
ddcms701 comparesig   1234567890123456 1234567890123456 -> 0
ddcms702 comparesig   1234567890123456 1234567890123457 -> -1
ddcms703 comparesig   1234567890123456 0234567890123456 -> 1
ddcms704 comparesig   1234567890123456 1234567890123456 -> 0
ddcms705 comparesig   1234567890123456 2234567890123456 -> -1
ddcms706 comparesig   1134567890123456 1034567890123456 -> 1
ddcms707 comparesig   1134567890123456 1134567890123456 -> 0
ddcms708 comparesig   1134567890123456 1234567890123456 -> -1

-- miscellaneous
ddcms721 comparesig 12345678000 1 -> 1
ddcms722 comparesig 1 12345678000 -> -1
ddcms723 comparesig 1234567800  1 -> 1
ddcms724 comparesig 1 1234567800  -> -1
ddcms725 comparesig 1234567890  1 -> 1
ddcms726 comparesig 1 1234567890  -> -1
ddcms727 comparesig 1234567891  1 -> 1
ddcms728 comparesig 1 1234567891  -> -1
ddcms729 comparesig 12345678901 1 -> 1
ddcms730 comparesig 1 12345678901 -> -1
ddcms731 comparesig 1234567896  1 -> 1
ddcms732 comparesig 1 1234567896  -> -1

-- residue cases at lower precision
ddcms740 comparesig  1  0.9999999  -> 1
ddcms741 comparesig  1  0.999999   -> 1
ddcms742 comparesig  1  0.99999    -> 1
ddcms743 comparesig  1  1.0000     -> 0
ddcms744 comparesig  1  1.00001    -> -1
ddcms745 comparesig  1  1.000001   -> -1
ddcms746 comparesig  1  1.0000001  -> -1
ddcms750 comparesig  0.9999999  1  -> -1
ddcms751 comparesig  0.999999   1  -> -1
ddcms752 comparesig  0.99999    1  -> -1
ddcms753 comparesig  1.0000     1  -> 0
ddcms754 comparesig  1.00001    1  -> 1
ddcms755 comparesig  1.000001   1  -> 1
ddcms756 comparesig  1.0000001  1  -> 1

-- Specials
ddcms780 comparesig  Inf  -Inf   ->  1
ddcms781 comparesig  Inf  -1000  ->  1
ddcms782 comparesig  Inf  -1     ->  1
ddcms783 comparesig  Inf  -0     ->  1
ddcms784 comparesig  Inf   0     ->  1
ddcms785 comparesig  Inf   1     ->  1
ddcms786 comparesig  Inf   1000  ->  1
ddcms787 comparesig  Inf   Inf   ->  0
ddcms788 comparesig -1000  Inf   -> -1
ddcms789 comparesig -Inf   Inf   -> -1
ddcms790 comparesig -1     Inf   -> -1
ddcms791 comparesig -0     Inf   -> -1
ddcms792 comparesig  0     Inf   -> -1
ddcms793 comparesig  1     Inf   -> -1
ddcms794 comparesig  1000  Inf   -> -1
ddcms795 comparesig  Inf   Inf   ->  0

ddcms800 comparesig -Inf  -Inf   ->  0
ddcms801 comparesig -Inf  -1000  -> -1
ddcms802 comparesig -Inf  -1     -> -1
ddcms803 comparesig -Inf  -0     -> -1
ddcms804 comparesig -Inf   0     -> -1
ddcms805 comparesig -Inf   1     -> -1
ddcms806 comparesig -Inf   1000  -> -1
ddcms807 comparesig -Inf   Inf   -> -1
ddcms808 comparesig -Inf  -Inf   ->  0
ddcms809 comparesig -1000 -Inf   ->  1
ddcms810 comparesig -1    -Inf   ->  1
ddcms811 comparesig -0    -Inf   ->  1
ddcms812 comparesig  0    -Inf   ->  1
ddcms813 comparesig  1    -Inf   ->  1
ddcms814 comparesig  1000 -Inf   ->  1
ddcms815 comparesig  Inf  -Inf   ->  1

ddcms821 comparesig  NaN -Inf    ->  NaN  Invalid_operation
ddcms822 comparesig  NaN -1000   ->  NaN  Invalid_operation
ddcms823 comparesig  NaN -1      ->  NaN  Invalid_operation
ddcms824 comparesig  NaN -0      ->  NaN  Invalid_operation
ddcms825 comparesig  NaN  0      ->  NaN  Invalid_operation
ddcms826 comparesig  NaN  1      ->  NaN  Invalid_operation
ddcms827 comparesig  NaN  1000   ->  NaN  Invalid_operation
ddcms828 comparesig  NaN  Inf    ->  NaN  Invalid_operation
ddcms829 comparesig  NaN  NaN    ->  NaN  Invalid_operation
ddcms830 comparesig -Inf  NaN    ->  NaN  Invalid_operation
ddcms831 comparesig -1000 NaN    ->  NaN  Invalid_operation
ddcms832 comparesig -1    NaN    ->  NaN  Invalid_operation
ddcms833 comparesig -0    NaN    ->  NaN  Invalid_operation
ddcms834 comparesig  0    NaN    ->  NaN  Invalid_operation
ddcms835 comparesig  1    NaN    ->  NaN  Invalid_operation
ddcms836 comparesig  1000 NaN    ->  NaN  Invalid_operation
ddcms837 comparesig  Inf  NaN    ->  NaN  Invalid_operation
ddcms838 comparesig -NaN -NaN    -> -NaN  Invalid_operation
ddcms839 comparesig +NaN -NaN    ->  NaN  Invalid_operation
ddcms840 comparesig -NaN +NaN    -> -NaN  Invalid_operation

ddcms841 comparesig  sNaN -Inf   ->  NaN  Invalid_operation
ddcms842 comparesig  sNaN -1000  ->  NaN  Invalid_operation
ddcms843 comparesig  sNaN -1     ->  NaN  Invalid_operation
ddcms844 comparesig  sNaN -0     ->  NaN  Invalid_operation
ddcms845 comparesig  sNaN  0     ->  NaN  Invalid_operation
ddcms846 comparesig  sNaN  1     ->  NaN  Invalid_operation
ddcms847 comparesig  sNaN  1000  ->  NaN  Invalid_operation
ddcms848 comparesig  sNaN  NaN   ->  NaN  Invalid_operation
ddcms849 comparesig  sNaN sNaN   ->  NaN  Invalid_operation
ddcms850 comparesig  NaN  sNaN   ->  NaN  Invalid_operation
ddcms851 comparesig -Inf  sNaN   ->  NaN  Invalid_operation
ddcms852 comparesig -1000 sNaN   ->  NaN  Invalid_operation
ddcms853 comparesig -1    sNaN   ->  NaN  Invalid_operation
ddcms854 comparesig -0    sNaN   ->  NaN  Invalid_operation
ddcms855 comparesig  0    sNaN   ->  NaN  Invalid_operation
ddcms856 comparesig  1    sNaN   ->  NaN  Invalid_operation
ddcms857 comparesig  1000 sNaN   ->  NaN  Invalid_operation
ddcms858 comparesig  Inf  sNaN   ->  NaN  Invalid_operation
ddcms859 comparesig  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddcms860 comparesig  NaN9 -Inf   ->  NaN9   Invalid_operation
ddcms861 comparesig  NaN8  999   ->  NaN8   Invalid_operation
ddcms862 comparesig  NaN77 Inf   ->  NaN77  Invalid_operation
ddcms863 comparesig -NaN67 NaN5  -> -NaN67  Invalid_operation
ddcms864 comparesig -Inf  -NaN4  -> -NaN4   Invalid_operation
ddcms865 comparesig -999  -NaN33 -> -NaN33  Invalid_operation
ddcms866 comparesig  Inf   NaN2  ->  NaN2   Invalid_operation
ddcms867 comparesig -NaN41 -NaN42 -> -NaN41 Invalid_operation
ddcms868 comparesig +NaN41 -NaN42 ->  NaN41 Invalid_operation
ddcms869 comparesig -NaN41 +NaN42 -> -NaN41 Invalid_operation
ddcms870 comparesig +NaN41 +NaN42 ->  NaN41 Invalid_operation

ddcms871 comparesig -sNaN99 -Inf    -> -NaN99 Invalid_operation
ddcms872 comparesig  sNaN98 -11     ->  NaN98 Invalid_operation
ddcms873 comparesig  sNaN97  NaN    ->  NaN97 Invalid_operation
ddcms874 comparesig  sNaN16 sNaN94  ->  NaN16 Invalid_operation
ddcms875 comparesig  NaN85  sNaN83  ->  NaN83 Invalid_operation
ddcms876 comparesig -Inf    sNaN92  ->  NaN92 Invalid_operation
ddcms877 comparesig  088    sNaN81  ->  NaN81 Invalid_operation
ddcms878 comparesig  Inf    sNaN90  ->  NaN90 Invalid_operation
ddcms879 comparesig  NaN   -sNaN89  -> -NaN89 Invalid_operation

-- wide range
ddcms880 comparesig +1.23456789012345E-0 9E+384 -> -1
ddcms881 comparesig 9E+384 +1.23456789012345E-0 ->  1
ddcms882 comparesig +0.100 9E-383               ->  1
ddcms883 comparesig 9E-383 +0.100               -> -1
ddcms885 comparesig -1.23456789012345E-0 9E+384 -> -1
ddcms886 comparesig 9E+384 -1.23456789012345E-0 ->  1
ddcms887 comparesig -0.100 9E-383               -> -1
ddcms888 comparesig 9E-383 -0.100               ->  1

-- signs
ddcms901 comparesig  1e+77  1e+11 ->  1
ddcms902 comparesig  1e+77 -1e+11 ->  1
ddcms903 comparesig -1e+77  1e+11 -> -1
ddcms904 comparesig -1e+77 -1e+11 -> -1
ddcms905 comparesig  1e-77  1e-11 -> -1
ddcms906 comparesig  1e-77 -1e-11 ->  1
ddcms907 comparesig -1e-77  1e-11 -> -1
ddcms908 comparesig -1e-77 -1e-11 ->  1

-- Null tests
ddcms990 comparesig 10  # -> NaN Invalid_operation
ddcms991 comparesig  # 10 -> NaN Invalid_operation

Added test/dectest/ddCompareTotal.decTest.





































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
------------------------------------------------------------------------
-- ddCompareTotal.decTest -- decDouble comparison using total ordering--
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Note that we cannot assume add/subtract tests cover paths adequately,
-- here, because the code might be quite different (comparison cannot
-- overflow or underflow, so actual subtractions are not necessary).
-- Similarly, comparetotal will have some radically different paths
-- than compare.

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks
ddcot001 comparetotal  -2  -2  -> 0
ddcot002 comparetotal  -2  -1  -> -1
ddcot003 comparetotal  -2   0  -> -1
ddcot004 comparetotal  -2   1  -> -1
ddcot005 comparetotal  -2   2  -> -1
ddcot006 comparetotal  -1  -2  -> 1
ddcot007 comparetotal  -1  -1  -> 0
ddcot008 comparetotal  -1   0  -> -1
ddcot009 comparetotal  -1   1  -> -1
ddcot010 comparetotal  -1   2  -> -1
ddcot011 comparetotal   0  -2  -> 1
ddcot012 comparetotal   0  -1  -> 1
ddcot013 comparetotal   0   0  -> 0
ddcot014 comparetotal   0   1  -> -1
ddcot015 comparetotal   0   2  -> -1
ddcot016 comparetotal   1  -2  -> 1
ddcot017 comparetotal   1  -1  -> 1
ddcot018 comparetotal   1   0  -> 1
ddcot019 comparetotal   1   1  -> 0
ddcot020 comparetotal   1   2  -> -1
ddcot021 comparetotal   2  -2  -> 1
ddcot022 comparetotal   2  -1  -> 1
ddcot023 comparetotal   2   0  -> 1
ddcot025 comparetotal   2   1  -> 1
ddcot026 comparetotal   2   2  -> 0

ddcot031 comparetotal  -20  -20  -> 0
ddcot032 comparetotal  -20  -10  -> -1
ddcot033 comparetotal  -20   00  -> -1
ddcot034 comparetotal  -20   10  -> -1
ddcot035 comparetotal  -20   20  -> -1
ddcot036 comparetotal  -10  -20  -> 1
ddcot037 comparetotal  -10  -10  -> 0
ddcot038 comparetotal  -10   00  -> -1
ddcot039 comparetotal  -10   10  -> -1
ddcot040 comparetotal  -10   20  -> -1
ddcot041 comparetotal   00  -20  -> 1
ddcot042 comparetotal   00  -10  -> 1
ddcot043 comparetotal   00   00  -> 0
ddcot044 comparetotal   00   10  -> -1
ddcot045 comparetotal   00   20  -> -1
ddcot046 comparetotal   10  -20  -> 1
ddcot047 comparetotal   10  -10  -> 1
ddcot048 comparetotal   10   00  -> 1
ddcot049 comparetotal   10   10  -> 0
ddcot050 comparetotal   10   20  -> -1
ddcot051 comparetotal   20  -20  -> 1
ddcot052 comparetotal   20  -10  -> 1
ddcot053 comparetotal   20   00  -> 1
ddcot055 comparetotal   20   10  -> 1
ddcot056 comparetotal   20   20  -> 0

ddcot061 comparetotal  -2.0  -2.0  -> 0
ddcot062 comparetotal  -2.0  -1.0  -> -1
ddcot063 comparetotal  -2.0   0.0  -> -1
ddcot064 comparetotal  -2.0   1.0  -> -1
ddcot065 comparetotal  -2.0   2.0  -> -1
ddcot066 comparetotal  -1.0  -2.0  -> 1
ddcot067 comparetotal  -1.0  -1.0  -> 0
ddcot068 comparetotal  -1.0   0.0  -> -1
ddcot069 comparetotal  -1.0   1.0  -> -1
ddcot070 comparetotal  -1.0   2.0  -> -1
ddcot071 comparetotal   0.0  -2.0  -> 1
ddcot072 comparetotal   0.0  -1.0  -> 1
ddcot073 comparetotal   0.0   0.0  -> 0
ddcot074 comparetotal   0.0   1.0  -> -1
ddcot075 comparetotal   0.0   2.0  -> -1
ddcot076 comparetotal   1.0  -2.0  -> 1
ddcot077 comparetotal   1.0  -1.0  -> 1
ddcot078 comparetotal   1.0   0.0  -> 1
ddcot079 comparetotal   1.0   1.0  -> 0
ddcot080 comparetotal   1.0   2.0  -> -1
ddcot081 comparetotal   2.0  -2.0  -> 1
ddcot082 comparetotal   2.0  -1.0  -> 1
ddcot083 comparetotal   2.0   0.0  -> 1
ddcot085 comparetotal   2.0   1.0  -> 1
ddcot086 comparetotal   2.0   2.0  -> 0

-- now some cases which might overflow if subtract were used
ddcot090 comparetotal  9.99999999E+384 9.99999999E+384  -> 0
ddcot091 comparetotal -9.99999999E+384 9.99999999E+384  -> -1
ddcot092 comparetotal  9.99999999E+384 -9.99999999E+384 -> 1
ddcot093 comparetotal -9.99999999E+384 -9.99999999E+384 -> 0

-- some differing length/exponent cases
-- in this first group, compare would compare all equal
ddcot100 comparetotal   7.0    7.0    -> 0
ddcot101 comparetotal   7.0    7      -> -1
ddcot102 comparetotal   7      7.0    -> 1
ddcot103 comparetotal   7E+0   7.0    -> 1
ddcot104 comparetotal   70E-1  7.0    -> 0
ddcot105 comparetotal   0.7E+1 7      -> 0
ddcot106 comparetotal   70E-1  7      -> -1
ddcot107 comparetotal   7.0    7E+0   -> -1
ddcot108 comparetotal   7.0    70E-1  -> 0
ddcot109 comparetotal   7      0.7E+1 -> 0
ddcot110 comparetotal   7      70E-1  -> 1

ddcot120 comparetotal   8.0    7.0    -> 1
ddcot121 comparetotal   8.0    7      -> 1
ddcot122 comparetotal   8      7.0    -> 1
ddcot123 comparetotal   8E+0   7.0    -> 1
ddcot124 comparetotal   80E-1  7.0    -> 1
ddcot125 comparetotal   0.8E+1 7      -> 1
ddcot126 comparetotal   80E-1  7      -> 1
ddcot127 comparetotal   8.0    7E+0   -> 1
ddcot128 comparetotal   8.0    70E-1  -> 1
ddcot129 comparetotal   8      0.7E+1  -> 1
ddcot130 comparetotal   8      70E-1  -> 1

ddcot140 comparetotal   8.0    9.0    -> -1
ddcot141 comparetotal   8.0    9      -> -1
ddcot142 comparetotal   8      9.0    -> -1
ddcot143 comparetotal   8E+0   9.0    -> -1
ddcot144 comparetotal   80E-1  9.0    -> -1
ddcot145 comparetotal   0.8E+1 9      -> -1
ddcot146 comparetotal   80E-1  9      -> -1
ddcot147 comparetotal   8.0    9E+0   -> -1
ddcot148 comparetotal   8.0    90E-1  -> -1
ddcot149 comparetotal   8      0.9E+1 -> -1
ddcot150 comparetotal   8      90E-1  -> -1

-- and again, with sign changes -+ ..
ddcot200 comparetotal  -7.0    7.0    -> -1
ddcot201 comparetotal  -7.0    7      -> -1
ddcot202 comparetotal  -7      7.0    -> -1
ddcot203 comparetotal  -7E+0   7.0    -> -1
ddcot204 comparetotal  -70E-1  7.0    -> -1
ddcot205 comparetotal  -0.7E+1 7      -> -1
ddcot206 comparetotal  -70E-1  7      -> -1
ddcot207 comparetotal  -7.0    7E+0   -> -1
ddcot208 comparetotal  -7.0    70E-1  -> -1
ddcot209 comparetotal  -7      0.7E+1 -> -1
ddcot210 comparetotal  -7      70E-1  -> -1

ddcot220 comparetotal  -8.0    7.0    -> -1
ddcot221 comparetotal  -8.0    7      -> -1
ddcot222 comparetotal  -8      7.0    -> -1
ddcot223 comparetotal  -8E+0   7.0    -> -1
ddcot224 comparetotal  -80E-1  7.0    -> -1
ddcot225 comparetotal  -0.8E+1 7      -> -1
ddcot226 comparetotal  -80E-1  7      -> -1
ddcot227 comparetotal  -8.0    7E+0   -> -1
ddcot228 comparetotal  -8.0    70E-1  -> -1
ddcot229 comparetotal  -8      0.7E+1 -> -1
ddcot230 comparetotal  -8      70E-1  -> -1

ddcot240 comparetotal  -8.0    9.0    -> -1
ddcot241 comparetotal  -8.0    9      -> -1
ddcot242 comparetotal  -8      9.0    -> -1
ddcot243 comparetotal  -8E+0   9.0    -> -1
ddcot244 comparetotal  -80E-1  9.0    -> -1
ddcot245 comparetotal  -0.8E+1 9      -> -1
ddcot246 comparetotal  -80E-1  9      -> -1
ddcot247 comparetotal  -8.0    9E+0   -> -1
ddcot248 comparetotal  -8.0    90E-1  -> -1
ddcot249 comparetotal  -8      0.9E+1 -> -1
ddcot250 comparetotal  -8      90E-1  -> -1

-- and again, with sign changes +- ..
ddcot300 comparetotal   7.0    -7.0    -> 1
ddcot301 comparetotal   7.0    -7      -> 1
ddcot302 comparetotal   7      -7.0    -> 1
ddcot303 comparetotal   7E+0   -7.0    -> 1
ddcot304 comparetotal   70E-1  -7.0    -> 1
ddcot305 comparetotal   .7E+1  -7      -> 1
ddcot306 comparetotal   70E-1  -7      -> 1
ddcot307 comparetotal   7.0    -7E+0   -> 1
ddcot308 comparetotal   7.0    -70E-1  -> 1
ddcot309 comparetotal   7      -.7E+1  -> 1
ddcot310 comparetotal   7      -70E-1  -> 1

ddcot320 comparetotal   8.0    -7.0    -> 1
ddcot321 comparetotal   8.0    -7      -> 1
ddcot322 comparetotal   8      -7.0    -> 1
ddcot323 comparetotal   8E+0   -7.0    -> 1
ddcot324 comparetotal   80E-1  -7.0    -> 1
ddcot325 comparetotal   .8E+1  -7      -> 1
ddcot326 comparetotal   80E-1  -7      -> 1
ddcot327 comparetotal   8.0    -7E+0   -> 1
ddcot328 comparetotal   8.0    -70E-1  -> 1
ddcot329 comparetotal   8      -.7E+1  -> 1
ddcot330 comparetotal   8      -70E-1  -> 1

ddcot340 comparetotal   8.0    -9.0    -> 1
ddcot341 comparetotal   8.0    -9      -> 1
ddcot342 comparetotal   8      -9.0    -> 1
ddcot343 comparetotal   8E+0   -9.0    -> 1
ddcot344 comparetotal   80E-1  -9.0    -> 1
ddcot345 comparetotal   .8E+1  -9      -> 1
ddcot346 comparetotal   80E-1  -9      -> 1
ddcot347 comparetotal   8.0    -9E+0   -> 1
ddcot348 comparetotal   8.0    -90E-1  -> 1
ddcot349 comparetotal   8      -.9E+1  -> 1
ddcot350 comparetotal   8      -90E-1  -> 1

-- and again, with sign changes -- ..
ddcot400 comparetotal   -7.0    -7.0    -> 0
ddcot401 comparetotal   -7.0    -7      -> 1
ddcot402 comparetotal   -7      -7.0    -> -1
ddcot403 comparetotal   -7E+0   -7.0    -> -1
ddcot404 comparetotal   -70E-1  -7.0    -> 0
ddcot405 comparetotal   -.7E+1  -7      -> 0
ddcot406 comparetotal   -70E-1  -7      -> 1
ddcot407 comparetotal   -7.0    -7E+0   -> 1
ddcot408 comparetotal   -7.0    -70E-1  -> 0
ddcot409 comparetotal   -7      -.7E+1  -> 0
ddcot410 comparetotal   -7      -70E-1  -> -1

ddcot420 comparetotal   -8.0    -7.0    -> -1
ddcot421 comparetotal   -8.0    -7      -> -1
ddcot422 comparetotal   -8      -7.0    -> -1
ddcot423 comparetotal   -8E+0   -7.0    -> -1
ddcot424 comparetotal   -80E-1  -7.0    -> -1
ddcot425 comparetotal   -.8E+1  -7      -> -1
ddcot426 comparetotal   -80E-1  -7      -> -1
ddcot427 comparetotal   -8.0    -7E+0   -> -1
ddcot428 comparetotal   -8.0    -70E-1  -> -1
ddcot429 comparetotal   -8      -.7E+1  -> -1
ddcot430 comparetotal   -8      -70E-1  -> -1

ddcot440 comparetotal   -8.0    -9.0    -> 1
ddcot441 comparetotal   -8.0    -9      -> 1
ddcot442 comparetotal   -8      -9.0    -> 1
ddcot443 comparetotal   -8E+0   -9.0    -> 1
ddcot444 comparetotal   -80E-1  -9.0    -> 1
ddcot445 comparetotal   -.8E+1  -9      -> 1
ddcot446 comparetotal   -80E-1  -9      -> 1
ddcot447 comparetotal   -8.0    -9E+0   -> 1
ddcot448 comparetotal   -8.0    -90E-1  -> 1
ddcot449 comparetotal   -8      -.9E+1  -> 1
ddcot450 comparetotal   -8      -90E-1  -> 1


-- testcases that subtract to lots of zeros at boundaries [pgr]
ddcot473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
ddcot474 comparetotal 123.456000000000E+89 123.456E+89 -> -1
ddcot475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
ddcot476 comparetotal 123.4560000000E+89 123.456E+89 -> -1
ddcot477 comparetotal 123.456000000E-89 123.456E-89 -> -1
ddcot478 comparetotal 123.45600000E+89 123.456E+89 -> -1
ddcot479 comparetotal 123.4560000E-89 123.456E-89 -> -1
ddcot480 comparetotal 123.456000E+89 123.456E+89 -> -1
ddcot481 comparetotal 123.45600E-89 123.456E-89 -> -1
ddcot482 comparetotal 123.4560E+89 123.456E+89 -> -1
ddcot483 comparetotal 123.456E-89 123.456E-89 -> 0
ddcot487 comparetotal 123.456E+89 123.4560000000000E+89 -> 1
ddcot488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
ddcot489 comparetotal 123.456E+89 123.45600000000E+89 -> 1
ddcot490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
ddcot491 comparetotal 123.456E+89 123.456000000E+89 -> 1
ddcot492 comparetotal 123.456E-89 123.45600000E-89 -> 1
ddcot493 comparetotal 123.456E+89 123.4560000E+89 -> 1
ddcot494 comparetotal 123.456E-89 123.456000E-89 -> 1
ddcot495 comparetotal 123.456E+89 123.45600E+89 -> 1
ddcot496 comparetotal 123.456E-89 123.4560E-89 -> 1
ddcot497 comparetotal 123.456E+89 123.456E+89 -> 0

-- wide-ranging, around precision; signs equal
ddcot498 comparetotal    1     1E-17    -> 1
ddcot499 comparetotal    1     1E-16    -> 1
ddcot500 comparetotal    1     1E-15    -> 1
ddcot501 comparetotal    1     1E-14    -> 1
ddcot502 comparetotal    1     1E-13    -> 1
ddcot503 comparetotal    1     1E-12    -> 1
ddcot504 comparetotal    1     1E-11    -> 1
ddcot505 comparetotal    1     1E-10    -> 1
ddcot506 comparetotal    1     1E-9     -> 1
ddcot507 comparetotal    1     1E-8     -> 1
ddcot508 comparetotal    1     1E-7     -> 1
ddcot509 comparetotal    1     1E-6     -> 1
ddcot510 comparetotal    1     1E-5     -> 1
ddcot511 comparetotal    1     1E-4     -> 1
ddcot512 comparetotal    1     1E-3     -> 1
ddcot513 comparetotal    1     1E-2     -> 1
ddcot514 comparetotal    1     1E-1     -> 1
ddcot515 comparetotal    1     1E-0     -> 0
ddcot516 comparetotal    1     1E+1     -> -1
ddcot517 comparetotal    1     1E+2     -> -1
ddcot518 comparetotal    1     1E+3     -> -1
ddcot519 comparetotal    1     1E+4     -> -1
ddcot521 comparetotal    1     1E+5     -> -1
ddcot522 comparetotal    1     1E+6     -> -1
ddcot523 comparetotal    1     1E+7     -> -1
ddcot524 comparetotal    1     1E+8     -> -1
ddcot525 comparetotal    1     1E+9     -> -1
ddcot526 comparetotal    1     1E+10    -> -1
ddcot527 comparetotal    1     1E+11    -> -1
ddcot528 comparetotal    1     1E+12    -> -1
ddcot529 comparetotal    1     1E+13    -> -1
ddcot530 comparetotal    1     1E+14    -> -1
ddcot531 comparetotal    1     1E+15    -> -1
ddcot532 comparetotal    1     1E+16    -> -1
ddcot533 comparetotal    1     1E+17    -> -1
-- LR swap
ddcot538 comparetotal    1E-17  1       -> -1
ddcot539 comparetotal    1E-16  1       -> -1
ddcot540 comparetotal    1E-15  1       -> -1
ddcot541 comparetotal    1E-14  1       -> -1
ddcot542 comparetotal    1E-13  1       -> -1
ddcot543 comparetotal    1E-12  1       -> -1
ddcot544 comparetotal    1E-11  1       -> -1
ddcot545 comparetotal    1E-10  1       -> -1
ddcot546 comparetotal    1E-9   1       -> -1
ddcot547 comparetotal    1E-8   1       -> -1
ddcot548 comparetotal    1E-7   1       -> -1
ddcot549 comparetotal    1E-6   1       -> -1
ddcot550 comparetotal    1E-5   1       -> -1
ddcot551 comparetotal    1E-4   1       -> -1
ddcot552 comparetotal    1E-3   1       -> -1
ddcot553 comparetotal    1E-2   1       -> -1
ddcot554 comparetotal    1E-1   1       -> -1
ddcot555 comparetotal    1E-0   1       ->  0
ddcot556 comparetotal    1E+1   1       ->  1
ddcot557 comparetotal    1E+2   1       ->  1
ddcot558 comparetotal    1E+3   1       ->  1
ddcot559 comparetotal    1E+4   1       ->  1
ddcot561 comparetotal    1E+5   1       ->  1
ddcot562 comparetotal    1E+6   1       ->  1
ddcot563 comparetotal    1E+7   1       ->  1
ddcot564 comparetotal    1E+8   1       ->  1
ddcot565 comparetotal    1E+9   1       ->  1
ddcot566 comparetotal    1E+10  1       ->  1
ddcot567 comparetotal    1E+11  1       ->  1
ddcot568 comparetotal    1E+12  1       ->  1
ddcot569 comparetotal    1E+13  1       ->  1
ddcot570 comparetotal    1E+14  1       ->  1
ddcot571 comparetotal    1E+15  1       ->  1
ddcot572 comparetotal    1E+16  1       ->  1
ddcot573 comparetotal    1E+17  1       ->  1
-- similar with a useful coefficient, one side only
ddcot578 comparetotal  0.000000987654321     1E-17    -> 1
ddcot579 comparetotal  0.000000987654321     1E-16    -> 1
ddcot580 comparetotal  0.000000987654321     1E-15    -> 1
ddcot581 comparetotal  0.000000987654321     1E-14    -> 1
ddcot582 comparetotal  0.000000987654321     1E-13    -> 1
ddcot583 comparetotal  0.000000987654321     1E-12    -> 1
ddcot584 comparetotal  0.000000987654321     1E-11    -> 1
ddcot585 comparetotal  0.000000987654321     1E-10    -> 1
ddcot586 comparetotal  0.000000987654321     1E-9     -> 1
ddcot587 comparetotal  0.000000987654321     1E-8     -> 1
ddcot588 comparetotal  0.000000987654321     1E-7     -> 1
ddcot589 comparetotal  0.000000987654321     1E-6     -> -1
ddcot590 comparetotal  0.000000987654321     1E-5     -> -1
ddcot591 comparetotal  0.000000987654321     1E-4     -> -1
ddcot592 comparetotal  0.000000987654321     1E-3     -> -1
ddcot593 comparetotal  0.000000987654321     1E-2     -> -1
ddcot594 comparetotal  0.000000987654321     1E-1     -> -1
ddcot595 comparetotal  0.000000987654321     1E-0     -> -1
ddcot596 comparetotal  0.000000987654321     1E+1     -> -1
ddcot597 comparetotal  0.000000987654321     1E+2     -> -1
ddcot598 comparetotal  0.000000987654321     1E+3     -> -1
ddcot599 comparetotal  0.000000987654321     1E+4     -> -1

-- check some unit-y traps
ddcot600 comparetotal   12            12.2345 -> -1
ddcot601 comparetotal   12.0          12.2345 -> -1
ddcot602 comparetotal   12.00         12.2345 -> -1
ddcot603 comparetotal   12.000        12.2345 -> -1
ddcot604 comparetotal   12.0000       12.2345 -> -1
ddcot605 comparetotal   12.00000      12.2345 -> -1
ddcot606 comparetotal   12.000000     12.2345 -> -1
ddcot607 comparetotal   12.0000000    12.2345 -> -1
ddcot608 comparetotal   12.00000000   12.2345 -> -1
ddcot609 comparetotal   12.000000000  12.2345 -> -1
ddcot610 comparetotal   12.1234 12            ->  1
ddcot611 comparetotal   12.1234 12.0          ->  1
ddcot612 comparetotal   12.1234 12.00         ->  1
ddcot613 comparetotal   12.1234 12.000        ->  1
ddcot614 comparetotal   12.1234 12.0000       ->  1
ddcot615 comparetotal   12.1234 12.00000      ->  1
ddcot616 comparetotal   12.1234 12.000000     ->  1
ddcot617 comparetotal   12.1234 12.0000000    ->  1
ddcot618 comparetotal   12.1234 12.00000000   ->  1
ddcot619 comparetotal   12.1234 12.000000000  ->  1
ddcot620 comparetotal  -12           -12.2345 ->  1
ddcot621 comparetotal  -12.0         -12.2345 ->  1
ddcot622 comparetotal  -12.00        -12.2345 ->  1
ddcot623 comparetotal  -12.000       -12.2345 ->  1
ddcot624 comparetotal  -12.0000      -12.2345 ->  1
ddcot625 comparetotal  -12.00000     -12.2345 ->  1
ddcot626 comparetotal  -12.000000    -12.2345 ->  1
ddcot627 comparetotal  -12.0000000   -12.2345 ->  1
ddcot628 comparetotal  -12.00000000  -12.2345 ->  1
ddcot629 comparetotal  -12.000000000 -12.2345 ->  1
ddcot630 comparetotal  -12.1234 -12           -> -1
ddcot631 comparetotal  -12.1234 -12.0         -> -1
ddcot632 comparetotal  -12.1234 -12.00        -> -1
ddcot633 comparetotal  -12.1234 -12.000       -> -1
ddcot634 comparetotal  -12.1234 -12.0000      -> -1
ddcot635 comparetotal  -12.1234 -12.00000     -> -1
ddcot636 comparetotal  -12.1234 -12.000000    -> -1
ddcot637 comparetotal  -12.1234 -12.0000000   -> -1
ddcot638 comparetotal  -12.1234 -12.00000000  -> -1
ddcot639 comparetotal  -12.1234 -12.000000000 -> -1

-- extended zeros
ddcot640 comparetotal   0     0   -> 0
ddcot641 comparetotal   0    -0   -> 1
ddcot642 comparetotal   0    -0.0 -> 1
ddcot643 comparetotal   0     0.0 -> 1
ddcot644 comparetotal  -0     0   -> -1
ddcot645 comparetotal  -0    -0   -> 0
ddcot646 comparetotal  -0    -0.0 -> -1
ddcot647 comparetotal  -0     0.0 -> -1
ddcot648 comparetotal   0.0   0   -> -1
ddcot649 comparetotal   0.0  -0   -> 1
ddcot650 comparetotal   0.0  -0.0 -> 1
ddcot651 comparetotal   0.0   0.0 -> 0
ddcot652 comparetotal  -0.0   0   -> -1
ddcot653 comparetotal  -0.0  -0   -> 1
ddcot654 comparetotal  -0.0  -0.0 -> 0
ddcot655 comparetotal  -0.0   0.0 -> -1

ddcot656 comparetotal  -0E1   0.0 -> -1
ddcot657 comparetotal  -0E2   0.0 -> -1
ddcot658 comparetotal   0E1   0.0 -> 1
ddcot659 comparetotal   0E2   0.0 -> 1
ddcot660 comparetotal  -0E1   0   -> -1
ddcot661 comparetotal  -0E2   0   -> -1
ddcot662 comparetotal   0E1   0   -> 1
ddcot663 comparetotal   0E2   0   -> 1
ddcot664 comparetotal  -0E1  -0E1 -> 0
ddcot665 comparetotal  -0E2  -0E1 -> -1
ddcot666 comparetotal   0E1  -0E1 -> 1
ddcot667 comparetotal   0E2  -0E1 -> 1
ddcot668 comparetotal  -0E1  -0E2 -> 1
ddcot669 comparetotal  -0E2  -0E2 -> 0
ddcot670 comparetotal   0E1  -0E2 -> 1
ddcot671 comparetotal   0E2  -0E2 -> 1
ddcot672 comparetotal  -0E1   0E1 -> -1
ddcot673 comparetotal  -0E2   0E1 -> -1
ddcot674 comparetotal   0E1   0E1 -> 0
ddcot675 comparetotal   0E2   0E1 -> 1
ddcot676 comparetotal  -0E1   0E2 -> -1
ddcot677 comparetotal  -0E2   0E2 -> -1
ddcot678 comparetotal   0E1   0E2 -> -1
ddcot679 comparetotal   0E2   0E2 -> 0

-- trailing zeros; unit-y
ddcot680 comparetotal   12    12           -> 0
ddcot681 comparetotal   12    12.0         -> 1
ddcot682 comparetotal   12    12.00        -> 1
ddcot683 comparetotal   12    12.000       -> 1
ddcot684 comparetotal   12    12.0000      -> 1
ddcot685 comparetotal   12    12.00000     -> 1
ddcot686 comparetotal   12    12.000000    -> 1
ddcot687 comparetotal   12    12.0000000   -> 1
ddcot688 comparetotal   12    12.00000000  -> 1
ddcot689 comparetotal   12    12.000000000 -> 1
ddcot690 comparetotal   12              12 -> 0
ddcot691 comparetotal   12.0            12 -> -1
ddcot692 comparetotal   12.00           12 -> -1
ddcot693 comparetotal   12.000          12 -> -1
ddcot694 comparetotal   12.0000         12 -> -1
ddcot695 comparetotal   12.00000        12 -> -1
ddcot696 comparetotal   12.000000       12 -> -1
ddcot697 comparetotal   12.0000000      12 -> -1
ddcot698 comparetotal   12.00000000     12 -> -1
ddcot699 comparetotal   12.000000000    12 -> -1

-- old long operand checks
ddcot701 comparetotal 12345678000  1 ->  1
ddcot702 comparetotal 1 12345678000  -> -1
ddcot703 comparetotal 1234567800   1 ->  1
ddcot704 comparetotal 1 1234567800   -> -1
ddcot705 comparetotal 1234567890   1 ->  1
ddcot706 comparetotal 1 1234567890   -> -1
ddcot707 comparetotal 1234567891   1 ->  1
ddcot708 comparetotal 1 1234567891   -> -1
ddcot709 comparetotal 12345678901  1 ->  1
ddcot710 comparetotal 1 12345678901  -> -1
ddcot711 comparetotal 1234567896   1 ->  1
ddcot712 comparetotal 1 1234567896   -> -1
ddcot713 comparetotal -1234567891  1 -> -1
ddcot714 comparetotal 1 -1234567891  ->  1
ddcot715 comparetotal -12345678901 1 -> -1
ddcot716 comparetotal 1 -12345678901 ->  1
ddcot717 comparetotal -1234567896  1 -> -1
ddcot718 comparetotal 1 -1234567896  ->  1

-- old residue cases
ddcot740 comparetotal  1  0.9999999  -> 1
ddcot741 comparetotal  1  0.999999   -> 1
ddcot742 comparetotal  1  0.99999    -> 1
ddcot743 comparetotal  1  1.0000     -> 1
ddcot744 comparetotal  1  1.00001    -> -1
ddcot745 comparetotal  1  1.000001   -> -1
ddcot746 comparetotal  1  1.0000001  -> -1
ddcot750 comparetotal  0.9999999  1  -> -1
ddcot751 comparetotal  0.999999   1  -> -1
ddcot752 comparetotal  0.99999    1  -> -1
ddcot753 comparetotal  1.0000     1  -> -1
ddcot754 comparetotal  1.00001    1  -> 1
ddcot755 comparetotal  1.000001   1  -> 1
ddcot756 comparetotal  1.0000001  1  -> 1

-- Specials
ddcot780 comparetotal  Inf  -Inf   ->  1
ddcot781 comparetotal  Inf  -1000  ->  1
ddcot782 comparetotal  Inf  -1     ->  1
ddcot783 comparetotal  Inf  -0     ->  1
ddcot784 comparetotal  Inf   0     ->  1
ddcot785 comparetotal  Inf   1     ->  1
ddcot786 comparetotal  Inf   1000  ->  1
ddcot787 comparetotal  Inf   Inf   ->  0
ddcot788 comparetotal -1000  Inf   -> -1
ddcot789 comparetotal -Inf   Inf   -> -1
ddcot790 comparetotal -1     Inf   -> -1
ddcot791 comparetotal -0     Inf   -> -1
ddcot792 comparetotal  0     Inf   -> -1
ddcot793 comparetotal  1     Inf   -> -1
ddcot794 comparetotal  1000  Inf   -> -1
ddcot795 comparetotal  Inf   Inf   ->  0

ddcot800 comparetotal -Inf  -Inf   ->  0
ddcot801 comparetotal -Inf  -1000  -> -1
ddcot802 comparetotal -Inf  -1     -> -1
ddcot803 comparetotal -Inf  -0     -> -1
ddcot804 comparetotal -Inf   0     -> -1
ddcot805 comparetotal -Inf   1     -> -1
ddcot806 comparetotal -Inf   1000  -> -1
ddcot807 comparetotal -Inf   Inf   -> -1
ddcot808 comparetotal -Inf  -Inf   ->  0
ddcot809 comparetotal -1000 -Inf   ->  1
ddcot810 comparetotal -1    -Inf   ->  1
ddcot811 comparetotal -0    -Inf   ->  1
ddcot812 comparetotal  0    -Inf   ->  1
ddcot813 comparetotal  1    -Inf   ->  1
ddcot814 comparetotal  1000 -Inf   ->  1
ddcot815 comparetotal  Inf  -Inf   ->  1

ddcot821 comparetotal  NaN -Inf    ->  1
ddcot822 comparetotal  NaN -1000   ->  1
ddcot823 comparetotal  NaN -1      ->  1
ddcot824 comparetotal  NaN -0      ->  1
ddcot825 comparetotal  NaN  0      ->  1
ddcot826 comparetotal  NaN  1      ->  1
ddcot827 comparetotal  NaN  1000   ->  1
ddcot828 comparetotal  NaN  Inf    ->  1
ddcot829 comparetotal  NaN  NaN    ->  0
ddcot830 comparetotal -Inf  NaN    ->  -1
ddcot831 comparetotal -1000 NaN    ->  -1
ddcot832 comparetotal -1    NaN    ->  -1
ddcot833 comparetotal -0    NaN    ->  -1
ddcot834 comparetotal  0    NaN    ->  -1
ddcot835 comparetotal  1    NaN    ->  -1
ddcot836 comparetotal  1000 NaN    ->  -1
ddcot837 comparetotal  Inf  NaN    ->  -1
ddcot838 comparetotal -NaN -NaN    ->  0
ddcot839 comparetotal +NaN -NaN    ->  1
ddcot840 comparetotal -NaN +NaN    ->  -1

ddcot841 comparetotal  sNaN -sNaN  ->  1
ddcot842 comparetotal  sNaN -NaN   ->  1
ddcot843 comparetotal  sNaN -Inf   ->  1
ddcot844 comparetotal  sNaN -1000  ->  1
ddcot845 comparetotal  sNaN -1     ->  1
ddcot846 comparetotal  sNaN -0     ->  1
ddcot847 comparetotal  sNaN  0     ->  1
ddcot848 comparetotal  sNaN  1     ->  1
ddcot849 comparetotal  sNaN  1000  ->  1
ddcot850 comparetotal  sNaN  NaN   ->  -1
ddcot851 comparetotal  sNaN sNaN   ->  0

ddcot852 comparetotal -sNaN sNaN   ->  -1
ddcot853 comparetotal -NaN  sNaN   ->  -1
ddcot854 comparetotal -Inf  sNaN   ->  -1
ddcot855 comparetotal -1000 sNaN   ->  -1
ddcot856 comparetotal -1    sNaN   ->  -1
ddcot857 comparetotal -0    sNaN   ->  -1
ddcot858 comparetotal  0    sNaN   ->  -1
ddcot859 comparetotal  1    sNaN   ->  -1
ddcot860 comparetotal  1000 sNaN   ->  -1
ddcot861 comparetotal  Inf  sNaN   ->  -1
ddcot862 comparetotal  NaN  sNaN   ->  1
ddcot863 comparetotal  sNaN sNaN   ->  0

ddcot871 comparetotal  -sNaN -sNaN  ->  0
ddcot872 comparetotal  -sNaN -NaN   ->  1
ddcot873 comparetotal  -sNaN -Inf   ->  -1
ddcot874 comparetotal  -sNaN -1000  ->  -1
ddcot875 comparetotal  -sNaN -1     ->  -1
ddcot876 comparetotal  -sNaN -0     ->  -1
ddcot877 comparetotal  -sNaN  0     ->  -1
ddcot878 comparetotal  -sNaN  1     ->  -1
ddcot879 comparetotal  -sNaN  1000  ->  -1
ddcot880 comparetotal  -sNaN  NaN   ->  -1
ddcot881 comparetotal  -sNaN sNaN   ->  -1

ddcot882 comparetotal -sNaN -sNaN   ->  0
ddcot883 comparetotal -NaN  -sNaN   ->  -1
ddcot884 comparetotal -Inf  -sNaN   ->  1
ddcot885 comparetotal -1000 -sNaN   ->  1
ddcot886 comparetotal -1    -sNaN   ->  1
ddcot887 comparetotal -0    -sNaN   ->  1
ddcot888 comparetotal  0    -sNaN   ->  1
ddcot889 comparetotal  1    -sNaN   ->  1
ddcot890 comparetotal  1000 -sNaN   ->  1
ddcot891 comparetotal  Inf  -sNaN   ->  1
ddcot892 comparetotal  NaN  -sNaN   ->  1
ddcot893 comparetotal  sNaN -sNaN   ->  1

-- NaNs with payload
ddcot960 comparetotal  NaN9 -Inf   ->  1
ddcot961 comparetotal  NaN8  999   ->  1
ddcot962 comparetotal  NaN77 Inf   ->  1
ddcot963 comparetotal -NaN67 NaN5  ->  -1
ddcot964 comparetotal -Inf  -NaN4  ->  1
ddcot965 comparetotal -999  -NaN33 ->  1
ddcot966 comparetotal  Inf   NaN2  ->  -1

ddcot970 comparetotal -NaN41 -NaN42 -> 1
ddcot971 comparetotal +NaN41 -NaN42 -> 1
ddcot972 comparetotal -NaN41 +NaN42 -> -1
ddcot973 comparetotal +NaN41 +NaN42 -> -1
ddcot974 comparetotal -NaN42 -NaN01 -> -1
ddcot975 comparetotal +NaN42 -NaN01 ->  1
ddcot976 comparetotal -NaN42 +NaN01 -> -1
ddcot977 comparetotal +NaN42 +NaN01 ->  1

ddcot980 comparetotal -sNaN771 -sNaN772 -> 1
ddcot981 comparetotal +sNaN771 -sNaN772 -> 1
ddcot982 comparetotal -sNaN771 +sNaN772 -> -1
ddcot983 comparetotal +sNaN771 +sNaN772 -> -1
ddcot984 comparetotal -sNaN772 -sNaN771 -> -1
ddcot985 comparetotal +sNaN772 -sNaN771 ->  1
ddcot986 comparetotal -sNaN772 +sNaN771 -> -1
ddcot987 comparetotal +sNaN772 +sNaN771 ->  1

ddcot991 comparetotal -sNaN99 -Inf    -> -1
ddcot992 comparetotal  sNaN98 -11     ->  1
ddcot993 comparetotal  sNaN97  NaN    -> -1
ddcot994 comparetotal  sNaN16 sNaN94  -> -1
ddcot995 comparetotal  NaN85  sNaN83  ->  1
ddcot996 comparetotal -Inf    sNaN92  -> -1
ddcot997 comparetotal  088    sNaN81  -> -1
ddcot998 comparetotal  Inf    sNaN90  -> -1
ddcot999 comparetotal  NaN   -sNaN89  ->  1

-- spread zeros
ddcot1110 comparetotal   0E-383  0       -> -1
ddcot1111 comparetotal   0E-383 -0       ->  1
ddcot1112 comparetotal  -0E-383  0       -> -1
ddcot1113 comparetotal  -0E-383 -0       ->  1
ddcot1114 comparetotal   0E-383  0E+384  -> -1
ddcot1115 comparetotal   0E-383 -0E+384  ->  1
ddcot1116 comparetotal  -0E-383  0E+384  -> -1
ddcot1117 comparetotal  -0E-383 -0E+384  ->  1
ddcot1118 comparetotal   0       0E+384  -> -1
ddcot1119 comparetotal   0      -0E+384  ->  1
ddcot1120 comparetotal  -0       0E+384  -> -1
ddcot1121 comparetotal  -0      -0E+384  ->  1

ddcot1130 comparetotal   0E+384  0       ->  1
ddcot1131 comparetotal   0E+384 -0       ->  1
ddcot1132 comparetotal  -0E+384  0       -> -1
ddcot1133 comparetotal  -0E+384 -0       -> -1
ddcot1134 comparetotal   0E+384  0E-383  ->  1
ddcot1135 comparetotal   0E+384 -0E-383  ->  1
ddcot1136 comparetotal  -0E+384  0E-383  -> -1
ddcot1137 comparetotal  -0E+384 -0E-383  -> -1
ddcot1138 comparetotal   0       0E-383  ->  1
ddcot1139 comparetotal   0      -0E-383  ->  1
ddcot1140 comparetotal  -0       0E-383  -> -1
ddcot1141 comparetotal  -0      -0E-383  -> -1

-- Null tests
ddcot9990 comparetotal 10  # -> NaN Invalid_operation
ddcot9991 comparetotal  # 10 -> NaN Invalid_operation

Added test/dectest/ddCompareTotalMag.decTest.





































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
------------------------------------------------------------------------
-- ddCompareTotalMag.decTest -- decDouble comparison; abs. total order--
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Note that we cannot assume add/subtract tests cover paths adequately,
-- here, because the code might be quite different (comparison cannot
-- overflow or underflow, so actual subtractions are not necessary).
-- Similarly, comparetotal will have some radically different paths
-- than compare.

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks
ddctm001 comparetotmag  -2  -2   ->   0
ddctm002 comparetotmag  -2  -1   ->   1
ddctm003 comparetotmag  -2   0   ->   1
ddctm004 comparetotmag  -2   1   ->   1
ddctm005 comparetotmag  -2   2   ->   0
ddctm006 comparetotmag  -1  -2   ->  -1
ddctm007 comparetotmag  -1  -1   ->   0
ddctm008 comparetotmag  -1   0   ->   1
ddctm009 comparetotmag  -1   1   ->   0
ddctm010 comparetotmag  -1   2   ->  -1
ddctm011 comparetotmag   0  -2   ->  -1
ddctm012 comparetotmag   0  -1   ->  -1
ddctm013 comparetotmag   0   0   ->   0
ddctm014 comparetotmag   0   1   ->  -1
ddctm015 comparetotmag   0   2   ->  -1
ddctm016 comparetotmag   1  -2   ->  -1
ddctm017 comparetotmag   1  -1   ->   0
ddctm018 comparetotmag   1   0   ->   1
ddctm019 comparetotmag   1   1   ->   0
ddctm020 comparetotmag   1   2   ->  -1
ddctm021 comparetotmag   2  -2   ->   0
ddctm022 comparetotmag   2  -1   ->   1
ddctm023 comparetotmag   2   0   ->   1
ddctm025 comparetotmag   2   1   ->   1
ddctm026 comparetotmag   2   2   ->   0

ddctm031 comparetotmag  -20  -20   ->   0
ddctm032 comparetotmag  -20  -10   ->   1
ddctm033 comparetotmag  -20   00   ->   1
ddctm034 comparetotmag  -20   10   ->   1
ddctm035 comparetotmag  -20   20   ->   0
ddctm036 comparetotmag  -10  -20   ->  -1
ddctm037 comparetotmag  -10  -10   ->   0
ddctm038 comparetotmag  -10   00   ->   1
ddctm039 comparetotmag  -10   10   ->   0
ddctm040 comparetotmag  -10   20   ->  -1
ddctm041 comparetotmag   00  -20   ->  -1
ddctm042 comparetotmag   00  -10   ->  -1
ddctm043 comparetotmag   00   00   ->   0
ddctm044 comparetotmag   00   10   ->  -1
ddctm045 comparetotmag   00   20   ->  -1
ddctm046 comparetotmag   10  -20   ->  -1
ddctm047 comparetotmag   10  -10   ->   0
ddctm048 comparetotmag   10   00   ->   1
ddctm049 comparetotmag   10   10   ->   0
ddctm050 comparetotmag   10   20   ->  -1
ddctm051 comparetotmag   20  -20   ->   0
ddctm052 comparetotmag   20  -10   ->   1
ddctm053 comparetotmag   20   00   ->   1
ddctm055 comparetotmag   20   10   ->   1
ddctm056 comparetotmag   20   20   ->   0

ddctm061 comparetotmag  -2.0  -2.0   ->   0
ddctm062 comparetotmag  -2.0  -1.0   ->   1
ddctm063 comparetotmag  -2.0   0.0   ->   1
ddctm064 comparetotmag  -2.0   1.0   ->   1
ddctm065 comparetotmag  -2.0   2.0   ->   0
ddctm066 comparetotmag  -1.0  -2.0   ->  -1
ddctm067 comparetotmag  -1.0  -1.0   ->   0
ddctm068 comparetotmag  -1.0   0.0   ->   1
ddctm069 comparetotmag  -1.0   1.0   ->   0
ddctm070 comparetotmag  -1.0   2.0   ->  -1
ddctm071 comparetotmag   0.0  -2.0   ->  -1
ddctm072 comparetotmag   0.0  -1.0   ->  -1
ddctm073 comparetotmag   0.0   0.0   ->   0
ddctm074 comparetotmag   0.0   1.0   ->  -1
ddctm075 comparetotmag   0.0   2.0   ->  -1
ddctm076 comparetotmag   1.0  -2.0   ->  -1
ddctm077 comparetotmag   1.0  -1.0   ->   0
ddctm078 comparetotmag   1.0   0.0   ->   1
ddctm079 comparetotmag   1.0   1.0   ->   0
ddctm080 comparetotmag   1.0   2.0   ->  -1
ddctm081 comparetotmag   2.0  -2.0   ->   0
ddctm082 comparetotmag   2.0  -1.0   ->   1
ddctm083 comparetotmag   2.0   0.0   ->   1
ddctm085 comparetotmag   2.0   1.0   ->   1
ddctm086 comparetotmag   2.0   2.0   ->   0

-- now some cases which might overflow if subtract were used
ddctm090 comparetotmag  9.99999999E+384 9.99999999E+384   ->   0
ddctm091 comparetotmag -9.99999999E+384 9.99999999E+384   ->   0
ddctm092 comparetotmag  9.99999999E+384 -9.99999999E+384  ->   0
ddctm093 comparetotmag -9.99999999E+384 -9.99999999E+384  ->   0

-- some differing length/exponent cases
-- in this first group, compare would compare all equal
ddctm100 comparetotmag   7.0    7.0     ->   0
ddctm101 comparetotmag   7.0    7       ->  -1
ddctm102 comparetotmag   7      7.0     ->   1
ddctm103 comparetotmag   7E+0   7.0     ->   1
ddctm104 comparetotmag   70E-1  7.0     ->   0
ddctm105 comparetotmag   0.7E+1 7       ->   0
ddctm106 comparetotmag   70E-1  7       ->  -1
ddctm107 comparetotmag   7.0    7E+0    ->  -1
ddctm108 comparetotmag   7.0    70E-1   ->   0
ddctm109 comparetotmag   7      0.7E+1  ->   0
ddctm110 comparetotmag   7      70E-1   ->   1

ddctm120 comparetotmag   8.0    7.0     ->   1
ddctm121 comparetotmag   8.0    7       ->   1
ddctm122 comparetotmag   8      7.0     ->   1
ddctm123 comparetotmag   8E+0   7.0     ->   1
ddctm124 comparetotmag   80E-1  7.0     ->   1
ddctm125 comparetotmag   0.8E+1 7       ->   1
ddctm126 comparetotmag   80E-1  7       ->   1
ddctm127 comparetotmag   8.0    7E+0    ->   1
ddctm128 comparetotmag   8.0    70E-1   ->   1
ddctm129 comparetotmag   8      0.7E+1   ->   1
ddctm130 comparetotmag   8      70E-1   ->   1

ddctm140 comparetotmag   8.0    9.0     ->  -1
ddctm141 comparetotmag   8.0    9       ->  -1
ddctm142 comparetotmag   8      9.0     ->  -1
ddctm143 comparetotmag   8E+0   9.0     ->  -1
ddctm144 comparetotmag   80E-1  9.0     ->  -1
ddctm145 comparetotmag   0.8E+1 9       ->  -1
ddctm146 comparetotmag   80E-1  9       ->  -1
ddctm147 comparetotmag   8.0    9E+0    ->  -1
ddctm148 comparetotmag   8.0    90E-1   ->  -1
ddctm149 comparetotmag   8      0.9E+1  ->  -1
ddctm150 comparetotmag   8      90E-1   ->  -1

-- and again, with sign changes -+ ..
ddctm200 comparetotmag  -7.0    7.0     ->   0
ddctm201 comparetotmag  -7.0    7       ->  -1
ddctm202 comparetotmag  -7      7.0     ->   1
ddctm203 comparetotmag  -7E+0   7.0     ->   1
ddctm204 comparetotmag  -70E-1  7.0     ->   0
ddctm205 comparetotmag  -0.7E+1 7       ->   0
ddctm206 comparetotmag  -70E-1  7       ->  -1
ddctm207 comparetotmag  -7.0    7E+0    ->  -1
ddctm208 comparetotmag  -7.0    70E-1   ->   0
ddctm209 comparetotmag  -7      0.7E+1  ->   0
ddctm210 comparetotmag  -7      70E-1   ->   1

ddctm220 comparetotmag  -8.0    7.0     ->   1
ddctm221 comparetotmag  -8.0    7       ->   1
ddctm222 comparetotmag  -8      7.0     ->   1
ddctm223 comparetotmag  -8E+0   7.0     ->   1
ddctm224 comparetotmag  -80E-1  7.0     ->   1
ddctm225 comparetotmag  -0.8E+1 7       ->   1
ddctm226 comparetotmag  -80E-1  7       ->   1
ddctm227 comparetotmag  -8.0    7E+0    ->   1
ddctm228 comparetotmag  -8.0    70E-1   ->   1
ddctm229 comparetotmag  -8      0.7E+1  ->   1
ddctm230 comparetotmag  -8      70E-1   ->   1

ddctm240 comparetotmag  -8.0    9.0     ->  -1
ddctm241 comparetotmag  -8.0    9       ->  -1
ddctm242 comparetotmag  -8      9.0     ->  -1
ddctm243 comparetotmag  -8E+0   9.0     ->  -1
ddctm244 comparetotmag  -80E-1  9.0     ->  -1
ddctm245 comparetotmag  -0.8E+1 9       ->  -1
ddctm246 comparetotmag  -80E-1  9       ->  -1
ddctm247 comparetotmag  -8.0    9E+0    ->  -1
ddctm248 comparetotmag  -8.0    90E-1   ->  -1
ddctm249 comparetotmag  -8      0.9E+1  ->  -1
ddctm250 comparetotmag  -8      90E-1   ->  -1

-- and again, with sign changes +- ..
ddctm300 comparetotmag   7.0    -7.0     ->   0
ddctm301 comparetotmag   7.0    -7       ->  -1
ddctm302 comparetotmag   7      -7.0     ->   1
ddctm303 comparetotmag   7E+0   -7.0     ->   1
ddctm304 comparetotmag   70E-1  -7.0     ->   0
ddctm305 comparetotmag   .7E+1  -7       ->   0
ddctm306 comparetotmag   70E-1  -7       ->  -1
ddctm307 comparetotmag   7.0    -7E+0    ->  -1
ddctm308 comparetotmag   7.0    -70E-1   ->   0
ddctm309 comparetotmag   7      -.7E+1   ->   0
ddctm310 comparetotmag   7      -70E-1   ->   1

ddctm320 comparetotmag   8.0    -7.0     ->   1
ddctm321 comparetotmag   8.0    -7       ->   1
ddctm322 comparetotmag   8      -7.0     ->   1
ddctm323 comparetotmag   8E+0   -7.0     ->   1
ddctm324 comparetotmag   80E-1  -7.0     ->   1
ddctm325 comparetotmag   .8E+1  -7       ->   1
ddctm326 comparetotmag   80E-1  -7       ->   1
ddctm327 comparetotmag   8.0    -7E+0    ->   1
ddctm328 comparetotmag   8.0    -70E-1   ->   1
ddctm329 comparetotmag   8      -.7E+1   ->   1
ddctm330 comparetotmag   8      -70E-1   ->   1

ddctm340 comparetotmag   8.0    -9.0     ->  -1
ddctm341 comparetotmag   8.0    -9       ->  -1
ddctm342 comparetotmag   8      -9.0     ->  -1
ddctm343 comparetotmag   8E+0   -9.0     ->  -1
ddctm344 comparetotmag   80E-1  -9.0     ->  -1
ddctm345 comparetotmag   .8E+1  -9       ->  -1
ddctm346 comparetotmag   80E-1  -9       ->  -1
ddctm347 comparetotmag   8.0    -9E+0    ->  -1
ddctm348 comparetotmag   8.0    -90E-1   ->  -1
ddctm349 comparetotmag   8      -.9E+1   ->  -1
ddctm350 comparetotmag   8      -90E-1   ->  -1

-- and again, with sign changes -- ..
ddctm400 comparetotmag   -7.0    -7.0     ->   0
ddctm401 comparetotmag   -7.0    -7       ->  -1
ddctm402 comparetotmag   -7      -7.0     ->   1
ddctm403 comparetotmag   -7E+0   -7.0     ->   1
ddctm404 comparetotmag   -70E-1  -7.0     ->   0
ddctm405 comparetotmag   -.7E+1  -7       ->   0
ddctm406 comparetotmag   -70E-1  -7       ->  -1
ddctm407 comparetotmag   -7.0    -7E+0    ->  -1
ddctm408 comparetotmag   -7.0    -70E-1   ->   0
ddctm409 comparetotmag   -7      -.7E+1   ->   0
ddctm410 comparetotmag   -7      -70E-1   ->   1

ddctm420 comparetotmag   -8.0    -7.0     ->   1
ddctm421 comparetotmag   -8.0    -7       ->   1
ddctm422 comparetotmag   -8      -7.0     ->   1
ddctm423 comparetotmag   -8E+0   -7.0     ->   1
ddctm424 comparetotmag   -80E-1  -7.0     ->   1
ddctm425 comparetotmag   -.8E+1  -7       ->   1
ddctm426 comparetotmag   -80E-1  -7       ->   1
ddctm427 comparetotmag   -8.0    -7E+0    ->   1
ddctm428 comparetotmag   -8.0    -70E-1   ->   1
ddctm429 comparetotmag   -8      -.7E+1   ->   1
ddctm430 comparetotmag   -8      -70E-1   ->   1

ddctm440 comparetotmag   -8.0    -9.0     ->  -1
ddctm441 comparetotmag   -8.0    -9       ->  -1
ddctm442 comparetotmag   -8      -9.0     ->  -1
ddctm443 comparetotmag   -8E+0   -9.0     ->  -1
ddctm444 comparetotmag   -80E-1  -9.0     ->  -1
ddctm445 comparetotmag   -.8E+1  -9       ->  -1
ddctm446 comparetotmag   -80E-1  -9       ->  -1
ddctm447 comparetotmag   -8.0    -9E+0    ->  -1
ddctm448 comparetotmag   -8.0    -90E-1   ->  -1
ddctm449 comparetotmag   -8      -.9E+1   ->  -1
ddctm450 comparetotmag   -8      -90E-1   ->  -1


-- testcases that subtract to lots of zeros at boundaries [pgr]
ddctm473 comparetotmag 123.4560000000000E-89 123.456E-89  ->  -1
ddctm474 comparetotmag 123.456000000000E+89 123.456E+89  ->  -1
ddctm475 comparetotmag 123.45600000000E-89 123.456E-89  ->  -1
ddctm476 comparetotmag 123.4560000000E+89 123.456E+89  ->  -1
ddctm477 comparetotmag 123.456000000E-89 123.456E-89  ->  -1
ddctm478 comparetotmag 123.45600000E+89 123.456E+89  ->  -1
ddctm479 comparetotmag 123.4560000E-89 123.456E-89  ->  -1
ddctm480 comparetotmag 123.456000E+89 123.456E+89  ->  -1
ddctm481 comparetotmag 123.45600E-89 123.456E-89  ->  -1
ddctm482 comparetotmag 123.4560E+89 123.456E+89  ->  -1
ddctm483 comparetotmag 123.456E-89 123.456E-89  ->   0
ddctm487 comparetotmag 123.456E+89 123.4560000000000E+89  ->   1
ddctm488 comparetotmag 123.456E-89 123.456000000000E-89  ->   1
ddctm489 comparetotmag 123.456E+89 123.45600000000E+89  ->   1
ddctm490 comparetotmag 123.456E-89 123.4560000000E-89  ->   1
ddctm491 comparetotmag 123.456E+89 123.456000000E+89  ->   1
ddctm492 comparetotmag 123.456E-89 123.45600000E-89  ->   1
ddctm493 comparetotmag 123.456E+89 123.4560000E+89  ->   1
ddctm494 comparetotmag 123.456E-89 123.456000E-89  ->   1
ddctm495 comparetotmag 123.456E+89 123.45600E+89  ->   1
ddctm496 comparetotmag 123.456E-89 123.4560E-89  ->   1
ddctm497 comparetotmag 123.456E+89 123.456E+89  ->   0

-- wide-ranging, around precision; signs equal
ddctm498 comparetotmag    1     1E-17     ->   1
ddctm499 comparetotmag    1     1E-16     ->   1
ddctm500 comparetotmag    1     1E-15     ->   1
ddctm501 comparetotmag    1     1E-14     ->   1
ddctm502 comparetotmag    1     1E-13     ->   1
ddctm503 comparetotmag    1     1E-12     ->   1
ddctm504 comparetotmag    1     1E-11     ->   1
ddctm505 comparetotmag    1     1E-10     ->   1
ddctm506 comparetotmag    1     1E-9      ->   1
ddctm507 comparetotmag    1     1E-8      ->   1
ddctm508 comparetotmag    1     1E-7      ->   1
ddctm509 comparetotmag    1     1E-6      ->   1
ddctm510 comparetotmag    1     1E-5      ->   1
ddctm511 comparetotmag    1     1E-4      ->   1
ddctm512 comparetotmag    1     1E-3      ->   1
ddctm513 comparetotmag    1     1E-2      ->   1
ddctm514 comparetotmag    1     1E-1      ->   1
ddctm515 comparetotmag    1     1E-0      ->   0
ddctm516 comparetotmag    1     1E+1      ->  -1
ddctm517 comparetotmag    1     1E+2      ->  -1
ddctm518 comparetotmag    1     1E+3      ->  -1
ddctm519 comparetotmag    1     1E+4      ->  -1
ddctm521 comparetotmag    1     1E+5      ->  -1
ddctm522 comparetotmag    1     1E+6      ->  -1
ddctm523 comparetotmag    1     1E+7      ->  -1
ddctm524 comparetotmag    1     1E+8      ->  -1
ddctm525 comparetotmag    1     1E+9      ->  -1
ddctm526 comparetotmag    1     1E+10     ->  -1
ddctm527 comparetotmag    1     1E+11     ->  -1
ddctm528 comparetotmag    1     1E+12     ->  -1
ddctm529 comparetotmag    1     1E+13     ->  -1
ddctm530 comparetotmag    1     1E+14     ->  -1
ddctm531 comparetotmag    1     1E+15     ->  -1
ddctm532 comparetotmag    1     1E+16     ->  -1
ddctm533 comparetotmag    1     1E+17     ->  -1
-- LR swap
ddctm538 comparetotmag    1E-17  1        ->  -1
ddctm539 comparetotmag    1E-16  1        ->  -1
ddctm540 comparetotmag    1E-15  1        ->  -1
ddctm541 comparetotmag    1E-14  1        ->  -1
ddctm542 comparetotmag    1E-13  1        ->  -1
ddctm543 comparetotmag    1E-12  1        ->  -1
ddctm544 comparetotmag    1E-11  1        ->  -1
ddctm545 comparetotmag    1E-10  1        ->  -1
ddctm546 comparetotmag    1E-9   1        ->  -1
ddctm547 comparetotmag    1E-8   1        ->  -1
ddctm548 comparetotmag    1E-7   1        ->  -1
ddctm549 comparetotmag    1E-6   1        ->  -1
ddctm550 comparetotmag    1E-5   1        ->  -1
ddctm551 comparetotmag    1E-4   1        ->  -1
ddctm552 comparetotmag    1E-3   1        ->  -1
ddctm553 comparetotmag    1E-2   1        ->  -1
ddctm554 comparetotmag    1E-1   1        ->  -1
ddctm555 comparetotmag    1E-0   1        ->   0
ddctm556 comparetotmag    1E+1   1        ->   1
ddctm557 comparetotmag    1E+2   1        ->   1
ddctm558 comparetotmag    1E+3   1        ->   1
ddctm559 comparetotmag    1E+4   1        ->   1
ddctm561 comparetotmag    1E+5   1        ->   1
ddctm562 comparetotmag    1E+6   1        ->   1
ddctm563 comparetotmag    1E+7   1        ->   1
ddctm564 comparetotmag    1E+8   1        ->   1
ddctm565 comparetotmag    1E+9   1        ->   1
ddctm566 comparetotmag    1E+10  1        ->   1
ddctm567 comparetotmag    1E+11  1        ->   1
ddctm568 comparetotmag    1E+12  1        ->   1
ddctm569 comparetotmag    1E+13  1        ->   1
ddctm570 comparetotmag    1E+14  1        ->   1
ddctm571 comparetotmag    1E+15  1        ->   1
ddctm572 comparetotmag    1E+16  1        ->   1
ddctm573 comparetotmag    1E+17  1        ->   1
-- similar with a useful coefficient, one side only
ddctm578 comparetotmag  0.000000987654321     1E-17     ->   1
ddctm579 comparetotmag  0.000000987654321     1E-16     ->   1
ddctm580 comparetotmag  0.000000987654321     1E-15     ->   1
ddctm581 comparetotmag  0.000000987654321     1E-14     ->   1
ddctm582 comparetotmag  0.000000987654321     1E-13     ->   1
ddctm583 comparetotmag  0.000000987654321     1E-12     ->   1
ddctm584 comparetotmag  0.000000987654321     1E-11     ->   1
ddctm585 comparetotmag  0.000000987654321     1E-10     ->   1
ddctm586 comparetotmag  0.000000987654321     1E-9      ->   1
ddctm587 comparetotmag  0.000000987654321     1E-8      ->   1
ddctm588 comparetotmag  0.000000987654321     1E-7      ->   1
ddctm589 comparetotmag  0.000000987654321     1E-6      ->  -1
ddctm590 comparetotmag  0.000000987654321     1E-5      ->  -1
ddctm591 comparetotmag  0.000000987654321     1E-4      ->  -1
ddctm592 comparetotmag  0.000000987654321     1E-3      ->  -1
ddctm593 comparetotmag  0.000000987654321     1E-2      ->  -1
ddctm594 comparetotmag  0.000000987654321     1E-1      ->  -1
ddctm595 comparetotmag  0.000000987654321     1E-0      ->  -1
ddctm596 comparetotmag  0.000000987654321     1E+1      ->  -1
ddctm597 comparetotmag  0.000000987654321     1E+2      ->  -1
ddctm598 comparetotmag  0.000000987654321     1E+3      ->  -1
ddctm599 comparetotmag  0.000000987654321     1E+4      ->  -1

-- check some unit-y traps
ddctm600 comparetotmag   12            12.2345  ->  -1
ddctm601 comparetotmag   12.0          12.2345  ->  -1
ddctm602 comparetotmag   12.00         12.2345  ->  -1
ddctm603 comparetotmag   12.000        12.2345  ->  -1
ddctm604 comparetotmag   12.0000       12.2345  ->  -1
ddctm605 comparetotmag   12.00000      12.2345  ->  -1
ddctm606 comparetotmag   12.000000     12.2345  ->  -1
ddctm607 comparetotmag   12.0000000    12.2345  ->  -1
ddctm608 comparetotmag   12.00000000   12.2345  ->  -1
ddctm609 comparetotmag   12.000000000  12.2345  ->  -1
ddctm610 comparetotmag   12.1234 12             ->   1
ddctm611 comparetotmag   12.1234 12.0           ->   1
ddctm612 comparetotmag   12.1234 12.00          ->   1
ddctm613 comparetotmag   12.1234 12.000         ->   1
ddctm614 comparetotmag   12.1234 12.0000        ->   1
ddctm615 comparetotmag   12.1234 12.00000       ->   1
ddctm616 comparetotmag   12.1234 12.000000      ->   1
ddctm617 comparetotmag   12.1234 12.0000000     ->   1
ddctm618 comparetotmag   12.1234 12.00000000    ->   1
ddctm619 comparetotmag   12.1234 12.000000000   ->   1
ddctm620 comparetotmag  -12           -12.2345  ->  -1
ddctm621 comparetotmag  -12.0         -12.2345  ->  -1
ddctm622 comparetotmag  -12.00        -12.2345  ->  -1
ddctm623 comparetotmag  -12.000       -12.2345  ->  -1
ddctm624 comparetotmag  -12.0000      -12.2345  ->  -1
ddctm625 comparetotmag  -12.00000     -12.2345  ->  -1
ddctm626 comparetotmag  -12.000000    -12.2345  ->  -1
ddctm627 comparetotmag  -12.0000000   -12.2345  ->  -1
ddctm628 comparetotmag  -12.00000000  -12.2345  ->  -1
ddctm629 comparetotmag  -12.000000000 -12.2345  ->  -1
ddctm630 comparetotmag  -12.1234 -12            ->   1
ddctm631 comparetotmag  -12.1234 -12.0          ->   1
ddctm632 comparetotmag  -12.1234 -12.00         ->   1
ddctm633 comparetotmag  -12.1234 -12.000        ->   1
ddctm634 comparetotmag  -12.1234 -12.0000       ->   1
ddctm635 comparetotmag  -12.1234 -12.00000      ->   1
ddctm636 comparetotmag  -12.1234 -12.000000     ->   1
ddctm637 comparetotmag  -12.1234 -12.0000000    ->   1
ddctm638 comparetotmag  -12.1234 -12.00000000   ->   1
ddctm639 comparetotmag  -12.1234 -12.000000000  ->   1

-- extended zeros
ddctm640 comparetotmag   0     0    ->   0
ddctm641 comparetotmag   0    -0    ->   0
ddctm642 comparetotmag   0    -0.0  ->   1
ddctm643 comparetotmag   0     0.0  ->   1
ddctm644 comparetotmag  -0     0    ->   0
ddctm645 comparetotmag  -0    -0    ->   0
ddctm646 comparetotmag  -0    -0.0  ->   1
ddctm647 comparetotmag  -0     0.0  ->   1
ddctm648 comparetotmag   0.0   0    ->  -1
ddctm649 comparetotmag   0.0  -0    ->  -1
ddctm650 comparetotmag   0.0  -0.0  ->   0
ddctm651 comparetotmag   0.0   0.0  ->   0
ddctm652 comparetotmag  -0.0   0    ->  -1
ddctm653 comparetotmag  -0.0  -0    ->  -1
ddctm654 comparetotmag  -0.0  -0.0  ->   0
ddctm655 comparetotmag  -0.0   0.0  ->   0

ddctm656 comparetotmag  -0E1   0.0  ->   1
ddctm657 comparetotmag  -0E2   0.0  ->   1
ddctm658 comparetotmag   0E1   0.0  ->   1
ddctm659 comparetotmag   0E2   0.0  ->   1
ddctm660 comparetotmag  -0E1   0    ->   1
ddctm661 comparetotmag  -0E2   0    ->   1
ddctm662 comparetotmag   0E1   0    ->   1
ddctm663 comparetotmag   0E2   0    ->   1
ddctm664 comparetotmag  -0E1  -0E1  ->   0
ddctm665 comparetotmag  -0E2  -0E1  ->   1
ddctm666 comparetotmag   0E1  -0E1  ->   0
ddctm667 comparetotmag   0E2  -0E1  ->   1
ddctm668 comparetotmag  -0E1  -0E2  ->  -1
ddctm669 comparetotmag  -0E2  -0E2  ->   0
ddctm670 comparetotmag   0E1  -0E2  ->  -1
ddctm671 comparetotmag   0E2  -0E2  ->   0
ddctm672 comparetotmag  -0E1   0E1  ->   0
ddctm673 comparetotmag  -0E2   0E1  ->   1
ddctm674 comparetotmag   0E1   0E1  ->   0
ddctm675 comparetotmag   0E2   0E1  ->   1
ddctm676 comparetotmag  -0E1   0E2  ->  -1
ddctm677 comparetotmag  -0E2   0E2  ->   0
ddctm678 comparetotmag   0E1   0E2  ->  -1
ddctm679 comparetotmag   0E2   0E2  ->   0

-- trailing zeros; unit-y
ddctm680 comparetotmag   12    12            ->   0
ddctm681 comparetotmag   12    12.0          ->   1
ddctm682 comparetotmag   12    12.00         ->   1
ddctm683 comparetotmag   12    12.000        ->   1
ddctm684 comparetotmag   12    12.0000       ->   1
ddctm685 comparetotmag   12    12.00000      ->   1
ddctm686 comparetotmag   12    12.000000     ->   1
ddctm687 comparetotmag   12    12.0000000    ->   1
ddctm688 comparetotmag   12    12.00000000   ->   1
ddctm689 comparetotmag   12    12.000000000  ->   1
ddctm690 comparetotmag   12              12  ->   0
ddctm691 comparetotmag   12.0            12  ->  -1
ddctm692 comparetotmag   12.00           12  ->  -1
ddctm693 comparetotmag   12.000          12  ->  -1
ddctm694 comparetotmag   12.0000         12  ->  -1
ddctm695 comparetotmag   12.00000        12  ->  -1
ddctm696 comparetotmag   12.000000       12  ->  -1
ddctm697 comparetotmag   12.0000000      12  ->  -1
ddctm698 comparetotmag   12.00000000     12  ->  -1
ddctm699 comparetotmag   12.000000000    12  ->  -1

-- old long operand checks
ddctm701 comparetotmag 12345678000  1  ->   1
ddctm702 comparetotmag 1 12345678000   ->  -1
ddctm703 comparetotmag 1234567800   1  ->   1
ddctm704 comparetotmag 1 1234567800    ->  -1
ddctm705 comparetotmag 1234567890   1  ->   1
ddctm706 comparetotmag 1 1234567890    ->  -1
ddctm707 comparetotmag 1234567891   1  ->   1
ddctm708 comparetotmag 1 1234567891    ->  -1
ddctm709 comparetotmag 12345678901  1  ->   1
ddctm710 comparetotmag 1 12345678901   ->  -1
ddctm711 comparetotmag 1234567896   1  ->   1
ddctm712 comparetotmag 1 1234567896    ->  -1
ddctm713 comparetotmag -1234567891  1  ->   1
ddctm714 comparetotmag 1 -1234567891   ->  -1
ddctm715 comparetotmag -12345678901 1  ->   1
ddctm716 comparetotmag 1 -12345678901  ->  -1
ddctm717 comparetotmag -1234567896  1  ->   1
ddctm718 comparetotmag 1 -1234567896   ->  -1

-- old residue cases
ddctm740 comparetotmag  1  0.9999999   ->   1
ddctm741 comparetotmag  1  0.999999    ->   1
ddctm742 comparetotmag  1  0.99999     ->   1
ddctm743 comparetotmag  1  1.0000      ->   1
ddctm744 comparetotmag  1  1.00001     ->  -1
ddctm745 comparetotmag  1  1.000001    ->  -1
ddctm746 comparetotmag  1  1.0000001   ->  -1
ddctm750 comparetotmag  0.9999999  1   ->  -1
ddctm751 comparetotmag  0.999999   1   ->  -1
ddctm752 comparetotmag  0.99999    1   ->  -1
ddctm753 comparetotmag  1.0000     1   ->  -1
ddctm754 comparetotmag  1.00001    1   ->   1
ddctm755 comparetotmag  1.000001   1   ->   1
ddctm756 comparetotmag  1.0000001  1   ->   1

-- Specials
ddctm780 comparetotmag  Inf  -Inf   ->  0
ddctm781 comparetotmag  Inf  -1000  ->  1
ddctm782 comparetotmag  Inf  -1     ->  1
ddctm783 comparetotmag  Inf  -0     ->  1
ddctm784 comparetotmag  Inf   0     ->  1
ddctm785 comparetotmag  Inf   1     ->  1
ddctm786 comparetotmag  Inf   1000  ->  1
ddctm787 comparetotmag  Inf   Inf   ->  0
ddctm788 comparetotmag -1000  Inf   -> -1
ddctm789 comparetotmag -Inf   Inf   ->  0
ddctm790 comparetotmag -1     Inf   -> -1
ddctm791 comparetotmag -0     Inf   -> -1
ddctm792 comparetotmag  0     Inf   -> -1
ddctm793 comparetotmag  1     Inf   -> -1
ddctm794 comparetotmag  1000  Inf   -> -1
ddctm795 comparetotmag  Inf   Inf   ->  0

ddctm800 comparetotmag -Inf  -Inf   ->  0
ddctm801 comparetotmag -Inf  -1000  ->  1
ddctm802 comparetotmag -Inf  -1     ->  1
ddctm803 comparetotmag -Inf  -0     ->  1
ddctm804 comparetotmag -Inf   0     ->  1
ddctm805 comparetotmag -Inf   1     ->  1
ddctm806 comparetotmag -Inf   1000  ->  1
ddctm807 comparetotmag -Inf   Inf   ->  0
ddctm808 comparetotmag -Inf  -Inf   ->  0
ddctm809 comparetotmag -1000 -Inf   -> -1
ddctm810 comparetotmag -1    -Inf   -> -1
ddctm811 comparetotmag -0    -Inf   -> -1
ddctm812 comparetotmag  0    -Inf   -> -1
ddctm813 comparetotmag  1    -Inf   -> -1
ddctm814 comparetotmag  1000 -Inf   -> -1
ddctm815 comparetotmag  Inf  -Inf   ->  0

ddctm821 comparetotmag  NaN -Inf    ->  1
ddctm822 comparetotmag  NaN -1000   ->  1
ddctm823 comparetotmag  NaN -1      ->  1
ddctm824 comparetotmag  NaN -0      ->  1
ddctm825 comparetotmag  NaN  0      ->  1
ddctm826 comparetotmag  NaN  1      ->  1
ddctm827 comparetotmag  NaN  1000   ->  1
ddctm828 comparetotmag  NaN  Inf    ->  1
ddctm829 comparetotmag  NaN  NaN    ->  0
ddctm830 comparetotmag -Inf  NaN    ->  -1
ddctm831 comparetotmag -1000 NaN    ->  -1
ddctm832 comparetotmag -1    NaN    ->  -1
ddctm833 comparetotmag -0    NaN    ->  -1
ddctm834 comparetotmag  0    NaN    ->  -1
ddctm835 comparetotmag  1    NaN    ->  -1
ddctm836 comparetotmag  1000 NaN    ->  -1
ddctm837 comparetotmag  Inf  NaN    ->  -1
ddctm838 comparetotmag -NaN -NaN    ->  0
ddctm839 comparetotmag +NaN -NaN    ->  0
ddctm840 comparetotmag -NaN +NaN    ->  0

ddctm841 comparetotmag  sNaN -sNaN  ->  0
ddctm842 comparetotmag  sNaN -NaN   ->  -1
ddctm843 comparetotmag  sNaN -Inf   ->  1
ddctm844 comparetotmag  sNaN -1000  ->  1
ddctm845 comparetotmag  sNaN -1     ->  1
ddctm846 comparetotmag  sNaN -0     ->  1
ddctm847 comparetotmag  sNaN  0     ->  1
ddctm848 comparetotmag  sNaN  1     ->  1
ddctm849 comparetotmag  sNaN  1000  ->  1
ddctm850 comparetotmag  sNaN  NaN   ->  -1
ddctm851 comparetotmag  sNaN sNaN   ->  0

ddctm852 comparetotmag -sNaN sNaN   ->  0
ddctm853 comparetotmag -NaN  sNaN   ->  1
ddctm854 comparetotmag -Inf  sNaN   ->  -1
ddctm855 comparetotmag -1000 sNaN   ->  -1
ddctm856 comparetotmag -1    sNaN   ->  -1
ddctm857 comparetotmag -0    sNaN   ->  -1
ddctm858 comparetotmag  0    sNaN   ->  -1
ddctm859 comparetotmag  1    sNaN   ->  -1
ddctm860 comparetotmag  1000 sNaN   ->  -1
ddctm861 comparetotmag  Inf  sNaN   ->  -1
ddctm862 comparetotmag  NaN  sNaN   ->  1
ddctm863 comparetotmag  sNaN sNaN   ->  0

ddctm871 comparetotmag  -sNaN -sNaN  ->  0
ddctm872 comparetotmag  -sNaN -NaN   ->  -1
ddctm873 comparetotmag  -sNaN -Inf   ->  1
ddctm874 comparetotmag  -sNaN -1000  ->  1
ddctm875 comparetotmag  -sNaN -1     ->  1
ddctm876 comparetotmag  -sNaN -0     ->  1
ddctm877 comparetotmag  -sNaN  0     ->  1
ddctm878 comparetotmag  -sNaN  1     ->  1
ddctm879 comparetotmag  -sNaN  1000  ->  1
ddctm880 comparetotmag  -sNaN  NaN   ->  -1
ddctm881 comparetotmag  -sNaN sNaN   ->  0

ddctm882 comparetotmag -sNaN -sNaN   ->  0
ddctm883 comparetotmag -NaN  -sNaN   ->  1
ddctm884 comparetotmag -Inf  -sNaN   ->  -1
ddctm885 comparetotmag -1000 -sNaN   ->  -1
ddctm886 comparetotmag -1    -sNaN   ->  -1
ddctm887 comparetotmag -0    -sNaN   ->  -1
ddctm888 comparetotmag  0    -sNaN   ->  -1
ddctm889 comparetotmag  1    -sNaN   ->  -1
ddctm890 comparetotmag  1000 -sNaN   ->  -1
ddctm891 comparetotmag  Inf  -sNaN   ->  -1
ddctm892 comparetotmag  NaN  -sNaN   ->  1
ddctm893 comparetotmag  sNaN -sNaN   ->  0

-- NaNs with payload
ddctm960 comparetotmag  NaN9 -Inf   ->  1
ddctm961 comparetotmag  NaN8  999   ->  1
ddctm962 comparetotmag  NaN77 Inf   ->  1
ddctm963 comparetotmag -NaN67 NaN5  ->  1
ddctm964 comparetotmag -Inf  -NaN4  ->  -1
ddctm965 comparetotmag -999  -NaN33 ->  -1
ddctm966 comparetotmag  Inf   NaN2  ->  -1

ddctm970 comparetotmag -NaN41 -NaN42 -> -1
ddctm971 comparetotmag +NaN41 -NaN42 -> -1
ddctm972 comparetotmag -NaN41 +NaN42 -> -1
ddctm973 comparetotmag +NaN41 +NaN42 -> -1
ddctm974 comparetotmag -NaN42 -NaN01 ->  1
ddctm975 comparetotmag +NaN42 -NaN01 ->  1
ddctm976 comparetotmag -NaN42 +NaN01 ->  1
ddctm977 comparetotmag +NaN42 +NaN01 ->  1

ddctm980 comparetotmag -sNaN771 -sNaN772 -> -1
ddctm981 comparetotmag +sNaN771 -sNaN772 -> -1
ddctm982 comparetotmag -sNaN771 +sNaN772 -> -1
ddctm983 comparetotmag +sNaN771 +sNaN772 -> -1
ddctm984 comparetotmag -sNaN772 -sNaN771 ->  1
ddctm985 comparetotmag +sNaN772 -sNaN771 ->  1
ddctm986 comparetotmag -sNaN772 +sNaN771 ->  1
ddctm987 comparetotmag +sNaN772 +sNaN771 ->  1

ddctm991 comparetotmag -sNaN99 -Inf    ->  1
ddctm992 comparetotmag  sNaN98 -11     ->  1
ddctm993 comparetotmag  sNaN97  NaN    -> -1
ddctm994 comparetotmag  sNaN16 sNaN94  -> -1
ddctm995 comparetotmag  NaN85  sNaN83  ->  1
ddctm996 comparetotmag -Inf    sNaN92  -> -1
ddctm997 comparetotmag  088    sNaN81  -> -1
ddctm998 comparetotmag  Inf    sNaN90  -> -1
ddctm999 comparetotmag  NaN   -sNaN89  ->  1

-- spread zeros
ddctm1110 comparetotmag   0E-383  0        ->  -1
ddctm1111 comparetotmag   0E-383 -0        ->  -1
ddctm1112 comparetotmag  -0E-383  0        ->  -1
ddctm1113 comparetotmag  -0E-383 -0        ->  -1
ddctm1114 comparetotmag   0E-383  0E+384   ->  -1
ddctm1115 comparetotmag   0E-383 -0E+384   ->  -1
ddctm1116 comparetotmag  -0E-383  0E+384   ->  -1
ddctm1117 comparetotmag  -0E-383 -0E+384   ->  -1
ddctm1118 comparetotmag   0       0E+384   ->  -1
ddctm1119 comparetotmag   0      -0E+384   ->  -1
ddctm1120 comparetotmag  -0       0E+384   ->  -1
ddctm1121 comparetotmag  -0      -0E+384   ->  -1

ddctm1130 comparetotmag   0E+384  0        ->   1
ddctm1131 comparetotmag   0E+384 -0        ->   1
ddctm1132 comparetotmag  -0E+384  0        ->   1
ddctm1133 comparetotmag  -0E+384 -0        ->   1
ddctm1134 comparetotmag   0E+384  0E-383   ->   1
ddctm1135 comparetotmag   0E+384 -0E-383   ->   1
ddctm1136 comparetotmag  -0E+384  0E-383   ->   1
ddctm1137 comparetotmag  -0E+384 -0E-383   ->   1
ddctm1138 comparetotmag   0       0E-383   ->   1
ddctm1139 comparetotmag   0      -0E-383   ->   1
ddctm1140 comparetotmag  -0       0E-383   ->   1
ddctm1141 comparetotmag  -0      -0E-383   ->   1

-- Null tests
ddctm9990 comparetotmag 10  # -> NaN Invalid_operation
ddctm9991 comparetotmag  # 10 -> NaN Invalid_operation

Added test/dectest/ddCopy.decTest.

















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
------------------------------------------------------------------------
-- ddCopy.decTest -- quiet decDouble copy                             --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check
ddcpy001 copy       +7.50  -> 7.50

-- Infinities
ddcpy011 copy  Infinity    -> Infinity
ddcpy012 copy  -Infinity   -> -Infinity

-- NaNs, 0 payload
ddcpy021 copy         NaN  -> NaN
ddcpy022 copy        -NaN  -> -NaN
ddcpy023 copy        sNaN  -> sNaN
ddcpy024 copy       -sNaN  -> -sNaN

-- NaNs, non-0 payload
ddcpy031 copy       NaN10  -> NaN10
ddcpy032 copy      -NaN10  -> -NaN10
ddcpy033 copy      sNaN10  -> sNaN10
ddcpy034 copy     -sNaN10  -> -sNaN10
ddcpy035 copy       NaN7   -> NaN7
ddcpy036 copy      -NaN7   -> -NaN7
ddcpy037 copy      sNaN101 -> sNaN101
ddcpy038 copy     -sNaN101 -> -sNaN101

-- finites
ddcpy101 copy          7   -> 7
ddcpy102 copy         -7   -> -7
ddcpy103 copy         75   -> 75
ddcpy104 copy        -75   -> -75
ddcpy105 copy       7.50   -> 7.50
ddcpy106 copy      -7.50   -> -7.50
ddcpy107 copy       7.500  -> 7.500
ddcpy108 copy      -7.500  -> -7.500

-- zeros
ddcpy111 copy          0   -> 0
ddcpy112 copy         -0   -> -0
ddcpy113 copy       0E+4   -> 0E+4
ddcpy114 copy      -0E+4   -> -0E+4
ddcpy115 copy     0.0000   -> 0.0000
ddcpy116 copy    -0.0000   -> -0.0000
ddcpy117 copy      0E-141  -> 0E-141
ddcpy118 copy     -0E-141  -> -0E-141

-- full coefficients, alternating bits
ddcpy121 copy  2682682682682682         -> 2682682682682682
ddcpy122 copy  -2682682682682682        -> -2682682682682682
ddcpy123 copy  1341341341341341         -> 1341341341341341
ddcpy124 copy  -1341341341341341        -> -1341341341341341

-- Nmax, Nmin, Ntiny
ddcpy131 copy  9.999999999999999E+384   -> 9.999999999999999E+384
ddcpy132 copy  1E-383                   -> 1E-383
ddcpy133 copy  1.000000000000000E-383   -> 1.000000000000000E-383
ddcpy134 copy  1E-398                   -> 1E-398

ddcpy135 copy  -1E-398                  -> -1E-398
ddcpy136 copy  -1.000000000000000E-383  -> -1.000000000000000E-383
ddcpy137 copy  -1E-383                  -> -1E-383
ddcpy138 copy  -9.999999999999999E+384  -> -9.999999999999999E+384

Added test/dectest/ddCopyAbs.decTest.

















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
------------------------------------------------------------------------
-- ddCopyAbs.decTest -- quiet decDouble copy and set sign to zero     --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check
ddcpa001 copyabs       +7.50  -> 7.50

-- Infinities
ddcpa011 copyabs  Infinity    -> Infinity
ddcpa012 copyabs  -Infinity   -> Infinity

-- NaNs, 0 payload
ddcpa021 copyabs         NaN  -> NaN
ddcpa022 copyabs        -NaN  -> NaN
ddcpa023 copyabs        sNaN  -> sNaN
ddcpa024 copyabs       -sNaN  -> sNaN

-- NaNs, non-0 payload
ddcpa031 copyabs       NaN10  -> NaN10
ddcpa032 copyabs      -NaN15  -> NaN15
ddcpa033 copyabs      sNaN15  -> sNaN15
ddcpa034 copyabs     -sNaN10  -> sNaN10
ddcpa035 copyabs       NaN7   -> NaN7
ddcpa036 copyabs      -NaN7   -> NaN7
ddcpa037 copyabs      sNaN101 -> sNaN101
ddcpa038 copyabs     -sNaN101 -> sNaN101

-- finites
ddcpa101 copyabs          7   -> 7
ddcpa102 copyabs         -7   -> 7
ddcpa103 copyabs         75   -> 75
ddcpa104 copyabs        -75   -> 75
ddcpa105 copyabs       7.10   -> 7.10
ddcpa106 copyabs      -7.10   -> 7.10
ddcpa107 copyabs       7.500  -> 7.500
ddcpa108 copyabs      -7.500  -> 7.500

-- zeros
ddcpa111 copyabs          0   -> 0
ddcpa112 copyabs         -0   -> 0
ddcpa113 copyabs       0E+6   -> 0E+6
ddcpa114 copyabs      -0E+6   -> 0E+6
ddcpa115 copyabs     0.0000   -> 0.0000
ddcpa116 copyabs    -0.0000   -> 0.0000
ddcpa117 copyabs      0E-141  -> 0E-141
ddcpa118 copyabs     -0E-141  -> 0E-141

-- full coefficients, alternating bits
ddcpa121 copyabs  2682682682682682         -> 2682682682682682
ddcpa122 copyabs  -2682682682682682        -> 2682682682682682
ddcpa123 copyabs  1341341341341341         -> 1341341341341341
ddcpa124 copyabs  -1341341341341341        -> 1341341341341341

-- Nmax, Nmin, Ntiny
ddcpa131 copyabs  9.999999999999999E+384   -> 9.999999999999999E+384
ddcpa132 copyabs  1E-383                   -> 1E-383
ddcpa133 copyabs  1.000000000000000E-383   -> 1.000000000000000E-383
ddcpa134 copyabs  1E-398                   -> 1E-398

ddcpa135 copyabs  -1E-398                  -> 1E-398
ddcpa136 copyabs  -1.000000000000000E-383  -> 1.000000000000000E-383
ddcpa137 copyabs  -1E-383                  -> 1E-383
ddcpa138 copyabs  -9.999999999999999E+384  -> 9.999999999999999E+384

Added test/dectest/ddCopyNegate.decTest.

















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
------------------------------------------------------------------------
-- ddCopyNegate.decTest -- quiet decDouble copy and negate            --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check
ddcpn001 copynegate       +7.50  -> -7.50

-- Infinities
ddcpn011 copynegate  Infinity    -> -Infinity
ddcpn012 copynegate  -Infinity   -> Infinity

-- NaNs, 0 payload
ddcpn021 copynegate         NaN  -> -NaN
ddcpn022 copynegate        -NaN  -> NaN
ddcpn023 copynegate        sNaN  -> -sNaN
ddcpn024 copynegate       -sNaN  -> sNaN

-- NaNs, non-0 payload
ddcpn031 copynegate       NaN13  -> -NaN13
ddcpn032 copynegate      -NaN13  -> NaN13
ddcpn033 copynegate      sNaN13  -> -sNaN13
ddcpn034 copynegate     -sNaN13  -> sNaN13
ddcpn035 copynegate       NaN70  -> -NaN70
ddcpn036 copynegate      -NaN70  -> NaN70
ddcpn037 copynegate      sNaN101 -> -sNaN101
ddcpn038 copynegate     -sNaN101 -> sNaN101

-- finites
ddcpn101 copynegate          7   -> -7
ddcpn102 copynegate         -7   -> 7
ddcpn103 copynegate         75   -> -75
ddcpn104 copynegate        -75   -> 75
ddcpn105 copynegate       7.50   -> -7.50
ddcpn106 copynegate      -7.50   -> 7.50
ddcpn107 copynegate       7.500  -> -7.500
ddcpn108 copynegate      -7.500  -> 7.500

-- zeros
ddcpn111 copynegate          0   -> -0
ddcpn112 copynegate         -0   -> 0
ddcpn113 copynegate       0E+4   -> -0E+4
ddcpn114 copynegate      -0E+4   -> 0E+4
ddcpn115 copynegate     0.0000   -> -0.0000
ddcpn116 copynegate    -0.0000   -> 0.0000
ddcpn117 copynegate      0E-141  -> -0E-141
ddcpn118 copynegate     -0E-141  -> 0E-141

-- full coefficients, alternating bits
ddcpn121 copynegate  2682682682682682         -> -2682682682682682
ddcpn122 copynegate  -2682682682682682        -> 2682682682682682
ddcpn123 copynegate  1341341341341341         -> -1341341341341341
ddcpn124 copynegate  -1341341341341341        -> 1341341341341341

-- Nmax, Nmin, Ntiny
ddcpn131 copynegate  9.999999999999999E+384   -> -9.999999999999999E+384
ddcpn132 copynegate  1E-383                   -> -1E-383
ddcpn133 copynegate  1.000000000000000E-383   -> -1.000000000000000E-383
ddcpn134 copynegate  1E-398                   -> -1E-398

ddcpn135 copynegate  -1E-398                  -> 1E-398
ddcpn136 copynegate  -1.000000000000000E-383  -> 1.000000000000000E-383
ddcpn137 copynegate  -1E-383                  -> 1E-383
ddcpn138 copynegate  -9.999999999999999E+384  -> 9.999999999999999E+384

Added test/dectest/ddCopySign.decTest.































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
------------------------------------------------------------------------
-- ddCopySign.decTest -- quiet decDouble copy with sign from rhs      --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check
ddcps001 copysign       +7.50     11 -> 7.50

-- Infinities
ddcps011 copysign  Infinity       11 -> Infinity
ddcps012 copysign  -Infinity      11 -> Infinity

-- NaNs, 0 payload
ddcps021 copysign         NaN     11 -> NaN
ddcps022 copysign        -NaN     11 -> NaN
ddcps023 copysign        sNaN     11 -> sNaN
ddcps024 copysign       -sNaN     11 -> sNaN

-- NaNs, non-0 payload
ddcps031 copysign       NaN10     11 -> NaN10
ddcps032 copysign      -NaN10     11 -> NaN10
ddcps033 copysign      sNaN10     11 -> sNaN10
ddcps034 copysign     -sNaN10     11 -> sNaN10
ddcps035 copysign       NaN7      11 -> NaN7
ddcps036 copysign      -NaN7      11 -> NaN7
ddcps037 copysign      sNaN101    11 -> sNaN101
ddcps038 copysign     -sNaN101    11 -> sNaN101

-- finites
ddcps101 copysign          7      11 -> 7
ddcps102 copysign         -7      11 -> 7
ddcps103 copysign         75      11 -> 75
ddcps104 copysign        -75      11 -> 75
ddcps105 copysign       7.50      11 -> 7.50
ddcps106 copysign      -7.50      11 -> 7.50
ddcps107 copysign       7.500     11 -> 7.500
ddcps108 copysign      -7.500     11 -> 7.500

-- zeros
ddcps111 copysign          0      11 -> 0
ddcps112 copysign         -0      11 -> 0
ddcps113 copysign       0E+4      11 -> 0E+4
ddcps114 copysign      -0E+4      11 -> 0E+4
ddcps115 copysign     0.0000      11 -> 0.0000
ddcps116 copysign    -0.0000      11 -> 0.0000
ddcps117 copysign      0E-141     11 -> 0E-141
ddcps118 copysign     -0E-141     11 -> 0E-141

-- full coefficients, alternating bits
ddcps121 copysign  2682682682682682            11 -> 2682682682682682
ddcps122 copysign  -2682682682682682           11 -> 2682682682682682
ddcps123 copysign  1341341341341341            11 -> 1341341341341341
ddcps124 copysign  -1341341341341341           11 -> 1341341341341341

-- Nmax, Nmin, Ntiny
ddcps131 copysign  9.999999999999999E+384      11 -> 9.999999999999999E+384
ddcps132 copysign  1E-383                      11 -> 1E-383
ddcps133 copysign  1.000000000000000E-383      11 -> 1.000000000000000E-383
ddcps134 copysign  1E-398                      11 -> 1E-398

ddcps135 copysign  -1E-398                     11 -> 1E-398
ddcps136 copysign  -1.000000000000000E-383     11 -> 1.000000000000000E-383
ddcps137 copysign  -1E-383                     11 -> 1E-383
ddcps138 copysign  -9.999999999999999E+384     11 -> 9.999999999999999E+384

-- repeat with negative RHS

-- Infinities
ddcps211 copysign  Infinity       -34 -> -Infinity
ddcps212 copysign  -Infinity      -34 -> -Infinity

-- NaNs, 0 payload
ddcps221 copysign         NaN     -34 -> -NaN
ddcps222 copysign        -NaN     -34 -> -NaN
ddcps223 copysign        sNaN     -34 -> -sNaN
ddcps224 copysign       -sNaN     -34 -> -sNaN

-- NaNs, non-0 payload
ddcps231 copysign       NaN10     -34 -> -NaN10
ddcps232 copysign      -NaN10     -34 -> -NaN10
ddcps233 copysign      sNaN10     -34 -> -sNaN10
ddcps234 copysign     -sNaN10     -34 -> -sNaN10
ddcps235 copysign       NaN7      -34 -> -NaN7
ddcps236 copysign      -NaN7      -34 -> -NaN7
ddcps237 copysign      sNaN101    -34 -> -sNaN101
ddcps238 copysign     -sNaN101    -34 -> -sNaN101

-- finites
ddcps301 copysign          7      -34 -> -7
ddcps302 copysign         -7      -34 -> -7
ddcps303 copysign         75      -34 -> -75
ddcps304 copysign        -75      -34 -> -75
ddcps305 copysign       7.50      -34 -> -7.50
ddcps306 copysign      -7.50      -34 -> -7.50
ddcps307 copysign       7.500     -34 -> -7.500
ddcps308 copysign      -7.500     -34 -> -7.500

-- zeros
ddcps311 copysign          0      -34 -> -0
ddcps312 copysign         -0      -34 -> -0
ddcps313 copysign       0E+4      -34 -> -0E+4
ddcps314 copysign      -0E+4      -34 -> -0E+4
ddcps315 copysign     0.0000      -34 -> -0.0000
ddcps316 copysign    -0.0000      -34 -> -0.0000
ddcps317 copysign      0E-141     -34 -> -0E-141
ddcps318 copysign     -0E-141     -34 -> -0E-141

-- full coefficients, alternating bits
ddcps321 copysign  2682682682682682            -34 -> -2682682682682682
ddcps322 copysign  -2682682682682682           -34 -> -2682682682682682
ddcps323 copysign  1341341341341341            -34 -> -1341341341341341
ddcps324 copysign  -1341341341341341           -34 -> -1341341341341341

-- Nmax, Nmin, Ntiny
ddcps331 copysign  9.999999999999999E+384      -34 -> -9.999999999999999E+384
ddcps332 copysign  1E-383                      -34 -> -1E-383
ddcps333 copysign  1.000000000000000E-383      -34 -> -1.000000000000000E-383
ddcps334 copysign  1E-398                      -34 -> -1E-398

ddcps335 copysign  -1E-398                     -34 -> -1E-398
ddcps336 copysign  -1.000000000000000E-383     -34 -> -1.000000000000000E-383
ddcps337 copysign  -1E-383                     -34 -> -1E-383
ddcps338 copysign  -9.999999999999999E+384     -34 -> -9.999999999999999E+384

-- Other kinds of RHS
ddcps401 copysign          701    -34 -> -701
ddcps402 copysign         -720    -34 -> -720
ddcps403 copysign          701    -0  -> -701
ddcps404 copysign         -720    -0  -> -720
ddcps405 copysign          701    +0  ->  701
ddcps406 copysign         -720    +0  ->  720
ddcps407 copysign          701    +34 ->  701
ddcps408 copysign         -720    +34 ->  720

ddcps413 copysign          701    -Inf  -> -701
ddcps414 copysign         -720    -Inf  -> -720
ddcps415 copysign          701    +Inf  ->  701
ddcps416 copysign         -720    +Inf  ->  720

ddcps420 copysign          701    -NaN  -> -701
ddcps421 copysign         -720    -NaN  -> -720
ddcps422 copysign          701    +NaN  ->  701
ddcps423 copysign         -720    +NaN  ->  720
ddcps425 copysign         -720    +NaN8 ->  720

ddcps426 copysign          701    -sNaN  -> -701
ddcps427 copysign         -720    -sNaN  -> -720
ddcps428 copysign          701    +sNaN  ->  701
ddcps429 copysign         -720    +sNaN  ->  720
ddcps430 copysign         -720    +sNaN3 ->  720

Added test/dectest/ddDivide.decTest.



































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
------------------------------------------------------------------------
-- ddDivide.decTest -- decDouble division                             --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks
dddiv001 divide  1     1    ->  1
dddiv002 divide  2     1    ->  2
dddiv003 divide  1     2    ->  0.5
dddiv004 divide  2     2    ->  1
dddiv005 divide  0     1    ->  0
dddiv006 divide  0     2    ->  0
dddiv007 divide  1     3    ->  0.3333333333333333 Inexact Rounded
dddiv008 divide  2     3    ->  0.6666666666666667 Inexact Rounded
dddiv009 divide  3     3    ->  1

dddiv010 divide  2.4   1    ->  2.4
dddiv011 divide  2.4   -1   ->  -2.4
dddiv012 divide  -2.4  1    ->  -2.4
dddiv013 divide  -2.4  -1   ->  2.4
dddiv014 divide  2.40  1    ->  2.40
dddiv015 divide  2.400 1    ->  2.400
dddiv016 divide  2.4   2    ->  1.2
dddiv017 divide  2.400 2    ->  1.200
dddiv018 divide  2.    2    ->  1
dddiv019 divide  20    20   ->  1

dddiv020 divide  187   187    ->  1
dddiv021 divide  5     2      ->  2.5
dddiv022 divide  50    20     ->  2.5
dddiv023 divide  500   200    ->  2.5
dddiv024 divide  50.0  20.0   ->  2.5
dddiv025 divide  5.00  2.00   ->  2.5
dddiv026 divide  5     2.0    ->  2.5
dddiv027 divide  5     2.000  ->  2.5
dddiv028 divide  5     0.20   ->  25
dddiv029 divide  5     0.200  ->  25
dddiv030 divide  10    1      ->  10
dddiv031 divide  100   1      ->  100
dddiv032 divide  1000  1      ->  1000
dddiv033 divide  1000  100    ->  10

dddiv035 divide  1     2      ->  0.5
dddiv036 divide  1     4      ->  0.25
dddiv037 divide  1     8      ->  0.125
dddiv038 divide  1     16     ->  0.0625
dddiv039 divide  1     32     ->  0.03125
dddiv040 divide  1     64     ->  0.015625
dddiv041 divide  1    -2      ->  -0.5
dddiv042 divide  1    -4      ->  -0.25
dddiv043 divide  1    -8      ->  -0.125
dddiv044 divide  1    -16     ->  -0.0625
dddiv045 divide  1    -32     ->  -0.03125
dddiv046 divide  1    -64     ->  -0.015625
dddiv047 divide -1     2      ->  -0.5
dddiv048 divide -1     4      ->  -0.25
dddiv049 divide -1     8      ->  -0.125
dddiv050 divide -1     16     ->  -0.0625
dddiv051 divide -1     32     ->  -0.03125
dddiv052 divide -1     64     ->  -0.015625
dddiv053 divide -1    -2      ->  0.5
dddiv054 divide -1    -4      ->  0.25
dddiv055 divide -1    -8      ->  0.125
dddiv056 divide -1    -16     ->  0.0625
dddiv057 divide -1    -32     ->  0.03125
dddiv058 divide -1    -64     ->  0.015625

-- bcdTime
dddiv060 divide  1 7                   -> 0.1428571428571429 Inexact Rounded
dddiv061 divide 1.2345678  1.9876543   -> 0.6211179680490717 Inexact Rounded

--               1234567890123456
dddiv071 divide  9999999999999999 1  ->  9999999999999999
dddiv072 divide  999999999999999  1  ->  999999999999999
dddiv073 divide  99999999999999   1  ->  99999999999999
dddiv074 divide  9999999999999    1  ->  9999999999999
dddiv075 divide  999999999999     1  ->  999999999999
dddiv076 divide  99999999999      1  ->  99999999999
dddiv077 divide  9999999999       1  ->  9999999999
dddiv078 divide  999999999        1  ->  999999999
dddiv079 divide  99999999         1  ->  99999999
dddiv080 divide  9999999          1  ->  9999999
dddiv081 divide  999999           1  ->  999999
dddiv082 divide  99999            1  ->  99999
dddiv083 divide  9999             1  ->  9999
dddiv084 divide  999              1  ->  999
dddiv085 divide  99               1  ->  99
dddiv086 divide  9                1  ->  9

dddiv090 divide  0.            1    ->  0
dddiv091 divide  .0            1    ->  0.0
dddiv092 divide  0.00          1    ->  0.00
dddiv093 divide  0.00E+9       1    ->  0E+7
dddiv094 divide  0.0000E-50    1    ->  0E-54

dddiv095 divide  1            1E-8  ->  1E+8
dddiv096 divide  1            1E-9  ->  1E+9
dddiv097 divide  1            1E-10 ->  1E+10
dddiv098 divide  1            1E-11 ->  1E+11
dddiv099 divide  1            1E-12 ->  1E+12

dddiv100 divide  1  1   -> 1
dddiv101 divide  1  2   -> 0.5
dddiv102 divide  1  3   -> 0.3333333333333333 Inexact Rounded
dddiv103 divide  1  4   -> 0.25
dddiv104 divide  1  5   -> 0.2
dddiv105 divide  1  6   -> 0.1666666666666667 Inexact Rounded
dddiv106 divide  1  7   -> 0.1428571428571429 Inexact Rounded
dddiv107 divide  1  8   -> 0.125
dddiv108 divide  1  9   -> 0.1111111111111111 Inexact Rounded
dddiv109 divide  1  10  -> 0.1
dddiv110 divide  1  1   -> 1
dddiv111 divide  2  1   -> 2
dddiv112 divide  3  1   -> 3
dddiv113 divide  4  1   -> 4
dddiv114 divide  5  1   -> 5
dddiv115 divide  6  1   -> 6
dddiv116 divide  7  1   -> 7
dddiv117 divide  8  1   -> 8
dddiv118 divide  9  1   -> 9
dddiv119 divide  10 1   -> 10

dddiv120 divide  3E+1 0.001  -> 3E+4
dddiv121 divide  2.200 2     -> 1.100

dddiv130 divide  12345  4.999  ->  2469.493898779756    Inexact Rounded
dddiv131 divide  12345  4.99   ->  2473.947895791583    Inexact Rounded
dddiv132 divide  12345  4.9    ->  2519.387755102041    Inexact Rounded
dddiv133 divide  12345  5      ->  2469
dddiv134 divide  12345  5.1    ->  2420.588235294118    Inexact Rounded
dddiv135 divide  12345  5.01   ->  2464.071856287425    Inexact Rounded
dddiv136 divide  12345  5.001  ->  2468.506298740252    Inexact Rounded

-- test possibly imprecise results
dddiv220 divide 391   597 ->  0.6549413735343384  Inexact Rounded
dddiv221 divide 391  -597 -> -0.6549413735343384  Inexact Rounded
dddiv222 divide -391  597 -> -0.6549413735343384  Inexact Rounded
dddiv223 divide -391 -597 ->  0.6549413735343384  Inexact Rounded

-- test some cases that are close to exponent overflow
dddiv270 divide 1 1e384                  -> 1E-384                 Subnormal
dddiv271 divide 1 0.9e384                -> 1.11111111111111E-384  Rounded Inexact Subnormal Underflow
dddiv272 divide 1 0.99e384               -> 1.01010101010101E-384  Rounded Inexact Subnormal Underflow
dddiv273 divide 1 0.9999999999999999e384 -> 1.00000000000000E-384  Rounded Inexact Subnormal Underflow
dddiv274 divide 9e384    1               -> 9.000000000000000E+384 Clamped
dddiv275 divide 9.9e384  1               -> 9.900000000000000E+384 Clamped
dddiv276 divide 9.99e384 1               -> 9.990000000000000E+384 Clamped
dddiv277 divide 9.999999999999999e384 1  -> 9.999999999999999E+384

-- Divide into 0 tests
dddiv301 divide    0    7     -> 0
dddiv302 divide    0    7E-5  -> 0E+5
dddiv303 divide    0    7E-1  -> 0E+1
dddiv304 divide    0    7E+1  -> 0.0
dddiv305 divide    0    7E+5  -> 0.00000
dddiv306 divide    0    7E+6  -> 0.000000
dddiv307 divide    0    7E+7  -> 0E-7
dddiv308 divide    0   70E-5  -> 0E+5
dddiv309 divide    0   70E-1  -> 0E+1
dddiv310 divide    0   70E+0  -> 0
dddiv311 divide    0   70E+1  -> 0.0
dddiv312 divide    0   70E+5  -> 0.00000
dddiv313 divide    0   70E+6  -> 0.000000
dddiv314 divide    0   70E+7  -> 0E-7
dddiv315 divide    0  700E-5  -> 0E+5
dddiv316 divide    0  700E-1  -> 0E+1
dddiv317 divide    0  700E+0  -> 0
dddiv318 divide    0  700E+1  -> 0.0
dddiv319 divide    0  700E+5  -> 0.00000
dddiv320 divide    0  700E+6  -> 0.000000
dddiv321 divide    0  700E+7  -> 0E-7
dddiv322 divide    0  700E+77 -> 0E-77

dddiv331 divide 0E-3    7E-5  -> 0E+2
dddiv332 divide 0E-3    7E-1  -> 0.00
dddiv333 divide 0E-3    7E+1  -> 0.0000
dddiv334 divide 0E-3    7E+5  -> 0E-8
dddiv335 divide 0E-1    7E-5  -> 0E+4
dddiv336 divide 0E-1    7E-1  -> 0
dddiv337 divide 0E-1    7E+1  -> 0.00
dddiv338 divide 0E-1    7E+5  -> 0.000000
dddiv339 divide 0E+1    7E-5  -> 0E+6
dddiv340 divide 0E+1    7E-1  -> 0E+2
dddiv341 divide 0E+1    7E+1  -> 0
dddiv342 divide 0E+1    7E+5  -> 0.0000
dddiv343 divide 0E+3    7E-5  -> 0E+8
dddiv344 divide 0E+3    7E-1  -> 0E+4
dddiv345 divide 0E+3    7E+1  -> 0E+2
dddiv346 divide 0E+3    7E+5  -> 0.00

-- These were 'input rounding'
dddiv441 divide 12345678000 1 -> 12345678000
dddiv442 divide 1 12345678000 -> 8.100000664200054E-11 Inexact Rounded
dddiv443 divide 1234567800  1 -> 1234567800
dddiv444 divide 1 1234567800  -> 8.100000664200054E-10 Inexact Rounded
dddiv445 divide 1234567890  1 -> 1234567890
dddiv446 divide 1 1234567890  -> 8.100000073710001E-10 Inexact Rounded
dddiv447 divide 1234567891  1 -> 1234567891
dddiv448 divide 1 1234567891  -> 8.100000067149001E-10 Inexact Rounded
dddiv449 divide 12345678901 1 -> 12345678901
dddiv450 divide 1 12345678901 -> 8.100000073053901E-11 Inexact Rounded
dddiv451 divide 1234567896  1 -> 1234567896
dddiv452 divide 1 1234567896  -> 8.100000034344000E-10 Inexact Rounded

-- high-lows
dddiv453 divide 1e+1   1    ->   1E+1
dddiv454 divide 1e+1   1.0  ->   1E+1
dddiv455 divide 1e+1   1.00 ->   1E+1
dddiv456 divide 1e+2   2    ->   5E+1
dddiv457 divide 1e+2   2.0  ->   5E+1
dddiv458 divide 1e+2   2.00 ->   5E+1

-- some from IEEE discussions
dddiv460 divide 3e0      2e0     -> 1.5
dddiv461 divide 30e-1    2e0     -> 1.5
dddiv462 divide 300e-2   2e0     -> 1.50
dddiv464 divide 3000e-3  2e0     -> 1.500
dddiv465 divide 3e0      20e-1   -> 1.5
dddiv466 divide 30e-1    20e-1   -> 1.5
dddiv467 divide 300e-2   20e-1   -> 1.5
dddiv468 divide 3000e-3  20e-1   -> 1.50
dddiv469 divide 3e0      200e-2  -> 1.5
dddiv470 divide 30e-1    200e-2  -> 1.5
dddiv471 divide 300e-2   200e-2  -> 1.5
dddiv472 divide 3000e-3  200e-2  -> 1.5
dddiv473 divide 3e0      2000e-3 -> 1.5
dddiv474 divide 30e-1    2000e-3 -> 1.5
dddiv475 divide 300e-2   2000e-3 -> 1.5
dddiv476 divide 3000e-3  2000e-3 -> 1.5

-- some reciprocals
dddiv480 divide 1        1.0E+33 -> 1E-33
dddiv481 divide 1        10E+33  -> 1E-34
dddiv482 divide 1        1.0E-33 -> 1E+33
dddiv483 divide 1        10E-33  -> 1E+32

-- RMS discussion table
dddiv484 divide 0e5     1e3 ->   0E+2
dddiv485 divide 0e5     2e3 ->   0E+2
dddiv486 divide 0e5    10e2 ->   0E+3
dddiv487 divide 0e5    20e2 ->   0E+3
dddiv488 divide 0e5   100e1 ->   0E+4
dddiv489 divide 0e5   200e1 ->   0E+4

dddiv491 divide 1e5     1e3 ->   1E+2
dddiv492 divide 1e5     2e3 ->   5E+1
dddiv493 divide 1e5    10e2 ->   1E+2
dddiv494 divide 1e5    20e2 ->   5E+1
dddiv495 divide 1e5   100e1 ->   1E+2
dddiv496 divide 1e5   200e1 ->   5E+1

-- tryzeros cases
rounding:    half_up
dddiv497  divide  0E+380 1000E-13  -> 0E+369 Clamped
dddiv498  divide  0E-390 1000E+13  -> 0E-398 Clamped

rounding:    half_up

-- focus on trailing zeros issues
dddiv500 divide  1      9.9    ->  0.1010101010101010  Inexact Rounded
dddiv501 divide  1      9.09   ->  0.1100110011001100  Inexact Rounded
dddiv502 divide  1      9.009  ->  0.1110001110001110  Inexact Rounded

dddiv511 divide 1         2    -> 0.5
dddiv512 divide 1.0       2    -> 0.5
dddiv513 divide 1.00      2    -> 0.50
dddiv514 divide 1.000     2    -> 0.500
dddiv515 divide 1.0000    2    -> 0.5000
dddiv516 divide 1.00000   2    -> 0.50000
dddiv517 divide 1.000000  2    -> 0.500000
dddiv518 divide 1.0000000 2    -> 0.5000000
dddiv519 divide 1.00      2.00 -> 0.5

dddiv521 divide 2    1         -> 2
dddiv522 divide 2    1.0       -> 2
dddiv523 divide 2    1.00      -> 2
dddiv524 divide 2    1.000     -> 2
dddiv525 divide 2    1.0000    -> 2
dddiv526 divide 2    1.00000   -> 2
dddiv527 divide 2    1.000000  -> 2
dddiv528 divide 2    1.0000000 -> 2
dddiv529 divide 2.00 1.00      -> 2

dddiv530 divide  2.40   2      ->  1.20
dddiv531 divide  2.40   4      ->  0.60
dddiv532 divide  2.40  10      ->  0.24
dddiv533 divide  2.40   2.0    ->  1.2
dddiv534 divide  2.40   4.0    ->  0.6
dddiv535 divide  2.40  10.0    ->  0.24
dddiv536 divide  2.40   2.00   ->  1.2
dddiv537 divide  2.40   4.00   ->  0.6
dddiv538 divide  2.40  10.00   ->  0.24
dddiv539 divide  0.9    0.1    ->  9
dddiv540 divide  0.9    0.01   ->  9E+1
dddiv541 divide  0.9    0.001  ->  9E+2
dddiv542 divide  5      2      ->  2.5
dddiv543 divide  5      2.0    ->  2.5
dddiv544 divide  5      2.00   ->  2.5
dddiv545 divide  5      20     ->  0.25
dddiv546 divide  5      20.0   ->  0.25
dddiv547 divide  2.400  2      ->  1.200
dddiv548 divide  2.400  2.0    ->  1.20
dddiv549 divide  2.400  2.400  ->  1

dddiv550 divide  240    1      ->  240
dddiv551 divide  240    10     ->  24
dddiv552 divide  240    100    ->  2.4
dddiv553 divide  240    1000   ->  0.24
dddiv554 divide  2400   1      ->  2400
dddiv555 divide  2400   10     ->  240
dddiv556 divide  2400   100    ->  24
dddiv557 divide  2400   1000   ->  2.4

-- +ve exponent
dddiv600 divide  2.4E+9     2  ->  1.2E+9
dddiv601 divide  2.40E+9    2  ->  1.20E+9
dddiv602 divide  2.400E+9   2  ->  1.200E+9
dddiv603 divide  2.4000E+9  2  ->  1.2000E+9
dddiv604 divide  24E+8      2  ->  1.2E+9
dddiv605 divide  240E+7     2  ->  1.20E+9
dddiv606 divide  2400E+6    2  ->  1.200E+9
dddiv607 divide  24000E+5   2  ->  1.2000E+9

-- more zeros, etc.
dddiv731 divide 5.00 1E-3    -> 5.00E+3
dddiv732 divide 00.00 0.000  -> NaN Division_undefined
dddiv733 divide 00.00 0E-3   -> NaN Division_undefined
dddiv734 divide  0    -0     -> NaN Division_undefined
dddiv735 divide -0     0     -> NaN Division_undefined
dddiv736 divide -0    -0     -> NaN Division_undefined

dddiv741 divide  0    -1     -> -0
dddiv742 divide -0    -1     ->  0
dddiv743 divide  0     1     ->  0
dddiv744 divide -0     1     -> -0
dddiv745 divide -1     0     -> -Infinity Division_by_zero
dddiv746 divide -1    -0     ->  Infinity Division_by_zero
dddiv747 divide  1     0     ->  Infinity Division_by_zero
dddiv748 divide  1    -0     -> -Infinity Division_by_zero

dddiv751 divide  0.0  -1     -> -0.0
dddiv752 divide -0.0  -1     ->  0.0
dddiv753 divide  0.0   1     ->  0.0
dddiv754 divide -0.0   1     -> -0.0
dddiv755 divide -1.0   0     -> -Infinity Division_by_zero
dddiv756 divide -1.0  -0     ->  Infinity Division_by_zero
dddiv757 divide  1.0   0     ->  Infinity Division_by_zero
dddiv758 divide  1.0  -0     -> -Infinity Division_by_zero

dddiv761 divide  0    -1.0   -> -0E+1
dddiv762 divide -0    -1.0   ->  0E+1
dddiv763 divide  0     1.0   ->  0E+1
dddiv764 divide -0     1.0   -> -0E+1
dddiv765 divide -1     0.0   -> -Infinity Division_by_zero
dddiv766 divide -1    -0.0   ->  Infinity Division_by_zero
dddiv767 divide  1     0.0   ->  Infinity Division_by_zero
dddiv768 divide  1    -0.0   -> -Infinity Division_by_zero

dddiv771 divide  0.0  -1.0   -> -0
dddiv772 divide -0.0  -1.0   ->  0
dddiv773 divide  0.0   1.0   ->  0
dddiv774 divide -0.0   1.0   -> -0
dddiv775 divide -1.0   0.0   -> -Infinity Division_by_zero
dddiv776 divide -1.0  -0.0   ->  Infinity Division_by_zero
dddiv777 divide  1.0   0.0   ->  Infinity Division_by_zero
dddiv778 divide  1.0  -0.0   -> -Infinity Division_by_zero

-- Specials
dddiv780 divide  Inf  -Inf   ->  NaN Invalid_operation
dddiv781 divide  Inf  -1000  -> -Infinity
dddiv782 divide  Inf  -1     -> -Infinity
dddiv783 divide  Inf  -0     -> -Infinity
dddiv784 divide  Inf   0     ->  Infinity
dddiv785 divide  Inf   1     ->  Infinity
dddiv786 divide  Inf   1000  ->  Infinity
dddiv787 divide  Inf   Inf   ->  NaN Invalid_operation
dddiv788 divide -1000  Inf   -> -0E-398 Clamped
dddiv789 divide -Inf   Inf   ->  NaN Invalid_operation
dddiv790 divide -1     Inf   -> -0E-398 Clamped
dddiv791 divide -0     Inf   -> -0E-398 Clamped
dddiv792 divide  0     Inf   ->  0E-398 Clamped
dddiv793 divide  1     Inf   ->  0E-398 Clamped
dddiv794 divide  1000  Inf   ->  0E-398 Clamped
dddiv795 divide  Inf   Inf   ->  NaN Invalid_operation

dddiv800 divide -Inf  -Inf   ->  NaN Invalid_operation
dddiv801 divide -Inf  -1000  ->  Infinity
dddiv802 divide -Inf  -1     ->  Infinity
dddiv803 divide -Inf  -0     ->  Infinity
dddiv804 divide -Inf   0     -> -Infinity
dddiv805 divide -Inf   1     -> -Infinity
dddiv806 divide -Inf   1000  -> -Infinity
dddiv807 divide -Inf   Inf   ->  NaN Invalid_operation
dddiv808 divide -1000  Inf   -> -0E-398 Clamped
dddiv809 divide -Inf  -Inf   ->  NaN Invalid_operation
dddiv810 divide -1    -Inf   ->  0E-398 Clamped
dddiv811 divide -0    -Inf   ->  0E-398 Clamped
dddiv812 divide  0    -Inf   -> -0E-398 Clamped
dddiv813 divide  1    -Inf   -> -0E-398 Clamped
dddiv814 divide  1000 -Inf   -> -0E-398 Clamped
dddiv815 divide  Inf  -Inf   ->  NaN Invalid_operation

dddiv821 divide  NaN -Inf    ->  NaN
dddiv822 divide  NaN -1000   ->  NaN
dddiv823 divide  NaN -1      ->  NaN
dddiv824 divide  NaN -0      ->  NaN
dddiv825 divide  NaN  0      ->  NaN
dddiv826 divide  NaN  1      ->  NaN
dddiv827 divide  NaN  1000   ->  NaN
dddiv828 divide  NaN  Inf    ->  NaN
dddiv829 divide  NaN  NaN    ->  NaN
dddiv830 divide -Inf  NaN    ->  NaN
dddiv831 divide -1000 NaN    ->  NaN
dddiv832 divide -1    NaN    ->  NaN
dddiv833 divide -0    NaN    ->  NaN
dddiv834 divide  0    NaN    ->  NaN
dddiv835 divide  1    NaN    ->  NaN
dddiv836 divide  1000 NaN    ->  NaN
dddiv837 divide  Inf  NaN    ->  NaN

dddiv841 divide  sNaN -Inf   ->  NaN  Invalid_operation
dddiv842 divide  sNaN -1000  ->  NaN  Invalid_operation
dddiv843 divide  sNaN -1     ->  NaN  Invalid_operation
dddiv844 divide  sNaN -0     ->  NaN  Invalid_operation
dddiv845 divide  sNaN  0     ->  NaN  Invalid_operation
dddiv846 divide  sNaN  1     ->  NaN  Invalid_operation
dddiv847 divide  sNaN  1000  ->  NaN  Invalid_operation
dddiv848 divide  sNaN  NaN   ->  NaN  Invalid_operation
dddiv849 divide  sNaN sNaN   ->  NaN  Invalid_operation
dddiv850 divide  NaN  sNaN   ->  NaN  Invalid_operation
dddiv851 divide -Inf  sNaN   ->  NaN  Invalid_operation
dddiv852 divide -1000 sNaN   ->  NaN  Invalid_operation
dddiv853 divide -1    sNaN   ->  NaN  Invalid_operation
dddiv854 divide -0    sNaN   ->  NaN  Invalid_operation
dddiv855 divide  0    sNaN   ->  NaN  Invalid_operation
dddiv856 divide  1    sNaN   ->  NaN  Invalid_operation
dddiv857 divide  1000 sNaN   ->  NaN  Invalid_operation
dddiv858 divide  Inf  sNaN   ->  NaN  Invalid_operation
dddiv859 divide  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dddiv861 divide  NaN9 -Inf   ->  NaN9
dddiv862 divide  NaN8  1000  ->  NaN8
dddiv863 divide  NaN7  Inf   ->  NaN7
dddiv864 divide  NaN6  NaN5  ->  NaN6
dddiv865 divide -Inf   NaN4  ->  NaN4
dddiv866 divide -1000  NaN3  ->  NaN3
dddiv867 divide  Inf   NaN2  ->  NaN2

dddiv871 divide  sNaN99 -Inf    ->  NaN99 Invalid_operation
dddiv872 divide  sNaN98 -1      ->  NaN98 Invalid_operation
dddiv873 divide  sNaN97  NaN    ->  NaN97 Invalid_operation
dddiv874 divide  sNaN96 sNaN94  ->  NaN96 Invalid_operation
dddiv875 divide  NaN95  sNaN93  ->  NaN93 Invalid_operation
dddiv876 divide -Inf    sNaN92  ->  NaN92 Invalid_operation
dddiv877 divide  0      sNaN91  ->  NaN91 Invalid_operation
dddiv878 divide  Inf    sNaN90  ->  NaN90 Invalid_operation
dddiv879 divide  NaN    sNaN89  ->  NaN89 Invalid_operation

dddiv881 divide  -NaN9  -Inf   ->  -NaN9
dddiv882 divide  -NaN8   1000  ->  -NaN8
dddiv883 divide  -NaN7   Inf   ->  -NaN7
dddiv884 divide  -NaN6  -NaN5  ->  -NaN6
dddiv885 divide  -Inf   -NaN4  ->  -NaN4
dddiv886 divide  -1000  -NaN3  ->  -NaN3
dddiv887 divide   Inf   -NaN2  ->  -NaN2

dddiv891 divide -sNaN99 -Inf    -> -NaN99 Invalid_operation
dddiv892 divide -sNaN98 -1      -> -NaN98 Invalid_operation
dddiv893 divide -sNaN97  NaN    -> -NaN97 Invalid_operation
dddiv894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation
dddiv895 divide -NaN95  -sNaN93 -> -NaN93 Invalid_operation
dddiv896 divide -Inf    -sNaN92 -> -NaN92 Invalid_operation
dddiv897 divide  0      -sNaN91 -> -NaN91 Invalid_operation
dddiv898 divide  Inf    -sNaN90 -> -NaN90 Invalid_operation
dddiv899 divide -NaN    -sNaN89 -> -NaN89 Invalid_operation

-- Various flavours of divide by 0
dddiv901 divide    0       0   ->  NaN Division_undefined
dddiv902 divide    0.0E5   0   ->  NaN Division_undefined
dddiv903 divide    0.000   0   ->  NaN Division_undefined
dddiv904 divide    0.0001  0   ->  Infinity Division_by_zero
dddiv905 divide    0.01    0   ->  Infinity Division_by_zero
dddiv906 divide    0.1     0   ->  Infinity Division_by_zero
dddiv907 divide    1       0   ->  Infinity Division_by_zero
dddiv908 divide    1       0.0 ->  Infinity Division_by_zero
dddiv909 divide   10       0.0 ->  Infinity Division_by_zero
dddiv910 divide   1E+100   0.0 ->  Infinity Division_by_zero
dddiv911 divide   1E+100   0   ->  Infinity Division_by_zero

dddiv921 divide   -0.0001  0   -> -Infinity Division_by_zero
dddiv922 divide   -0.01    0   -> -Infinity Division_by_zero
dddiv923 divide   -0.1     0   -> -Infinity Division_by_zero
dddiv924 divide   -1       0   -> -Infinity Division_by_zero
dddiv925 divide   -1       0.0 -> -Infinity Division_by_zero
dddiv926 divide  -10       0.0 -> -Infinity Division_by_zero
dddiv927 divide  -1E+100   0.0 -> -Infinity Division_by_zero
dddiv928 divide  -1E+100   0   -> -Infinity Division_by_zero

dddiv931 divide    0.0001 -0   -> -Infinity Division_by_zero
dddiv932 divide    0.01   -0   -> -Infinity Division_by_zero
dddiv933 divide    0.1    -0   -> -Infinity Division_by_zero
dddiv934 divide    1      -0   -> -Infinity Division_by_zero
dddiv935 divide    1      -0.0 -> -Infinity Division_by_zero
dddiv936 divide   10      -0.0 -> -Infinity Division_by_zero
dddiv937 divide   1E+100  -0.0 -> -Infinity Division_by_zero
dddiv938 divide   1E+100  -0   -> -Infinity Division_by_zero

dddiv941 divide   -0.0001 -0   ->  Infinity Division_by_zero
dddiv942 divide   -0.01   -0   ->  Infinity Division_by_zero
dddiv943 divide   -0.1    -0   ->  Infinity Division_by_zero
dddiv944 divide   -1      -0   ->  Infinity Division_by_zero
dddiv945 divide   -1      -0.0 ->  Infinity Division_by_zero
dddiv946 divide  -10      -0.0 ->  Infinity Division_by_zero
dddiv947 divide  -1E+100  -0.0 ->  Infinity Division_by_zero
dddiv948 divide  -1E+100  -0   ->  Infinity Division_by_zero

-- Examples from SQL proposal (Krishna Kulkarni)
dddiv1021  divide 1E0          1E0 -> 1
dddiv1022  divide 1E0          2E0 -> 0.5
dddiv1023  divide 1E0          3E0 -> 0.3333333333333333 Inexact Rounded
dddiv1024  divide 100E-2   1000E-3 -> 1
dddiv1025  divide 24E-1        2E0 -> 1.2
dddiv1026  divide 2400E-3      2E0 -> 1.200
dddiv1027  divide 5E0          2E0 -> 2.5
dddiv1028  divide 5E0        20E-1 -> 2.5
dddiv1029  divide 5E0      2000E-3 -> 2.5
dddiv1030  divide 5E0         2E-1 -> 25
dddiv1031  divide 5E0        20E-2 -> 25
dddiv1032  divide 480E-2       3E0 -> 1.60
dddiv1033  divide 47E-1        2E0 -> 2.35

-- ECMAScript bad examples
rounding:    half_down
dddiv1040  divide 5 9  -> 0.5555555555555556 Inexact Rounded
rounding:    half_even
dddiv1041  divide 6 11 -> 0.5454545454545455 Inexact Rounded

-- overflow and underflow tests .. note subnormal results
-- signs
dddiv1051 divide  1e+277  1e-311 ->  Infinity Overflow Inexact Rounded
dddiv1052 divide  1e+277 -1e-311 -> -Infinity Overflow Inexact Rounded
dddiv1053 divide -1e+277  1e-311 -> -Infinity Overflow Inexact Rounded
dddiv1054 divide -1e+277 -1e-311 ->  Infinity Overflow Inexact Rounded
dddiv1055 divide  1e-277  1e+311 ->  0E-398 Underflow Subnormal Inexact Rounded Clamped
dddiv1056 divide  1e-277 -1e+311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
dddiv1057 divide -1e-277  1e+311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
dddiv1058 divide -1e-277 -1e+311 ->  0E-398 Underflow Subnormal Inexact Rounded Clamped

-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
dddiv1060 divide 1e-291 1e+101 -> 1E-392 Subnormal
dddiv1061 divide 1e-291 1e+102 -> 1E-393 Subnormal
dddiv1062 divide 1e-291 1e+103 -> 1E-394 Subnormal
dddiv1063 divide 1e-291 1e+104 -> 1E-395 Subnormal
dddiv1064 divide 1e-291 1e+105 -> 1E-396 Subnormal
dddiv1065 divide 1e-291 1e+106 -> 1E-397 Subnormal
dddiv1066 divide 1e-291 1e+107 -> 1E-398 Subnormal
dddiv1067 divide 1e-291 1e+108 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
dddiv1068 divide 1e-291 1e+109 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
dddiv1069 divide 1e-291 1e+110 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-- [no equivalent of 'subnormal' for overflow]
dddiv1070 divide 1e+60 1e-321 -> 1.000000000000E+381  Clamped
dddiv1071 divide 1e+60 1e-322 -> 1.0000000000000E+382  Clamped
dddiv1072 divide 1e+60 1e-323 -> 1.00000000000000E+383  Clamped
dddiv1073 divide 1e+60 1e-324 -> 1.000000000000000E+384  Clamped
dddiv1074 divide 1e+60 1e-325 -> Infinity Overflow Inexact Rounded
dddiv1075 divide 1e+60 1e-326 -> Infinity Overflow Inexact Rounded
dddiv1076 divide 1e+60 1e-327 -> Infinity Overflow Inexact Rounded
dddiv1077 divide 1e+60 1e-328 -> Infinity Overflow Inexact Rounded
dddiv1078 divide 1e+60 1e-329 -> Infinity Overflow Inexact Rounded
dddiv1079 divide 1e+60 1e-330 -> Infinity Overflow Inexact Rounded

dddiv1101 divide  1.0000E-394  1     -> 1.0000E-394 Subnormal
dddiv1102 divide  1.000E-394   1e+1  -> 1.000E-395  Subnormal
dddiv1103 divide  1.00E-394    1e+2  -> 1.00E-396   Subnormal
dddiv1104 divide  1.0E-394     1e+3  -> 1.0E-397    Subnormal
dddiv1105 divide  1.0E-394     1e+4  -> 1E-398     Subnormal Rounded
dddiv1106 divide  1.3E-394     1e+4  -> 1E-398     Underflow Subnormal Inexact Rounded
dddiv1107 divide  1.5E-394     1e+4  -> 2E-398     Underflow Subnormal Inexact Rounded
dddiv1108 divide  1.7E-394     1e+4  -> 2E-398     Underflow Subnormal Inexact Rounded
dddiv1109 divide  2.3E-394     1e+4  -> 2E-398     Underflow Subnormal Inexact Rounded
dddiv1110 divide  2.5E-394     1e+4  -> 2E-398     Underflow Subnormal Inexact Rounded
dddiv1111 divide  2.7E-394     1e+4  -> 3E-398     Underflow Subnormal Inexact Rounded
dddiv1112 divide  1.49E-394    1e+4  -> 1E-398     Underflow Subnormal Inexact Rounded
dddiv1113 divide  1.50E-394    1e+4  -> 2E-398     Underflow Subnormal Inexact Rounded
dddiv1114 divide  1.51E-394    1e+4  -> 2E-398     Underflow Subnormal Inexact Rounded
dddiv1115 divide  2.49E-394    1e+4  -> 2E-398     Underflow Subnormal Inexact Rounded
dddiv1116 divide  2.50E-394    1e+4  -> 2E-398     Underflow Subnormal Inexact Rounded
dddiv1117 divide  2.51E-394    1e+4  -> 3E-398     Underflow Subnormal Inexact Rounded

dddiv1118 divide  1E-394       1e+4  -> 1E-398     Subnormal
dddiv1119 divide  3E-394       1e+5  -> 0E-398     Underflow Subnormal Inexact Rounded Clamped
dddiv1120 divide  5E-394       1e+5  -> 0E-398     Underflow Subnormal Inexact Rounded Clamped
dddiv1121 divide  7E-394       1e+5  -> 1E-398     Underflow Subnormal Inexact Rounded
dddiv1122 divide  9E-394       1e+5  -> 1E-398     Underflow Subnormal Inexact Rounded
dddiv1123 divide  9.9E-394     1e+5  -> 1E-398     Underflow Subnormal Inexact Rounded

dddiv1124 divide  1E-394      -1e+4  -> -1E-398    Subnormal
dddiv1125 divide  3E-394      -1e+5  -> -0E-398    Underflow Subnormal Inexact Rounded Clamped
dddiv1126 divide -5E-394       1e+5  -> -0E-398    Underflow Subnormal Inexact Rounded Clamped
dddiv1127 divide  7E-394      -1e+5  -> -1E-398    Underflow Subnormal Inexact Rounded
dddiv1128 divide -9E-394       1e+5  -> -1E-398    Underflow Subnormal Inexact Rounded
dddiv1129 divide  9.9E-394    -1e+5  -> -1E-398    Underflow Subnormal Inexact Rounded
dddiv1130 divide  3.0E-394    -1e+5  -> -0E-398    Underflow Subnormal Inexact Rounded Clamped

dddiv1131 divide  1.0E-199     1e+200 -> 0E-398    Underflow Subnormal Inexact Rounded Clamped
dddiv1132 divide  1.0E-199     1e+199 -> 1E-398    Subnormal Rounded
dddiv1133 divide  1.0E-199     1e+198 -> 1.0E-397  Subnormal
dddiv1134 divide  2.0E-199     2e+198 -> 1.0E-397  Subnormal
dddiv1135 divide  4.0E-199     4e+198 -> 1.0E-397  Subnormal
dddiv1136 divide 10.0E-199    10e+198 -> 1.0E-397  Subnormal
dddiv1137 divide 30.0E-199    30e+198 -> 1.0E-397  Subnormal

-- randoms
dddiv2010  divide  -3.303226714900711E-35   8.796578842713183E+73   ->  -3.755126594058783E-109 Inexact Rounded
dddiv2011  divide   933153327821073.6       68782181090246.25       ->   13.56678885475763 Inexact Rounded
dddiv2012  divide   5.04752436057906E-72   -8.179481771238642E+64   ->  -6.170958627632835E-137 Inexact Rounded
dddiv2013  divide  -3707613309582318        3394911196503.048       ->  -1092.109070010836 Inexact Rounded
dddiv2014  divide   99689.0555190461       -4.735208553891464       ->  -21052.72753765411 Inexact Rounded
dddiv2015  divide  -1447915775613329        269750797.8184875       ->  -5367605.164925653 Inexact Rounded
dddiv2016  divide  -9.394881304225258E-19  -830585.0252671636       ->   1.131116143251358E-24 Inexact Rounded
dddiv2017  divide  -1.056283432738934       88.58754555124013       ->  -0.01192361100159352 Inexact Rounded
dddiv2018  divide   5763220933343.081       689089567025052.1       ->   0.008363529516524456 Inexact Rounded
dddiv2019  divide   873819.122103216        9.740612494523300E-49   ->   8.970884763093948E+53 Inexact Rounded
dddiv2020  divide   8022914.838533576       6178.566801742713       ->   1298.507420243583 Inexact Rounded
dddiv2021  divide   203982.7605650363      -2158.283639053435       ->  -94.51156320422168 Inexact Rounded
dddiv2022  divide   803.6310547013030       7101143795399.238       ->   1.131692411611166E-10 Inexact Rounded
dddiv2023  divide   9.251697842123399E-82  -1.342350220606119E-7    ->  -6.892163982321936E-75 Inexact Rounded
dddiv2024  divide  -1.980600645637992E-53  -5.474262753214457E+77   ->   3.618022617703168E-131 Inexact Rounded
dddiv2025  divide  -210.0322996351690      -8.580951835872843E+80   ->   2.447657365434971E-79 Inexact Rounded
dddiv2026  divide  -1.821980314020370E+85  -3.018915267138165       ->   6.035215144503042E+84 Inexact Rounded
dddiv2027  divide  -772264503601.1047       5.158258271408988E-86   ->  -1.497141986630614E+97 Inexact Rounded
dddiv2028  divide  -767.0532415847106       2.700027228028939E-59   ->  -2.840909282772941E+61 Inexact Rounded
dddiv2029  divide   496724.8548250093       7.32700588163100E+66    ->   6.779370220929013E-62 Inexact Rounded
dddiv2030  divide  -304232651447703.9      -108.9730808657440       ->   2791814721862.565 Inexact Rounded
dddiv2031  divide  -7.233817192699405E+42  -5711302004.149411       ->   1.266579352211430E+33 Inexact Rounded
dddiv2032  divide  -9.999221444912745E+96   4010569406446197        ->  -2.493217404202250E+81 Inexact Rounded
dddiv2033  divide  -1837272.061937622       8.356322838066762       ->  -219866.0939196882 Inexact Rounded
dddiv2034  divide   2168.517555606529       209.1910258615061       ->   10.36620737756784 Inexact Rounded
dddiv2035  divide  -1.884389790576371E+88   2.95181953870583E+20    ->  -6.383824505079828E+67 Inexact Rounded
dddiv2036  divide   732263.6037438196       961222.3634446889       ->   0.7618045850698269 Inexact Rounded
dddiv2037  divide  -813461419.0348336       5.376293753809143E+84   ->  -1.513052404285927E-76 Inexact Rounded
dddiv2038  divide  -45562133508108.50      -9.776843494690107E+51   ->   4.660208945029519E-39 Inexact Rounded
dddiv2039  divide  -6.489393172441016E+80  -9101965.097852113       ->   7.129661674897421E+73 Inexact Rounded
dddiv2040  divide   3.694576237117349E+93   6683512.012622003       ->   5.527896456443912E+86 Inexact Rounded
dddiv2041  divide  -2.252877726403272E+19  -7451913256.181367       ->   3023220546.125531 Inexact Rounded
dddiv2042  divide   518303.1989111842       50.01587020474133       ->   10362.77479107123 Inexact Rounded
dddiv2043  divide   2.902087881880103E+24   33.32400992305702       ->   8.708699488989578E+22 Inexact Rounded
dddiv2044  divide   549619.4559510557       1660824845196338        ->   3.309316196351104E-10 Inexact Rounded
dddiv2045  divide  -6775670774684043        8292152023.077262       ->  -817118.4941891062 Inexact Rounded
dddiv2046  divide  -77.50923921524079      -5.636882655425815E+74   ->   1.375037302588405E-73 Inexact Rounded
dddiv2047  divide  -2.984889459605149E-10  -88106156784122.99       ->   3.387833005721384E-24 Inexact Rounded
dddiv2048  divide   0.949517293997085       44767115.96450998       ->   2.121015110175589E-8 Inexact Rounded
dddiv2049  divide  -2760937211.084521      -1087015876975408        ->   0.000002539923537057024 Inexact Rounded
dddiv2050  divide   28438351.85030536      -4.209397904088624E-47   ->  -6.755919135770688E+53 Inexact Rounded
dddiv2051  divide  -85562731.6820956       -7.166045442530185E+45   ->   1.194002080621542E-38 Inexact Rounded
dddiv2052  divide   2533802852165.25        7154.119606235955       ->   354173957.3317501 Inexact Rounded
dddiv2053  divide  -8858831346851.474       97.59734208801716       ->  -90769186509.83577 Inexact Rounded
dddiv2054  divide   176783629801387.5       840073263.3109817       ->   210438.3480848206 Inexact Rounded
dddiv2055  divide  -493506471796175.6       79733894790822.03       ->  -6.189418854940746 Inexact Rounded
dddiv2056  divide   790.1682542103445       829.9449370367435       ->   0.9520731062371214 Inexact Rounded
dddiv2057  divide  -8920459838.583164      -4767.889187899214       ->   1870945.294035581 Inexact Rounded
dddiv2058  divide   53536687164422.1        53137.5007032689        ->   1007512330.385698 Inexact Rounded
dddiv2059  divide   4.051532311146561E-74  -2.343089768972261E+94   ->  -1.729140882606332E-168 Inexact Rounded
dddiv2060  divide  -14847758778636.88       3.062543516383807E-43   ->  -4.848178874587497E+55 Inexact Rounded

-- Division probably has pre-rounding, so need to test rounding
-- explicitly rather than assume included through other tests;
-- tests include simple rounding and also the tricky cases of sticky
-- bits following two zeros
--
--   1/99999 gives 0.0000100001000010000100001000010000100001
--                       1234567890123456
--
--   1/999999 gives 0.000001000001000001000001000001000001000001
--                         1234567890123456

rounding: ceiling
dddiv3001  divide  1     3    ->  0.3333333333333334 Inexact Rounded
dddiv3002  divide  2     3    ->  0.6666666666666667 Inexact Rounded
dddiv3003  divide  1 99999    ->  0.00001000010000100002  Inexact Rounded
dddiv3004  divide  1 999999   ->  0.000001000001000001001 Inexact Rounded

rounding: floor
dddiv3011  divide  1     3    ->  0.3333333333333333 Inexact Rounded
dddiv3012  divide  2     3    ->  0.6666666666666666 Inexact Rounded
dddiv3013  divide  1 99999    ->  0.00001000010000100001  Inexact Rounded
dddiv3014  divide  1 999999   ->  0.000001000001000001000 Inexact Rounded

rounding: up
dddiv3021  divide  1     3    ->  0.3333333333333334 Inexact Rounded
dddiv3022  divide  2     3    ->  0.6666666666666667 Inexact Rounded
dddiv3023  divide  1 99999    ->  0.00001000010000100002  Inexact Rounded
dddiv3024  divide  1 999999   ->  0.000001000001000001001 Inexact Rounded

rounding: down
dddiv3031  divide  1     3    ->  0.3333333333333333 Inexact Rounded
dddiv3032  divide  2     3    ->  0.6666666666666666 Inexact Rounded
dddiv3033  divide  1 99999    ->  0.00001000010000100001  Inexact Rounded
dddiv3034  divide  1 999999   ->  0.000001000001000001000 Inexact Rounded

rounding: half_up
dddiv3041  divide  1     3    ->  0.3333333333333333 Inexact Rounded
dddiv3042  divide  2     3    ->  0.6666666666666667 Inexact Rounded
dddiv3043  divide  1 99999    ->  0.00001000010000100001  Inexact Rounded
dddiv3044  divide  1 999999   ->  0.000001000001000001000 Inexact Rounded

rounding: half_down
dddiv3051  divide  1     3    ->  0.3333333333333333 Inexact Rounded
dddiv3052  divide  2     3    ->  0.6666666666666667 Inexact Rounded
dddiv3053  divide  1 99999    ->  0.00001000010000100001  Inexact Rounded
dddiv3054  divide  1 999999   ->  0.000001000001000001000 Inexact Rounded

rounding: half_even
dddiv3061  divide  1     3    ->  0.3333333333333333 Inexact Rounded
dddiv3062  divide  2     3    ->  0.6666666666666667 Inexact Rounded
dddiv3063  divide  1 99999    ->  0.00001000010000100001  Inexact Rounded
dddiv3064  divide  1 999999   ->  0.000001000001000001000 Inexact Rounded

rounding: 05up
dddiv3071  divide  1     3    ->  0.3333333333333333 Inexact Rounded
dddiv3072  divide  2     3    ->  0.6666666666666666 Inexact Rounded
dddiv3073  divide  1 99999    ->  0.00001000010000100001  Inexact Rounded
dddiv3074  divide  1 999999   ->  0.000001000001000001001 Inexact Rounded


-- Null tests
dddiv9998 divide 10  # -> NaN Invalid_operation
dddiv9999 divide  # 10 -> NaN Invalid_operation

Added test/dectest/ddDivideInt.decTest.



































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
------------------------------------------------------------------------
-- ddDivideInt.decTest -- decDouble integer division                  --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

dddvi001 divideint  1     1    ->  1
dddvi002 divideint  2     1    ->  2
dddvi003 divideint  1     2    ->  0
dddvi004 divideint  2     2    ->  1
dddvi005 divideint  0     1    ->  0
dddvi006 divideint  0     2    ->  0
dddvi007 divideint  1     3    ->  0
dddvi008 divideint  2     3    ->  0
dddvi009 divideint  3     3    ->  1

dddvi010 divideint  2.4   1    ->  2
dddvi011 divideint  2.4   -1   ->  -2
dddvi012 divideint  -2.4  1    ->  -2
dddvi013 divideint  -2.4  -1   ->  2
dddvi014 divideint  2.40  1    ->  2
dddvi015 divideint  2.400 1    ->  2
dddvi016 divideint  2.4   2    ->  1
dddvi017 divideint  2.400 2    ->  1
dddvi018 divideint  2.    2    ->  1
dddvi019 divideint  20    20   ->  1

dddvi020 divideint  187   187  ->  1
dddvi021 divideint  5     2    ->  2
dddvi022 divideint  5     2.0    ->  2
dddvi023 divideint  5     2.000  ->  2
dddvi024 divideint  5     0.200  ->  25
dddvi025 divideint  5     0.200  ->  25

dddvi030 divideint  1     2      ->  0
dddvi031 divideint  1     4      ->  0
dddvi032 divideint  1     8      ->  0
dddvi033 divideint  1     16     ->  0
dddvi034 divideint  1     32     ->  0
dddvi035 divideint  1     64     ->  0
dddvi040 divideint  1    -2      -> -0
dddvi041 divideint  1    -4      -> -0
dddvi042 divideint  1    -8      -> -0
dddvi043 divideint  1    -16     -> -0
dddvi044 divideint  1    -32     -> -0
dddvi045 divideint  1    -64     -> -0
dddvi050 divideint -1     2      -> -0
dddvi051 divideint -1     4      -> -0
dddvi052 divideint -1     8      -> -0
dddvi053 divideint -1     16     -> -0
dddvi054 divideint -1     32     -> -0
dddvi055 divideint -1     64     -> -0
dddvi060 divideint -1    -2      ->  0
dddvi061 divideint -1    -4      ->  0
dddvi062 divideint -1    -8      ->  0
dddvi063 divideint -1    -16     ->  0
dddvi064 divideint -1    -32     ->  0
dddvi065 divideint -1    -64     ->  0

-- similar with powers of ten
dddvi160 divideint  1     1         ->  1
dddvi161 divideint  1     10        ->  0
dddvi162 divideint  1     100       ->  0
dddvi163 divideint  1     1000      ->  0
dddvi164 divideint  1     10000     ->  0
dddvi165 divideint  1     100000    ->  0
dddvi166 divideint  1     1000000   ->  0
dddvi167 divideint  1     10000000  ->  0
dddvi168 divideint  1     100000000 ->  0
dddvi170 divideint  1    -1         -> -1
dddvi171 divideint  1    -10        -> -0
dddvi172 divideint  1    -100       -> -0
dddvi173 divideint  1    -1000      -> -0
dddvi174 divideint  1    -10000     -> -0
dddvi175 divideint  1    -100000    -> -0
dddvi176 divideint  1    -1000000   -> -0
dddvi177 divideint  1    -10000000  -> -0
dddvi178 divideint  1    -100000000 -> -0
dddvi180 divideint -1     1         -> -1
dddvi181 divideint -1     10        -> -0
dddvi182 divideint -1     100       -> -0
dddvi183 divideint -1     1000      -> -0
dddvi184 divideint -1     10000     -> -0
dddvi185 divideint -1     100000    -> -0
dddvi186 divideint -1     1000000   -> -0
dddvi187 divideint -1     10000000  -> -0
dddvi188 divideint -1     100000000 -> -0
dddvi190 divideint -1    -1         ->  1
dddvi191 divideint -1    -10        ->  0
dddvi192 divideint -1    -100       ->  0
dddvi193 divideint -1    -1000      ->  0
dddvi194 divideint -1    -10000     ->  0
dddvi195 divideint -1    -100000    ->  0
dddvi196 divideint -1    -1000000   ->  0
dddvi197 divideint -1    -10000000  ->  0
dddvi198 divideint -1    -100000000 ->  0

-- some long operand (at p=9) cases
dddvi070 divideint  999999999     1  ->  999999999
dddvi071 divideint  999999999.4   1  ->  999999999
dddvi072 divideint  999999999.5   1  ->  999999999
dddvi073 divideint  999999999.9   1  ->  999999999
dddvi074 divideint  999999999.999 1  ->  999999999

dddvi090 divideint  0.            1    ->  0
dddvi091 divideint  .0            1    ->  0
dddvi092 divideint  0.00          1    ->  0
dddvi093 divideint  0.00E+9       1    ->  0
dddvi094 divideint  0.0000E-50    1    ->  0

dddvi100 divideint  1  1   -> 1
dddvi101 divideint  1  2   -> 0
dddvi102 divideint  1  3   -> 0
dddvi103 divideint  1  4   -> 0
dddvi104 divideint  1  5   -> 0
dddvi105 divideint  1  6   -> 0
dddvi106 divideint  1  7   -> 0
dddvi107 divideint  1  8   -> 0
dddvi108 divideint  1  9   -> 0
dddvi109 divideint  1  10  -> 0
dddvi110 divideint  1  1   -> 1
dddvi111 divideint  2  1   -> 2
dddvi112 divideint  3  1   -> 3
dddvi113 divideint  4  1   -> 4
dddvi114 divideint  5  1   -> 5
dddvi115 divideint  6  1   -> 6
dddvi116 divideint  7  1   -> 7
dddvi117 divideint  8  1   -> 8
dddvi118 divideint  9  1   -> 9
dddvi119 divideint  10 1   -> 10

-- from DiagBigDecimal
dddvi131 divideint  101.3   1     ->  101
dddvi132 divideint  101.0   1     ->  101
dddvi133 divideint  101.3   3     ->  33
dddvi134 divideint  101.0   3     ->  33
dddvi135 divideint  2.4     1     ->  2
dddvi136 divideint  2.400   1     ->  2
dddvi137 divideint  18      18    ->  1
dddvi138 divideint  1120    1000  ->  1
dddvi139 divideint  2.4     2     ->  1
dddvi140 divideint  2.400   2     ->  1
dddvi141 divideint  0.5     2.000 ->  0
dddvi142 divideint  8.005   7     ->  1
dddvi143 divideint  5       2     ->  2
dddvi144 divideint  0       2     ->  0
dddvi145 divideint  0.00    2     ->  0

-- Others
dddvi150 divideint  12345  4.999  ->  2469
dddvi151 divideint  12345  4.99   ->  2473
dddvi152 divideint  12345  4.9    ->  2519
dddvi153 divideint  12345  5      ->  2469
dddvi154 divideint  12345  5.1    ->  2420
dddvi155 divideint  12345  5.01   ->  2464
dddvi156 divideint  12345  5.001  ->  2468
dddvi157 divideint    101  7.6    ->  13

-- Various flavours of divideint by 0
dddvi201 divideint  0      0   -> NaN Division_undefined
dddvi202 divideint  0.0E5  0   -> NaN Division_undefined
dddvi203 divideint  0.000  0   -> NaN Division_undefined
dddvi204 divideint  0.0001 0   -> Infinity Division_by_zero
dddvi205 divideint  0.01   0   -> Infinity Division_by_zero
dddvi206 divideint  0.1    0   -> Infinity Division_by_zero
dddvi207 divideint  1      0   -> Infinity Division_by_zero
dddvi208 divideint  1      0.0 -> Infinity Division_by_zero
dddvi209 divideint 10      0.0 -> Infinity Division_by_zero
dddvi210 divideint 1E+100  0.0 -> Infinity Division_by_zero
dddvi211 divideint 1E+380  0   -> Infinity Division_by_zero
dddvi214 divideint  -0.0001 0   -> -Infinity Division_by_zero
dddvi215 divideint  -0.01   0   -> -Infinity Division_by_zero
dddvi216 divideint  -0.1    0   -> -Infinity Division_by_zero
dddvi217 divideint  -1      0   -> -Infinity Division_by_zero
dddvi218 divideint  -1      0.0 -> -Infinity Division_by_zero
dddvi219 divideint -10      0.0 -> -Infinity Division_by_zero
dddvi220 divideint -1E+100  0.0 -> -Infinity Division_by_zero
dddvi221 divideint -1E+380  0   -> -Infinity Division_by_zero

-- test some cases that are close to exponent overflow
dddvi270 divideint 1 1e384          -> 0
dddvi271 divideint 1 0.9e384        -> 0
dddvi272 divideint 1 0.99e384       -> 0
dddvi273 divideint 1 0.9999999999999999e384       -> 0
dddvi274 divideint 9e384    1       -> NaN Division_impossible
dddvi275 divideint 9.9e384  1       -> NaN Division_impossible
dddvi276 divideint 9.99e384 1       -> NaN Division_impossible
dddvi277 divideint 9.999999999999999e384 1 -> NaN Division_impossible

dddvi280 divideint 0.1 9e-383       -> NaN Division_impossible
dddvi281 divideint 0.1 99e-383      -> NaN Division_impossible
dddvi282 divideint 0.1 999e-383     -> NaN Division_impossible
dddvi283 divideint 0.1 9e-382       -> NaN Division_impossible
dddvi284 divideint 0.1 99e-382      -> NaN Division_impossible

-- GD edge cases: lhs smaller than rhs but more digits
dddvi301  divideint  0.9      2      ->  0
dddvi302  divideint  0.9      2.0    ->  0
dddvi303  divideint  0.9      2.1    ->  0
dddvi304  divideint  0.9      2.00   ->  0
dddvi305  divideint  0.9      2.01   ->  0
dddvi306  divideint  0.12     1      ->  0
dddvi307  divideint  0.12     1.0    ->  0
dddvi308  divideint  0.12     1.00   ->  0
dddvi309  divideint  0.12     1.0    ->  0
dddvi310  divideint  0.12     1.00   ->  0
dddvi311  divideint  0.12     2      ->  0
dddvi312  divideint  0.12     2.0    ->  0
dddvi313  divideint  0.12     2.1    ->  0
dddvi314  divideint  0.12     2.00   ->  0
dddvi315  divideint  0.12     2.01   ->  0

-- edge cases of impossible
dddvi330  divideint  1234567890123456  10    ->  123456789012345
dddvi331  divideint  1234567890123456   1    ->  1234567890123456
dddvi332  divideint  1234567890123456   0.1  ->  NaN Division_impossible
dddvi333  divideint  1234567890123456   0.01 ->  NaN Division_impossible

-- overflow and underflow tests [from divide]
dddvi1051 divideint  1e+277  1e-311 ->  NaN Division_impossible
dddvi1052 divideint  1e+277 -1e-311 ->  NaN Division_impossible
dddvi1053 divideint -1e+277  1e-311 ->  NaN Division_impossible
dddvi1054 divideint -1e+277 -1e-311 ->  NaN Division_impossible
dddvi1055 divideint  1e-277  1e+311 ->  0
dddvi1056 divideint  1e-277 -1e+311 -> -0
dddvi1057 divideint -1e-277  1e+311 -> -0
dddvi1058 divideint -1e-277 -1e+311 ->  0

-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
dddvi1060 divideint 1e-291 1e+101 -> 0
dddvi1061 divideint 1e-291 1e+102 -> 0
dddvi1062 divideint 1e-291 1e+103 -> 0
dddvi1063 divideint 1e-291 1e+104 -> 0
dddvi1064 divideint 1e-291 1e+105 -> 0
dddvi1065 divideint 1e-291 1e+106 -> 0
dddvi1066 divideint 1e-291 1e+107 -> 0
dddvi1067 divideint 1e-291 1e+108 -> 0
dddvi1068 divideint 1e-291 1e+109 -> 0
dddvi1069 divideint 1e-291 1e+110 -> 0

dddvi1101 divideint  1.0000E-394  1     -> 0
dddvi1102 divideint  1.000E-394   1e+1  -> 0
dddvi1103 divideint  1.00E-394    1e+2  -> 0

dddvi1118 divideint  1E-394       1e+4  -> 0
dddvi1119 divideint  3E-394      -1e+5  -> -0
dddvi1120 divideint  5E-394       1e+5  -> 0

dddvi1124 divideint  1E-394      -1e+4  -> -0
dddvi1130 divideint  3.0E-394    -1e+5  -> -0

dddvi1131 divideint  1.0E-199     1e+200 -> 0
dddvi1132 divideint  1.0E-199     1e+199 -> 0
dddvi1133 divideint  1.0E-199     1e+198 -> 0
dddvi1134 divideint  2.0E-199     2e+198 -> 0
dddvi1135 divideint  4.0E-199     4e+198 -> 0

-- long operand checks
dddvi401 divideint 12345678000 100 -> 123456780
dddvi402 divideint 1 12345678000   -> 0
dddvi403 divideint 1234567800  10  -> 123456780
dddvi404 divideint 1 1234567800    -> 0
dddvi405 divideint 1234567890  10  -> 123456789
dddvi406 divideint 1 1234567890    -> 0
dddvi407 divideint 1234567891  10  -> 123456789
dddvi408 divideint 1 1234567891    -> 0
dddvi409 divideint 12345678901 100 -> 123456789
dddvi410 divideint 1 12345678901   -> 0
dddvi411 divideint 1234567896  10  -> 123456789
dddvi412 divideint 1 1234567896    -> 0
dddvi413 divideint 12345678948 100 -> 123456789
dddvi414 divideint 12345678949 100 -> 123456789
dddvi415 divideint 12345678950 100 -> 123456789
dddvi416 divideint 12345678951 100 -> 123456789
dddvi417 divideint 12345678999 100 -> 123456789
dddvi441 divideint 12345678000 1 -> 12345678000
dddvi442 divideint 1 12345678000 -> 0
dddvi443 divideint 1234567800  1 -> 1234567800
dddvi444 divideint 1 1234567800  -> 0
dddvi445 divideint 1234567890  1 -> 1234567890
dddvi446 divideint 1 1234567890  -> 0
dddvi447 divideint 1234567891  1 -> 1234567891
dddvi448 divideint 1 1234567891  -> 0
dddvi449 divideint 12345678901 1 -> 12345678901
dddvi450 divideint 1 12345678901 -> 0
dddvi451 divideint 1234567896  1 -> 1234567896
dddvi452 divideint 1 1234567896  -> 0

-- more zeros, etc.
dddvi531 divideint 5.00 1E-3    -> 5000
dddvi532 divideint 00.00 0.000  -> NaN Division_undefined
dddvi533 divideint 00.00 0E-3   -> NaN Division_undefined
dddvi534 divideint  0    -0     -> NaN Division_undefined
dddvi535 divideint -0     0     -> NaN Division_undefined
dddvi536 divideint -0    -0     -> NaN Division_undefined

dddvi541 divideint  0    -1     -> -0
dddvi542 divideint -0    -1     ->  0
dddvi543 divideint  0     1     ->  0
dddvi544 divideint -0     1     -> -0
dddvi545 divideint -1     0     -> -Infinity Division_by_zero
dddvi546 divideint -1    -0     ->  Infinity Division_by_zero
dddvi547 divideint  1     0     ->  Infinity Division_by_zero
dddvi548 divideint  1    -0     -> -Infinity Division_by_zero

dddvi551 divideint  0.0  -1     -> -0
dddvi552 divideint -0.0  -1     ->  0
dddvi553 divideint  0.0   1     ->  0
dddvi554 divideint -0.0   1     -> -0
dddvi555 divideint -1.0   0     -> -Infinity Division_by_zero
dddvi556 divideint -1.0  -0     ->  Infinity Division_by_zero
dddvi557 divideint  1.0   0     ->  Infinity Division_by_zero
dddvi558 divideint  1.0  -0     -> -Infinity Division_by_zero

dddvi561 divideint  0    -1.0   -> -0
dddvi562 divideint -0    -1.0   ->  0
dddvi563 divideint  0     1.0   ->  0
dddvi564 divideint -0     1.0   -> -0
dddvi565 divideint -1     0.0   -> -Infinity Division_by_zero
dddvi566 divideint -1    -0.0   ->  Infinity Division_by_zero
dddvi567 divideint  1     0.0   ->  Infinity Division_by_zero
dddvi568 divideint  1    -0.0   -> -Infinity Division_by_zero

dddvi571 divideint  0.0  -1.0   -> -0
dddvi572 divideint -0.0  -1.0   ->  0
dddvi573 divideint  0.0   1.0   ->  0
dddvi574 divideint -0.0   1.0   -> -0
dddvi575 divideint -1.0   0.0   -> -Infinity Division_by_zero
dddvi576 divideint -1.0  -0.0   ->  Infinity Division_by_zero
dddvi577 divideint  1.0   0.0   ->  Infinity Division_by_zero
dddvi578 divideint  1.0  -0.0   -> -Infinity Division_by_zero

-- Specials
dddvi580 divideint  Inf  -Inf   ->  NaN Invalid_operation
dddvi581 divideint  Inf  -1000  -> -Infinity
dddvi582 divideint  Inf  -1     -> -Infinity
dddvi583 divideint  Inf  -0     -> -Infinity
dddvi584 divideint  Inf   0     ->  Infinity
dddvi585 divideint  Inf   1     ->  Infinity
dddvi586 divideint  Inf   1000  ->  Infinity
dddvi587 divideint  Inf   Inf   ->  NaN Invalid_operation
dddvi588 divideint -1000  Inf   -> -0
dddvi589 divideint -Inf   Inf   ->  NaN Invalid_operation
dddvi590 divideint -1     Inf   -> -0
dddvi591 divideint -0     Inf   -> -0
dddvi592 divideint  0     Inf   ->  0
dddvi593 divideint  1     Inf   ->  0
dddvi594 divideint  1000  Inf   ->  0
dddvi595 divideint  Inf   Inf   ->  NaN Invalid_operation

dddvi600 divideint -Inf  -Inf   ->  NaN Invalid_operation
dddvi601 divideint -Inf  -1000  ->  Infinity
dddvi602 divideint -Inf  -1     ->  Infinity
dddvi603 divideint -Inf  -0     ->  Infinity
dddvi604 divideint -Inf   0     -> -Infinity
dddvi605 divideint -Inf   1     -> -Infinity
dddvi606 divideint -Inf   1000  -> -Infinity
dddvi607 divideint -Inf   Inf   ->  NaN Invalid_operation
dddvi608 divideint -1000  Inf   -> -0
dddvi609 divideint -Inf  -Inf   ->  NaN Invalid_operation
dddvi610 divideint -1    -Inf   ->  0
dddvi611 divideint -0    -Inf   ->  0
dddvi612 divideint  0    -Inf   -> -0
dddvi613 divideint  1    -Inf   -> -0
dddvi614 divideint  1000 -Inf   -> -0
dddvi615 divideint  Inf  -Inf   ->  NaN Invalid_operation

dddvi621 divideint  NaN -Inf    ->  NaN
dddvi622 divideint  NaN -1000   ->  NaN
dddvi623 divideint  NaN -1      ->  NaN
dddvi624 divideint  NaN -0      ->  NaN
dddvi625 divideint  NaN  0      ->  NaN
dddvi626 divideint  NaN  1      ->  NaN
dddvi627 divideint  NaN  1000   ->  NaN
dddvi628 divideint  NaN  Inf    ->  NaN
dddvi629 divideint  NaN  NaN    ->  NaN
dddvi630 divideint -Inf  NaN    ->  NaN
dddvi631 divideint -1000 NaN    ->  NaN
dddvi632 divideint -1    NaN    ->  NaN
dddvi633 divideint -0    NaN    ->  NaN
dddvi634 divideint  0    NaN    ->  NaN
dddvi635 divideint  1    NaN    ->  NaN
dddvi636 divideint  1000 NaN    ->  NaN
dddvi637 divideint  Inf  NaN    ->  NaN

dddvi641 divideint  sNaN -Inf   ->  NaN  Invalid_operation
dddvi642 divideint  sNaN -1000  ->  NaN  Invalid_operation
dddvi643 divideint  sNaN -1     ->  NaN  Invalid_operation
dddvi644 divideint  sNaN -0     ->  NaN  Invalid_operation
dddvi645 divideint  sNaN  0     ->  NaN  Invalid_operation
dddvi646 divideint  sNaN  1     ->  NaN  Invalid_operation
dddvi647 divideint  sNaN  1000  ->  NaN  Invalid_operation
dddvi648 divideint  sNaN  NaN   ->  NaN  Invalid_operation
dddvi649 divideint  sNaN sNaN   ->  NaN  Invalid_operation
dddvi650 divideint  NaN  sNaN   ->  NaN  Invalid_operation
dddvi651 divideint -Inf  sNaN   ->  NaN  Invalid_operation
dddvi652 divideint -1000 sNaN   ->  NaN  Invalid_operation
dddvi653 divideint -1    sNaN   ->  NaN  Invalid_operation
dddvi654 divideint -0    sNaN   ->  NaN  Invalid_operation
dddvi655 divideint  0    sNaN   ->  NaN  Invalid_operation
dddvi656 divideint  1    sNaN   ->  NaN  Invalid_operation
dddvi657 divideint  1000 sNaN   ->  NaN  Invalid_operation
dddvi658 divideint  Inf  sNaN   ->  NaN  Invalid_operation
dddvi659 divideint  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dddvi661 divideint  NaN9 -Inf   ->  NaN9
dddvi662 divideint  NaN8  1000  ->  NaN8
dddvi663 divideint  NaN7  Inf   ->  NaN7
dddvi664 divideint -NaN6  NaN5  -> -NaN6
dddvi665 divideint -Inf   NaN4  ->  NaN4
dddvi666 divideint -1000  NaN3  ->  NaN3
dddvi667 divideint  Inf  -NaN2  -> -NaN2

dddvi671 divideint -sNaN99 -Inf    -> -NaN99 Invalid_operation
dddvi672 divideint  sNaN98 -1      ->  NaN98 Invalid_operation
dddvi673 divideint  sNaN97  NaN    ->  NaN97 Invalid_operation
dddvi674 divideint  sNaN96 sNaN94  ->  NaN96 Invalid_operation
dddvi675 divideint  NaN95  sNaN93  ->  NaN93 Invalid_operation
dddvi676 divideint -Inf    sNaN92  ->  NaN92 Invalid_operation
dddvi677 divideint  0      sNaN91  ->  NaN91 Invalid_operation
dddvi678 divideint  Inf   -sNaN90  -> -NaN90 Invalid_operation
dddvi679 divideint  NaN    sNaN89  ->  NaN89 Invalid_operation

-- Null tests
dddvi900 divideint  10  # -> NaN Invalid_operation
dddvi901 divideint   # 10 -> NaN Invalid_operation

Added test/dectest/ddEncode.decTest.















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
------------------------------------------------------------------------
-- ddEncode.decTest -- decimal eight-byte format testcases            --
-- Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
-- [Previously called decimal64.decTest]
version: 2.55

-- This set of tests is for the eight-byte concrete representation.
-- Its characteristics are:
--
--  1 bit  sign
--  5 bits combination field
--  8 bits exponent continuation
-- 50 bits coefficient continuation
--
-- Total exponent length 10 bits
-- Total coefficient length 54 bits (16 digits)
--
-- Elimit =  767 (maximum encoded exponent)
-- Emax   =  384 (largest exponent value)
-- Emin   = -383 (smallest exponent value)
-- bias   =  398 (subtracted from encoded exponent) = -Etiny

-- The testcases here have only exactly representable data on the
-- 'left-hand-side'; rounding from strings is tested in 'base'
-- testcase groups.

extended:    1
clamp:       1
precision:   16
rounding:    half_up
maxExponent: 384
minExponent: -383

-- General testcases
-- (mostly derived from the Strawman 4 document and examples)
dece001 apply   #A2300000000003D0 -> -7.50
dece002 apply   -7.50             -> #A2300000000003D0
-- derivative canonical plain strings
dece003 apply   #A23c0000000003D0 -> -7.50E+3
dece004 apply   -7.50E+3          -> #A23c0000000003D0
dece005 apply   #A2380000000003D0 -> -750
dece006 apply   -750              -> #A2380000000003D0
dece007 apply   #A2340000000003D0 -> -75.0
dece008 apply   -75.0             -> #A2340000000003D0
dece009 apply   #A22c0000000003D0 -> -0.750
dece010 apply   -0.750            -> #A22c0000000003D0
dece011 apply   #A2280000000003D0 -> -0.0750
dece012 apply   -0.0750           -> #A2280000000003D0
dece013 apply   #A2200000000003D0 -> -0.000750
dece014 apply   -0.000750         -> #A2200000000003D0
dece015 apply   #A2180000000003D0 -> -0.00000750
dece016 apply   -0.00000750       -> #A2180000000003D0
dece017 apply   #A2140000000003D0 -> -7.50E-7
dece018 apply   -7.50E-7          -> #A2140000000003D0

-- Normality
dece020 apply   1234567890123456   -> #263934b9c1e28e56
dece021 apply  -1234567890123456   -> #a63934b9c1e28e56
dece022 apply   1234.567890123456  -> #260934b9c1e28e56
dece023 apply  #260934b9c1e28e56   -> 1234.567890123456
dece024 apply   1111111111111111   -> #2638912449124491
dece025 apply   9999999999999999   -> #6e38ff3fcff3fcff

-- Nmax and similar
dece031 apply   9999999999999999E+369   -> #77fcff3fcff3fcff
dece032 apply   9.999999999999999E+384  -> #77fcff3fcff3fcff
dece033 apply   #77fcff3fcff3fcff       -> 9.999999999999999E+384
dece034 apply   1.234567890123456E+384  -> #47fd34b9c1e28e56
dece035 apply   #47fd34b9c1e28e56       -> 1.234567890123456E+384
-- fold-downs (more below)
dece036 apply   1.23E+384               -> #47fd300000000000 Clamped
dece037 apply   #47fd300000000000       -> 1.230000000000000E+384
decd038 apply   1E+384                  -> #47fc000000000000 Clamped
decd039 apply   #47fc000000000000       -> 1.000000000000000E+384

decd051 apply   12345                   -> #22380000000049c5
decd052 apply   #22380000000049c5       -> 12345
decd053 apply   1234                    -> #2238000000000534
decd054 apply   #2238000000000534       -> 1234
decd055 apply   123                     -> #22380000000000a3
decd056 apply   #22380000000000a3       -> 123
decd057 apply   12                      -> #2238000000000012
decd058 apply   #2238000000000012       -> 12
decd059 apply   1                       -> #2238000000000001
decd060 apply   #2238000000000001       -> 1
decd061 apply   1.23                    -> #22300000000000a3
decd062 apply   #22300000000000a3       -> 1.23
decd063 apply   123.45                  -> #22300000000049c5
decd064 apply   #22300000000049c5       -> 123.45

-- Nmin and below
decd071 apply   1E-383                  -> #003c000000000001
decd072 apply   #003c000000000001       -> 1E-383
decd073 apply   1.000000000000000E-383  -> #0400000000000000
decd074 apply   #0400000000000000       -> 1.000000000000000E-383
decd075 apply   1.000000000000001E-383  -> #0400000000000001
decd076 apply   #0400000000000001       -> 1.000000000000001E-383

decd077 apply   0.100000000000000E-383  -> #0000800000000000      Subnormal
decd078 apply   #0000800000000000       -> 1.00000000000000E-384  Subnormal
decd079 apply   0.000000000000010E-383  -> #0000000000000010      Subnormal
decd080 apply   #0000000000000010       -> 1.0E-397               Subnormal
decd081 apply   0.00000000000001E-383   -> #0004000000000001      Subnormal
decd082 apply   #0004000000000001       -> 1E-397                 Subnormal
decd083 apply   0.000000000000001E-383  -> #0000000000000001      Subnormal
decd084 apply   #0000000000000001       -> 1E-398                 Subnormal
-- next is smallest all-nines
decd085 apply   9999999999999999E-398   -> #6400ff3fcff3fcff
decd086 apply   #6400ff3fcff3fcff       -> 9.999999999999999E-383
-- and a problematic divide result
decd088 apply   1.111111111111111E-383  -> #0400912449124491
decd089 apply   #0400912449124491       -> 1.111111111111111E-383

-- forties
decd090 apply        40                -> #2238000000000040
decd091 apply        39.99             -> #2230000000000cff

-- underflows cannot be tested as all LHS exact

-- Same again, negatives
-- Nmax and similar
decd122 apply  -9.999999999999999E+384  -> #f7fcff3fcff3fcff
decd123 apply   #f7fcff3fcff3fcff       -> -9.999999999999999E+384
decd124 apply  -1.234567890123456E+384  -> #c7fd34b9c1e28e56
decd125 apply   #c7fd34b9c1e28e56       -> -1.234567890123456E+384
-- fold-downs (more below)
decd130 apply  -1.23E+384               -> #c7fd300000000000 Clamped
decd131 apply   #c7fd300000000000       -> -1.230000000000000E+384
decd132 apply  -1E+384                  -> #c7fc000000000000 Clamped
decd133 apply   #c7fc000000000000       -> -1.000000000000000E+384

-- overflows
decd151 apply  -12345                   -> #a2380000000049c5
decd152 apply   #a2380000000049c5       -> -12345
decd153 apply  -1234                    -> #a238000000000534
decd154 apply   #a238000000000534       -> -1234
decd155 apply  -123                     -> #a2380000000000a3
decd156 apply   #a2380000000000a3       -> -123
decd157 apply  -12                      -> #a238000000000012
decd158 apply   #a238000000000012       -> -12
decd159 apply  -1                       -> #a238000000000001
decd160 apply   #a238000000000001       -> -1
decd161 apply  -1.23                    -> #a2300000000000a3
decd162 apply   #a2300000000000a3       -> -1.23
decd163 apply  -123.45                  -> #a2300000000049c5
decd164 apply   #a2300000000049c5       -> -123.45

-- Nmin and below
decd171 apply  -1E-383                  -> #803c000000000001
decd172 apply   #803c000000000001       -> -1E-383
decd173 apply  -1.000000000000000E-383  -> #8400000000000000
decd174 apply   #8400000000000000       -> -1.000000000000000E-383
decd175 apply  -1.000000000000001E-383  -> #8400000000000001
decd176 apply   #8400000000000001       -> -1.000000000000001E-383

decd177 apply  -0.100000000000000E-383  -> #8000800000000000       Subnormal
decd178 apply   #8000800000000000       -> -1.00000000000000E-384  Subnormal
decd179 apply  -0.000000000000010E-383  -> #8000000000000010       Subnormal
decd180 apply   #8000000000000010       -> -1.0E-397               Subnormal
decd181 apply  -0.00000000000001E-383   -> #8004000000000001       Subnormal
decd182 apply   #8004000000000001       -> -1E-397                 Subnormal
decd183 apply  -0.000000000000001E-383  -> #8000000000000001       Subnormal
decd184 apply   #8000000000000001       -> -1E-398                 Subnormal
-- next is smallest all-nines
decd185 apply   -9999999999999999E-398   -> #e400ff3fcff3fcff
decd186 apply   #e400ff3fcff3fcff       -> -9.999999999999999E-383
-- and a tricky subnormal
decd187 apply   1.11111111111524E-384    -> #00009124491246a4      Subnormal
decd188 apply   #00009124491246a4        -> 1.11111111111524E-384  Subnormal

-- near-underflows
decd189 apply   -1e-398                 -> #8000000000000001  Subnormal
decd190 apply   -1.0e-398               -> #8000000000000001  Subnormal Rounded

-- zeros
decd401 apply   0E-500                  -> #0000000000000000  Clamped
decd402 apply   0E-400                  -> #0000000000000000  Clamped
decd403 apply   0E-398                  -> #0000000000000000
decd404 apply   #0000000000000000       -> 0E-398
decd405 apply   0.000000000000000E-383  -> #0000000000000000
decd406 apply   #0000000000000000       -> 0E-398
decd407 apply   0E-2                    -> #2230000000000000
decd408 apply   #2230000000000000       -> 0.00
decd409 apply   0                       -> #2238000000000000
decd410 apply   #2238000000000000       -> 0
decd411 apply   0E+3                    -> #2244000000000000
decd412 apply   #2244000000000000       -> 0E+3
decd413 apply   0E+369                  -> #43fc000000000000
decd414 apply   #43fc000000000000       -> 0E+369
-- clamped zeros...
decd415 apply   0E+370                  -> #43fc000000000000  Clamped
decd416 apply   #43fc000000000000       -> 0E+369
decd417 apply   0E+384                  -> #43fc000000000000  Clamped
decd418 apply   #43fc000000000000       -> 0E+369
decd419 apply   0E+400                  -> #43fc000000000000  Clamped
decd420 apply   #43fc000000000000       -> 0E+369
decd421 apply   0E+500                  -> #43fc000000000000  Clamped
decd422 apply   #43fc000000000000       -> 0E+369

-- negative zeros
decd431 apply   -0E-400                 -> #8000000000000000  Clamped
decd432 apply   -0E-400                 -> #8000000000000000  Clamped
decd433 apply   -0E-398                 -> #8000000000000000
decd434 apply   #8000000000000000       -> -0E-398
decd435 apply   -0.000000000000000E-383 -> #8000000000000000
decd436 apply   #8000000000000000       -> -0E-398
decd437 apply   -0E-2                   -> #a230000000000000
decd438 apply   #a230000000000000       -> -0.00
decd439 apply   -0                      -> #a238000000000000
decd440 apply   #a238000000000000       -> -0
decd441 apply   -0E+3                   -> #a244000000000000
decd442 apply   #a244000000000000       -> -0E+3
decd443 apply   -0E+369                 -> #c3fc000000000000
decd444 apply   #c3fc000000000000       -> -0E+369
-- clamped zeros...
decd445 apply   -0E+370                 -> #c3fc000000000000  Clamped
decd446 apply   #c3fc000000000000       -> -0E+369
decd447 apply   -0E+384                 -> #c3fc000000000000  Clamped
decd448 apply   #c3fc000000000000       -> -0E+369
decd449 apply   -0E+400                 -> #c3fc000000000000  Clamped
decd450 apply   #c3fc000000000000       -> -0E+369
decd451 apply   -0E+500                 -> #c3fc000000000000  Clamped
decd452 apply   #c3fc000000000000       -> -0E+369

-- exponents
decd460 apply   #225c000000000007 -> 7E+9
decd461 apply   7E+9  -> #225c000000000007
decd462 apply   #23c4000000000007 -> 7E+99
decd463 apply   7E+99 -> #23c4000000000007

-- Specials
decd500 apply   Infinity          -> #7800000000000000
decd501 apply   #7878787878787878 -> #7800000000000000
decd502 apply   #7800000000000000 -> Infinity
decd503 apply   #7979797979797979 -> #7800000000000000
decd504 apply   #7900000000000000 -> Infinity
decd505 apply   #7a7a7a7a7a7a7a7a -> #7800000000000000
decd506 apply   #7a00000000000000 -> Infinity
decd507 apply   #7b7b7b7b7b7b7b7b -> #7800000000000000
decd508 apply   #7b00000000000000 -> Infinity

decd509 apply   NaN               -> #7c00000000000000
decd510 apply   #7c7c7c7c7c7c7c7c -> #7c007c7c7c7c7c7c
decd511 apply   #7c00000000000000 -> NaN
decd512 apply   #7d7d7d7d7d7d7d7d -> #7c017d7d7d7d7d7d
decd513 apply   #7d00000000000000 -> NaN
decd514 apply   #7e7e7e7e7e7e7e7e -> #7e007e7e7e7e7c7e
decd515 apply   #7e00000000000000 -> sNaN
decd516 apply   #7f7f7f7f7f7f7f7f -> #7e007f7f7f7f7c7f
decd517 apply   #7f00000000000000 -> sNaN
decd518 apply   #7fffffffffffffff -> sNaN999999999999999
decd519 apply   #7fffffffffffffff -> #7e00ff3fcff3fcff

decd520 apply   -Infinity         -> #f800000000000000
decd521 apply   #f878787878787878 -> #f800000000000000
decd522 apply   #f800000000000000 -> -Infinity
decd523 apply   #f979797979797979 -> #f800000000000000
decd524 apply   #f900000000000000 -> -Infinity
decd525 apply   #fa7a7a7a7a7a7a7a -> #f800000000000000
decd526 apply   #fa00000000000000 -> -Infinity
decd527 apply   #fb7b7b7b7b7b7b7b -> #f800000000000000
decd528 apply   #fb00000000000000 -> -Infinity

decd529 apply   -NaN              -> #fc00000000000000
decd530 apply   #fc7c7c7c7c7c7c7c -> #fc007c7c7c7c7c7c
decd531 apply   #fc00000000000000 -> -NaN
decd532 apply   #fd7d7d7d7d7d7d7d -> #fc017d7d7d7d7d7d
decd533 apply   #fd00000000000000 -> -NaN
decd534 apply   #fe7e7e7e7e7e7e7e -> #fe007e7e7e7e7c7e
decd535 apply   #fe00000000000000 -> -sNaN
decd536 apply   #ff7f7f7f7f7f7f7f -> #fe007f7f7f7f7c7f
decd537 apply   #ff00000000000000 -> -sNaN
decd538 apply   #ffffffffffffffff -> -sNaN999999999999999
decd539 apply   #ffffffffffffffff -> #fe00ff3fcff3fcff

-- diagnostic NaNs
decd540 apply   NaN                 -> #7c00000000000000
decd541 apply   NaN0                -> #7c00000000000000
decd542 apply   NaN1                -> #7c00000000000001
decd543 apply   NaN12               -> #7c00000000000012
decd544 apply   NaN79               -> #7c00000000000079
decd545 apply   NaN12345            -> #7c000000000049c5
decd546 apply   NaN123456           -> #7c00000000028e56
decd547 apply   NaN799799           -> #7c000000000f7fdf
decd548 apply   NaN799799799799799  -> #7c03dff7fdff7fdf
decd549 apply   NaN999999999999999  -> #7c00ff3fcff3fcff
-- too many digits

-- fold-down full sequence
decd601 apply   1E+384                  -> #47fc000000000000 Clamped
decd602 apply   #47fc000000000000       -> 1.000000000000000E+384
decd603 apply   1E+383                  -> #43fc800000000000 Clamped
decd604 apply   #43fc800000000000       -> 1.00000000000000E+383
decd605 apply   1E+382                  -> #43fc100000000000 Clamped
decd606 apply   #43fc100000000000       -> 1.0000000000000E+382
decd607 apply   1E+381                  -> #43fc010000000000 Clamped
decd608 apply   #43fc010000000000       -> 1.000000000000E+381
decd609 apply   1E+380                  -> #43fc002000000000 Clamped
decd610 apply   #43fc002000000000       -> 1.00000000000E+380
decd611 apply   1E+379                  -> #43fc000400000000 Clamped
decd612 apply   #43fc000400000000       -> 1.0000000000E+379
decd613 apply   1E+378                  -> #43fc000040000000 Clamped
decd614 apply   #43fc000040000000       -> 1.000000000E+378
decd615 apply   1E+377                  -> #43fc000008000000 Clamped
decd616 apply   #43fc000008000000       -> 1.00000000E+377
decd617 apply   1E+376                  -> #43fc000001000000 Clamped
decd618 apply   #43fc000001000000       -> 1.0000000E+376
decd619 apply   1E+375                  -> #43fc000000100000 Clamped
decd620 apply   #43fc000000100000       -> 1.000000E+375
decd621 apply   1E+374                  -> #43fc000000020000 Clamped
decd622 apply   #43fc000000020000       -> 1.00000E+374
decd623 apply   1E+373                  -> #43fc000000004000 Clamped
decd624 apply   #43fc000000004000       -> 1.0000E+373
decd625 apply   1E+372                  -> #43fc000000000400 Clamped
decd626 apply   #43fc000000000400       -> 1.000E+372
decd627 apply   1E+371                  -> #43fc000000000080 Clamped
decd628 apply   #43fc000000000080       -> 1.00E+371
decd629 apply   1E+370                  -> #43fc000000000010 Clamped
decd630 apply   #43fc000000000010       -> 1.0E+370
decd631 apply   1E+369                  -> #43fc000000000001
decd632 apply   #43fc000000000001       -> 1E+369
decd633 apply   1E+368                  -> #43f8000000000001
decd634 apply   #43f8000000000001       -> 1E+368
-- same with 9s
decd641 apply   9E+384                  -> #77fc000000000000 Clamped
decd642 apply   #77fc000000000000       -> 9.000000000000000E+384
decd643 apply   9E+383                  -> #43fc8c0000000000 Clamped
decd644 apply   #43fc8c0000000000       -> 9.00000000000000E+383
decd645 apply   9E+382                  -> #43fc1a0000000000 Clamped
decd646 apply   #43fc1a0000000000       -> 9.0000000000000E+382
decd647 apply   9E+381                  -> #43fc090000000000 Clamped
decd648 apply   #43fc090000000000       -> 9.000000000000E+381
decd649 apply   9E+380                  -> #43fc002300000000 Clamped
decd650 apply   #43fc002300000000       -> 9.00000000000E+380
decd651 apply   9E+379                  -> #43fc000680000000 Clamped
decd652 apply   #43fc000680000000       -> 9.0000000000E+379
decd653 apply   9E+378                  -> #43fc000240000000 Clamped
decd654 apply   #43fc000240000000       -> 9.000000000E+378
decd655 apply   9E+377                  -> #43fc000008c00000 Clamped
decd656 apply   #43fc000008c00000       -> 9.00000000E+377
decd657 apply   9E+376                  -> #43fc000001a00000 Clamped
decd658 apply   #43fc000001a00000       -> 9.0000000E+376
decd659 apply   9E+375                  -> #43fc000000900000 Clamped
decd660 apply   #43fc000000900000       -> 9.000000E+375
decd661 apply   9E+374                  -> #43fc000000023000 Clamped
decd662 apply   #43fc000000023000       -> 9.00000E+374
decd663 apply   9E+373                  -> #43fc000000006800 Clamped
decd664 apply   #43fc000000006800       -> 9.0000E+373
decd665 apply   9E+372                  -> #43fc000000002400 Clamped
decd666 apply   #43fc000000002400       -> 9.000E+372
decd667 apply   9E+371                  -> #43fc00000000008c Clamped
decd668 apply   #43fc00000000008c       -> 9.00E+371
decd669 apply   9E+370                  -> #43fc00000000001a Clamped
decd670 apply   #43fc00000000001a       -> 9.0E+370
decd671 apply   9E+369                  -> #43fc000000000009
decd672 apply   #43fc000000000009       -> 9E+369
decd673 apply   9E+368                  -> #43f8000000000009
decd674 apply   #43f8000000000009       -> 9E+368


-- Selected DPD codes
decd700 apply   #2238000000000000       -> 0
decd701 apply   #2238000000000009       -> 9
decd702 apply   #2238000000000010       -> 10
decd703 apply   #2238000000000019       -> 19
decd704 apply   #2238000000000020       -> 20
decd705 apply   #2238000000000029       -> 29
decd706 apply   #2238000000000030       -> 30
decd707 apply   #2238000000000039       -> 39
decd708 apply   #2238000000000040       -> 40
decd709 apply   #2238000000000049       -> 49
decd710 apply   #2238000000000050       -> 50
decd711 apply   #2238000000000059       -> 59
decd712 apply   #2238000000000060       -> 60
decd713 apply   #2238000000000069       -> 69
decd714 apply   #2238000000000070       -> 70
decd715 apply   #2238000000000071       -> 71
decd716 apply   #2238000000000072       -> 72
decd717 apply   #2238000000000073       -> 73
decd718 apply   #2238000000000074       -> 74
decd719 apply   #2238000000000075       -> 75
decd720 apply   #2238000000000076       -> 76
decd721 apply   #2238000000000077       -> 77
decd722 apply   #2238000000000078       -> 78
decd723 apply   #2238000000000079       -> 79

decd725 apply   #223800000000029e       -> 994
decd726 apply   #223800000000029f       -> 995
decd727 apply   #22380000000002a0       -> 520
decd728 apply   #22380000000002a1       -> 521
-- from telco test data
decd730 apply   #2238000000000188       -> 308
decd731 apply   #22380000000001a3       -> 323
decd732 apply   #223800000000002a       ->  82
decd733 apply   #22380000000001a9       -> 329
decd734 apply   #2238000000000081       -> 101
decd735 apply   #22380000000002a2       -> 522

-- DPD: one of each of the huffman groups
decd740 apply   #22380000000003f7       -> 777
decd741 apply   #22380000000003f8       -> 778
decd742 apply   #22380000000003eb       -> 787
decd743 apply   #223800000000037d       -> 877
decd744 apply   #223800000000039f       -> 997
decd745 apply   #22380000000003bf       -> 979
decd746 apply   #22380000000003df       -> 799
decd747 apply   #223800000000006e       -> 888

-- DPD all-highs cases (includes the 24 redundant codes)
decd750 apply   #223800000000006e       -> 888
decd751 apply   #223800000000016e       -> 888
decd752 apply   #223800000000026e       -> 888
decd753 apply   #223800000000036e       -> 888
decd754 apply   #223800000000006f       -> 889
decd755 apply   #223800000000016f       -> 889
decd756 apply   #223800000000026f       -> 889
decd757 apply   #223800000000036f       -> 889

decd760 apply   #223800000000007e       -> 898
decd761 apply   #223800000000017e       -> 898
decd762 apply   #223800000000027e       -> 898
decd763 apply   #223800000000037e       -> 898
decd764 apply   #223800000000007f       -> 899
decd765 apply   #223800000000017f       -> 899
decd766 apply   #223800000000027f       -> 899
decd767 apply   #223800000000037f       -> 899

decd770 apply   #22380000000000ee       -> 988
decd771 apply   #22380000000001ee       -> 988
decd772 apply   #22380000000002ee       -> 988
decd773 apply   #22380000000003ee       -> 988
decd774 apply   #22380000000000ef       -> 989
decd775 apply   #22380000000001ef       -> 989
decd776 apply   #22380000000002ef       -> 989
decd777 apply   #22380000000003ef       -> 989

decd780 apply   #22380000000000fe       -> 998
decd781 apply   #22380000000001fe       -> 998
decd782 apply   #22380000000002fe       -> 998
decd783 apply   #22380000000003fe       -> 998
decd784 apply   #22380000000000ff       -> 999
decd785 apply   #22380000000001ff       -> 999
decd786 apply   #22380000000002ff       -> 999
decd787 apply   #22380000000003ff       -> 999

-- values around [u]int32 edges (zeros done earlier)
decd800 apply -2147483646  -> #a23800008c78af46
decd801 apply -2147483647  -> #a23800008c78af47
decd802 apply -2147483648  -> #a23800008c78af48
decd803 apply -2147483649  -> #a23800008c78af49
decd804 apply  2147483646  -> #223800008c78af46
decd805 apply  2147483647  -> #223800008c78af47
decd806 apply  2147483648  -> #223800008c78af48
decd807 apply  2147483649  -> #223800008c78af49
decd808 apply  4294967294  -> #2238000115afb55a
decd809 apply  4294967295  -> #2238000115afb55b
decd810 apply  4294967296  -> #2238000115afb57a
decd811 apply  4294967297  -> #2238000115afb57b

decd820 apply  #a23800008c78af46 -> -2147483646
decd821 apply  #a23800008c78af47 -> -2147483647
decd822 apply  #a23800008c78af48 -> -2147483648
decd823 apply  #a23800008c78af49 -> -2147483649
decd824 apply  #223800008c78af46 ->  2147483646
decd825 apply  #223800008c78af47 ->  2147483647
decd826 apply  #223800008c78af48 ->  2147483648
decd827 apply  #223800008c78af49 ->  2147483649
decd828 apply  #2238000115afb55a ->  4294967294
decd829 apply  #2238000115afb55b ->  4294967295
decd830 apply  #2238000115afb57a ->  4294967296
decd831 apply  #2238000115afb57b ->  4294967297

Added test/dectest/ddFMA.decTest.













































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
------------------------------------------------------------------------
-- ddFMA.decTest -- decDouble Fused Multiply Add                      --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- These tests comprese three parts:
--   1. Sanity checks and other three-operand tests (especially those
--      where the fused operation makes a difference)
--   2. Multiply tests (third operand is neutral zero [0E+emax])
--   3. Addition tests (first operand is 1)
-- The multiply and addition tests are extensive because FMA may have
-- its own dedicated multiplication or addition routine(s), and they
-- also inherently check the left-to-right properties.

-- Sanity checks
ddfma0001 fma  1   1   1 ->   2
ddfma0002 fma  1   1   2 ->   3
ddfma0003 fma  2   2   3 ->   7
ddfma0004 fma  9   9   9 ->  90
ddfma0005 fma -1   1   1 ->   0
ddfma0006 fma -1   1   2 ->   1
ddfma0007 fma -2   2   3 ->  -1
ddfma0008 fma -9   9   9 -> -72
ddfma0011 fma  1  -1   1 ->   0
ddfma0012 fma  1  -1   2 ->   1
ddfma0013 fma  2  -2   3 ->  -1
ddfma0014 fma  9  -9   9 -> -72
ddfma0015 fma  1   1  -1 ->   0
ddfma0016 fma  1   1  -2 ->  -1
ddfma0017 fma  2   2  -3 ->   1
ddfma0018 fma  9   9  -9 ->  72

-- non-integer exacts
ddfma0100  fma    25.2   63.6   -438  ->  1164.72
ddfma0101  fma   0.301  0.380    334  ->  334.114380
ddfma0102  fma    49.2   -4.8   23.3  ->  -212.86
ddfma0103  fma    4.22  0.079  -94.6  ->  -94.26662
ddfma0104  fma     903  0.797  0.887  ->  720.578
ddfma0105  fma    6.13   -161   65.9  ->  -921.03
ddfma0106  fma    28.2    727   5.45  ->  20506.85
ddfma0107  fma       4    605    688  ->  3108
ddfma0108  fma    93.3   0.19  0.226  ->  17.953
ddfma0109  fma   0.169   -341   5.61  ->  -52.019
ddfma0110  fma   -72.2     30  -51.2  ->  -2217.2
ddfma0111  fma  -0.409     13   20.4  ->  15.083
ddfma0112  fma     317   77.0   19.0  ->  24428.0
ddfma0113  fma      47   6.58   1.62  ->  310.88
ddfma0114  fma    1.36  0.984  0.493  ->  1.83124
ddfma0115  fma    72.7    274   1.56  ->  19921.36
ddfma0116  fma     335    847     83  ->  283828
ddfma0117  fma     666  0.247   25.4  ->  189.902
ddfma0118  fma   -3.87   3.06   78.0  ->  66.1578
ddfma0119  fma   0.742    192   35.6  ->  178.064
ddfma0120  fma   -91.6   5.29  0.153  ->  -484.411

-- cases where result is different from separate multiply + add; each
-- is preceded by the result of unfused multiply and add
-- [this is about 20% of all similar  cases in general]
--                                                                      ->  7.123356429257969E+16
ddfma0201  fma       27583489.6645      2582471078.04      2593183.42371  ->  7.123356429257970E+16  Inexact Rounded
--                                                                      ->  22813275328.80506
ddfma0208  fma        24280.355566      939577.397653        2032.013252  ->  22813275328.80507      Inexact Rounded
--                                                                      ->  -2.030397734278062E+16
ddfma0209  fma          7848976432      -2586831.2281      137903.517909  ->  -2.030397734278061E+16 Inexact Rounded
--                                                                      ->  2040774094814.077
ddfma0217  fma        56890.388731      35872030.4255      339337.123410  ->  2040774094814.078      Inexact Rounded
--                                                                      ->  2.714469575205049E+18
ddfma0220  fma       7533543.57445       360317763928      5073392.31638  ->  2.714469575205050E+18  Inexact Rounded
--                                                                      ->  1.011676297716716E+19
ddfma0223  fma       739945255.563      13672312784.1      -994381.53572  ->  1.011676297716715E+19  Inexact Rounded
--                                                                      ->  -2.914135721455315E+23
ddfma0224  fma       -413510957218       704729988550       9234162614.0  ->  -2.914135721455314E+23 Inexact Rounded
--                                                                      ->  2.620119863365786E+17
ddfma0226  fma        437484.00601       598906432790      894450638.442  ->  2.620119863365787E+17  Inexact Rounded
--                                                                      ->  1.272647995808178E+19
ddfma0253  fma         73287556929      173651305.784     -358312568.389  ->  1.272647995808177E+19  Inexact Rounded
--                                                                      ->  -1.753769320861851E+18
ddfma0257  fma        203258304486      -8628278.8066      153127.446727  ->  -1.753769320861850E+18 Inexact Rounded
--                                                                      ->  -1.550737835263346E+17
ddfma0260  fma       42560533.1774     -3643605282.86       178277.96377  ->  -1.550737835263347E+17 Inexact Rounded
--                                                                      ->  2.897624620576005E+22
ddfma0269  fma        142656587375       203118879670       604576103991  ->  2.897624620576004E+22  Inexact Rounded

-- Cases where multiply would overflow or underflow if separate
fma0300  fma   9e+384    10   0         -> Infinity  Overflow Inexact Rounded
fma0301  fma   1e+384    10   0         -> Infinity  Overflow Inexact Rounded
fma0302  fma   1e+384    10   -1e+384   -> 9.000000000000000E+384  Clamped
fma0303  fma   1e+384    10   -9e+384   -> 1.000000000000000E+384  Clamped
-- subnormal etc.
fma0305  fma   1e-398    0.1  0         -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
fma0306  fma   1e-398    0.1  1         -> 1.000000000000000 Inexact Rounded
fma0307  fma   1e-398    0.1  1e-398    -> 1E-398 Underflow Subnormal Inexact Rounded

-- Infinite combinations
ddfma0800 fma  Inf   Inf   Inf    ->  Infinity
ddfma0801 fma  Inf   Inf  -Inf    ->  NaN Invalid_operation
ddfma0802 fma  Inf  -Inf   Inf    ->  NaN Invalid_operation
ddfma0803 fma  Inf  -Inf  -Inf    -> -Infinity
ddfma0804 fma -Inf   Inf   Inf    ->  NaN Invalid_operation
ddfma0805 fma -Inf   Inf  -Inf    -> -Infinity
ddfma0806 fma -Inf  -Inf   Inf    ->  Infinity
ddfma0807 fma -Inf  -Inf  -Inf    ->  NaN Invalid_operation

-- Triple NaN propagation
ddfma0900 fma  NaN2  NaN3  NaN5   ->  NaN2
ddfma0901 fma  0     NaN3  NaN5   ->  NaN3
ddfma0902 fma  0     0     NaN5   ->  NaN5
-- first sNaN wins (consider qNaN from earlier sNaN being
-- overridden by an sNaN in third operand)
ddfma0903 fma  sNaN1 sNaN2 sNaN3  ->  NaN1 Invalid_operation
ddfma0904 fma  0     sNaN2 sNaN3  ->  NaN2 Invalid_operation
ddfma0905 fma  0     0     sNaN3  ->  NaN3 Invalid_operation
ddfma0906 fma  sNaN1 sNaN2 sNaN3  ->  NaN1 Invalid_operation
ddfma0907 fma  NaN7  sNaN2 sNaN3  ->  NaN2 Invalid_operation
ddfma0908 fma  NaN7  NaN5  sNaN3  ->  NaN3 Invalid_operation

-- MULTIPLICATION TESTS ------------------------------------------------

-- sanity checks
ddfma2000 fma  2      2   0e+384  ->  4
ddfma2001 fma  2      3   0e+384  ->  6
ddfma2002 fma  5      1   0e+384  ->  5
ddfma2003 fma  5      2   0e+384  ->  10
ddfma2004 fma  1.20   2   0e+384  ->  2.40
ddfma2005 fma  1.20   0   0e+384  ->  0.00
ddfma2006 fma  1.20  -2   0e+384  ->  -2.40
ddfma2007 fma  -1.20  2   0e+384  ->  -2.40
ddfma2008 fma  -1.20  0   0e+384  ->  0.00
ddfma2009 fma  -1.20 -2   0e+384  ->  2.40
ddfma2010 fma  5.09 7.1   0e+384  ->  36.139
ddfma2011 fma  2.5    4   0e+384  ->  10.0
ddfma2012 fma  2.50   4   0e+384  ->  10.00
ddfma2013 fma  1.23456789 1.00000000   0e+384  ->  1.234567890000000 Rounded
ddfma2015 fma  2.50   4   0e+384  ->  10.00
ddfma2016 fma   9.999999999  9.999999999   0e+384  ->   99.99999998000000 Inexact Rounded
ddfma2017 fma   9.999999999 -9.999999999   0e+384  ->  -99.99999998000000 Inexact Rounded
ddfma2018 fma  -9.999999999  9.999999999   0e+384  ->  -99.99999998000000 Inexact Rounded
ddfma2019 fma  -9.999999999 -9.999999999   0e+384  ->   99.99999998000000 Inexact Rounded

-- zeros, etc.
ddfma2021 fma   0      0       0e+384  ->   0
ddfma2022 fma   0     -0       0e+384  ->   0
ddfma2023 fma  -0      0       0e+384  ->   0
ddfma2024 fma  -0     -0       0e+384  ->   0
ddfma2025 fma  -0.0   -0.0     0e+384  ->   0.00
ddfma2026 fma  -0.0   -0.0     0e+384  ->   0.00
ddfma2027 fma  -0.0   -0.0     0e+384  ->   0.00
ddfma2028 fma  -0.0   -0.0     0e+384  ->   0.00
ddfma2030 fma   5.00   1E-3    0e+384  ->   0.00500
ddfma2031 fma   00.00  0.000   0e+384  ->   0.00000
ddfma2032 fma   00.00  0E-3    0e+384  ->   0.00000     -- rhs is 0
ddfma2033 fma   0E-3   00.00   0e+384  ->   0.00000     -- lhs is 0
ddfma2034 fma  -5.00   1E-3    0e+384  ->  -0.00500
ddfma2035 fma  -00.00  0.000   0e+384  ->   0.00000
ddfma2036 fma  -00.00  0E-3    0e+384  ->   0.00000     -- rhs is 0
ddfma2037 fma  -0E-3   00.00   0e+384  ->   0.00000     -- lhs is 0
ddfma2038 fma   5.00  -1E-3    0e+384  ->  -0.00500
ddfma2039 fma   00.00 -0.000   0e+384  ->   0.00000
ddfma2040 fma   00.00 -0E-3    0e+384  ->   0.00000     -- rhs is 0
ddfma2041 fma   0E-3  -00.00   0e+384  ->   0.00000     -- lhs is 0
ddfma2042 fma  -5.00  -1E-3    0e+384  ->   0.00500
ddfma2043 fma  -00.00 -0.000   0e+384  ->   0.00000
ddfma2044 fma  -00.00 -0E-3    0e+384  ->   0.00000     -- rhs is 0
ddfma2045 fma  -0E-3  -00.00  -0e+384  ->   0.00000     -- lhs is 0
ddfma2046 fma  -0E-3   00.00  -0e+384  ->  -0.00000
ddfma2047 fma   0E-3  -00.00  -0e+384  ->  -0.00000
ddfma2048 fma   0E-3   00.00  -0e+384  ->   0.00000

-- examples from decarith
ddfma2050 fma  1.20 3          0e+384  ->  3.60
ddfma2051 fma  7    3          0e+384  ->  21
ddfma2052 fma  0.9  0.8        0e+384  ->  0.72
ddfma2053 fma  0.9  -0         0e+384  ->  0.0
ddfma2054 fma  654321 654321   0e+384  ->  428135971041

ddfma2060 fma  123.45 1e7    0e+384  ->   1.2345E+9
ddfma2061 fma  123.45 1e8    0e+384  ->   1.2345E+10
ddfma2062 fma  123.45 1e+9   0e+384  ->   1.2345E+11
ddfma2063 fma  123.45 1e10   0e+384  ->   1.2345E+12
ddfma2064 fma  123.45 1e11   0e+384  ->   1.2345E+13
ddfma2065 fma  123.45 1e12   0e+384  ->   1.2345E+14
ddfma2066 fma  123.45 1e13   0e+384  ->   1.2345E+15


-- test some intermediate lengths
--                    1234567890123456
ddfma2080 fma  0.1 1230123456456789       0e+384  ->  123012345645678.9
ddfma2084 fma  0.1 1230123456456789       0e+384  ->  123012345645678.9
ddfma2090 fma  1230123456456789     0.1   0e+384  ->  123012345645678.9
ddfma2094 fma  1230123456456789     0.1   0e+384  ->  123012345645678.9

-- test some more edge cases and carries
ddfma2101 fma  9 9     0e+384  ->  81
ddfma2102 fma  9 90     0e+384  ->  810
ddfma2103 fma  9 900     0e+384  ->  8100
ddfma2104 fma  9 9000     0e+384  ->  81000
ddfma2105 fma  9 90000     0e+384  ->  810000
ddfma2106 fma  9 900000     0e+384  ->  8100000
ddfma2107 fma  9 9000000     0e+384  ->  81000000
ddfma2108 fma  9 90000000     0e+384  ->  810000000
ddfma2109 fma  9 900000000     0e+384  ->  8100000000
ddfma2110 fma  9 9000000000     0e+384  ->  81000000000
ddfma2111 fma  9 90000000000     0e+384  ->  810000000000
ddfma2112 fma  9 900000000000     0e+384  ->  8100000000000
ddfma2113 fma  9 9000000000000     0e+384  ->  81000000000000
ddfma2114 fma  9 90000000000000     0e+384  ->  810000000000000
ddfma2115 fma  9 900000000000000     0e+384  ->  8100000000000000
--ddfma2116 fma  9 9000000000000000     0e+384  ->  81000000000000000
--ddfma2117 fma  9 90000000000000000     0e+384  ->  810000000000000000
--ddfma2118 fma  9 900000000000000000     0e+384  ->  8100000000000000000
--ddfma2119 fma  9 9000000000000000000     0e+384  ->  81000000000000000000
--ddfma2120 fma  9 90000000000000000000     0e+384  ->  810000000000000000000
--ddfma2121 fma  9 900000000000000000000     0e+384  ->  8100000000000000000000
--ddfma2122 fma  9 9000000000000000000000     0e+384  ->  81000000000000000000000
--ddfma2123 fma  9 90000000000000000000000     0e+384  ->  810000000000000000000000
-- test some more edge cases without carries
ddfma2131 fma  3 3     0e+384  ->  9
ddfma2132 fma  3 30     0e+384  ->  90
ddfma2133 fma  3 300     0e+384  ->  900
ddfma2134 fma  3 3000     0e+384  ->  9000
ddfma2135 fma  3 30000     0e+384  ->  90000
ddfma2136 fma  3 300000     0e+384  ->  900000
ddfma2137 fma  3 3000000     0e+384  ->  9000000
ddfma2138 fma  3 30000000     0e+384  ->  90000000
ddfma2139 fma  3 300000000     0e+384  ->  900000000
ddfma2140 fma  3 3000000000     0e+384  ->  9000000000
ddfma2141 fma  3 30000000000     0e+384  ->  90000000000
ddfma2142 fma  3 300000000000     0e+384  ->  900000000000
ddfma2143 fma  3 3000000000000     0e+384  ->  9000000000000
ddfma2144 fma  3 30000000000000     0e+384  ->  90000000000000
ddfma2145 fma  3 300000000000000     0e+384  ->  900000000000000

-- test some edge cases with exact rounding
ddfma2301 fma  9 9     0e+384  ->  81
ddfma2302 fma  9 90     0e+384  ->  810
ddfma2303 fma  9 900     0e+384  ->  8100
ddfma2304 fma  9 9000     0e+384  ->  81000
ddfma2305 fma  9 90000     0e+384  ->  810000
ddfma2306 fma  9 900000     0e+384  ->  8100000
ddfma2307 fma  9 9000000     0e+384  ->  81000000
ddfma2308 fma  9 90000000     0e+384  ->  810000000
ddfma2309 fma  9 900000000     0e+384  ->  8100000000
ddfma2310 fma  9 9000000000     0e+384  ->  81000000000
ddfma2311 fma  9 90000000000     0e+384  ->  810000000000
ddfma2312 fma  9 900000000000     0e+384  ->  8100000000000
ddfma2313 fma  9 9000000000000     0e+384  ->  81000000000000
ddfma2314 fma  9 90000000000000     0e+384  ->  810000000000000
ddfma2315 fma  9 900000000000000     0e+384  ->  8100000000000000
ddfma2316 fma  9 9000000000000000     0e+384  ->  8.100000000000000E+16  Rounded
ddfma2317 fma  90 9000000000000000     0e+384  ->  8.100000000000000E+17  Rounded
ddfma2318 fma  900 9000000000000000     0e+384  ->  8.100000000000000E+18  Rounded
ddfma2319 fma  9000 9000000000000000     0e+384  ->  8.100000000000000E+19  Rounded
ddfma2320 fma  90000 9000000000000000     0e+384  ->  8.100000000000000E+20  Rounded
ddfma2321 fma  900000 9000000000000000     0e+384  ->  8.100000000000000E+21  Rounded
ddfma2322 fma  9000000 9000000000000000     0e+384  ->  8.100000000000000E+22  Rounded
ddfma2323 fma  90000000 9000000000000000     0e+384  ->  8.100000000000000E+23  Rounded

-- tryzeros cases
ddfma2504  fma   0E-260 1000E-260    0e+384  ->  0E-398 Clamped
ddfma2505  fma   100E+260 0E+260     0e+384  ->  0E+369 Clamped

-- mixed with zeros
ddfma2541 fma   0    -1       0e+384  ->   0
ddfma2542 fma  -0    -1       0e+384  ->   0
ddfma2543 fma   0     1       0e+384  ->   0
ddfma2544 fma  -0     1       0e+384  ->   0
ddfma2545 fma  -1     0       0e+384  ->   0
ddfma2546 fma  -1    -0       0e+384  ->   0
ddfma2547 fma   1     0       0e+384  ->   0
ddfma2548 fma   1    -0       0e+384  ->   0

ddfma2551 fma   0.0  -1       0e+384  ->   0.0
ddfma2552 fma  -0.0  -1       0e+384  ->   0.0
ddfma2553 fma   0.0   1       0e+384  ->   0.0
ddfma2554 fma  -0.0   1       0e+384  ->   0.0
ddfma2555 fma  -1.0   0       0e+384  ->   0.0
ddfma2556 fma  -1.0  -0       0e+384  ->   0.0
ddfma2557 fma   1.0   0       0e+384  ->   0.0
ddfma2558 fma   1.0  -0       0e+384  ->   0.0

ddfma2561 fma   0    -1.0     0e+384  ->   0.0
ddfma2562 fma  -0    -1.0     0e+384  ->   0.0
ddfma2563 fma   0     1.0     0e+384  ->   0.0
ddfma2564 fma  -0     1.0     0e+384  ->   0.0
ddfma2565 fma  -1     0.0     0e+384  ->   0.0
ddfma2566 fma  -1    -0.0     0e+384  ->   0.0
ddfma2567 fma   1     0.0     0e+384  ->   0.0
ddfma2568 fma   1    -0.0     0e+384  ->   0.0

ddfma2571 fma   0.0  -1.0     0e+384  ->   0.00
ddfma2572 fma  -0.0  -1.0     0e+384  ->   0.00
ddfma2573 fma   0.0   1.0     0e+384  ->   0.00
ddfma2574 fma  -0.0   1.0     0e+384  ->   0.00
ddfma2575 fma  -1.0   0.0     0e+384  ->   0.00
ddfma2576 fma  -1.0  -0.0     0e+384  ->   0.00
ddfma2577 fma   1.0   0.0     0e+384  ->   0.00
ddfma2578 fma   1.0  -0.0     0e+384  ->   0.00

-- Specials
ddfma2580 fma   Inf  -Inf     0e+384  ->  -Infinity
ddfma2581 fma   Inf  -1000    0e+384  ->  -Infinity
ddfma2582 fma   Inf  -1       0e+384  ->  -Infinity
ddfma2583 fma   Inf  -0       0e+384  ->   NaN  Invalid_operation
ddfma2584 fma   Inf   0       0e+384  ->   NaN  Invalid_operation
ddfma2585 fma   Inf   1       0e+384  ->   Infinity
ddfma2586 fma   Inf   1000    0e+384  ->   Infinity
ddfma2587 fma   Inf   Inf     0e+384  ->   Infinity
ddfma2588 fma  -1000  Inf     0e+384  ->  -Infinity
ddfma2589 fma  -Inf   Inf     0e+384  ->  -Infinity
ddfma2590 fma  -1     Inf     0e+384  ->  -Infinity
ddfma2591 fma  -0     Inf     0e+384  ->   NaN  Invalid_operation
ddfma2592 fma   0     Inf     0e+384  ->   NaN  Invalid_operation
ddfma2593 fma   1     Inf     0e+384  ->   Infinity
ddfma2594 fma   1000  Inf     0e+384  ->   Infinity
ddfma2595 fma   Inf   Inf     0e+384  ->   Infinity

ddfma2600 fma  -Inf  -Inf     0e+384  ->   Infinity
ddfma2601 fma  -Inf  -1000    0e+384  ->   Infinity
ddfma2602 fma  -Inf  -1       0e+384  ->   Infinity
ddfma2603 fma  -Inf  -0       0e+384  ->   NaN  Invalid_operation
ddfma2604 fma  -Inf   0       0e+384  ->   NaN  Invalid_operation
ddfma2605 fma  -Inf   1       0e+384  ->  -Infinity
ddfma2606 fma  -Inf   1000    0e+384  ->  -Infinity
ddfma2607 fma  -Inf   Inf     0e+384  ->  -Infinity
ddfma2608 fma  -1000  Inf     0e+384  ->  -Infinity
ddfma2609 fma  -Inf  -Inf     0e+384  ->   Infinity
ddfma2610 fma  -1    -Inf     0e+384  ->   Infinity
ddfma2611 fma  -0    -Inf     0e+384  ->   NaN  Invalid_operation
ddfma2612 fma   0    -Inf     0e+384  ->   NaN  Invalid_operation
ddfma2613 fma   1    -Inf     0e+384  ->  -Infinity
ddfma2614 fma   1000 -Inf     0e+384  ->  -Infinity
ddfma2615 fma   Inf  -Inf     0e+384  ->  -Infinity

ddfma2621 fma   NaN -Inf      0e+384  ->   NaN
ddfma2622 fma   NaN -1000     0e+384  ->   NaN
ddfma2623 fma   NaN -1        0e+384  ->   NaN
ddfma2624 fma   NaN -0        0e+384  ->   NaN
ddfma2625 fma   NaN  0        0e+384  ->   NaN
ddfma2626 fma   NaN  1        0e+384  ->   NaN
ddfma2627 fma   NaN  1000     0e+384  ->   NaN
ddfma2628 fma   NaN  Inf      0e+384  ->   NaN
ddfma2629 fma   NaN  NaN      0e+384  ->   NaN
ddfma2630 fma  -Inf  NaN      0e+384  ->   NaN
ddfma2631 fma  -1000 NaN      0e+384  ->   NaN
ddfma2632 fma  -1    NaN      0e+384  ->   NaN
ddfma2633 fma  -0    NaN      0e+384  ->   NaN
ddfma2634 fma   0    NaN      0e+384  ->   NaN
ddfma2635 fma   1    NaN      0e+384  ->   NaN
ddfma2636 fma   1000 NaN      0e+384  ->   NaN
ddfma2637 fma   Inf  NaN      0e+384  ->   NaN

ddfma2641 fma   sNaN -Inf     0e+384  ->   NaN  Invalid_operation
ddfma2642 fma   sNaN -1000    0e+384  ->   NaN  Invalid_operation
ddfma2643 fma   sNaN -1       0e+384  ->   NaN  Invalid_operation
ddfma2644 fma   sNaN -0       0e+384  ->   NaN  Invalid_operation
ddfma2645 fma   sNaN  0       0e+384  ->   NaN  Invalid_operation
ddfma2646 fma   sNaN  1       0e+384  ->   NaN  Invalid_operation
ddfma2647 fma   sNaN  1000    0e+384  ->   NaN  Invalid_operation
ddfma2648 fma   sNaN  NaN     0e+384  ->   NaN  Invalid_operation
ddfma2649 fma   sNaN sNaN     0e+384  ->   NaN  Invalid_operation
ddfma2650 fma   NaN  sNaN     0e+384  ->   NaN  Invalid_operation
ddfma2651 fma  -Inf  sNaN     0e+384  ->   NaN  Invalid_operation
ddfma2652 fma  -1000 sNaN     0e+384  ->   NaN  Invalid_operation
ddfma2653 fma  -1    sNaN     0e+384  ->   NaN  Invalid_operation
ddfma2654 fma  -0    sNaN     0e+384  ->   NaN  Invalid_operation
ddfma2655 fma   0    sNaN     0e+384  ->   NaN  Invalid_operation
ddfma2656 fma   1    sNaN     0e+384  ->   NaN  Invalid_operation
ddfma2657 fma   1000 sNaN     0e+384  ->   NaN  Invalid_operation
ddfma2658 fma   Inf  sNaN     0e+384  ->   NaN  Invalid_operation
ddfma2659 fma   NaN  sNaN     0e+384  ->   NaN  Invalid_operation

-- propagating NaNs
ddfma2661 fma   NaN9 -Inf     0e+384  ->   NaN9
ddfma2662 fma   NaN8  999     0e+384  ->   NaN8
ddfma2663 fma   NaN71 Inf     0e+384  ->   NaN71
ddfma2664 fma   NaN6  NaN5    0e+384  ->   NaN6
ddfma2665 fma  -Inf   NaN4    0e+384  ->   NaN4
ddfma2666 fma  -999   NaN33   0e+384  ->   NaN33
ddfma2667 fma   Inf   NaN2    0e+384  ->   NaN2

ddfma2671 fma   sNaN99 -Inf      0e+384  ->   NaN99 Invalid_operation
ddfma2672 fma   sNaN98 -11       0e+384  ->   NaN98 Invalid_operation
ddfma2673 fma   sNaN97  NaN      0e+384  ->   NaN97 Invalid_operation
ddfma2674 fma   sNaN16 sNaN94    0e+384  ->   NaN16 Invalid_operation
ddfma2675 fma   NaN95  sNaN93    0e+384  ->   NaN93 Invalid_operation
ddfma2676 fma  -Inf    sNaN92    0e+384  ->   NaN92 Invalid_operation
ddfma2677 fma   088    sNaN91    0e+384  ->   NaN91 Invalid_operation
ddfma2678 fma   Inf    sNaN90    0e+384  ->   NaN90 Invalid_operation
ddfma2679 fma   NaN    sNaN89    0e+384  ->   NaN89 Invalid_operation

ddfma2681 fma  -NaN9 -Inf     0e+384  ->  -NaN9
ddfma2682 fma  -NaN8  999     0e+384  ->  -NaN8
ddfma2683 fma  -NaN71 Inf     0e+384  ->  -NaN71
ddfma2684 fma  -NaN6 -NaN5    0e+384  ->  -NaN6
ddfma2685 fma  -Inf  -NaN4    0e+384  ->  -NaN4
ddfma2686 fma  -999  -NaN33   0e+384  ->  -NaN33
ddfma2687 fma   Inf  -NaN2    0e+384  ->  -NaN2

ddfma2691 fma  -sNaN99 -Inf      0e+384  ->  -NaN99 Invalid_operation
ddfma2692 fma  -sNaN98 -11       0e+384  ->  -NaN98 Invalid_operation
ddfma2693 fma  -sNaN97  NaN      0e+384  ->  -NaN97 Invalid_operation
ddfma2694 fma  -sNaN16 -sNaN94   0e+384  ->  -NaN16 Invalid_operation
ddfma2695 fma  -NaN95  -sNaN93   0e+384  ->  -NaN93 Invalid_operation
ddfma2696 fma  -Inf    -sNaN92   0e+384  ->  -NaN92 Invalid_operation
ddfma2697 fma   088    -sNaN91   0e+384  ->  -NaN91 Invalid_operation
ddfma2698 fma   Inf    -sNaN90   0e+384  ->  -NaN90 Invalid_operation
ddfma2699 fma  -NaN    -sNaN89   0e+384  ->  -NaN89 Invalid_operation

ddfma2701 fma  -NaN  -Inf     0e+384  ->  -NaN
ddfma2702 fma  -NaN   999     0e+384  ->  -NaN
ddfma2703 fma  -NaN   Inf     0e+384  ->  -NaN
ddfma2704 fma  -NaN  -NaN     0e+384  ->  -NaN
ddfma2705 fma  -Inf  -NaN0    0e+384  ->  -NaN
ddfma2706 fma  -999  -NaN     0e+384  ->  -NaN
ddfma2707 fma   Inf  -NaN     0e+384  ->  -NaN

ddfma2711 fma  -sNaN   -Inf      0e+384  ->  -NaN Invalid_operation
ddfma2712 fma  -sNaN   -11       0e+384  ->  -NaN Invalid_operation
ddfma2713 fma  -sNaN00  NaN      0e+384  ->  -NaN Invalid_operation
ddfma2714 fma  -sNaN   -sNaN     0e+384  ->  -NaN Invalid_operation
ddfma2715 fma  -NaN    -sNaN     0e+384  ->  -NaN Invalid_operation
ddfma2716 fma  -Inf    -sNaN     0e+384  ->  -NaN Invalid_operation
ddfma2717 fma   088    -sNaN     0e+384  ->  -NaN Invalid_operation
ddfma2718 fma   Inf    -sNaN     0e+384  ->  -NaN Invalid_operation
ddfma2719 fma  -NaN    -sNaN     0e+384  ->  -NaN Invalid_operation

-- overflow and underflow tests .. note subnormal results
-- signs
ddfma2751 fma   1e+277  1e+311   0e+384  ->   Infinity Overflow Inexact Rounded
ddfma2752 fma   1e+277 -1e+311   0e+384  ->  -Infinity Overflow Inexact Rounded
ddfma2753 fma  -1e+277  1e+311   0e+384  ->  -Infinity Overflow Inexact Rounded
ddfma2754 fma  -1e+277 -1e+311   0e+384  ->   Infinity Overflow Inexact Rounded
ddfma2755 fma   1e-277  1e-311   0e+384  ->   0E-398 Underflow Subnormal Inexact Rounded Clamped
ddfma2756 fma   1e-277 -1e-311   0e+384  ->  -0E-398 Underflow Subnormal Inexact Rounded Clamped
ddfma2757 fma  -1e-277  1e-311   0e+384  ->  -0E-398 Underflow Subnormal Inexact Rounded Clamped
ddfma2758 fma  -1e-277 -1e-311   0e+384  ->   0E-398 Underflow Subnormal Inexact Rounded Clamped

-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
ddfma2760 fma  1e-291 1e-101   0e+384  ->  1E-392 Subnormal
ddfma2761 fma  1e-291 1e-102   0e+384  ->  1E-393 Subnormal
ddfma2762 fma  1e-291 1e-103   0e+384  ->  1E-394 Subnormal
ddfma2763 fma  1e-291 1e-104   0e+384  ->  1E-395 Subnormal
ddfma2764 fma  1e-291 1e-105   0e+384  ->  1E-396 Subnormal
ddfma2765 fma  1e-291 1e-106   0e+384  ->  1E-397 Subnormal
ddfma2766 fma  1e-291 1e-107   0e+384  ->  1E-398 Subnormal
ddfma2767 fma  1e-291 1e-108   0e+384  ->  0E-398 Underflow Subnormal Inexact Rounded Clamped
ddfma2768 fma  1e-291 1e-109   0e+384  ->  0E-398 Underflow Subnormal Inexact Rounded Clamped
ddfma2769 fma  1e-291 1e-110   0e+384  ->  0E-398 Underflow Subnormal Inexact Rounded Clamped
-- [no equivalent of 'subnormal' for overflow]
ddfma2770 fma  1e+60 1e+321   0e+384  ->  1.000000000000E+381  Clamped
ddfma2771 fma  1e+60 1e+322   0e+384  ->  1.0000000000000E+382  Clamped
ddfma2772 fma  1e+60 1e+323   0e+384  ->  1.00000000000000E+383  Clamped
ddfma2773 fma  1e+60 1e+324   0e+384  ->  1.000000000000000E+384  Clamped
ddfma2774 fma  1e+60 1e+325   0e+384  ->  Infinity Overflow Inexact Rounded
ddfma2775 fma  1e+60 1e+326   0e+384  ->  Infinity Overflow Inexact Rounded
ddfma2776 fma  1e+60 1e+327   0e+384  ->  Infinity Overflow Inexact Rounded
ddfma2777 fma  1e+60 1e+328   0e+384  ->  Infinity Overflow Inexact Rounded
ddfma2778 fma  1e+60 1e+329   0e+384  ->  Infinity Overflow Inexact Rounded
ddfma2779 fma  1e+60 1e+330   0e+384  ->  Infinity Overflow Inexact Rounded

ddfma2801 fma   1.0000E-394  1       0e+384  ->  1.0000E-394 Subnormal
ddfma2802 fma   1.000E-394   1e-1    0e+384  ->  1.000E-395  Subnormal
ddfma2803 fma   1.00E-394    1e-2    0e+384  ->  1.00E-396   Subnormal
ddfma2804 fma   1.0E-394     1e-3    0e+384  ->  1.0E-397    Subnormal
ddfma2805 fma   1.0E-394     1e-4    0e+384  ->  1E-398     Subnormal Rounded
ddfma2806 fma   1.3E-394     1e-4    0e+384  ->  1E-398     Underflow Subnormal Inexact Rounded
ddfma2807 fma   1.5E-394     1e-4    0e+384  ->  2E-398     Underflow Subnormal Inexact Rounded
ddfma2808 fma   1.7E-394     1e-4    0e+384  ->  2E-398     Underflow Subnormal Inexact Rounded
ddfma2809 fma   2.3E-394     1e-4    0e+384  ->  2E-398     Underflow Subnormal Inexact Rounded
ddfma2810 fma   2.5E-394     1e-4    0e+384  ->  2E-398     Underflow Subnormal Inexact Rounded
ddfma2811 fma   2.7E-394     1e-4    0e+384  ->  3E-398     Underflow Subnormal Inexact Rounded
ddfma2812 fma   1.49E-394    1e-4    0e+384  ->  1E-398     Underflow Subnormal Inexact Rounded
ddfma2813 fma   1.50E-394    1e-4    0e+384  ->  2E-398     Underflow Subnormal Inexact Rounded
ddfma2814 fma   1.51E-394    1e-4    0e+384  ->  2E-398     Underflow Subnormal Inexact Rounded
ddfma2815 fma   2.49E-394    1e-4    0e+384  ->  2E-398     Underflow Subnormal Inexact Rounded
ddfma2816 fma   2.50E-394    1e-4    0e+384  ->  2E-398     Underflow Subnormal Inexact Rounded
ddfma2817 fma   2.51E-394    1e-4    0e+384  ->  3E-398     Underflow Subnormal Inexact Rounded

ddfma2818 fma   1E-394       1e-4    0e+384  ->  1E-398     Subnormal
ddfma2819 fma   3E-394       1e-5    0e+384  ->  0E-398     Underflow Subnormal Inexact Rounded Clamped
ddfma2820 fma   5E-394       1e-5    0e+384  ->  0E-398     Underflow Subnormal Inexact Rounded Clamped
ddfma2821 fma   7E-394       1e-5    0e+384  ->  1E-398     Underflow Subnormal Inexact Rounded
ddfma2822 fma   9E-394       1e-5    0e+384  ->  1E-398     Underflow Subnormal Inexact Rounded
ddfma2823 fma   9.9E-394     1e-5    0e+384  ->  1E-398     Underflow Subnormal Inexact Rounded

ddfma2824 fma   1E-394      -1e-4    0e+384  ->  -1E-398    Subnormal
ddfma2825 fma   3E-394      -1e-5    0e+384  ->  -0E-398    Underflow Subnormal Inexact Rounded Clamped
ddfma2826 fma  -5E-394       1e-5    0e+384  ->  -0E-398    Underflow Subnormal Inexact Rounded Clamped
ddfma2827 fma   7E-394      -1e-5    0e+384  ->  -1E-398    Underflow Subnormal Inexact Rounded
ddfma2828 fma  -9E-394       1e-5    0e+384  ->  -1E-398    Underflow Subnormal Inexact Rounded
ddfma2829 fma   9.9E-394    -1e-5    0e+384  ->  -1E-398    Underflow Subnormal Inexact Rounded
ddfma2830 fma   3.0E-394    -1e-5    0e+384  ->  -0E-398    Underflow Subnormal Inexact Rounded Clamped

ddfma2831 fma   1.0E-199     1e-200   0e+384  ->  0E-398 Underflow Subnormal Inexact Rounded Clamped
ddfma2832 fma   1.0E-199     1e-199   0e+384  ->  1E-398    Subnormal Rounded
ddfma2833 fma   1.0E-199     1e-198   0e+384  ->  1.0E-397    Subnormal
ddfma2834 fma   2.0E-199     2e-198   0e+384  ->  4.0E-397    Subnormal
ddfma2835 fma   4.0E-199     4e-198   0e+384  ->  1.60E-396   Subnormal
ddfma2836 fma  10.0E-199    10e-198   0e+384  ->  1.000E-395  Subnormal
ddfma2837 fma  30.0E-199    30e-198   0e+384  ->  9.000E-395  Subnormal
ddfma2838 fma  40.0E-199    40e-188   0e+384  ->  1.6000E-384 Subnormal
ddfma2839 fma  40.0E-199    40e-187   0e+384  ->  1.6000E-383
ddfma2840 fma  40.0E-199    40e-186   0e+384  ->  1.6000E-382

-- Long operand overflow may be a different path
ddfma2870 fma  100  9.999E+383           0e+384  ->   Infinity Inexact Overflow Rounded
ddfma2871 fma  100 -9.999E+383       0e+384  ->  -Infinity Inexact Overflow Rounded
ddfma2872 fma       9.999E+383 100   0e+384  ->   Infinity Inexact Overflow Rounded
ddfma2873 fma      -9.999E+383 100   0e+384  ->  -Infinity Inexact Overflow Rounded

-- check for double-rounded subnormals
ddfma2881 fma   1.2347E-355 1.2347E-40    0e+384  ->   1.524E-395 Inexact Rounded Subnormal Underflow
ddfma2882 fma   1.234E-355 1.234E-40      0e+384  ->   1.523E-395 Inexact Rounded Subnormal Underflow
ddfma2883 fma   1.23E-355  1.23E-40       0e+384  ->   1.513E-395 Inexact Rounded Subnormal Underflow
ddfma2884 fma   1.2E-355   1.2E-40        0e+384  ->   1.44E-395  Subnormal
ddfma2885 fma   1.2E-355   1.2E-41        0e+384  ->   1.44E-396  Subnormal
ddfma2886 fma   1.2E-355   1.2E-42        0e+384  ->   1.4E-397   Subnormal Inexact Rounded Underflow
ddfma2887 fma   1.2E-355   1.3E-42        0e+384  ->   1.6E-397   Subnormal Inexact Rounded Underflow
ddfma2888 fma   1.3E-355   1.3E-42        0e+384  ->   1.7E-397   Subnormal Inexact Rounded Underflow
ddfma2889 fma   1.3E-355   1.3E-43        0e+384  ->     2E-398   Subnormal Inexact Rounded Underflow
ddfma2890 fma   1.3E-356   1.3E-43        0e+384  ->     0E-398   Clamped Subnormal Inexact Rounded Underflow

ddfma2891 fma   1.2345E-39   1.234E-355   0e+384  ->   1.5234E-394 Inexact Rounded Subnormal Underflow
ddfma2892 fma   1.23456E-39  1.234E-355   0e+384  ->   1.5234E-394 Inexact Rounded Subnormal Underflow
ddfma2893 fma   1.2345E-40   1.234E-355   0e+384  ->   1.523E-395  Inexact Rounded Subnormal Underflow
ddfma2894 fma   1.23456E-40  1.234E-355   0e+384  ->   1.523E-395  Inexact Rounded Subnormal Underflow
ddfma2895 fma   1.2345E-41   1.234E-355   0e+384  ->   1.52E-396   Inexact Rounded Subnormal Underflow
ddfma2896 fma   1.23456E-41  1.234E-355   0e+384  ->   1.52E-396   Inexact Rounded Subnormal Underflow

-- Now explore the case where we get a normal result with Underflow
ddfma2900 fma   0.3000000000E-191 0.3000000000E-191   0e+384  ->  9.00000000000000E-384 Subnormal Rounded
ddfma2901 fma   0.3000000001E-191 0.3000000001E-191   0e+384  ->  9.00000000600000E-384 Underflow Inexact Subnormal Rounded
ddfma2902 fma   9.999999999999999E-383  0.0999999999999           0e+384  ->  9.99999999999000E-384 Underflow Inexact Subnormal Rounded
ddfma2903 fma   9.999999999999999E-383  0.09999999999999          0e+384  ->  9.99999999999900E-384 Underflow Inexact Subnormal Rounded
ddfma2904 fma   9.999999999999999E-383  0.099999999999999         0e+384  ->  9.99999999999990E-384 Underflow Inexact Subnormal Rounded
ddfma2905 fma   9.999999999999999E-383  0.0999999999999999        0e+384  ->  9.99999999999999E-384 Underflow Inexact Subnormal Rounded
-- prove operands are exact
ddfma2906 fma   9.999999999999999E-383  1                         0e+384  ->  9.999999999999999E-383
ddfma2907 fma                        1  0.09999999999999999       0e+384  ->  0.09999999999999999
-- the next rounds to Nmin
ddfma2908 fma   9.999999999999999E-383  0.09999999999999999       0e+384  ->  1.000000000000000E-383 Underflow Inexact Subnormal Rounded

-- hugest
ddfma2909 fma   9999999999999999 9999999999999999   0e+384  ->  9.999999999999998E+31 Inexact Rounded

-- Null tests
ddfma2990 fma  10  #   0e+384  ->  NaN Invalid_operation
ddfma2991 fma   # 10   0e+384  ->  NaN Invalid_operation


-- ADDITION TESTS ------------------------------------------------------

-- [first group are 'quick confidence check']
ddfma3001 fma  1  1       1       ->  2
ddfma3002 fma  1  2       3       ->  5
ddfma3003 fma  1  '5.75'  '3.3'   ->  9.05
ddfma3004 fma  1  '5'     '-3'    ->  2
ddfma3005 fma  1  '-5'    '-3'    ->  -8
ddfma3006 fma  1  '-7'    '2.5'   ->  -4.5
ddfma3007 fma  1  '0.7'   '0.3'   ->  1.0
ddfma3008 fma  1  '1.25'  '1.25'  ->  2.50
ddfma3009 fma  1  '1.23456789'  '1.00000000' -> '2.23456789'
ddfma3010 fma  1  '1.23456789'  '1.00000011' -> '2.23456800'

--             1234567890123456      1234567890123456
ddfma3011 fma  1  '0.4444444444444446'  '0.5555555555555555' -> '1.000000000000000' Inexact Rounded
ddfma3012 fma  1  '0.4444444444444445'  '0.5555555555555555' -> '1.000000000000000' Rounded
ddfma3013 fma  1  '0.4444444444444444'  '0.5555555555555555' -> '0.9999999999999999'
ddfma3014 fma  1    '4444444444444444' '0.49'   -> '4444444444444444' Inexact Rounded
ddfma3015 fma  1    '4444444444444444' '0.499'  -> '4444444444444444' Inexact Rounded
ddfma3016 fma  1    '4444444444444444' '0.4999' -> '4444444444444444' Inexact Rounded
ddfma3017 fma  1    '4444444444444444' '0.5000' -> '4444444444444444' Inexact Rounded
ddfma3018 fma  1    '4444444444444444' '0.5001' -> '4444444444444445' Inexact Rounded
ddfma3019 fma  1    '4444444444444444' '0.501'  -> '4444444444444445' Inexact Rounded
ddfma3020 fma  1    '4444444444444444' '0.51'   -> '4444444444444445' Inexact Rounded

ddfma3021 fma  1  0 1 -> 1
ddfma3022 fma  1  1 1 -> 2
ddfma3023 fma  1  2 1 -> 3
ddfma3024 fma  1  3 1 -> 4
ddfma3025 fma  1  4 1 -> 5
ddfma3026 fma  1  5 1 -> 6
ddfma3027 fma  1  6 1 -> 7
ddfma3028 fma  1  7 1 -> 8
ddfma3029 fma  1  8 1 -> 9
ddfma3030 fma  1  9 1 -> 10

-- some carrying effects
ddfma3031 fma  1  '0.9998'  '0.0000' -> '0.9998'
ddfma3032 fma  1  '0.9998'  '0.0001' -> '0.9999'
ddfma3033 fma  1  '0.9998'  '0.0002' -> '1.0000'
ddfma3034 fma  1  '0.9998'  '0.0003' -> '1.0001'

ddfma3035 fma  1  '70'  '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
ddfma3036 fma  1  '700'  '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
ddfma3037 fma  1  '7000'  '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
ddfma3038 fma  1  '70000'  '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
ddfma3039 fma  1  '700000'  '10000e+16' -> '1.000000000000007E+20' Rounded

-- symmetry:
ddfma3040 fma  1  '10000e+16'  '70' -> '1.000000000000000E+20' Inexact Rounded
ddfma3041 fma  1  '10000e+16'  '700' -> '1.000000000000000E+20' Inexact Rounded
ddfma3042 fma  1  '10000e+16'  '7000' -> '1.000000000000000E+20' Inexact Rounded
ddfma3044 fma  1  '10000e+16'  '70000' -> '1.000000000000001E+20' Inexact Rounded
ddfma3045 fma  1  '10000e+16'  '700000' -> '1.000000000000007E+20' Rounded

-- same, without rounding
ddfma3046 fma  1  '10000e+9'  '7' -> '10000000000007'
ddfma3047 fma  1  '10000e+9'  '70' -> '10000000000070'
ddfma3048 fma  1  '10000e+9'  '700' -> '10000000000700'
ddfma3049 fma  1  '10000e+9'  '7000' -> '10000000007000'
ddfma3050 fma  1  '10000e+9'  '70000' -> '10000000070000'
ddfma3051 fma  1  '10000e+9'  '700000' -> '10000000700000'
ddfma3052 fma  1  '10000e+9'  '7000000' -> '10000007000000'

-- examples from decarith
ddfma3053 fma  1  '12' '7.00' -> '19.00'
ddfma3054 fma  1  '1.3' '-1.07' -> '0.23'
ddfma3055 fma  1  '1.3' '-1.30' -> '0.00'
ddfma3056 fma  1  '1.3' '-2.07' -> '-0.77'
ddfma3057 fma  1  '1E+2' '1E+4' -> '1.01E+4'

-- leading zero preservation
ddfma3061 fma  1  1 '0.0001' -> '1.0001'
ddfma3062 fma  1  1 '0.00001' -> '1.00001'
ddfma3063 fma  1  1 '0.000001' -> '1.000001'
ddfma3064 fma  1  1 '0.0000001' -> '1.0000001'
ddfma3065 fma  1  1 '0.00000001' -> '1.00000001'

-- some funny zeros [in case of bad signum]
ddfma3070 fma  1  1  0    -> 1
ddfma3071 fma  1  1 0.    -> 1
ddfma3072 fma  1  1  .0   -> 1.0
ddfma3073 fma  1  1 0.0   -> 1.0
ddfma3074 fma  1  1 0.00  -> 1.00
ddfma3075 fma  1   0  1   -> 1
ddfma3076 fma  1  0.  1   -> 1
ddfma3077 fma  1   .0 1   -> 1.0
ddfma3078 fma  1  0.0 1   -> 1.0
ddfma3079 fma  1  0.00 1  -> 1.00

-- some carries
ddfma3080 fma  1  999999998 1  -> 999999999
ddfma3081 fma  1  999999999 1  -> 1000000000
ddfma3082 fma  1   99999999 1  -> 100000000
ddfma3083 fma  1    9999999 1  -> 10000000
ddfma3084 fma  1     999999 1  -> 1000000
ddfma3085 fma  1      99999 1  -> 100000
ddfma3086 fma  1       9999 1  -> 10000
ddfma3087 fma  1        999 1  -> 1000
ddfma3088 fma  1         99 1  -> 100
ddfma3089 fma  1          9 1  -> 10


-- more LHS swaps
ddfma3090 fma  1  '-56267E-10'   0 ->  '-0.0000056267'
ddfma3091 fma  1  '-56267E-6'    0 ->  '-0.056267'
ddfma3092 fma  1  '-56267E-5'    0 ->  '-0.56267'
ddfma3093 fma  1  '-56267E-4'    0 ->  '-5.6267'
ddfma3094 fma  1  '-56267E-3'    0 ->  '-56.267'
ddfma3095 fma  1  '-56267E-2'    0 ->  '-562.67'
ddfma3096 fma  1  '-56267E-1'    0 ->  '-5626.7'
ddfma3097 fma  1  '-56267E-0'    0 ->  '-56267'
ddfma3098 fma  1  '-5E-10'       0 ->  '-5E-10'
ddfma3099 fma  1  '-5E-7'        0 ->  '-5E-7'
ddfma3100 fma  1  '-5E-6'        0 ->  '-0.000005'
ddfma3101 fma  1  '-5E-5'        0 ->  '-0.00005'
ddfma3102 fma  1  '-5E-4'        0 ->  '-0.0005'
ddfma3103 fma  1  '-5E-1'        0 ->  '-0.5'
ddfma3104 fma  1  '-5E0'         0 ->  '-5'
ddfma3105 fma  1  '-5E1'         0 ->  '-50'
ddfma3106 fma  1  '-5E5'         0 ->  '-500000'
ddfma3107 fma  1  '-5E15'        0 ->  '-5000000000000000'
ddfma3108 fma  1  '-5E16'        0 ->  '-5.000000000000000E+16'  Rounded
ddfma3109 fma  1  '-5E17'        0 ->  '-5.000000000000000E+17'  Rounded
ddfma3110 fma  1  '-5E18'        0 ->  '-5.000000000000000E+18'  Rounded
ddfma3111 fma  1  '-5E100'       0 ->  '-5.000000000000000E+100' Rounded

-- more RHS swaps
ddfma3113 fma  1  0  '-56267E-10' ->  '-0.0000056267'
ddfma3114 fma  1  0  '-56267E-6'  ->  '-0.056267'
ddfma3116 fma  1  0  '-56267E-5'  ->  '-0.56267'
ddfma3117 fma  1  0  '-56267E-4'  ->  '-5.6267'
ddfma3119 fma  1  0  '-56267E-3'  ->  '-56.267'
ddfma3120 fma  1  0  '-56267E-2'  ->  '-562.67'
ddfma3121 fma  1  0  '-56267E-1'  ->  '-5626.7'
ddfma3122 fma  1  0  '-56267E-0'  ->  '-56267'
ddfma3123 fma  1  0  '-5E-10'     ->  '-5E-10'
ddfma3124 fma  1  0  '-5E-7'      ->  '-5E-7'
ddfma3125 fma  1  0  '-5E-6'      ->  '-0.000005'
ddfma3126 fma  1  0  '-5E-5'      ->  '-0.00005'
ddfma3127 fma  1  0  '-5E-4'      ->  '-0.0005'
ddfma3128 fma  1  0  '-5E-1'      ->  '-0.5'
ddfma3129 fma  1  0  '-5E0'       ->  '-5'
ddfma3130 fma  1  0  '-5E1'       ->  '-50'
ddfma3131 fma  1  0  '-5E5'       ->  '-500000'
ddfma3132 fma  1  0  '-5E15'      ->  '-5000000000000000'
ddfma3133 fma  1  0  '-5E16'      ->  '-5.000000000000000E+16'   Rounded
ddfma3134 fma  1  0  '-5E17'      ->  '-5.000000000000000E+17'   Rounded
ddfma3135 fma  1  0  '-5E18'      ->  '-5.000000000000000E+18'   Rounded
ddfma3136 fma  1  0  '-5E100'     ->  '-5.000000000000000E+100'  Rounded

-- related
ddfma3137 fma  1   1  '0E-19'      ->  '1.000000000000000'  Rounded
ddfma3138 fma  1  -1  '0E-19'      ->  '-1.000000000000000' Rounded
ddfma3139 fma  1  '0E-19' 1        ->  '1.000000000000000'  Rounded
ddfma3140 fma  1  '0E-19' -1       ->  '-1.000000000000000' Rounded
ddfma3141 fma  1  1E+11   0.0000   ->  '100000000000.0000'
ddfma3142 fma  1  1E+11   0.00000  ->  '100000000000.0000'  Rounded
ddfma3143 fma  1  0.000   1E+12    ->  '1000000000000.000'
ddfma3144 fma  1  0.0000  1E+12    ->  '1000000000000.000'  Rounded

-- [some of the next group are really constructor tests]
ddfma3146 fma  1  '00.0'  0       ->  '0.0'
ddfma3147 fma  1  '0.00'  0       ->  '0.00'
ddfma3148 fma  1   0      '0.00'  ->  '0.00'
ddfma3149 fma  1   0      '00.0'  ->  '0.0'
ddfma3150 fma  1  '00.0'  '0.00'  ->  '0.00'
ddfma3151 fma  1  '0.00'  '00.0'  ->  '0.00'
ddfma3152 fma  1  '3'     '.3'    ->  '3.3'
ddfma3153 fma  1  '3.'    '.3'    ->  '3.3'
ddfma3154 fma  1  '3.0'   '.3'    ->  '3.3'
ddfma3155 fma  1  '3.00'  '.3'    ->  '3.30'
ddfma3156 fma  1  '3'     '3'     ->  '6'
ddfma3157 fma  1  '3'     '+3'    ->  '6'
ddfma3158 fma  1  '3'     '-3'    ->  '0'
ddfma3159 fma  1  '0.3'   '-0.3'  ->  '0.0'
ddfma3160 fma  1  '0.03'  '-0.03' ->  '0.00'

-- try borderline precision, with carries, etc.
ddfma3161 fma  1  '1E+12' '-1'    -> '999999999999'
ddfma3162 fma  1  '1E+12'  '1.11' -> '1000000000001.11'
ddfma3163 fma  1  '1.11'  '1E+12' -> '1000000000001.11'
ddfma3164 fma  1  '-1'    '1E+12' -> '999999999999'
ddfma3165 fma  1  '7E+12' '-1'    -> '6999999999999'
ddfma3166 fma  1  '7E+12'  '1.11' -> '7000000000001.11'
ddfma3167 fma  1  '1.11'  '7E+12' -> '7000000000001.11'
ddfma3168 fma  1  '-1'    '7E+12' -> '6999999999999'

rounding: half_up
--           1.234567890123456      1234567890123456      1 234567890123456
ddfma3170 fma  1  '4.444444444444444'  '0.5555555555555567' -> '5.000000000000001' Inexact Rounded
ddfma3171 fma  1  '4.444444444444444'  '0.5555555555555566' -> '5.000000000000001' Inexact Rounded
ddfma3172 fma  1  '4.444444444444444'  '0.5555555555555565' -> '5.000000000000001' Inexact Rounded
ddfma3173 fma  1  '4.444444444444444'  '0.5555555555555564' -> '5.000000000000000' Inexact Rounded
ddfma3174 fma  1  '4.444444444444444'  '0.5555555555555553' -> '4.999999999999999' Inexact Rounded
ddfma3175 fma  1  '4.444444444444444'  '0.5555555555555552' -> '4.999999999999999' Inexact Rounded
ddfma3176 fma  1  '4.444444444444444'  '0.5555555555555551' -> '4.999999999999999' Inexact Rounded
ddfma3177 fma  1  '4.444444444444444'  '0.5555555555555550' -> '4.999999999999999' Rounded
ddfma3178 fma  1  '4.444444444444444'  '0.5555555555555545' -> '4.999999999999999' Inexact Rounded
ddfma3179 fma  1  '4.444444444444444'  '0.5555555555555544' -> '4.999999999999998' Inexact Rounded
ddfma3180 fma  1  '4.444444444444444'  '0.5555555555555543' -> '4.999999999999998' Inexact Rounded
ddfma3181 fma  1  '4.444444444444444'  '0.5555555555555542' -> '4.999999999999998' Inexact Rounded
ddfma3182 fma  1  '4.444444444444444'  '0.5555555555555541' -> '4.999999999999998' Inexact Rounded
ddfma3183 fma  1  '4.444444444444444'  '0.5555555555555540' -> '4.999999999999998' Rounded

-- and some more, including residue effects and different roundings
rounding: half_up
ddfma3200 fma  1  '1234560123456789' 0             -> '1234560123456789'
ddfma3201 fma  1  '1234560123456789' 0.000000001   -> '1234560123456789' Inexact Rounded
ddfma3202 fma  1  '1234560123456789' 0.000001      -> '1234560123456789' Inexact Rounded
ddfma3203 fma  1  '1234560123456789' 0.1           -> '1234560123456789' Inexact Rounded
ddfma3204 fma  1  '1234560123456789' 0.4           -> '1234560123456789' Inexact Rounded
ddfma3205 fma  1  '1234560123456789' 0.49          -> '1234560123456789' Inexact Rounded
ddfma3206 fma  1  '1234560123456789' 0.499999      -> '1234560123456789' Inexact Rounded
ddfma3207 fma  1  '1234560123456789' 0.499999999   -> '1234560123456789' Inexact Rounded
ddfma3208 fma  1  '1234560123456789' 0.5           -> '1234560123456790' Inexact Rounded
ddfma3209 fma  1  '1234560123456789' 0.500000001   -> '1234560123456790' Inexact Rounded
ddfma3210 fma  1  '1234560123456789' 0.500001      -> '1234560123456790' Inexact Rounded
ddfma3211 fma  1  '1234560123456789' 0.51          -> '1234560123456790' Inexact Rounded
ddfma3212 fma  1  '1234560123456789' 0.6           -> '1234560123456790' Inexact Rounded
ddfma3213 fma  1  '1234560123456789' 0.9           -> '1234560123456790' Inexact Rounded
ddfma3214 fma  1  '1234560123456789' 0.99999       -> '1234560123456790' Inexact Rounded
ddfma3215 fma  1  '1234560123456789' 0.999999999   -> '1234560123456790' Inexact Rounded
ddfma3216 fma  1  '1234560123456789' 1             -> '1234560123456790'
ddfma3217 fma  1  '1234560123456789' 1.000000001   -> '1234560123456790' Inexact Rounded
ddfma3218 fma  1  '1234560123456789' 1.00001       -> '1234560123456790' Inexact Rounded
ddfma3219 fma  1  '1234560123456789' 1.1           -> '1234560123456790' Inexact Rounded

rounding: half_even
ddfma3220 fma  1  '1234560123456789' 0             -> '1234560123456789'
ddfma3221 fma  1  '1234560123456789' 0.000000001   -> '1234560123456789' Inexact Rounded
ddfma3222 fma  1  '1234560123456789' 0.000001      -> '1234560123456789' Inexact Rounded
ddfma3223 fma  1  '1234560123456789' 0.1           -> '1234560123456789' Inexact Rounded
ddfma3224 fma  1  '1234560123456789' 0.4           -> '1234560123456789' Inexact Rounded
ddfma3225 fma  1  '1234560123456789' 0.49          -> '1234560123456789' Inexact Rounded
ddfma3226 fma  1  '1234560123456789' 0.499999      -> '1234560123456789' Inexact Rounded
ddfma3227 fma  1  '1234560123456789' 0.499999999   -> '1234560123456789' Inexact Rounded
ddfma3228 fma  1  '1234560123456789' 0.5           -> '1234560123456790' Inexact Rounded
ddfma3229 fma  1  '1234560123456789' 0.500000001   -> '1234560123456790' Inexact Rounded
ddfma3230 fma  1  '1234560123456789' 0.500001      -> '1234560123456790' Inexact Rounded
ddfma3231 fma  1  '1234560123456789' 0.51          -> '1234560123456790' Inexact Rounded
ddfma3232 fma  1  '1234560123456789' 0.6           -> '1234560123456790' Inexact Rounded
ddfma3233 fma  1  '1234560123456789' 0.9           -> '1234560123456790' Inexact Rounded
ddfma3234 fma  1  '1234560123456789' 0.99999       -> '1234560123456790' Inexact Rounded
ddfma3235 fma  1  '1234560123456789' 0.999999999   -> '1234560123456790' Inexact Rounded
ddfma3236 fma  1  '1234560123456789' 1             -> '1234560123456790'
ddfma3237 fma  1  '1234560123456789' 1.00000001    -> '1234560123456790' Inexact Rounded
ddfma3238 fma  1  '1234560123456789' 1.00001       -> '1234560123456790' Inexact Rounded
ddfma3239 fma  1  '1234560123456789' 1.1           -> '1234560123456790' Inexact Rounded
-- critical few with even bottom digit...
ddfma3240 fma  1  '1234560123456788' 0.499999999   -> '1234560123456788' Inexact Rounded
ddfma3241 fma  1  '1234560123456788' 0.5           -> '1234560123456788' Inexact Rounded
ddfma3242 fma  1  '1234560123456788' 0.500000001   -> '1234560123456789' Inexact Rounded

rounding: down
ddfma3250 fma  1  '1234560123456789' 0             -> '1234560123456789'
ddfma3251 fma  1  '1234560123456789' 0.000000001   -> '1234560123456789' Inexact Rounded
ddfma3252 fma  1  '1234560123456789' 0.000001      -> '1234560123456789' Inexact Rounded
ddfma3253 fma  1  '1234560123456789' 0.1           -> '1234560123456789' Inexact Rounded
ddfma3254 fma  1  '1234560123456789' 0.4           -> '1234560123456789' Inexact Rounded
ddfma3255 fma  1  '1234560123456789' 0.49          -> '1234560123456789' Inexact Rounded
ddfma3256 fma  1  '1234560123456789' 0.499999      -> '1234560123456789' Inexact Rounded
ddfma3257 fma  1  '1234560123456789' 0.499999999   -> '1234560123456789' Inexact Rounded
ddfma3258 fma  1  '1234560123456789' 0.5           -> '1234560123456789' Inexact Rounded
ddfma3259 fma  1  '1234560123456789' 0.500000001   -> '1234560123456789' Inexact Rounded
ddfma3260 fma  1  '1234560123456789' 0.500001      -> '1234560123456789' Inexact Rounded
ddfma3261 fma  1  '1234560123456789' 0.51          -> '1234560123456789' Inexact Rounded
ddfma3262 fma  1  '1234560123456789' 0.6           -> '1234560123456789' Inexact Rounded
ddfma3263 fma  1  '1234560123456789' 0.9           -> '1234560123456789' Inexact Rounded
ddfma3264 fma  1  '1234560123456789' 0.99999       -> '1234560123456789' Inexact Rounded
ddfma3265 fma  1  '1234560123456789' 0.999999999   -> '1234560123456789' Inexact Rounded
ddfma3266 fma  1  '1234560123456789' 1             -> '1234560123456790'
ddfma3267 fma  1  '1234560123456789' 1.00000001    -> '1234560123456790' Inexact Rounded
ddfma3268 fma  1  '1234560123456789' 1.00001       -> '1234560123456790' Inexact Rounded
ddfma3269 fma  1  '1234560123456789' 1.1           -> '1234560123456790' Inexact Rounded

-- 1 in last place tests
rounding: half_up
ddfma3301 fma  1   -1   1      ->   0
ddfma3302 fma  1    0   1      ->   1
ddfma3303 fma  1    1   1      ->   2
ddfma3304 fma  1   12   1      ->  13
ddfma3305 fma  1   98   1      ->  99
ddfma3306 fma  1   99   1      -> 100
ddfma3307 fma  1  100   1      -> 101
ddfma3308 fma  1  101   1      -> 102
ddfma3309 fma  1   -1  -1      ->  -2
ddfma3310 fma  1    0  -1      ->  -1
ddfma3311 fma  1    1  -1      ->   0
ddfma3312 fma  1   12  -1      ->  11
ddfma3313 fma  1   98  -1      ->  97
ddfma3314 fma  1   99  -1      ->  98
ddfma3315 fma  1  100  -1      ->  99
ddfma3316 fma  1  101  -1      -> 100

ddfma3321 fma  1  -0.01  0.01    ->  0.00
ddfma3322 fma  1   0.00  0.01    ->  0.01
ddfma3323 fma  1   0.01  0.01    ->  0.02
ddfma3324 fma  1   0.12  0.01    ->  0.13
ddfma3325 fma  1   0.98  0.01    ->  0.99
ddfma3326 fma  1   0.99  0.01    ->  1.00
ddfma3327 fma  1   1.00  0.01    ->  1.01
ddfma3328 fma  1   1.01  0.01    ->  1.02
ddfma3329 fma  1  -0.01 -0.01    -> -0.02
ddfma3330 fma  1   0.00 -0.01    -> -0.01
ddfma3331 fma  1   0.01 -0.01    ->  0.00
ddfma3332 fma  1   0.12 -0.01    ->  0.11
ddfma3333 fma  1   0.98 -0.01    ->  0.97
ddfma3334 fma  1   0.99 -0.01    ->  0.98
ddfma3335 fma  1   1.00 -0.01    ->  0.99
ddfma3336 fma  1   1.01 -0.01    ->  1.00

-- some more cases where adding 0 affects the coefficient
ddfma3340 fma  1  1E+3    0    ->         1000
ddfma3341 fma  1  1E+15   0    ->    1000000000000000
ddfma3342 fma  1  1E+16   0    ->   1.000000000000000E+16  Rounded
ddfma3343 fma  1  1E+20   0    ->   1.000000000000000E+20  Rounded
-- which simply follow from these cases ...
ddfma3344 fma  1  1E+3    1    ->         1001
ddfma3345 fma  1  1E+15   1    ->    1000000000000001
ddfma3346 fma  1  1E+16   1    ->   1.000000000000000E+16  Inexact Rounded
ddfma3347 fma  1  1E+20   1    ->   1.000000000000000E+20  Inexact Rounded
ddfma3348 fma  1  1E+3    7    ->         1007
ddfma3349 fma  1  1E+15   7    ->    1000000000000007
ddfma3350 fma  1  1E+16   7    ->   1.000000000000001E+16  Inexact Rounded
ddfma3351 fma  1  1E+20   7    ->   1.000000000000000E+20  Inexact Rounded

-- tryzeros cases
rounding:    half_up
ddfma3360  fma  1  0E+50 10000E+1  -> 1.0000E+5
ddfma3361  fma  1  0E-50 10000E+1  -> 100000.0000000000 Rounded
ddfma3362  fma  1  10000E+1 0E-50  -> 100000.0000000000 Rounded
ddfma3363  fma  1  10000E+1 10000E-50  -> 100000.0000000000 Rounded Inexact
ddfma3364  fma  1  9.999999999999999E+384 -9.999999999999999E+384 -> 0E+369

-- a curiosity from JSR 13 testing
rounding:    half_down
ddfma3370 fma  1   999999999999999 815 -> 1000000000000814
ddfma3371 fma  1  9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
rounding:    half_up
ddfma3372 fma  1   999999999999999 815 -> 1000000000000814
ddfma3373 fma  1  9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
rounding:    half_even
ddfma3374 fma  1   999999999999999 815 -> 1000000000000814
ddfma3375 fma  1  9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact

-- ulp replacement tests
ddfma3400 fma  1    1   77e-14      ->  1.00000000000077
ddfma3401 fma  1    1   77e-15      ->  1.000000000000077
ddfma3402 fma  1    1   77e-16      ->  1.000000000000008 Inexact Rounded
ddfma3403 fma  1    1   77e-17      ->  1.000000000000001 Inexact Rounded
ddfma3404 fma  1    1   77e-18      ->  1.000000000000000 Inexact Rounded
ddfma3405 fma  1    1   77e-19      ->  1.000000000000000 Inexact Rounded
ddfma3406 fma  1    1   77e-299     ->  1.000000000000000 Inexact Rounded

ddfma3410 fma  1   10   77e-14      ->  10.00000000000077
ddfma3411 fma  1   10   77e-15      ->  10.00000000000008 Inexact Rounded
ddfma3412 fma  1   10   77e-16      ->  10.00000000000001 Inexact Rounded
ddfma3413 fma  1   10   77e-17      ->  10.00000000000000 Inexact Rounded
ddfma3414 fma  1   10   77e-18      ->  10.00000000000000 Inexact Rounded
ddfma3415 fma  1   10   77e-19      ->  10.00000000000000 Inexact Rounded
ddfma3416 fma  1   10   77e-299     ->  10.00000000000000 Inexact Rounded

ddfma3420 fma  1   77e-14       1   ->  1.00000000000077
ddfma3421 fma  1   77e-15       1   ->  1.000000000000077
ddfma3422 fma  1   77e-16       1   ->  1.000000000000008 Inexact Rounded
ddfma3423 fma  1   77e-17       1   ->  1.000000000000001 Inexact Rounded
ddfma3424 fma  1   77e-18       1   ->  1.000000000000000 Inexact Rounded
ddfma3425 fma  1   77e-19       1   ->  1.000000000000000 Inexact Rounded
ddfma3426 fma  1   77e-299      1   ->  1.000000000000000 Inexact Rounded

ddfma3430 fma  1   77e-14      10   ->  10.00000000000077
ddfma3431 fma  1   77e-15      10   ->  10.00000000000008 Inexact Rounded
ddfma3432 fma  1   77e-16      10   ->  10.00000000000001 Inexact Rounded
ddfma3433 fma  1   77e-17      10   ->  10.00000000000000 Inexact Rounded
ddfma3434 fma  1   77e-18      10   ->  10.00000000000000 Inexact Rounded
ddfma3435 fma  1   77e-19      10   ->  10.00000000000000 Inexact Rounded
ddfma3436 fma  1   77e-299     10   ->  10.00000000000000 Inexact Rounded

-- negative ulps
ddfma36440 fma  1    1   -77e-14      ->  0.99999999999923
ddfma36441 fma  1    1   -77e-15      ->  0.999999999999923
ddfma36442 fma  1    1   -77e-16      ->  0.9999999999999923
ddfma36443 fma  1    1   -77e-17      ->  0.9999999999999992 Inexact Rounded
ddfma36444 fma  1    1   -77e-18      ->  0.9999999999999999 Inexact Rounded
ddfma36445 fma  1    1   -77e-19      ->  1.000000000000000 Inexact Rounded
ddfma36446 fma  1    1   -77e-99      ->  1.000000000000000 Inexact Rounded

ddfma36450 fma  1   10   -77e-14      ->   9.99999999999923
ddfma36451 fma  1   10   -77e-15      ->   9.999999999999923
ddfma36452 fma  1   10   -77e-16      ->   9.999999999999992 Inexact Rounded
ddfma36453 fma  1   10   -77e-17      ->   9.999999999999999 Inexact Rounded
ddfma36454 fma  1   10   -77e-18      ->  10.00000000000000 Inexact Rounded
ddfma36455 fma  1   10   -77e-19      ->  10.00000000000000 Inexact Rounded
ddfma36456 fma  1   10   -77e-99      ->  10.00000000000000 Inexact Rounded

ddfma36460 fma  1   -77e-14       1   ->  0.99999999999923
ddfma36461 fma  1   -77e-15       1   ->  0.999999999999923
ddfma36462 fma  1   -77e-16       1   ->  0.9999999999999923
ddfma36463 fma  1   -77e-17       1   ->  0.9999999999999992 Inexact Rounded
ddfma36464 fma  1   -77e-18       1   ->  0.9999999999999999 Inexact Rounded
ddfma36465 fma  1   -77e-19       1   ->  1.000000000000000 Inexact Rounded
ddfma36466 fma  1   -77e-99       1   ->  1.000000000000000 Inexact Rounded

ddfma36470 fma  1   -77e-14      10   ->   9.99999999999923
ddfma36471 fma  1   -77e-15      10   ->   9.999999999999923
ddfma36472 fma  1   -77e-16      10   ->   9.999999999999992 Inexact Rounded
ddfma36473 fma  1   -77e-17      10   ->   9.999999999999999 Inexact Rounded
ddfma36474 fma  1   -77e-18      10   ->  10.00000000000000 Inexact Rounded
ddfma36475 fma  1   -77e-19      10   ->  10.00000000000000 Inexact Rounded
ddfma36476 fma  1   -77e-99      10   ->  10.00000000000000 Inexact Rounded

-- negative ulps
ddfma36480 fma  1   -1    77e-14      ->  -0.99999999999923
ddfma36481 fma  1   -1    77e-15      ->  -0.999999999999923
ddfma36482 fma  1   -1    77e-16      ->  -0.9999999999999923
ddfma36483 fma  1   -1    77e-17      ->  -0.9999999999999992 Inexact Rounded
ddfma36484 fma  1   -1    77e-18      ->  -0.9999999999999999 Inexact Rounded
ddfma36485 fma  1   -1    77e-19      ->  -1.000000000000000 Inexact Rounded
ddfma36486 fma  1   -1    77e-99      ->  -1.000000000000000 Inexact Rounded

ddfma36490 fma  1  -10    77e-14      ->   -9.99999999999923
ddfma36491 fma  1  -10    77e-15      ->   -9.999999999999923
ddfma36492 fma  1  -10    77e-16      ->   -9.999999999999992 Inexact Rounded
ddfma36493 fma  1  -10    77e-17      ->   -9.999999999999999 Inexact Rounded
ddfma36494 fma  1  -10    77e-18      ->  -10.00000000000000 Inexact Rounded
ddfma36495 fma  1  -10    77e-19      ->  -10.00000000000000 Inexact Rounded
ddfma36496 fma  1  -10    77e-99      ->  -10.00000000000000 Inexact Rounded

ddfma36500 fma  1    77e-14      -1   ->  -0.99999999999923
ddfma36501 fma  1    77e-15      -1   ->  -0.999999999999923
ddfma36502 fma  1    77e-16      -1   ->  -0.9999999999999923
ddfma36503 fma  1    77e-17      -1   ->  -0.9999999999999992 Inexact Rounded
ddfma36504 fma  1    77e-18      -1   ->  -0.9999999999999999 Inexact Rounded
ddfma36505 fma  1    77e-19      -1   ->  -1.000000000000000 Inexact Rounded
ddfma36506 fma  1    77e-99      -1   ->  -1.000000000000000 Inexact Rounded

ddfma36510 fma  1    77e-14      -10  ->   -9.99999999999923
ddfma36511 fma  1    77e-15      -10  ->   -9.999999999999923
ddfma36512 fma  1    77e-16      -10  ->   -9.999999999999992 Inexact Rounded
ddfma36513 fma  1    77e-17      -10  ->   -9.999999999999999 Inexact Rounded
ddfma36514 fma  1    77e-18      -10  ->  -10.00000000000000 Inexact Rounded
ddfma36515 fma  1    77e-19      -10  ->  -10.00000000000000 Inexact Rounded
ddfma36516 fma  1    77e-99      -10  ->  -10.00000000000000 Inexact Rounded

-- and a couple more with longer RHS
ddfma36520 fma  1    1   -7777e-16      ->  0.9999999999992223
ddfma36521 fma  1    1   -7777e-17      ->  0.9999999999999222 Inexact Rounded
ddfma36522 fma  1    1   -7777e-18      ->  0.9999999999999922 Inexact Rounded
ddfma36523 fma  1    1   -7777e-19      ->  0.9999999999999992 Inexact Rounded
ddfma36524 fma  1    1   -7777e-20      ->  0.9999999999999999 Inexact Rounded
ddfma36525 fma  1    1   -7777e-21      ->  1.000000000000000 Inexact Rounded
ddfma36526 fma  1    1   -7777e-22      ->  1.000000000000000 Inexact Rounded


-- and some more residue effects and different roundings
rounding: half_up
ddfma36540 fma  1  '6543210123456789' 0             -> '6543210123456789'
ddfma36541 fma  1  '6543210123456789' 0.000000001   -> '6543210123456789' Inexact Rounded
ddfma36542 fma  1  '6543210123456789' 0.000001      -> '6543210123456789' Inexact Rounded
ddfma36543 fma  1  '6543210123456789' 0.1           -> '6543210123456789' Inexact Rounded
ddfma36544 fma  1  '6543210123456789' 0.4           -> '6543210123456789' Inexact Rounded
ddfma36545 fma  1  '6543210123456789' 0.49          -> '6543210123456789' Inexact Rounded
ddfma36546 fma  1  '6543210123456789' 0.499999      -> '6543210123456789' Inexact Rounded
ddfma36547 fma  1  '6543210123456789' 0.499999999   -> '6543210123456789' Inexact Rounded
ddfma36548 fma  1  '6543210123456789' 0.5           -> '6543210123456790' Inexact Rounded
ddfma36549 fma  1  '6543210123456789' 0.500000001   -> '6543210123456790' Inexact Rounded
ddfma36550 fma  1  '6543210123456789' 0.500001      -> '6543210123456790' Inexact Rounded
ddfma36551 fma  1  '6543210123456789' 0.51          -> '6543210123456790' Inexact Rounded
ddfma36552 fma  1  '6543210123456789' 0.6           -> '6543210123456790' Inexact Rounded
ddfma36553 fma  1  '6543210123456789' 0.9           -> '6543210123456790' Inexact Rounded
ddfma36554 fma  1  '6543210123456789' 0.99999       -> '6543210123456790' Inexact Rounded
ddfma36555 fma  1  '6543210123456789' 0.999999999   -> '6543210123456790' Inexact Rounded
ddfma36556 fma  1  '6543210123456789' 1             -> '6543210123456790'
ddfma36557 fma  1  '6543210123456789' 1.000000001   -> '6543210123456790' Inexact Rounded
ddfma36558 fma  1  '6543210123456789' 1.00001       -> '6543210123456790' Inexact Rounded
ddfma36559 fma  1  '6543210123456789' 1.1           -> '6543210123456790' Inexact Rounded

rounding: half_even
ddfma36560 fma  1  '6543210123456789' 0             -> '6543210123456789'
ddfma36561 fma  1  '6543210123456789' 0.000000001   -> '6543210123456789' Inexact Rounded
ddfma36562 fma  1  '6543210123456789' 0.000001      -> '6543210123456789' Inexact Rounded
ddfma36563 fma  1  '6543210123456789' 0.1           -> '6543210123456789' Inexact Rounded
ddfma36564 fma  1  '6543210123456789' 0.4           -> '6543210123456789' Inexact Rounded
ddfma36565 fma  1  '6543210123456789' 0.49          -> '6543210123456789' Inexact Rounded
ddfma36566 fma  1  '6543210123456789' 0.499999      -> '6543210123456789' Inexact Rounded
ddfma36567 fma  1  '6543210123456789' 0.499999999   -> '6543210123456789' Inexact Rounded
ddfma36568 fma  1  '6543210123456789' 0.5           -> '6543210123456790' Inexact Rounded
ddfma36569 fma  1  '6543210123456789' 0.500000001   -> '6543210123456790' Inexact Rounded
ddfma36570 fma  1  '6543210123456789' 0.500001      -> '6543210123456790' Inexact Rounded
ddfma36571 fma  1  '6543210123456789' 0.51          -> '6543210123456790' Inexact Rounded
ddfma36572 fma  1  '6543210123456789' 0.6           -> '6543210123456790' Inexact Rounded
ddfma36573 fma  1  '6543210123456789' 0.9           -> '6543210123456790' Inexact Rounded
ddfma36574 fma  1  '6543210123456789' 0.99999       -> '6543210123456790' Inexact Rounded
ddfma36575 fma  1  '6543210123456789' 0.999999999   -> '6543210123456790' Inexact Rounded
ddfma36576 fma  1  '6543210123456789' 1             -> '6543210123456790'
ddfma36577 fma  1  '6543210123456789' 1.00000001    -> '6543210123456790' Inexact Rounded
ddfma36578 fma  1  '6543210123456789' 1.00001       -> '6543210123456790' Inexact Rounded
ddfma36579 fma  1  '6543210123456789' 1.1           -> '6543210123456790' Inexact Rounded

-- critical few with even bottom digit...
ddfma37540 fma  1  '6543210123456788' 0.499999999   -> '6543210123456788' Inexact Rounded
ddfma37541 fma  1  '6543210123456788' 0.5           -> '6543210123456788' Inexact Rounded
ddfma37542 fma  1  '6543210123456788' 0.500000001   -> '6543210123456789' Inexact Rounded

rounding: down
ddfma37550 fma  1  '6543210123456789' 0             -> '6543210123456789'
ddfma37551 fma  1  '6543210123456789' 0.000000001   -> '6543210123456789' Inexact Rounded
ddfma37552 fma  1  '6543210123456789' 0.000001      -> '6543210123456789' Inexact Rounded
ddfma37553 fma  1  '6543210123456789' 0.1           -> '6543210123456789' Inexact Rounded
ddfma37554 fma  1  '6543210123456789' 0.4           -> '6543210123456789' Inexact Rounded
ddfma37555 fma  1  '6543210123456789' 0.49          -> '6543210123456789' Inexact Rounded
ddfma37556 fma  1  '6543210123456789' 0.499999      -> '6543210123456789' Inexact Rounded
ddfma37557 fma  1  '6543210123456789' 0.499999999   -> '6543210123456789' Inexact Rounded
ddfma37558 fma  1  '6543210123456789' 0.5           -> '6543210123456789' Inexact Rounded
ddfma37559 fma  1  '6543210123456789' 0.500000001   -> '6543210123456789' Inexact Rounded
ddfma37560 fma  1  '6543210123456789' 0.500001      -> '6543210123456789' Inexact Rounded
ddfma37561 fma  1  '6543210123456789' 0.51          -> '6543210123456789' Inexact Rounded
ddfma37562 fma  1  '6543210123456789' 0.6           -> '6543210123456789' Inexact Rounded
ddfma37563 fma  1  '6543210123456789' 0.9           -> '6543210123456789' Inexact Rounded
ddfma37564 fma  1  '6543210123456789' 0.99999       -> '6543210123456789' Inexact Rounded
ddfma37565 fma  1  '6543210123456789' 0.999999999   -> '6543210123456789' Inexact Rounded
ddfma37566 fma  1  '6543210123456789' 1             -> '6543210123456790'
ddfma37567 fma  1  '6543210123456789' 1.00000001    -> '6543210123456790' Inexact Rounded
ddfma37568 fma  1  '6543210123456789' 1.00001       -> '6543210123456790' Inexact Rounded
ddfma37569 fma  1  '6543210123456789' 1.1           -> '6543210123456790' Inexact Rounded


-- verify a query
rounding:     down
ddfma37661 fma  1  1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
ddfma37662 fma  1       0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
ddfma37663 fma  1  1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
ddfma37664 fma  1       0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded

-- more zeros, etc.
rounding: half_even

ddfma37701 fma  1  5.00 1.00E-3 -> 5.00100
ddfma37702 fma  1  00.00 0.000  -> 0.000
ddfma37703 fma  1  00.00 0E-3   -> 0.000
ddfma37704 fma  1  0E-3  00.00  -> 0.000

ddfma37710 fma  1  0E+3  00.00  -> 0.00
ddfma37711 fma  1  0E+3  00.0   -> 0.0
ddfma37712 fma  1  0E+3  00.    -> 0
ddfma37713 fma  1  0E+3  00.E+1 -> 0E+1
ddfma37714 fma  1  0E+3  00.E+2 -> 0E+2
ddfma37715 fma  1  0E+3  00.E+3 -> 0E+3
ddfma37716 fma  1  0E+3  00.E+4 -> 0E+3
ddfma37717 fma  1  0E+3  00.E+5 -> 0E+3
ddfma37718 fma  1  0E+3  -00.0   -> 0.0
ddfma37719 fma  1  0E+3  -00.    -> 0
ddfma37731 fma  1  0E+3  -00.E+1 -> 0E+1

ddfma37720 fma  1  00.00  0E+3  -> 0.00
ddfma37721 fma  1  00.0   0E+3  -> 0.0
ddfma37722 fma  1  00.    0E+3  -> 0
ddfma37723 fma  1  00.E+1 0E+3  -> 0E+1
ddfma37724 fma  1  00.E+2 0E+3  -> 0E+2
ddfma37725 fma  1  00.E+3 0E+3  -> 0E+3
ddfma37726 fma  1  00.E+4 0E+3  -> 0E+3
ddfma37727 fma  1  00.E+5 0E+3  -> 0E+3
ddfma37728 fma  1  -00.00 0E+3  -> 0.00
ddfma37729 fma  1  -00.0  0E+3  -> 0.0
ddfma37730 fma  1  -00.   0E+3  -> 0

ddfma37732 fma  1   0     0     ->  0
ddfma37733 fma  1   0    -0     ->  0
ddfma37734 fma  1  -0     0     ->  0
ddfma37735 fma  1  -0    -0     -> -0     -- IEEE 854 special case

ddfma37736 fma  1   1    -1     ->  0
ddfma37737 fma  1  -1    -1     -> -2
ddfma37738 fma  1   1     1     ->  2
ddfma37739 fma  1  -1     1     ->  0

ddfma37741 fma  1   0    -1     -> -1
ddfma37742 fma  1  -0    -1     -> -1
ddfma37743 fma  1   0     1     ->  1
ddfma37744 fma  1  -0     1     ->  1
ddfma37745 fma  1  -1     0     -> -1
ddfma37746 fma  1  -1    -0     -> -1
ddfma37747 fma  1   1     0     ->  1
ddfma37748 fma  1   1    -0     ->  1

ddfma37751 fma  1   0.0  -1     -> -1.0
ddfma37752 fma  1  -0.0  -1     -> -1.0
ddfma37753 fma  1   0.0   1     ->  1.0
ddfma37754 fma  1  -0.0   1     ->  1.0
ddfma37755 fma  1  -1.0   0     -> -1.0
ddfma37756 fma  1  -1.0  -0     -> -1.0
ddfma37757 fma  1   1.0   0     ->  1.0
ddfma37758 fma  1   1.0  -0     ->  1.0

ddfma37761 fma  1   0    -1.0   -> -1.0
ddfma37762 fma  1  -0    -1.0   -> -1.0
ddfma37763 fma  1   0     1.0   ->  1.0
ddfma37764 fma  1  -0     1.0   ->  1.0
ddfma37765 fma  1  -1     0.0   -> -1.0
ddfma37766 fma  1  -1    -0.0   -> -1.0
ddfma37767 fma  1   1     0.0   ->  1.0
ddfma37768 fma  1   1    -0.0   ->  1.0

ddfma37771 fma  1   0.0  -1.0   -> -1.0
ddfma37772 fma  1  -0.0  -1.0   -> -1.0
ddfma37773 fma  1   0.0   1.0   ->  1.0
ddfma37774 fma  1  -0.0   1.0   ->  1.0
ddfma37775 fma  1  -1.0   0.0   -> -1.0
ddfma37776 fma  1  -1.0  -0.0   -> -1.0
ddfma37777 fma  1   1.0   0.0   ->  1.0
ddfma37778 fma  1   1.0  -0.0   ->  1.0

-- Specials
ddfma37780 fma  1  -Inf  -Inf   -> -Infinity
ddfma37781 fma  1  -Inf  -1000  -> -Infinity
ddfma37782 fma  1  -Inf  -1     -> -Infinity
ddfma37783 fma  1  -Inf  -0     -> -Infinity
ddfma37784 fma  1  -Inf   0     -> -Infinity
ddfma37785 fma  1  -Inf   1     -> -Infinity
ddfma37786 fma  1  -Inf   1000  -> -Infinity
ddfma37787 fma  1  -1000 -Inf   -> -Infinity
ddfma37788 fma  1  -Inf  -Inf   -> -Infinity
ddfma37789 fma  1  -1    -Inf   -> -Infinity
ddfma37790 fma  1  -0    -Inf   -> -Infinity
ddfma37791 fma  1   0    -Inf   -> -Infinity
ddfma37792 fma  1   1    -Inf   -> -Infinity
ddfma37793 fma  1   1000 -Inf   -> -Infinity
ddfma37794 fma  1   Inf  -Inf   ->  NaN  Invalid_operation

ddfma37800 fma  1   Inf  -Inf   ->  NaN  Invalid_operation
ddfma37801 fma  1   Inf  -1000  ->  Infinity
ddfma37802 fma  1   Inf  -1     ->  Infinity
ddfma37803 fma  1   Inf  -0     ->  Infinity
ddfma37804 fma  1   Inf   0     ->  Infinity
ddfma37805 fma  1   Inf   1     ->  Infinity
ddfma37806 fma  1   Inf   1000  ->  Infinity
ddfma37807 fma  1   Inf   Inf   ->  Infinity
ddfma37808 fma  1  -1000  Inf   ->  Infinity
ddfma37809 fma  1  -Inf   Inf   ->  NaN  Invalid_operation
ddfma37810 fma  1  -1     Inf   ->  Infinity
ddfma37811 fma  1  -0     Inf   ->  Infinity
ddfma37812 fma  1   0     Inf   ->  Infinity
ddfma37813 fma  1   1     Inf   ->  Infinity
ddfma37814 fma  1   1000  Inf   ->  Infinity
ddfma37815 fma  1   Inf   Inf   ->  Infinity

ddfma37821 fma  1   NaN -Inf    ->  NaN
ddfma37822 fma  1   NaN -1000   ->  NaN
ddfma37823 fma  1   NaN -1      ->  NaN
ddfma37824 fma  1   NaN -0      ->  NaN
ddfma37825 fma  1   NaN  0      ->  NaN
ddfma37826 fma  1   NaN  1      ->  NaN
ddfma37827 fma  1   NaN  1000   ->  NaN
ddfma37828 fma  1   NaN  Inf    ->  NaN
ddfma37829 fma  1   NaN  NaN    ->  NaN
ddfma37830 fma  1  -Inf  NaN    ->  NaN
ddfma37831 fma  1  -1000 NaN    ->  NaN
ddfma37832 fma  1  -1    NaN    ->  NaN
ddfma37833 fma  1  -0    NaN    ->  NaN
ddfma37834 fma  1   0    NaN    ->  NaN
ddfma37835 fma  1   1    NaN    ->  NaN
ddfma37836 fma  1   1000 NaN    ->  NaN
ddfma37837 fma  1   Inf  NaN    ->  NaN

ddfma37841 fma  1   sNaN -Inf   ->  NaN  Invalid_operation
ddfma37842 fma  1   sNaN -1000  ->  NaN  Invalid_operation
ddfma37843 fma  1   sNaN -1     ->  NaN  Invalid_operation
ddfma37844 fma  1   sNaN -0     ->  NaN  Invalid_operation
ddfma37845 fma  1   sNaN  0     ->  NaN  Invalid_operation
ddfma37846 fma  1   sNaN  1     ->  NaN  Invalid_operation
ddfma37847 fma  1   sNaN  1000  ->  NaN  Invalid_operation
ddfma37848 fma  1   sNaN  NaN   ->  NaN  Invalid_operation
ddfma37849 fma  1   sNaN sNaN   ->  NaN  Invalid_operation
ddfma37850 fma  1   NaN  sNaN   ->  NaN  Invalid_operation
ddfma37851 fma  1  -Inf  sNaN   ->  NaN  Invalid_operation
ddfma37852 fma  1  -1000 sNaN   ->  NaN  Invalid_operation
ddfma37853 fma  1  -1    sNaN   ->  NaN  Invalid_operation
ddfma37854 fma  1  -0    sNaN   ->  NaN  Invalid_operation
ddfma37855 fma  1   0    sNaN   ->  NaN  Invalid_operation
ddfma37856 fma  1   1    sNaN   ->  NaN  Invalid_operation
ddfma37857 fma  1   1000 sNaN   ->  NaN  Invalid_operation
ddfma37858 fma  1   Inf  sNaN   ->  NaN  Invalid_operation
ddfma37859 fma  1   NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddfma37861 fma  1   NaN1   -Inf    ->  NaN1
ddfma37862 fma  1  +NaN2   -1000   ->  NaN2
ddfma37863 fma  1   NaN3    1000   ->  NaN3
ddfma37864 fma  1   NaN4    Inf    ->  NaN4
ddfma37865 fma  1   NaN5   +NaN6   ->  NaN5
ddfma37866 fma  1  -Inf     NaN7   ->  NaN7
ddfma37867 fma  1  -1000    NaN8   ->  NaN8
ddfma37868 fma  1   1000    NaN9   ->  NaN9
ddfma37869 fma  1   Inf    +NaN10  ->  NaN10
ddfma37871 fma  1   sNaN11  -Inf   ->  NaN11  Invalid_operation
ddfma37872 fma  1   sNaN12  -1000  ->  NaN12  Invalid_operation
ddfma37873 fma  1   sNaN13   1000  ->  NaN13  Invalid_operation
ddfma37874 fma  1   sNaN14   NaN17 ->  NaN14  Invalid_operation
ddfma37875 fma  1   sNaN15  sNaN18 ->  NaN15  Invalid_operation
ddfma37876 fma  1   NaN16   sNaN19 ->  NaN19  Invalid_operation
ddfma37877 fma  1  -Inf    +sNaN20 ->  NaN20  Invalid_operation
ddfma37878 fma  1  -1000    sNaN21 ->  NaN21  Invalid_operation
ddfma37879 fma  1   1000    sNaN22 ->  NaN22  Invalid_operation
ddfma37880 fma  1   Inf     sNaN23 ->  NaN23  Invalid_operation
ddfma37881 fma  1  +NaN25  +sNaN24 ->  NaN24  Invalid_operation
ddfma37882 fma  1  -NaN26    NaN28 -> -NaN26
ddfma37883 fma  1  -sNaN27  sNaN29 -> -NaN27  Invalid_operation
ddfma37884 fma  1   1000    -NaN30 -> -NaN30
ddfma37885 fma  1   1000   -sNaN31 -> -NaN31  Invalid_operation

-- Here we explore near the boundary of rounding a subnormal to Nmin
ddfma37575 fma  1   1E-383 -1E-398 ->  9.99999999999999E-384  Subnormal
ddfma37576 fma  1  -1E-383 +1E-398 -> -9.99999999999999E-384  Subnormal

-- check overflow edge case
--               1234567890123456
ddfma37972 apply   9.999999999999999E+384         -> 9.999999999999999E+384
ddfma37973 fma  1      9.999999999999999E+384  1      -> 9.999999999999999E+384 Inexact Rounded
ddfma37974 fma  1       9999999999999999E+369  1      -> 9.999999999999999E+384 Inexact Rounded
ddfma37975 fma  1       9999999999999999E+369  1E+369  -> Infinity Overflow Inexact Rounded
ddfma37976 fma  1       9999999999999999E+369  9E+368  -> Infinity Overflow Inexact Rounded
ddfma37977 fma  1       9999999999999999E+369  8E+368  -> Infinity Overflow Inexact Rounded
ddfma37978 fma  1       9999999999999999E+369  7E+368  -> Infinity Overflow Inexact Rounded
ddfma37979 fma  1       9999999999999999E+369  6E+368  -> Infinity Overflow Inexact Rounded
ddfma37980 fma  1       9999999999999999E+369  5E+368  -> Infinity Overflow Inexact Rounded
ddfma37981 fma  1       9999999999999999E+369  4E+368  -> 9.999999999999999E+384 Inexact Rounded
ddfma37982 fma  1       9999999999999999E+369  3E+368  -> 9.999999999999999E+384 Inexact Rounded
ddfma37983 fma  1       9999999999999999E+369  2E+368  -> 9.999999999999999E+384 Inexact Rounded
ddfma37984 fma  1       9999999999999999E+369  1E+368  -> 9.999999999999999E+384 Inexact Rounded

ddfma37985 apply  -9.999999999999999E+384         -> -9.999999999999999E+384
ddfma37986 fma  1     -9.999999999999999E+384 -1      -> -9.999999999999999E+384 Inexact Rounded
ddfma37987 fma  1      -9999999999999999E+369 -1      -> -9.999999999999999E+384 Inexact Rounded
ddfma37988 fma  1      -9999999999999999E+369 -1E+369  -> -Infinity Overflow Inexact Rounded
ddfma37989 fma  1      -9999999999999999E+369 -9E+368  -> -Infinity Overflow Inexact Rounded
ddfma37990 fma  1      -9999999999999999E+369 -8E+368  -> -Infinity Overflow Inexact Rounded
ddfma37991 fma  1      -9999999999999999E+369 -7E+368  -> -Infinity Overflow Inexact Rounded
ddfma37992 fma  1      -9999999999999999E+369 -6E+368  -> -Infinity Overflow Inexact Rounded
ddfma37993 fma  1      -9999999999999999E+369 -5E+368  -> -Infinity Overflow Inexact Rounded
ddfma37994 fma  1      -9999999999999999E+369 -4E+368  -> -9.999999999999999E+384 Inexact Rounded
ddfma37995 fma  1      -9999999999999999E+369 -3E+368  -> -9.999999999999999E+384 Inexact Rounded
ddfma37996 fma  1      -9999999999999999E+369 -2E+368  -> -9.999999999999999E+384 Inexact Rounded
ddfma37997 fma  1      -9999999999999999E+369 -1E+368  -> -9.999999999999999E+384 Inexact Rounded

-- And for round down full and subnormal results
rounding:     down
ddfma371100 fma  1  1e+2 -1e-383    -> 99.99999999999999 Rounded Inexact
ddfma371101 fma  1  1e+1 -1e-383    -> 9.999999999999999  Rounded Inexact
ddfma371103 fma  1    +1 -1e-383    -> 0.9999999999999999  Rounded Inexact
ddfma371104 fma  1  1e-1 -1e-383    -> 0.09999999999999999  Rounded Inexact
ddfma371105 fma  1  1e-2 -1e-383    -> 0.009999999999999999  Rounded Inexact
ddfma371106 fma  1  1e-3 -1e-383    -> 0.0009999999999999999  Rounded Inexact
ddfma371107 fma  1  1e-4 -1e-383    -> 0.00009999999999999999  Rounded Inexact
ddfma371108 fma  1  1e-5 -1e-383    -> 0.000009999999999999999  Rounded Inexact
ddfma371109 fma  1  1e-6 -1e-383    -> 9.999999999999999E-7  Rounded Inexact

rounding:     ceiling
ddfma371110 fma  1  -1e+2 +1e-383   -> -99.99999999999999 Rounded Inexact
ddfma371111 fma  1  -1e+1 +1e-383   -> -9.999999999999999  Rounded Inexact
ddfma371113 fma  1     -1 +1e-383   -> -0.9999999999999999  Rounded Inexact
ddfma371114 fma  1  -1e-1 +1e-383   -> -0.09999999999999999  Rounded Inexact
ddfma371115 fma  1  -1e-2 +1e-383   -> -0.009999999999999999  Rounded Inexact
ddfma371116 fma  1  -1e-3 +1e-383   -> -0.0009999999999999999  Rounded Inexact
ddfma371117 fma  1  -1e-4 +1e-383   -> -0.00009999999999999999  Rounded Inexact
ddfma371118 fma  1  -1e-5 +1e-383   -> -0.000009999999999999999  Rounded Inexact
ddfma371119 fma  1  -1e-6 +1e-383   -> -9.999999999999999E-7  Rounded Inexact

-- tests based on Gunnar Degnbol's edge case
rounding:     half_even

ddfma371300 fma  1  1E16  -0.5                 ->  1.000000000000000E+16 Inexact Rounded
ddfma371310 fma  1  1E16  -0.51                ->  9999999999999999      Inexact Rounded
ddfma371311 fma  1  1E16  -0.501               ->  9999999999999999      Inexact Rounded
ddfma371312 fma  1  1E16  -0.5001              ->  9999999999999999      Inexact Rounded
ddfma371313 fma  1  1E16  -0.50001             ->  9999999999999999      Inexact Rounded
ddfma371314 fma  1  1E16  -0.500001            ->  9999999999999999      Inexact Rounded
ddfma371315 fma  1  1E16  -0.5000001           ->  9999999999999999      Inexact Rounded
ddfma371316 fma  1  1E16  -0.50000001          ->  9999999999999999      Inexact Rounded
ddfma371317 fma  1  1E16  -0.500000001         ->  9999999999999999      Inexact Rounded
ddfma371318 fma  1  1E16  -0.5000000001        ->  9999999999999999      Inexact Rounded
ddfma371319 fma  1  1E16  -0.50000000001       ->  9999999999999999      Inexact Rounded
ddfma371320 fma  1  1E16  -0.500000000001      ->  9999999999999999      Inexact Rounded
ddfma371321 fma  1  1E16  -0.5000000000001     ->  9999999999999999      Inexact Rounded
ddfma371322 fma  1  1E16  -0.50000000000001    ->  9999999999999999      Inexact Rounded
ddfma371323 fma  1  1E16  -0.500000000000001   ->  9999999999999999      Inexact Rounded
ddfma371324 fma  1  1E16  -0.5000000000000001  ->  9999999999999999      Inexact Rounded
ddfma371325 fma  1  1E16  -0.5000000000000000  ->  1.000000000000000E+16 Inexact Rounded
ddfma371326 fma  1  1E16  -0.500000000000000   ->  1.000000000000000E+16 Inexact Rounded
ddfma371327 fma  1  1E16  -0.50000000000000    ->  1.000000000000000E+16 Inexact Rounded
ddfma371328 fma  1  1E16  -0.5000000000000     ->  1.000000000000000E+16 Inexact Rounded
ddfma371329 fma  1  1E16  -0.500000000000      ->  1.000000000000000E+16 Inexact Rounded
ddfma371330 fma  1  1E16  -0.50000000000       ->  1.000000000000000E+16 Inexact Rounded
ddfma371331 fma  1  1E16  -0.5000000000        ->  1.000000000000000E+16 Inexact Rounded
ddfma371332 fma  1  1E16  -0.500000000         ->  1.000000000000000E+16 Inexact Rounded
ddfma371333 fma  1  1E16  -0.50000000          ->  1.000000000000000E+16 Inexact Rounded
ddfma371334 fma  1  1E16  -0.5000000           ->  1.000000000000000E+16 Inexact Rounded
ddfma371335 fma  1  1E16  -0.500000            ->  1.000000000000000E+16 Inexact Rounded
ddfma371336 fma  1  1E16  -0.50000             ->  1.000000000000000E+16 Inexact Rounded
ddfma371337 fma  1  1E16  -0.5000              ->  1.000000000000000E+16 Inexact Rounded
ddfma371338 fma  1  1E16  -0.500               ->  1.000000000000000E+16 Inexact Rounded
ddfma371339 fma  1  1E16  -0.50                ->  1.000000000000000E+16 Inexact Rounded

ddfma371340 fma  1  1E16  -5000000.000010001   ->  9999999995000000      Inexact Rounded
ddfma371341 fma  1  1E16  -5000000.000000001   ->  9999999995000000      Inexact Rounded

ddfma371349 fma  1  9999999999999999 0.4                 ->  9999999999999999      Inexact Rounded
ddfma371350 fma  1  9999999999999999 0.49                ->  9999999999999999      Inexact Rounded
ddfma371351 fma  1  9999999999999999 0.499               ->  9999999999999999      Inexact Rounded
ddfma371352 fma  1  9999999999999999 0.4999              ->  9999999999999999      Inexact Rounded
ddfma371353 fma  1  9999999999999999 0.49999             ->  9999999999999999      Inexact Rounded
ddfma371354 fma  1  9999999999999999 0.499999            ->  9999999999999999      Inexact Rounded
ddfma371355 fma  1  9999999999999999 0.4999999           ->  9999999999999999      Inexact Rounded
ddfma371356 fma  1  9999999999999999 0.49999999          ->  9999999999999999      Inexact Rounded
ddfma371357 fma  1  9999999999999999 0.499999999         ->  9999999999999999      Inexact Rounded
ddfma371358 fma  1  9999999999999999 0.4999999999        ->  9999999999999999      Inexact Rounded
ddfma371359 fma  1  9999999999999999 0.49999999999       ->  9999999999999999      Inexact Rounded
ddfma371360 fma  1  9999999999999999 0.499999999999      ->  9999999999999999      Inexact Rounded
ddfma371361 fma  1  9999999999999999 0.4999999999999     ->  9999999999999999      Inexact Rounded
ddfma371362 fma  1  9999999999999999 0.49999999999999    ->  9999999999999999      Inexact Rounded
ddfma371363 fma  1  9999999999999999 0.499999999999999   ->  9999999999999999      Inexact Rounded
ddfma371364 fma  1  9999999999999999 0.4999999999999999  ->  9999999999999999      Inexact Rounded
ddfma371365 fma  1  9999999999999999 0.5000000000000000  ->  1.000000000000000E+16 Inexact Rounded
ddfma371367 fma  1  9999999999999999 0.500000000000000   ->  1.000000000000000E+16 Inexact Rounded
ddfma371368 fma  1  9999999999999999 0.50000000000000    ->  1.000000000000000E+16 Inexact Rounded
ddfma371369 fma  1  9999999999999999 0.5000000000000     ->  1.000000000000000E+16 Inexact Rounded
ddfma371370 fma  1  9999999999999999 0.500000000000      ->  1.000000000000000E+16 Inexact Rounded
ddfma371371 fma  1  9999999999999999 0.50000000000       ->  1.000000000000000E+16 Inexact Rounded
ddfma371372 fma  1  9999999999999999 0.5000000000        ->  1.000000000000000E+16 Inexact Rounded
ddfma371373 fma  1  9999999999999999 0.500000000         ->  1.000000000000000E+16 Inexact Rounded
ddfma371374 fma  1  9999999999999999 0.50000000          ->  1.000000000000000E+16 Inexact Rounded
ddfma371375 fma  1  9999999999999999 0.5000000           ->  1.000000000000000E+16 Inexact Rounded
ddfma371376 fma  1  9999999999999999 0.500000            ->  1.000000000000000E+16 Inexact Rounded
ddfma371377 fma  1  9999999999999999 0.50000             ->  1.000000000000000E+16 Inexact Rounded
ddfma371378 fma  1  9999999999999999 0.5000              ->  1.000000000000000E+16 Inexact Rounded
ddfma371379 fma  1  9999999999999999 0.500               ->  1.000000000000000E+16 Inexact Rounded
ddfma371380 fma  1  9999999999999999 0.50                ->  1.000000000000000E+16 Inexact Rounded
ddfma371381 fma  1  9999999999999999 0.5                 ->  1.000000000000000E+16 Inexact Rounded
ddfma371382 fma  1  9999999999999999 0.5000000000000001  ->  1.000000000000000E+16 Inexact Rounded
ddfma371383 fma  1  9999999999999999 0.500000000000001   ->  1.000000000000000E+16 Inexact Rounded
ddfma371384 fma  1  9999999999999999 0.50000000000001    ->  1.000000000000000E+16 Inexact Rounded
ddfma371385 fma  1  9999999999999999 0.5000000000001     ->  1.000000000000000E+16 Inexact Rounded
ddfma371386 fma  1  9999999999999999 0.500000000001      ->  1.000000000000000E+16 Inexact Rounded
ddfma371387 fma  1  9999999999999999 0.50000000001       ->  1.000000000000000E+16 Inexact Rounded
ddfma371388 fma  1  9999999999999999 0.5000000001        ->  1.000000000000000E+16 Inexact Rounded
ddfma371389 fma  1  9999999999999999 0.500000001         ->  1.000000000000000E+16 Inexact Rounded
ddfma371390 fma  1  9999999999999999 0.50000001          ->  1.000000000000000E+16 Inexact Rounded
ddfma371391 fma  1  9999999999999999 0.5000001           ->  1.000000000000000E+16 Inexact Rounded
ddfma371392 fma  1  9999999999999999 0.500001            ->  1.000000000000000E+16 Inexact Rounded
ddfma371393 fma  1  9999999999999999 0.50001             ->  1.000000000000000E+16 Inexact Rounded
ddfma371394 fma  1  9999999999999999 0.5001              ->  1.000000000000000E+16 Inexact Rounded
ddfma371395 fma  1  9999999999999999 0.501               ->  1.000000000000000E+16 Inexact Rounded
ddfma371396 fma  1  9999999999999999 0.51                ->  1.000000000000000E+16 Inexact Rounded

-- More GD edge cases, where difference between the unadjusted
-- exponents is larger than the maximum precision and one side is 0
ddfma371420 fma  1   0 1.123456789012345     -> 1.123456789012345
ddfma371421 fma  1   0 1.123456789012345E-1  -> 0.1123456789012345
ddfma371422 fma  1   0 1.123456789012345E-2  -> 0.01123456789012345
ddfma371423 fma  1   0 1.123456789012345E-3  -> 0.001123456789012345
ddfma371424 fma  1   0 1.123456789012345E-4  -> 0.0001123456789012345
ddfma371425 fma  1   0 1.123456789012345E-5  -> 0.00001123456789012345
ddfma371426 fma  1   0 1.123456789012345E-6  -> 0.000001123456789012345
ddfma371427 fma  1   0 1.123456789012345E-7  -> 1.123456789012345E-7
ddfma371428 fma  1   0 1.123456789012345E-8  -> 1.123456789012345E-8
ddfma371429 fma  1   0 1.123456789012345E-9  -> 1.123456789012345E-9
ddfma371430 fma  1   0 1.123456789012345E-10 -> 1.123456789012345E-10
ddfma371431 fma  1   0 1.123456789012345E-11 -> 1.123456789012345E-11
ddfma371432 fma  1   0 1.123456789012345E-12 -> 1.123456789012345E-12
ddfma371433 fma  1   0 1.123456789012345E-13 -> 1.123456789012345E-13
ddfma371434 fma  1   0 1.123456789012345E-14 -> 1.123456789012345E-14
ddfma371435 fma  1   0 1.123456789012345E-15 -> 1.123456789012345E-15
ddfma371436 fma  1   0 1.123456789012345E-16 -> 1.123456789012345E-16
ddfma371437 fma  1   0 1.123456789012345E-17 -> 1.123456789012345E-17
ddfma371438 fma  1   0 1.123456789012345E-18 -> 1.123456789012345E-18
ddfma371439 fma  1   0 1.123456789012345E-19 -> 1.123456789012345E-19

-- same, reversed 0
ddfma371440 fma  1  1.123456789012345     0 -> 1.123456789012345
ddfma371441 fma  1  1.123456789012345E-1  0 -> 0.1123456789012345
ddfma371442 fma  1  1.123456789012345E-2  0 -> 0.01123456789012345
ddfma371443 fma  1  1.123456789012345E-3  0 -> 0.001123456789012345
ddfma371444 fma  1  1.123456789012345E-4  0 -> 0.0001123456789012345
ddfma371445 fma  1  1.123456789012345E-5  0 -> 0.00001123456789012345
ddfma371446 fma  1  1.123456789012345E-6  0 -> 0.000001123456789012345
ddfma371447 fma  1  1.123456789012345E-7  0 -> 1.123456789012345E-7
ddfma371448 fma  1  1.123456789012345E-8  0 -> 1.123456789012345E-8
ddfma371449 fma  1  1.123456789012345E-9  0 -> 1.123456789012345E-9
ddfma371450 fma  1  1.123456789012345E-10 0 -> 1.123456789012345E-10
ddfma371451 fma  1  1.123456789012345E-11 0 -> 1.123456789012345E-11
ddfma371452 fma  1  1.123456789012345E-12 0 -> 1.123456789012345E-12
ddfma371453 fma  1  1.123456789012345E-13 0 -> 1.123456789012345E-13
ddfma371454 fma  1  1.123456789012345E-14 0 -> 1.123456789012345E-14
ddfma371455 fma  1  1.123456789012345E-15 0 -> 1.123456789012345E-15
ddfma371456 fma  1  1.123456789012345E-16 0 -> 1.123456789012345E-16
ddfma371457 fma  1  1.123456789012345E-17 0 -> 1.123456789012345E-17
ddfma371458 fma  1  1.123456789012345E-18 0 -> 1.123456789012345E-18
ddfma371459 fma  1  1.123456789012345E-19 0 -> 1.123456789012345E-19

-- same, Es on the 0
ddfma371460 fma  1  1.123456789012345  0E-0   -> 1.123456789012345
ddfma371461 fma  1  1.123456789012345  0E-1   -> 1.123456789012345
ddfma371462 fma  1  1.123456789012345  0E-2   -> 1.123456789012345
ddfma371463 fma  1  1.123456789012345  0E-3   -> 1.123456789012345
ddfma371464 fma  1  1.123456789012345  0E-4   -> 1.123456789012345
ddfma371465 fma  1  1.123456789012345  0E-5   -> 1.123456789012345
ddfma371466 fma  1  1.123456789012345  0E-6   -> 1.123456789012345
ddfma371467 fma  1  1.123456789012345  0E-7   -> 1.123456789012345
ddfma371468 fma  1  1.123456789012345  0E-8   -> 1.123456789012345
ddfma371469 fma  1  1.123456789012345  0E-9   -> 1.123456789012345
ddfma371470 fma  1  1.123456789012345  0E-10  -> 1.123456789012345
ddfma371471 fma  1  1.123456789012345  0E-11  -> 1.123456789012345
ddfma371472 fma  1  1.123456789012345  0E-12  -> 1.123456789012345
ddfma371473 fma  1  1.123456789012345  0E-13  -> 1.123456789012345
ddfma371474 fma  1  1.123456789012345  0E-14  -> 1.123456789012345
ddfma371475 fma  1  1.123456789012345  0E-15  -> 1.123456789012345
-- next four flag Rounded because the 0 extends the result
ddfma371476 fma  1  1.123456789012345  0E-16  -> 1.123456789012345 Rounded
ddfma371477 fma  1  1.123456789012345  0E-17  -> 1.123456789012345 Rounded
ddfma371478 fma  1  1.123456789012345  0E-18  -> 1.123456789012345 Rounded
ddfma371479 fma  1  1.123456789012345  0E-19  -> 1.123456789012345 Rounded

-- sum of two opposite-sign operands is exactly 0 and floor => -0
rounding:    half_up
-- exact zeros from zeros
ddfma371500 fma  1   0        0E-19  ->  0E-19
ddfma371501 fma  1  -0        0E-19  ->  0E-19
ddfma371502 fma  1   0       -0E-19  ->  0E-19
ddfma371503 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddfma371511 fma  1  -11      11    ->  0
ddfma371512 fma  1   11     -11    ->  0

rounding:    half_down
-- exact zeros from zeros
ddfma371520 fma  1   0        0E-19  ->  0E-19
ddfma371521 fma  1  -0        0E-19  ->  0E-19
ddfma371522 fma  1   0       -0E-19  ->  0E-19
ddfma371523 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddfma371531 fma  1  -11      11    ->  0
ddfma371532 fma  1   11     -11    ->  0

rounding:    half_even
-- exact zeros from zeros
ddfma371540 fma  1   0        0E-19  ->  0E-19
ddfma371541 fma  1  -0        0E-19  ->  0E-19
ddfma371542 fma  1   0       -0E-19  ->  0E-19
ddfma371543 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddfma371551 fma  1  -11      11    ->  0
ddfma371552 fma  1   11     -11    ->  0

rounding:    up
-- exact zeros from zeros
ddfma371560 fma  1   0        0E-19  ->  0E-19
ddfma371561 fma  1  -0        0E-19  ->  0E-19
ddfma371562 fma  1   0       -0E-19  ->  0E-19
ddfma371563 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddfma371571 fma  1  -11      11    ->  0
ddfma371572 fma  1   11     -11    ->  0

rounding:    down
-- exact zeros from zeros
ddfma371580 fma  1   0        0E-19  ->  0E-19
ddfma371581 fma  1  -0        0E-19  ->  0E-19
ddfma371582 fma  1   0       -0E-19  ->  0E-19
ddfma371583 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddfma371591 fma  1  -11      11    ->  0
ddfma371592 fma  1   11     -11    ->  0

rounding:    ceiling
-- exact zeros from zeros
ddfma371600 fma  1   0        0E-19  ->  0E-19
ddfma371601 fma  1  -0        0E-19  ->  0E-19
ddfma371602 fma  1   0       -0E-19  ->  0E-19
ddfma371603 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddfma371611 fma  1  -11      11    ->  0
ddfma371612 fma  1   11     -11    ->  0

-- and the extra-special ugly case; unusual minuses marked by -- *
rounding:    floor
-- exact zeros from zeros
ddfma371620 fma  1   0        0E-19  ->  0E-19
ddfma371621 fma  1  -0        0E-19  -> -0E-19           -- *
ddfma371622 fma  1   0       -0E-19  -> -0E-19           -- *
ddfma371623 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
ddfma371631 fma  1  -11      11    ->  -0                -- *
ddfma371632 fma  1   11     -11    ->  -0                -- *

-- Examples from SQL proposal (Krishna Kulkarni)
ddfma371701 fma  1  130E-2    120E-2    -> 2.50
ddfma371702 fma  1  130E-2    12E-1     -> 2.50
ddfma371703 fma  1  130E-2    1E0       -> 2.30
ddfma371704 fma  1  1E2       1E4       -> 1.01E+4
ddfma371705 fma  1  130E-2   -120E-2 -> 0.10
ddfma371706 fma  1  130E-2   -12E-1  -> 0.10
ddfma371707 fma  1  130E-2   -1E0    -> 0.30
ddfma371708 fma  1  1E2      -1E4    -> -9.9E+3

-- Gappy coefficients; check residue handling even with full coefficient gap
rounding: half_even

ddfma375001 fma  1  1234567890123456 1      -> 1234567890123457
ddfma375002 fma  1  1234567890123456 0.6    -> 1234567890123457  Inexact Rounded
ddfma375003 fma  1  1234567890123456 0.06   -> 1234567890123456  Inexact Rounded
ddfma375004 fma  1  1234567890123456 6E-3   -> 1234567890123456  Inexact Rounded
ddfma375005 fma  1  1234567890123456 6E-4   -> 1234567890123456  Inexact Rounded
ddfma375006 fma  1  1234567890123456 6E-5   -> 1234567890123456  Inexact Rounded
ddfma375007 fma  1  1234567890123456 6E-6   -> 1234567890123456  Inexact Rounded
ddfma375008 fma  1  1234567890123456 6E-7   -> 1234567890123456  Inexact Rounded
ddfma375009 fma  1  1234567890123456 6E-8   -> 1234567890123456  Inexact Rounded
ddfma375010 fma  1  1234567890123456 6E-9   -> 1234567890123456  Inexact Rounded
ddfma375011 fma  1  1234567890123456 6E-10  -> 1234567890123456  Inexact Rounded
ddfma375012 fma  1  1234567890123456 6E-11  -> 1234567890123456  Inexact Rounded
ddfma375013 fma  1  1234567890123456 6E-12  -> 1234567890123456  Inexact Rounded
ddfma375014 fma  1  1234567890123456 6E-13  -> 1234567890123456  Inexact Rounded
ddfma375015 fma  1  1234567890123456 6E-14  -> 1234567890123456  Inexact Rounded
ddfma375016 fma  1  1234567890123456 6E-15  -> 1234567890123456  Inexact Rounded
ddfma375017 fma  1  1234567890123456 6E-16  -> 1234567890123456  Inexact Rounded
ddfma375018 fma  1  1234567890123456 6E-17  -> 1234567890123456  Inexact Rounded
ddfma375019 fma  1  1234567890123456 6E-18  -> 1234567890123456  Inexact Rounded
ddfma375020 fma  1  1234567890123456 6E-19  -> 1234567890123456  Inexact Rounded
ddfma375021 fma  1  1234567890123456 6E-20  -> 1234567890123456  Inexact Rounded

-- widening second argument at gap
ddfma375030 fma  1  12345678 1                       -> 12345679
ddfma375031 fma  1  12345678 0.1                     -> 12345678.1
ddfma375032 fma  1  12345678 0.12                    -> 12345678.12
ddfma375033 fma  1  12345678 0.123                   -> 12345678.123
ddfma375034 fma  1  12345678 0.1234                  -> 12345678.1234
ddfma375035 fma  1  12345678 0.12345                 -> 12345678.12345
ddfma375036 fma  1  12345678 0.123456                -> 12345678.123456
ddfma375037 fma  1  12345678 0.1234567               -> 12345678.1234567
ddfma375038 fma  1  12345678 0.12345678              -> 12345678.12345678
ddfma375039 fma  1  12345678 0.123456789             -> 12345678.12345679 Inexact Rounded
ddfma375040 fma  1  12345678 0.123456785             -> 12345678.12345678 Inexact Rounded
ddfma375041 fma  1  12345678 0.1234567850            -> 12345678.12345678 Inexact Rounded
ddfma375042 fma  1  12345678 0.1234567851            -> 12345678.12345679 Inexact Rounded
ddfma375043 fma  1  12345678 0.12345678501           -> 12345678.12345679 Inexact Rounded
ddfma375044 fma  1  12345678 0.123456785001          -> 12345678.12345679 Inexact Rounded
ddfma375045 fma  1  12345678 0.1234567850001         -> 12345678.12345679 Inexact Rounded
ddfma375046 fma  1  12345678 0.12345678500001        -> 12345678.12345679 Inexact Rounded
ddfma375047 fma  1  12345678 0.123456785000001       -> 12345678.12345679 Inexact Rounded
ddfma375048 fma  1  12345678 0.1234567850000001      -> 12345678.12345679 Inexact Rounded
ddfma375049 fma  1  12345678 0.1234567850000000      -> 12345678.12345678 Inexact Rounded
--                               90123456
rounding: half_even
ddfma375050 fma  1  12345678 0.0234567750000000      -> 12345678.02345678 Inexact Rounded
ddfma375051 fma  1  12345678 0.0034567750000000      -> 12345678.00345678 Inexact Rounded
ddfma375052 fma  1  12345678 0.0004567750000000      -> 12345678.00045678 Inexact Rounded
ddfma375053 fma  1  12345678 0.0000567750000000      -> 12345678.00005678 Inexact Rounded
ddfma375054 fma  1  12345678 0.0000067750000000      -> 12345678.00000678 Inexact Rounded
ddfma375055 fma  1  12345678 0.0000007750000000      -> 12345678.00000078 Inexact Rounded
ddfma375056 fma  1  12345678 0.0000000750000000      -> 12345678.00000008 Inexact Rounded
ddfma375057 fma  1  12345678 0.0000000050000000      -> 12345678.00000000 Inexact Rounded
ddfma375060 fma  1  12345678 0.0234567750000001      -> 12345678.02345678 Inexact Rounded
ddfma375061 fma  1  12345678 0.0034567750000001      -> 12345678.00345678 Inexact Rounded
ddfma375062 fma  1  12345678 0.0004567750000001      -> 12345678.00045678 Inexact Rounded
ddfma375063 fma  1  12345678 0.0000567750000001      -> 12345678.00005678 Inexact Rounded
ddfma375064 fma  1  12345678 0.0000067750000001      -> 12345678.00000678 Inexact Rounded
ddfma375065 fma  1  12345678 0.0000007750000001      -> 12345678.00000078 Inexact Rounded
ddfma375066 fma  1  12345678 0.0000000750000001      -> 12345678.00000008 Inexact Rounded
ddfma375067 fma  1  12345678 0.0000000050000001      -> 12345678.00000001 Inexact Rounded
-- far-out residues (full coefficient gap is 16+15 digits)
rounding: up
ddfma375070 fma  1  12345678 1E-8                    -> 12345678.00000001
ddfma375071 fma  1  12345678 1E-9                    -> 12345678.00000001 Inexact Rounded
ddfma375072 fma  1  12345678 1E-10                   -> 12345678.00000001 Inexact Rounded
ddfma375073 fma  1  12345678 1E-11                   -> 12345678.00000001 Inexact Rounded
ddfma375074 fma  1  12345678 1E-12                   -> 12345678.00000001 Inexact Rounded
ddfma375075 fma  1  12345678 1E-13                   -> 12345678.00000001 Inexact Rounded
ddfma375076 fma  1  12345678 1E-14                   -> 12345678.00000001 Inexact Rounded
ddfma375077 fma  1  12345678 1E-15                   -> 12345678.00000001 Inexact Rounded
ddfma375078 fma  1  12345678 1E-16                   -> 12345678.00000001 Inexact Rounded
ddfma375079 fma  1  12345678 1E-17                   -> 12345678.00000001 Inexact Rounded
ddfma375080 fma  1  12345678 1E-18                   -> 12345678.00000001 Inexact Rounded
ddfma375081 fma  1  12345678 1E-19                   -> 12345678.00000001 Inexact Rounded
ddfma375082 fma  1  12345678 1E-20                   -> 12345678.00000001 Inexact Rounded
ddfma375083 fma  1  12345678 1E-25                   -> 12345678.00000001 Inexact Rounded
ddfma375084 fma  1  12345678 1E-30                   -> 12345678.00000001 Inexact Rounded
ddfma375085 fma  1  12345678 1E-31                   -> 12345678.00000001 Inexact Rounded
ddfma375086 fma  1  12345678 1E-32                   -> 12345678.00000001 Inexact Rounded
ddfma375087 fma  1  12345678 1E-33                   -> 12345678.00000001 Inexact Rounded
ddfma375088 fma  1  12345678 1E-34                   -> 12345678.00000001 Inexact Rounded
ddfma375089 fma  1  12345678 1E-35                   -> 12345678.00000001 Inexact Rounded

-- Null tests
ddfma39990 fma  1  10  # -> NaN Invalid_operation
ddfma39991 fma  1   # 10 -> NaN Invalid_operation


Added test/dectest/ddInvert.decTest.





















































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
------------------------------------------------------------------------
-- ddInvert.decTest -- digitwise logical INVERT for decDoubles        --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check (truth table)
ddinv001 invert             0 -> 1111111111111111
ddinv002 invert             1 -> 1111111111111110
ddinv003 invert            10 -> 1111111111111101
ddinv004 invert     111111111 -> 1111111000000000
ddinv005 invert     000000000 -> 1111111111111111
-- and at msd and msd-1
ddinv007 invert 0000000000000000 ->   1111111111111111
ddinv008 invert 1000000000000000 ->    111111111111111
ddinv009 invert 0000000000000000 ->   1111111111111111
ddinv010 invert 0100000000000000 ->   1011111111111111
ddinv011 invert 0111111111111111 ->   1000000000000000
ddinv012 invert 1111111111111111 ->                  0
ddinv013 invert 0011111111111111 ->   1100000000000000
ddinv014 invert 0111111111111111 ->   1000000000000000

-- Various lengths
--             123456789         1234567890123456
ddinv021 invert 111111111     ->  1111111000000000
ddinv022 invert 111111111111  ->  1111000000000000
ddinv023 invert  11111111     ->  1111111100000000
ddinv025 invert   1111111     ->  1111111110000000
ddinv026 invert    111111     ->  1111111111000000
ddinv027 invert     11111     ->  1111111111100000
ddinv028 invert      1111     ->  1111111111110000
ddinv029 invert       111     ->  1111111111111000
ddinv031 invert        11     ->  1111111111111100
ddinv032 invert         1     ->  1111111111111110
ddinv033 invert 111111111111  ->  1111000000000000
ddinv034 invert 11111111111   ->  1111100000000000
ddinv035 invert 1111111111    ->  1111110000000000
ddinv036 invert 111111111     ->  1111111000000000

ddinv040 invert 011111111   ->  1111111100000000
ddinv041 invert 101111111   ->  1111111010000000
ddinv042 invert 110111111   ->  1111111001000000
ddinv043 invert 111011111   ->  1111111000100000
ddinv044 invert 111101111   ->  1111111000010000
ddinv045 invert 111110111   ->  1111111000001000
ddinv046 invert 111111011   ->  1111111000000100
ddinv047 invert 111111101   ->  1111111000000010
ddinv048 invert 111111110   ->  1111111000000001
ddinv049 invert 011111011   ->  1111111100000100
ddinv050 invert 101111101   ->  1111111010000010
ddinv051 invert 110111110   ->  1111111001000001
ddinv052 invert 111011101   ->  1111111000100010
ddinv053 invert 111101011   ->  1111111000010100
ddinv054 invert 111110111   ->  1111111000001000
ddinv055 invert 111101011   ->  1111111000010100
ddinv056 invert 111011101   ->  1111111000100010
ddinv057 invert 110111110   ->  1111111001000001
ddinv058 invert 101111101   ->  1111111010000010
ddinv059 invert 011111011   ->  1111111100000100

ddinv080 invert 1000000011111111   ->   111111100000000
ddinv081 invert 0100000101111111   ->  1011111010000000
ddinv082 invert 0010000110111111   ->  1101111001000000
ddinv083 invert 0001000111011111   ->  1110111000100000
ddinv084 invert 0000100111101111   ->  1111011000010000
ddinv085 invert 0000010111110111   ->  1111101000001000
ddinv086 invert 0000001111111011   ->  1111110000000100
ddinv087 invert 0000010111111101   ->  1111101000000010
ddinv088 invert 0000100111111110   ->  1111011000000001
ddinv089 invert 0001000011111011   ->  1110111100000100
ddinv090 invert 0010000101111101   ->  1101111010000010
ddinv091 invert 0100000110111110   ->  1011111001000001
ddinv092 invert 1000000111011101   ->   111111000100010
ddinv093 invert 0100000111101011   ->  1011111000010100
ddinv094 invert 0010000111110111   ->  1101111000001000
ddinv095 invert 0001000111101011   ->  1110111000010100
ddinv096 invert 0000100111011101   ->  1111011000100010
ddinv097 invert 0000010110111110   ->  1111101001000001
ddinv098 invert 0000001101111101   ->  1111110010000010
ddinv099 invert 0000010011111011   ->  1111101100000100

-- non-0/1 should not be accepted, nor should signs
ddinv220 invert 111111112   ->  NaN Invalid_operation
ddinv221 invert 333333333   ->  NaN Invalid_operation
ddinv222 invert 555555555   ->  NaN Invalid_operation
ddinv223 invert 777777777   ->  NaN Invalid_operation
ddinv224 invert 999999999   ->  NaN Invalid_operation
ddinv225 invert 222222222   ->  NaN Invalid_operation
ddinv226 invert 444444444   ->  NaN Invalid_operation
ddinv227 invert 666666666   ->  NaN Invalid_operation
ddinv228 invert 888888888   ->  NaN Invalid_operation
ddinv229 invert 999999999   ->  NaN Invalid_operation
ddinv230 invert 999999999   ->  NaN Invalid_operation
ddinv231 invert 999999999   ->  NaN Invalid_operation
ddinv232 invert 999999999   ->  NaN Invalid_operation
-- a few randoms
ddinv240 invert  567468689  ->  NaN Invalid_operation
ddinv241 invert  567367689  ->  NaN Invalid_operation
ddinv242 invert -631917772  ->  NaN Invalid_operation
ddinv243 invert -756253257  ->  NaN Invalid_operation
ddinv244 invert  835590149  ->  NaN Invalid_operation
-- test MSD
ddinv250 invert  2000000000000000  ->  NaN Invalid_operation
ddinv251 invert  3000000000000000  ->  NaN Invalid_operation
ddinv252 invert  4000000000000000  ->  NaN Invalid_operation
ddinv253 invert  5000000000000000  ->  NaN Invalid_operation
ddinv254 invert  6000000000000000  ->  NaN Invalid_operation
ddinv255 invert  7000000000000000  ->  NaN Invalid_operation
ddinv256 invert  8000000000000000  ->  NaN Invalid_operation
ddinv257 invert  9000000000000000  ->  NaN Invalid_operation
-- test MSD-1
ddinv270 invert  0200001000000000  ->  NaN Invalid_operation
ddinv271 invert  0300000100000000  ->  NaN Invalid_operation
ddinv272 invert  0400000010000000  ->  NaN Invalid_operation
ddinv273 invert  0500000001000000  ->  NaN Invalid_operation
ddinv274 invert  1600000000100000  ->  NaN Invalid_operation
ddinv275 invert  1700000000010000  ->  NaN Invalid_operation
ddinv276 invert  1800000000001000  ->  NaN Invalid_operation
ddinv277 invert  1900000000000100  ->  NaN Invalid_operation
-- test LSD
ddinv280 invert  0010000000000002  ->  NaN Invalid_operation
ddinv281 invert  0001000000000003  ->  NaN Invalid_operation
ddinv282 invert  0000100000000004  ->  NaN Invalid_operation
ddinv283 invert  0000010000000005  ->  NaN Invalid_operation
ddinv284 invert  1000001000000006  ->  NaN Invalid_operation
ddinv285 invert  1000000100000007  ->  NaN Invalid_operation
ddinv286 invert  1000000010000008  ->  NaN Invalid_operation
ddinv287 invert  1000000001000009  ->  NaN Invalid_operation
-- test Middie
ddinv288 invert  0010000020000000  ->  NaN Invalid_operation
ddinv289 invert  0001000030000001  ->  NaN Invalid_operation
ddinv290 invert  0000100040000010  ->  NaN Invalid_operation
ddinv291 invert  0000010050000100  ->  NaN Invalid_operation
ddinv292 invert  1000001060001000  ->  NaN Invalid_operation
ddinv293 invert  1000000170010000  ->  NaN Invalid_operation
ddinv294 invert  1000000080100000  ->  NaN Invalid_operation
ddinv295 invert  1000000091000000  ->  NaN Invalid_operation
-- sign
ddinv296 invert -1000000001000000  ->  NaN Invalid_operation
ddinv299 invert  1000000001000000  ->  111111110111111


-- Nmax, Nmin, Ntiny-like
ddinv341 invert  9.99999999E+299   -> NaN Invalid_operation
ddinv342 invert  1E-299            -> NaN Invalid_operation
ddinv343 invert  1.00000000E-299   -> NaN Invalid_operation
ddinv344 invert  1E-207            -> NaN Invalid_operation
ddinv345 invert  -1E-207           -> NaN Invalid_operation
ddinv346 invert  -1.00000000E-299  -> NaN Invalid_operation
ddinv347 invert  -1E-299           -> NaN Invalid_operation
ddinv348 invert  -9.99999999E+299  -> NaN Invalid_operation

-- A few other non-integers
ddinv361 invert  1.0               -> NaN Invalid_operation
ddinv362 invert  1E+1              -> NaN Invalid_operation
ddinv363 invert  0.0               -> NaN Invalid_operation
ddinv364 invert  0E+1              -> NaN Invalid_operation
ddinv365 invert  9.9               -> NaN Invalid_operation
ddinv366 invert  9E+1              -> NaN Invalid_operation

-- All Specials are in error
ddinv788 invert -Inf     -> NaN  Invalid_operation
ddinv794 invert  Inf     -> NaN  Invalid_operation
ddinv821 invert  NaN     -> NaN  Invalid_operation
ddinv841 invert  sNaN    -> NaN  Invalid_operation
-- propagating NaNs
ddinv861 invert  NaN1    -> NaN Invalid_operation
ddinv862 invert +NaN2    -> NaN Invalid_operation
ddinv863 invert  NaN3    -> NaN Invalid_operation
ddinv864 invert  NaN4    -> NaN Invalid_operation
ddinv865 invert  NaN5    -> NaN Invalid_operation
ddinv871 invert  sNaN11  -> NaN Invalid_operation
ddinv872 invert  sNaN12  -> NaN Invalid_operation
ddinv873 invert  sNaN13  -> NaN Invalid_operation
ddinv874 invert  sNaN14  -> NaN Invalid_operation
ddinv875 invert  sNaN15  -> NaN Invalid_operation
ddinv876 invert  NaN16   -> NaN Invalid_operation
ddinv881 invert +NaN25   -> NaN Invalid_operation
ddinv882 invert -NaN26   -> NaN Invalid_operation
ddinv883 invert -sNaN27  -> NaN Invalid_operation

Added test/dectest/ddLogB.decTest.































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
------------------------------------------------------------------------
-- ddLogB.decTest -- integral 754r adjusted exponent, for decDoubles  --
-- Copyright (c) IBM Corporation, 2005, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- basics
ddlogb000 logb  0                 -> -Infinity  Division_by_zero
ddlogb001 logb  1E-398            -> -398
ddlogb002 logb  1E-383            -> -383
ddlogb003 logb  0.001             -> -3
ddlogb004 logb  0.03              -> -2
ddlogb005 logb  1                 ->  0
ddlogb006 logb  2                 ->  0
ddlogb007 logb  2.5               ->  0
ddlogb008 logb  2.500             ->  0
ddlogb009 logb  10                ->  1
ddlogb010 logb  70                ->  1
ddlogb011 logb  100               ->  2
ddlogb012 logb  333               ->  2
ddlogb013 logb  9E+384            ->  384
ddlogb014 logb +Infinity          ->  Infinity

-- negatives appear to be treated as positives
ddlogb021 logb -0                 -> -Infinity  Division_by_zero
ddlogb022 logb -1E-398            -> -398
ddlogb023 logb -9E-383            -> -383
ddlogb024 logb -0.001             -> -3
ddlogb025 logb -1                 ->  0
ddlogb026 logb -2                 ->  0
ddlogb027 logb -10                ->  1
ddlogb028 logb -70                ->  1
ddlogb029 logb -100               ->  2
ddlogb030 logb -9E+384            ->  384
ddlogb031 logb -Infinity          ->  Infinity

-- zeros
ddlogb111 logb          0   -> -Infinity  Division_by_zero
ddlogb112 logb         -0   -> -Infinity  Division_by_zero
ddlogb113 logb       0E+4   -> -Infinity  Division_by_zero
ddlogb114 logb      -0E+4   -> -Infinity  Division_by_zero
ddlogb115 logb     0.0000   -> -Infinity  Division_by_zero
ddlogb116 logb    -0.0000   -> -Infinity  Division_by_zero
ddlogb117 logb      0E-141  -> -Infinity  Division_by_zero
ddlogb118 logb     -0E-141  -> -Infinity  Division_by_zero

-- full coefficients, alternating bits
ddlogb121 logb   268268268        -> 8
ddlogb122 logb  -268268268        -> 8
ddlogb123 logb   134134134        -> 8
ddlogb124 logb  -134134134        -> 8

-- Nmax, Nmin, Ntiny
ddlogb131 logb  9.999999999999999E+384   ->  384
ddlogb132 logb  1E-383                   -> -383
ddlogb133 logb  1.000000000000000E-383   -> -383
ddlogb134 logb  1E-398                   -> -398

ddlogb135 logb  -1E-398                  -> -398
ddlogb136 logb  -1.000000000000000E-383  -> -383
ddlogb137 logb  -1E-383                  -> -383
ddlogb138 logb  -9.999999999999999E+384  ->  384

-- ones
ddlogb0061 logb  1                 ->   0
ddlogb0062 logb  1.0               ->   0
ddlogb0063 logb  1.000000000000000 ->   0

-- notable cases -- exact powers of 10
ddlogb1100 logb 1             -> 0
ddlogb1101 logb 10            -> 1
ddlogb1102 logb 100           -> 2
ddlogb1103 logb 1000          -> 3
ddlogb1104 logb 10000         -> 4
ddlogb1105 logb 100000        -> 5
ddlogb1106 logb 1000000       -> 6
ddlogb1107 logb 10000000      -> 7
ddlogb1108 logb 100000000     -> 8
ddlogb1109 logb 1000000000    -> 9
ddlogb1110 logb 10000000000   -> 10
ddlogb1111 logb 100000000000  -> 11
ddlogb1112 logb 1000000000000 -> 12
ddlogb1113 logb 0.00000000001 -> -11
ddlogb1114 logb 0.0000000001 -> -10
ddlogb1115 logb 0.000000001 -> -9
ddlogb1116 logb 0.00000001 -> -8
ddlogb1117 logb 0.0000001 -> -7
ddlogb1118 logb 0.000001 -> -6
ddlogb1119 logb 0.00001 -> -5
ddlogb1120 logb 0.0001 -> -4
ddlogb1121 logb 0.001 -> -3
ddlogb1122 logb 0.01 -> -2
ddlogb1123 logb 0.1 -> -1
ddlogb1124 logb 1E-99  -> -99
ddlogb1125 logb 1E-100 -> -100
ddlogb1127 logb 1E-299 -> -299
ddlogb1126 logb 1E-383 -> -383

-- suggestions from Ilan Nehama
ddlogb1400 logb 10E-3    -> -2
ddlogb1401 logb 10E-2    -> -1
ddlogb1402 logb 100E-2   ->  0
ddlogb1403 logb 1000E-2  ->  1
ddlogb1404 logb 10000E-2 ->  2
ddlogb1405 logb 10E-1    ->  0
ddlogb1406 logb 100E-1   ->  1
ddlogb1407 logb 1000E-1  ->  2
ddlogb1408 logb 10000E-1 ->  3
ddlogb1409 logb 10E0     ->  1
ddlogb1410 logb 100E0    ->  2
ddlogb1411 logb 1000E0   ->  3
ddlogb1412 logb 10000E0  ->  4
ddlogb1413 logb 10E1     ->  2
ddlogb1414 logb 100E1    ->  3
ddlogb1415 logb 1000E1   ->  4
ddlogb1416 logb 10000E1  ->  5
ddlogb1417 logb 10E2     ->  3
ddlogb1418 logb 100E2    ->  4
ddlogb1419 logb 1000E2   ->  5
ddlogb1420 logb 10000E2  ->  6

-- special values
ddlogb820  logb   Infinity ->   Infinity
ddlogb821  logb   0        ->  -Infinity Division_by_zero
ddlogb822  logb   NaN      ->   NaN
ddlogb823  logb   sNaN     ->   NaN     Invalid_operation
-- propagating NaNs
ddlogb824  logb   sNaN123  ->   NaN123  Invalid_operation
ddlogb825  logb   -sNaN321 ->  -NaN321  Invalid_operation
ddlogb826  logb   NaN456   ->   NaN456
ddlogb827  logb   -NaN654  ->  -NaN654
ddlogb828  logb   NaN1     ->   NaN1

-- Null test
ddlogb900  logb #   -> NaN Invalid_operation


Added test/dectest/ddMax.decTest.





































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
------------------------------------------------------------------------
-- ddMax.decTest -- decDouble maxnum                                  --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks
ddmax001 max  -2  -2  -> -2
ddmax002 max  -2  -1  -> -1
ddmax003 max  -2   0  ->  0
ddmax004 max  -2   1  ->  1
ddmax005 max  -2   2  ->  2
ddmax006 max  -1  -2  -> -1
ddmax007 max  -1  -1  -> -1
ddmax008 max  -1   0  ->  0
ddmax009 max  -1   1  ->  1
ddmax010 max  -1   2  ->  2
ddmax011 max   0  -2  ->  0
ddmax012 max   0  -1  ->  0
ddmax013 max   0   0  ->  0
ddmax014 max   0   1  ->  1
ddmax015 max   0   2  ->  2
ddmax016 max   1  -2  ->  1
ddmax017 max   1  -1  ->  1
ddmax018 max   1   0  ->  1
ddmax019 max   1   1  ->  1
ddmax020 max   1   2  ->  2
ddmax021 max   2  -2  ->  2
ddmax022 max   2  -1  ->  2
ddmax023 max   2   0  ->  2
ddmax025 max   2   1  ->  2
ddmax026 max   2   2  ->  2

-- extended zeros
ddmax030 max   0     0   ->  0
ddmax031 max   0    -0   ->  0
ddmax032 max   0    -0.0 ->  0
ddmax033 max   0     0.0 ->  0
ddmax034 max  -0     0   ->  0    -- note: -0 = 0, but 0 chosen
ddmax035 max  -0    -0   -> -0
ddmax036 max  -0    -0.0 -> -0.0
ddmax037 max  -0     0.0 ->  0.0
ddmax038 max   0.0   0   ->  0
ddmax039 max   0.0  -0   ->  0.0
ddmax040 max   0.0  -0.0 ->  0.0
ddmax041 max   0.0   0.0 ->  0.0
ddmax042 max  -0.0   0   ->  0
ddmax043 max  -0.0  -0   -> -0.0
ddmax044 max  -0.0  -0.0 -> -0.0
ddmax045 max  -0.0   0.0 ->  0.0

ddmax050 max  -0E1   0E1 ->  0E+1
ddmax051 max  -0E2   0E2 ->  0E+2
ddmax052 max  -0E2   0E1 ->  0E+1
ddmax053 max  -0E1   0E2 ->  0E+2
ddmax054 max   0E1  -0E1 ->  0E+1
ddmax055 max   0E2  -0E2 ->  0E+2
ddmax056 max   0E2  -0E1 ->  0E+2
ddmax057 max   0E1  -0E2 ->  0E+1

ddmax058 max   0E1   0E1 ->  0E+1
ddmax059 max   0E2   0E2 ->  0E+2
ddmax060 max   0E2   0E1 ->  0E+2
ddmax061 max   0E1   0E2 ->  0E+2
ddmax062 max  -0E1  -0E1 -> -0E+1
ddmax063 max  -0E2  -0E2 -> -0E+2
ddmax064 max  -0E2  -0E1 -> -0E+1
ddmax065 max  -0E1  -0E2 -> -0E+1

-- Specials
ddmax090 max  Inf  -Inf   ->  Infinity
ddmax091 max  Inf  -1000  ->  Infinity
ddmax092 max  Inf  -1     ->  Infinity
ddmax093 max  Inf  -0     ->  Infinity
ddmax094 max  Inf   0     ->  Infinity
ddmax095 max  Inf   1     ->  Infinity
ddmax096 max  Inf   1000  ->  Infinity
ddmax097 max  Inf   Inf   ->  Infinity
ddmax098 max -1000  Inf   ->  Infinity
ddmax099 max -Inf   Inf   ->  Infinity
ddmax100 max -1     Inf   ->  Infinity
ddmax101 max -0     Inf   ->  Infinity
ddmax102 max  0     Inf   ->  Infinity
ddmax103 max  1     Inf   ->  Infinity
ddmax104 max  1000  Inf   ->  Infinity
ddmax105 max  Inf   Inf   ->  Infinity

ddmax120 max -Inf  -Inf   -> -Infinity
ddmax121 max -Inf  -1000  -> -1000
ddmax122 max -Inf  -1     -> -1
ddmax123 max -Inf  -0     -> -0
ddmax124 max -Inf   0     ->  0
ddmax125 max -Inf   1     ->  1
ddmax126 max -Inf   1000  ->  1000
ddmax127 max -Inf   Inf   ->  Infinity
ddmax128 max -Inf  -Inf   ->  -Infinity
ddmax129 max -1000 -Inf   ->  -1000
ddmax130 max -1    -Inf   ->  -1
ddmax131 max -0    -Inf   ->  -0
ddmax132 max  0    -Inf   ->  0
ddmax133 max  1    -Inf   ->  1
ddmax134 max  1000 -Inf   ->  1000
ddmax135 max  Inf  -Inf   ->  Infinity

-- 2004.08.02 754r chooses number over NaN in mixed cases
ddmax141 max  NaN -Inf    -> -Infinity
ddmax142 max  NaN -1000   -> -1000
ddmax143 max  NaN -1      -> -1
ddmax144 max  NaN -0      -> -0
ddmax145 max  NaN  0      ->  0
ddmax146 max  NaN  1      ->  1
ddmax147 max  NaN  1000   ->  1000
ddmax148 max  NaN  Inf    ->  Infinity
ddmax149 max  NaN  NaN    ->  NaN
ddmax150 max -Inf  NaN    -> -Infinity
ddmax151 max -1000 NaN    -> -1000
ddmax152 max -1    NaN    -> -1
ddmax153 max -0    NaN    -> -0
ddmax154 max  0    NaN    ->  0
ddmax155 max  1    NaN    ->  1
ddmax156 max  1000 NaN    ->  1000
ddmax157 max  Inf  NaN    ->  Infinity

ddmax161 max  sNaN -Inf   ->  NaN  Invalid_operation
ddmax162 max  sNaN -1000  ->  NaN  Invalid_operation
ddmax163 max  sNaN -1     ->  NaN  Invalid_operation
ddmax164 max  sNaN -0     ->  NaN  Invalid_operation
ddmax165 max  sNaN  0     ->  NaN  Invalid_operation
ddmax166 max  sNaN  1     ->  NaN  Invalid_operation
ddmax167 max  sNaN  1000  ->  NaN  Invalid_operation
ddmax168 max  sNaN  NaN   ->  NaN  Invalid_operation
ddmax169 max  sNaN sNaN   ->  NaN  Invalid_operation
ddmax170 max  NaN  sNaN   ->  NaN  Invalid_operation
ddmax171 max -Inf  sNaN   ->  NaN  Invalid_operation
ddmax172 max -1000 sNaN   ->  NaN  Invalid_operation
ddmax173 max -1    sNaN   ->  NaN  Invalid_operation
ddmax174 max -0    sNaN   ->  NaN  Invalid_operation
ddmax175 max  0    sNaN   ->  NaN  Invalid_operation
ddmax176 max  1    sNaN   ->  NaN  Invalid_operation
ddmax177 max  1000 sNaN   ->  NaN  Invalid_operation
ddmax178 max  Inf  sNaN   ->  NaN  Invalid_operation
ddmax179 max  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddmax181 max  NaN9  -Inf   -> -Infinity
ddmax182 max  NaN8     9   ->  9
ddmax183 max -NaN7   Inf   ->  Infinity

ddmax184 max -NaN1   NaN11 -> -NaN1
ddmax185 max  NaN2   NaN12 ->  NaN2
ddmax186 max -NaN13 -NaN7  -> -NaN13
ddmax187 max  NaN14 -NaN5  ->  NaN14

ddmax188 max -Inf    NaN4  -> -Infinity
ddmax189 max -9     -NaN3  -> -9
ddmax190 max  Inf    NaN2  ->  Infinity

ddmax191 max  sNaN99 -Inf    ->  NaN99 Invalid_operation
ddmax192 max  sNaN98 -1      ->  NaN98 Invalid_operation
ddmax193 max -sNaN97  NaN    -> -NaN97 Invalid_operation
ddmax194 max  sNaN96 sNaN94  ->  NaN96 Invalid_operation
ddmax195 max  NaN95  sNaN93  ->  NaN93 Invalid_operation
ddmax196 max -Inf    sNaN92  ->  NaN92 Invalid_operation
ddmax197 max  0      sNaN91  ->  NaN91 Invalid_operation
ddmax198 max  Inf   -sNaN90  -> -NaN90 Invalid_operation
ddmax199 max  NaN    sNaN89  ->  NaN89 Invalid_operation

-- old rounding checks
ddmax221 max 12345678000 1  -> 12345678000
ddmax222 max 1 12345678000  -> 12345678000
ddmax223 max 1234567800  1  -> 1234567800
ddmax224 max 1 1234567800   -> 1234567800
ddmax225 max 1234567890  1  -> 1234567890
ddmax226 max 1 1234567890   -> 1234567890
ddmax227 max 1234567891  1  -> 1234567891
ddmax228 max 1 1234567891   -> 1234567891
ddmax229 max 12345678901 1  -> 12345678901
ddmax230 max 1 12345678901  -> 12345678901
ddmax231 max 1234567896  1  -> 1234567896
ddmax232 max 1 1234567896   -> 1234567896
ddmax233 max -1234567891  1 -> 1
ddmax234 max 1 -1234567891  -> 1
ddmax235 max -12345678901 1 -> 1
ddmax236 max 1 -12345678901 -> 1
ddmax237 max -1234567896  1 -> 1
ddmax238 max 1 -1234567896  -> 1

-- from examples
ddmax280 max '3'   '2'  ->  '3'
ddmax281 max '-10' '3'  ->  '3'
ddmax282 max '1.0' '1'  ->  '1'
ddmax283 max '1' '1.0'  ->  '1'
ddmax284 max '7' 'NaN'  ->  '7'

-- expanded list from min/max 754r purple prose
-- [explicit tests for exponent ordering]
ddmax401 max  Inf    1.1     ->  Infinity
ddmax402 max  1.1    1       ->  1.1
ddmax403 max  1      1.0     ->  1
ddmax404 max  1.0    0.1     ->  1.0
ddmax405 max  0.1    0.10    ->  0.1
ddmax406 max  0.10   0.100   ->  0.10
ddmax407 max  0.10   0       ->  0.10
ddmax408 max  0      0.0     ->  0
ddmax409 max  0.0   -0       ->  0.0
ddmax410 max  0.0   -0.0     ->  0.0
ddmax411 max  0.00  -0.0     ->  0.00
ddmax412 max  0.0   -0.00    ->  0.0
ddmax413 max  0     -0.0     ->  0
ddmax414 max  0     -0       ->  0
ddmax415 max -0.0   -0       -> -0.0
ddmax416 max -0     -0.100   -> -0
ddmax417 max -0.100 -0.10    -> -0.100
ddmax418 max -0.10  -0.1     -> -0.10
ddmax419 max -0.1   -1.0     -> -0.1
ddmax420 max -1.0   -1       -> -1.0
ddmax421 max -1     -1.1     -> -1
ddmax423 max -1.1   -Inf     -> -1.1
-- same with operands reversed
ddmax431 max  1.1    Inf     ->  Infinity
ddmax432 max  1      1.1     ->  1.1
ddmax433 max  1.0    1       ->  1
ddmax434 max  0.1    1.0     ->  1.0
ddmax435 max  0.10   0.1     ->  0.1
ddmax436 max  0.100  0.10    ->  0.10
ddmax437 max  0      0.10    ->  0.10
ddmax438 max  0.0    0       ->  0
ddmax439 max -0      0.0     ->  0.0
ddmax440 max -0.0    0.0     ->  0.0
ddmax441 max -0.0    0.00    ->  0.00
ddmax442 max -0.00   0.0     ->  0.0
ddmax443 max -0.0    0       ->  0
ddmax444 max -0      0       ->  0
ddmax445 max -0     -0.0     -> -0.0
ddmax446 max -0.100 -0       -> -0
ddmax447 max -0.10  -0.100   -> -0.100
ddmax448 max -0.1   -0.10    -> -0.10
ddmax449 max -1.0   -0.1     -> -0.1
ddmax450 max -1     -1.0     -> -1.0
ddmax451 max -1.1   -1       -> -1
ddmax453 max -Inf   -1.1     -> -1.1
-- largies
ddmax460 max  1000   1E+3    ->  1E+3
ddmax461 max  1E+3   1000    ->  1E+3
ddmax462 max  1000  -1E+3    ->  1000
ddmax463 max  1E+3  -1000    ->  1E+3
ddmax464 max -1000   1E+3    ->  1E+3
ddmax465 max -1E+3   1000    ->  1000
ddmax466 max -1000  -1E+3    -> -1000
ddmax467 max -1E+3  -1000    -> -1000

-- misalignment traps for little-endian
ddmax471 max      1.0       0.1  -> 1.0
ddmax472 max      0.1       1.0  -> 1.0
ddmax473 max     10.0       0.1  -> 10.0
ddmax474 max      0.1      10.0  -> 10.0
ddmax475 max      100       1.0  -> 100
ddmax476 max      1.0       100  -> 100
ddmax477 max     1000      10.0  -> 1000
ddmax478 max     10.0      1000  -> 1000
ddmax479 max    10000     100.0  -> 10000
ddmax480 max    100.0     10000  -> 10000
ddmax481 max   100000    1000.0  -> 100000
ddmax482 max   1000.0    100000  -> 100000
ddmax483 max  1000000   10000.0  -> 1000000
ddmax484 max  10000.0   1000000  -> 1000000

-- subnormals
ddmax510 max  1.00E-383       0  ->   1.00E-383
ddmax511 max  0.1E-383        0  ->   1E-384    Subnormal
ddmax512 max  0.10E-383       0  ->   1.0E-384  Subnormal
ddmax513 max  0.100E-383      0  ->   1.00E-384 Subnormal
ddmax514 max  0.01E-383       0  ->   1E-385    Subnormal
ddmax515 max  0.999E-383      0  ->   9.99E-384 Subnormal
ddmax516 max  0.099E-383      0  ->   9.9E-385  Subnormal
ddmax517 max  0.009E-383      0  ->   9E-386    Subnormal
ddmax518 max  0.001E-383      0  ->   1E-386    Subnormal
ddmax519 max  0.0009E-383     0  ->   9E-387    Subnormal
ddmax520 max  0.0001E-383     0  ->   1E-387    Subnormal

ddmax530 max -1.00E-383       0  ->   0
ddmax531 max -0.1E-383        0  ->   0
ddmax532 max -0.10E-383       0  ->   0
ddmax533 max -0.100E-383      0  ->   0
ddmax534 max -0.01E-383       0  ->   0
ddmax535 max -0.999E-383      0  ->   0
ddmax536 max -0.099E-383      0  ->   0
ddmax537 max -0.009E-383      0  ->   0
ddmax538 max -0.001E-383      0  ->   0
ddmax539 max -0.0009E-383     0  ->   0
ddmax540 max -0.0001E-383     0  ->   0

-- Null tests
ddmax900 max 10  #  -> NaN Invalid_operation
ddmax901 max  # 10  -> NaN Invalid_operation



Added test/dectest/ddMaxMag.decTest.

































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
------------------------------------------------------------------------
-- ddMaxMag.decTest -- decDouble maxnummag                            --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks
ddmxg001 maxmag  -2  -2  -> -2
ddmxg002 maxmag  -2  -1  -> -2
ddmxg003 maxmag  -2   0  -> -2
ddmxg004 maxmag  -2   1  -> -2
ddmxg005 maxmag  -2   2  ->  2
ddmxg006 maxmag  -1  -2  -> -2
ddmxg007 maxmag  -1  -1  -> -1
ddmxg008 maxmag  -1   0  -> -1
ddmxg009 maxmag  -1   1  ->  1
ddmxg010 maxmag  -1   2  ->  2
ddmxg011 maxmag   0  -2  -> -2
ddmxg012 maxmag   0  -1  -> -1
ddmxg013 maxmag   0   0  ->  0
ddmxg014 maxmag   0   1  ->  1
ddmxg015 maxmag   0   2  ->  2
ddmxg016 maxmag   1  -2  -> -2
ddmxg017 maxmag   1  -1  ->  1
ddmxg018 maxmag   1   0  ->  1
ddmxg019 maxmag   1   1  ->  1
ddmxg020 maxmag   1   2  ->  2
ddmxg021 maxmag   2  -2  ->  2
ddmxg022 maxmag   2  -1  ->  2
ddmxg023 maxmag   2   0  ->  2
ddmxg025 maxmag   2   1  ->  2
ddmxg026 maxmag   2   2  ->  2

-- extended zeros
ddmxg030 maxmag   0     0   ->  0
ddmxg031 maxmag   0    -0   ->  0
ddmxg032 maxmag   0    -0.0 ->  0
ddmxg033 maxmag   0     0.0 ->  0
ddmxg034 maxmag  -0     0   ->  0    -- note: -0 = 0, but 0 chosen
ddmxg035 maxmag  -0    -0   -> -0
ddmxg036 maxmag  -0    -0.0 -> -0.0
ddmxg037 maxmag  -0     0.0 ->  0.0
ddmxg038 maxmag   0.0   0   ->  0
ddmxg039 maxmag   0.0  -0   ->  0.0
ddmxg040 maxmag   0.0  -0.0 ->  0.0
ddmxg041 maxmag   0.0   0.0 ->  0.0
ddmxg042 maxmag  -0.0   0   ->  0
ddmxg043 maxmag  -0.0  -0   -> -0.0
ddmxg044 maxmag  -0.0  -0.0 -> -0.0
ddmxg045 maxmag  -0.0   0.0 ->  0.0

ddmxg050 maxmag  -0E1   0E1 ->  0E+1
ddmxg051 maxmag  -0E2   0E2 ->  0E+2
ddmxg052 maxmag  -0E2   0E1 ->  0E+1
ddmxg053 maxmag  -0E1   0E2 ->  0E+2
ddmxg054 maxmag   0E1  -0E1 ->  0E+1
ddmxg055 maxmag   0E2  -0E2 ->  0E+2
ddmxg056 maxmag   0E2  -0E1 ->  0E+2
ddmxg057 maxmag   0E1  -0E2 ->  0E+1

ddmxg058 maxmag   0E1   0E1 ->  0E+1
ddmxg059 maxmag   0E2   0E2 ->  0E+2
ddmxg060 maxmag   0E2   0E1 ->  0E+2
ddmxg061 maxmag   0E1   0E2 ->  0E+2
ddmxg062 maxmag  -0E1  -0E1 -> -0E+1
ddmxg063 maxmag  -0E2  -0E2 -> -0E+2
ddmxg064 maxmag  -0E2  -0E1 -> -0E+1
ddmxg065 maxmag  -0E1  -0E2 -> -0E+1

-- Specials
ddmxg090 maxmag  Inf  -Inf   ->  Infinity
ddmxg091 maxmag  Inf  -1000  ->  Infinity
ddmxg092 maxmag  Inf  -1     ->  Infinity
ddmxg093 maxmag  Inf  -0     ->  Infinity
ddmxg094 maxmag  Inf   0     ->  Infinity
ddmxg095 maxmag  Inf   1     ->  Infinity
ddmxg096 maxmag  Inf   1000  ->  Infinity
ddmxg097 maxmag  Inf   Inf   ->  Infinity
ddmxg098 maxmag -1000  Inf   ->  Infinity
ddmxg099 maxmag -Inf   Inf   ->  Infinity
ddmxg100 maxmag -1     Inf   ->  Infinity
ddmxg101 maxmag -0     Inf   ->  Infinity
ddmxg102 maxmag  0     Inf   ->  Infinity
ddmxg103 maxmag  1     Inf   ->  Infinity
ddmxg104 maxmag  1000  Inf   ->  Infinity
ddmxg105 maxmag  Inf   Inf   ->  Infinity

ddmxg120 maxmag -Inf  -Inf   -> -Infinity
ddmxg121 maxmag -Inf  -1000  -> -Infinity
ddmxg122 maxmag -Inf  -1     -> -Infinity
ddmxg123 maxmag -Inf  -0     -> -Infinity
ddmxg124 maxmag -Inf   0     -> -Infinity
ddmxg125 maxmag -Inf   1     -> -Infinity
ddmxg126 maxmag -Inf   1000  -> -Infinity
ddmxg127 maxmag -Inf   Inf   ->  Infinity
ddmxg128 maxmag -Inf  -Inf   ->  -Infinity
ddmxg129 maxmag -1000 -Inf   -> -Infinity
ddmxg130 maxmag -1    -Inf   -> -Infinity
ddmxg131 maxmag -0    -Inf   -> -Infinity
ddmxg132 maxmag  0    -Inf   -> -Infinity
ddmxg133 maxmag  1    -Inf   -> -Infinity
ddmxg134 maxmag  1000 -Inf   -> -Infinity
ddmxg135 maxmag  Inf  -Inf   ->  Infinity

-- 2004.08.02 754r chooses number over NaN in mixed cases
ddmxg141 maxmag  NaN -Inf    -> -Infinity
ddmxg142 maxmag  NaN -1000   -> -1000
ddmxg143 maxmag  NaN -1      -> -1
ddmxg144 maxmag  NaN -0      -> -0
ddmxg145 maxmag  NaN  0      ->  0
ddmxg146 maxmag  NaN  1      ->  1
ddmxg147 maxmag  NaN  1000   ->  1000
ddmxg148 maxmag  NaN  Inf    ->  Infinity
ddmxg149 maxmag  NaN  NaN    ->  NaN
ddmxg150 maxmag -Inf  NaN    -> -Infinity
ddmxg151 maxmag -1000 NaN    -> -1000
ddmxg152 maxmag -1    NaN    -> -1
ddmxg153 maxmag -0    NaN    -> -0
ddmxg154 maxmag  0    NaN    ->  0
ddmxg155 maxmag  1    NaN    ->  1
ddmxg156 maxmag  1000 NaN    ->  1000
ddmxg157 maxmag  Inf  NaN    ->  Infinity

ddmxg161 maxmag  sNaN -Inf   ->  NaN  Invalid_operation
ddmxg162 maxmag  sNaN -1000  ->  NaN  Invalid_operation
ddmxg163 maxmag  sNaN -1     ->  NaN  Invalid_operation
ddmxg164 maxmag  sNaN -0     ->  NaN  Invalid_operation
ddmxg165 maxmag  sNaN  0     ->  NaN  Invalid_operation
ddmxg166 maxmag  sNaN  1     ->  NaN  Invalid_operation
ddmxg167 maxmag  sNaN  1000  ->  NaN  Invalid_operation
ddmxg168 maxmag  sNaN  NaN   ->  NaN  Invalid_operation
ddmxg169 maxmag  sNaN sNaN   ->  NaN  Invalid_operation
ddmxg170 maxmag  NaN  sNaN   ->  NaN  Invalid_operation
ddmxg171 maxmag -Inf  sNaN   ->  NaN  Invalid_operation
ddmxg172 maxmag -1000 sNaN   ->  NaN  Invalid_operation
ddmxg173 maxmag -1    sNaN   ->  NaN  Invalid_operation
ddmxg174 maxmag -0    sNaN   ->  NaN  Invalid_operation
ddmxg175 maxmag  0    sNaN   ->  NaN  Invalid_operation
ddmxg176 maxmag  1    sNaN   ->  NaN  Invalid_operation
ddmxg177 maxmag  1000 sNaN   ->  NaN  Invalid_operation
ddmxg178 maxmag  Inf  sNaN   ->  NaN  Invalid_operation
ddmxg179 maxmag  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddmxg181 maxmag  NaN9  -Inf   -> -Infinity
ddmxg182 maxmag  NaN8     9   ->  9
ddmxg183 maxmag -NaN7   Inf   ->  Infinity

ddmxg184 maxmag -NaN1   NaN11 -> -NaN1
ddmxg185 maxmag  NaN2   NaN12 ->  NaN2
ddmxg186 maxmag -NaN13 -NaN7  -> -NaN13
ddmxg187 maxmag  NaN14 -NaN5  ->  NaN14

ddmxg188 maxmag -Inf    NaN4  -> -Infinity
ddmxg189 maxmag -9     -NaN3  -> -9
ddmxg190 maxmag  Inf    NaN2  ->  Infinity

ddmxg191 maxmag  sNaN99 -Inf    ->  NaN99 Invalid_operation
ddmxg192 maxmag  sNaN98 -1      ->  NaN98 Invalid_operation
ddmxg193 maxmag -sNaN97  NaN    -> -NaN97 Invalid_operation
ddmxg194 maxmag  sNaN96 sNaN94  ->  NaN96 Invalid_operation
ddmxg195 maxmag  NaN95  sNaN93  ->  NaN93 Invalid_operation
ddmxg196 maxmag -Inf    sNaN92  ->  NaN92 Invalid_operation
ddmxg197 maxmag  0      sNaN91  ->  NaN91 Invalid_operation
ddmxg198 maxmag  Inf   -sNaN90  -> -NaN90 Invalid_operation
ddmxg199 maxmag  NaN    sNaN89  ->  NaN89 Invalid_operation

-- old rounding checks
ddmxg221 maxmag 12345678000 1  -> 12345678000
ddmxg222 maxmag 1 12345678000  -> 12345678000
ddmxg223 maxmag 1234567800  1  -> 1234567800
ddmxg224 maxmag 1 1234567800   -> 1234567800
ddmxg225 maxmag 1234567890  1  -> 1234567890
ddmxg226 maxmag 1 1234567890   -> 1234567890
ddmxg227 maxmag 1234567891  1  -> 1234567891
ddmxg228 maxmag 1 1234567891   -> 1234567891
ddmxg229 maxmag 12345678901 1  -> 12345678901
ddmxg230 maxmag 1 12345678901  -> 12345678901
ddmxg231 maxmag 1234567896  1  -> 1234567896
ddmxg232 maxmag 1 1234567896   -> 1234567896
ddmxg233 maxmag -1234567891  1 -> -1234567891
ddmxg234 maxmag 1 -1234567891  -> -1234567891
ddmxg235 maxmag -12345678901 1 -> -12345678901
ddmxg236 maxmag 1 -12345678901 -> -12345678901
ddmxg237 maxmag -1234567896  1 -> -1234567896
ddmxg238 maxmag 1 -1234567896  -> -1234567896

-- from examples
ddmxg280 maxmag '3'   '2'  ->  '3'
ddmxg281 maxmag '-10' '3'  ->  '-10'
ddmxg282 maxmag '1.0' '1'  ->  '1'
ddmxg283 maxmag '1' '1.0'  ->  '1'
ddmxg284 maxmag '7' 'NaN'  ->  '7'

-- expanded list from min/max 754r purple prose
-- [explicit tests for exponent ordering]
ddmxg401 maxmag  Inf    1.1     ->  Infinity
ddmxg402 maxmag  1.1    1       ->  1.1
ddmxg403 maxmag  1      1.0     ->  1
ddmxg404 maxmag  1.0    0.1     ->  1.0
ddmxg405 maxmag  0.1    0.10    ->  0.1
ddmxg406 maxmag  0.10   0.100   ->  0.10
ddmxg407 maxmag  0.10   0       ->  0.10
ddmxg408 maxmag  0      0.0     ->  0
ddmxg409 maxmag  0.0   -0       ->  0.0
ddmxg410 maxmag  0.0   -0.0     ->  0.0
ddmxg411 maxmag  0.00  -0.0     ->  0.00
ddmxg412 maxmag  0.0   -0.00    ->  0.0
ddmxg413 maxmag  0     -0.0     ->  0
ddmxg414 maxmag  0     -0       ->  0
ddmxg415 maxmag -0.0   -0       -> -0.0
ddmxg416 maxmag -0     -0.100   -> -0.100
ddmxg417 maxmag -0.100 -0.10    -> -0.100
ddmxg418 maxmag -0.10  -0.1     -> -0.10
ddmxg419 maxmag -0.1   -1.0     -> -1.0
ddmxg420 maxmag -1.0   -1       -> -1.0
ddmxg421 maxmag -1     -1.1     -> -1.1
ddmxg423 maxmag -1.1   -Inf     -> -Infinity
-- same with operands reversed
ddmxg431 maxmag  1.1    Inf     ->  Infinity
ddmxg432 maxmag  1      1.1     ->  1.1
ddmxg433 maxmag  1.0    1       ->  1
ddmxg434 maxmag  0.1    1.0     ->  1.0
ddmxg435 maxmag  0.10   0.1     ->  0.1
ddmxg436 maxmag  0.100  0.10    ->  0.10
ddmxg437 maxmag  0      0.10    ->  0.10
ddmxg438 maxmag  0.0    0       ->  0
ddmxg439 maxmag -0      0.0     ->  0.0
ddmxg440 maxmag -0.0    0.0     ->  0.0
ddmxg441 maxmag -0.0    0.00    ->  0.00
ddmxg442 maxmag -0.00   0.0     ->  0.0
ddmxg443 maxmag -0.0    0       ->  0
ddmxg444 maxmag -0      0       ->  0
ddmxg445 maxmag -0     -0.0     -> -0.0
ddmxg446 maxmag -0.100 -0       -> -0.100
ddmxg447 maxmag -0.10  -0.100   -> -0.100
ddmxg448 maxmag -0.1   -0.10    -> -0.10
ddmxg449 maxmag -1.0   -0.1     -> -1.0
ddmxg450 maxmag -1     -1.0     -> -1.0
ddmxg451 maxmag -1.1   -1       -> -1.1
ddmxg453 maxmag -Inf   -1.1     -> -Infinity
-- largies
ddmxg460 maxmag  1000   1E+3    ->  1E+3
ddmxg461 maxmag  1E+3   1000    ->  1E+3
ddmxg462 maxmag  1000  -1E+3    ->  1000
ddmxg463 maxmag  1E+3  -1000    ->  1E+3
ddmxg464 maxmag -1000   1E+3    ->  1E+3
ddmxg465 maxmag -1E+3   1000    ->  1000
ddmxg466 maxmag -1000  -1E+3    -> -1000
ddmxg467 maxmag -1E+3  -1000    -> -1000

-- subnormals
ddmxg510 maxmag  1.00E-383       0  ->   1.00E-383
ddmxg511 maxmag  0.1E-383        0  ->   1E-384    Subnormal
ddmxg512 maxmag  0.10E-383       0  ->   1.0E-384  Subnormal
ddmxg513 maxmag  0.100E-383      0  ->   1.00E-384 Subnormal
ddmxg514 maxmag  0.01E-383       0  ->   1E-385    Subnormal
ddmxg515 maxmag  0.999E-383      0  ->   9.99E-384 Subnormal
ddmxg516 maxmag  0.099E-383      0  ->   9.9E-385  Subnormal
ddmxg517 maxmag  0.009E-383      0  ->   9E-386    Subnormal
ddmxg518 maxmag  0.001E-383      0  ->   1E-386    Subnormal
ddmxg519 maxmag  0.0009E-383     0  ->   9E-387    Subnormal
ddmxg520 maxmag  0.0001E-383     0  ->   1E-387    Subnormal

ddmxg530 maxmag -1.00E-383       0  ->  -1.00E-383
ddmxg531 maxmag -0.1E-383        0  ->  -1E-384    Subnormal
ddmxg532 maxmag -0.10E-383       0  ->  -1.0E-384  Subnormal
ddmxg533 maxmag -0.100E-383      0  ->  -1.00E-384 Subnormal
ddmxg534 maxmag -0.01E-383       0  ->  -1E-385    Subnormal
ddmxg535 maxmag -0.999E-383      0  ->  -9.99E-384 Subnormal
ddmxg536 maxmag -0.099E-383      0  ->  -9.9E-385  Subnormal
ddmxg537 maxmag -0.009E-383      0  ->  -9E-386    Subnormal
ddmxg538 maxmag -0.001E-383      0  ->  -1E-386    Subnormal
ddmxg539 maxmag -0.0009E-383     0  ->  -9E-387    Subnormal
ddmxg540 maxmag -0.0001E-383     0  ->  -1E-387    Subnormal

-- Null tests
ddmxg900 maxmag 10  #  -> NaN Invalid_operation
ddmxg901 maxmag  # 10  -> NaN Invalid_operation

Added test/dectest/ddMin.decTest.











































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
------------------------------------------------------------------------
-- ddMin.decTest -- decDouble minnum                                  --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks
ddmin001 min  -2  -2  -> -2
ddmin002 min  -2  -1  -> -2
ddmin003 min  -2   0  -> -2
ddmin004 min  -2   1  -> -2
ddmin005 min  -2   2  -> -2
ddmin006 min  -1  -2  -> -2
ddmin007 min  -1  -1  -> -1
ddmin008 min  -1   0  -> -1
ddmin009 min  -1   1  -> -1
ddmin010 min  -1   2  -> -1
ddmin011 min   0  -2  -> -2
ddmin012 min   0  -1  -> -1
ddmin013 min   0   0  ->  0
ddmin014 min   0   1  ->  0
ddmin015 min   0   2  ->  0
ddmin016 min   1  -2  -> -2
ddmin017 min   1  -1  -> -1
ddmin018 min   1   0  ->  0
ddmin019 min   1   1  ->  1
ddmin020 min   1   2  ->  1
ddmin021 min   2  -2  -> -2
ddmin022 min   2  -1  -> -1
ddmin023 min   2   0  ->  0
ddmin025 min   2   1  ->  1
ddmin026 min   2   2  ->  2

-- extended zeros
ddmin030 min   0     0   ->  0
ddmin031 min   0    -0   -> -0
ddmin032 min   0    -0.0 -> -0.0
ddmin033 min   0     0.0 ->  0.0
ddmin034 min  -0     0   -> -0
ddmin035 min  -0    -0   -> -0
ddmin036 min  -0    -0.0 -> -0
ddmin037 min  -0     0.0 -> -0
ddmin038 min   0.0   0   ->  0.0
ddmin039 min   0.0  -0   -> -0
ddmin040 min   0.0  -0.0 -> -0.0
ddmin041 min   0.0   0.0 ->  0.0
ddmin042 min  -0.0   0   -> -0.0
ddmin043 min  -0.0  -0   -> -0
ddmin044 min  -0.0  -0.0 -> -0.0
ddmin045 min  -0.0   0.0 -> -0.0

ddmin046 min   0E1  -0E1 -> -0E+1
ddmin047 min  -0E1   0E2 -> -0E+1
ddmin048 min   0E2   0E1 ->  0E+1
ddmin049 min   0E1   0E2 ->  0E+1
ddmin050 min  -0E3  -0E2 -> -0E+3
ddmin051 min  -0E2  -0E3 -> -0E+3

-- Specials
ddmin090 min  Inf  -Inf   -> -Infinity
ddmin091 min  Inf  -1000  -> -1000
ddmin092 min  Inf  -1     -> -1
ddmin093 min  Inf  -0     -> -0
ddmin094 min  Inf   0     ->  0
ddmin095 min  Inf   1     ->  1
ddmin096 min  Inf   1000  ->  1000
ddmin097 min  Inf   Inf   ->  Infinity
ddmin098 min -1000  Inf   -> -1000
ddmin099 min -Inf   Inf   -> -Infinity
ddmin100 min -1     Inf   -> -1
ddmin101 min -0     Inf   -> -0
ddmin102 min  0     Inf   ->  0
ddmin103 min  1     Inf   ->  1
ddmin104 min  1000  Inf   ->  1000
ddmin105 min  Inf   Inf   ->  Infinity

ddmin120 min -Inf  -Inf   -> -Infinity
ddmin121 min -Inf  -1000  -> -Infinity
ddmin122 min -Inf  -1     -> -Infinity
ddmin123 min -Inf  -0     -> -Infinity
ddmin124 min -Inf   0     -> -Infinity
ddmin125 min -Inf   1     -> -Infinity
ddmin126 min -Inf   1000  -> -Infinity
ddmin127 min -Inf   Inf   -> -Infinity
ddmin128 min -Inf  -Inf   -> -Infinity
ddmin129 min -1000 -Inf   -> -Infinity
ddmin130 min -1    -Inf   -> -Infinity
ddmin131 min -0    -Inf   -> -Infinity
ddmin132 min  0    -Inf   -> -Infinity
ddmin133 min  1    -Inf   -> -Infinity
ddmin134 min  1000 -Inf   -> -Infinity
ddmin135 min  Inf  -Inf   -> -Infinity

-- 2004.08.02 754r chooses number over NaN in mixed cases
ddmin141 min  NaN -Inf    ->  -Infinity
ddmin142 min  NaN -1000   ->  -1000
ddmin143 min  NaN -1      ->  -1
ddmin144 min  NaN -0      ->  -0
ddmin145 min  NaN  0      ->  0
ddmin146 min  NaN  1      ->  1
ddmin147 min  NaN  1000   ->  1000
ddmin148 min  NaN  Inf    ->  Infinity
ddmin149 min  NaN  NaN    ->  NaN
ddmin150 min -Inf  NaN    -> -Infinity
ddmin151 min -1000 NaN    -> -1000
ddmin152 min -1   -NaN    -> -1
ddmin153 min -0    NaN    -> -0
ddmin154 min  0   -NaN    ->  0
ddmin155 min  1    NaN    ->  1
ddmin156 min  1000 NaN    ->  1000
ddmin157 min  Inf  NaN    ->  Infinity

ddmin161 min  sNaN -Inf   ->  NaN  Invalid_operation
ddmin162 min  sNaN -1000  ->  NaN  Invalid_operation
ddmin163 min  sNaN -1     ->  NaN  Invalid_operation
ddmin164 min  sNaN -0     ->  NaN  Invalid_operation
ddmin165 min -sNaN  0     -> -NaN  Invalid_operation
ddmin166 min -sNaN  1     -> -NaN  Invalid_operation
ddmin167 min  sNaN  1000  ->  NaN  Invalid_operation
ddmin168 min  sNaN  NaN   ->  NaN  Invalid_operation
ddmin169 min  sNaN sNaN   ->  NaN  Invalid_operation
ddmin170 min  NaN  sNaN   ->  NaN  Invalid_operation
ddmin171 min -Inf  sNaN   ->  NaN  Invalid_operation
ddmin172 min -1000 sNaN   ->  NaN  Invalid_operation
ddmin173 min -1    sNaN   ->  NaN  Invalid_operation
ddmin174 min -0    sNaN   ->  NaN  Invalid_operation
ddmin175 min  0    sNaN   ->  NaN  Invalid_operation
ddmin176 min  1    sNaN   ->  NaN  Invalid_operation
ddmin177 min  1000 sNaN   ->  NaN  Invalid_operation
ddmin178 min  Inf  sNaN   ->  NaN  Invalid_operation
ddmin179 min  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddmin181 min  NaN9   -Inf   -> -Infinity
ddmin182 min -NaN8    9990  ->  9990
ddmin183 min  NaN71   Inf   ->  Infinity

ddmin184 min  NaN1    NaN54 ->  NaN1
ddmin185 min  NaN22  -NaN53 ->  NaN22
ddmin186 min -NaN3    NaN6  -> -NaN3
ddmin187 min -NaN44   NaN7  -> -NaN44

ddmin188 min -Inf     NaN41 -> -Infinity
ddmin189 min -9999   -NaN33 -> -9999
ddmin190 min  Inf     NaN2  ->  Infinity

ddmin191 min  sNaN99 -Inf    ->  NaN99 Invalid_operation
ddmin192 min  sNaN98 -11     ->  NaN98 Invalid_operation
ddmin193 min -sNaN97  NaN8   -> -NaN97 Invalid_operation
ddmin194 min  sNaN69 sNaN94  ->  NaN69 Invalid_operation
ddmin195 min  NaN95  sNaN93  ->  NaN93 Invalid_operation
ddmin196 min -Inf    sNaN92  ->  NaN92 Invalid_operation
ddmin197 min  088    sNaN91  ->  NaN91 Invalid_operation
ddmin198 min  Inf   -sNaN90  -> -NaN90 Invalid_operation
ddmin199 min  NaN    sNaN86  ->  NaN86 Invalid_operation

-- old rounding checks
ddmin221 min -12345678000 1  -> -12345678000
ddmin222 min 1 -12345678000  -> -12345678000
ddmin223 min -1234567800  1  -> -1234567800
ddmin224 min 1 -1234567800   -> -1234567800
ddmin225 min -1234567890  1  -> -1234567890
ddmin226 min 1 -1234567890   -> -1234567890
ddmin227 min -1234567891  1  -> -1234567891
ddmin228 min 1 -1234567891   -> -1234567891
ddmin229 min -12345678901 1  -> -12345678901
ddmin230 min 1 -12345678901  -> -12345678901
ddmin231 min -1234567896  1  -> -1234567896
ddmin232 min 1 -1234567896   -> -1234567896
ddmin233 min 1234567891  1   -> 1
ddmin234 min 1 1234567891    -> 1
ddmin235 min 12345678901 1   -> 1
ddmin236 min 1 12345678901   -> 1
ddmin237 min 1234567896  1   -> 1
ddmin238 min 1 1234567896    -> 1

-- from examples
ddmin280 min '3'   '2'  ->  '2'
ddmin281 min '-10' '3'  ->  '-10'
ddmin282 min '1.0' '1'  ->  '1.0'
ddmin283 min '1' '1.0'  ->  '1.0'
ddmin284 min '7' 'NaN'  ->  '7'

-- expanded list from min/max 754r purple prose
-- [explicit tests for exponent ordering]
ddmin401 min  Inf    1.1     ->  1.1
ddmin402 min  1.1    1       ->  1
ddmin403 min  1      1.0     ->  1.0
ddmin404 min  1.0    0.1     ->  0.1
ddmin405 min  0.1    0.10    ->  0.10
ddmin406 min  0.10   0.100   ->  0.100
ddmin407 min  0.10   0       ->  0
ddmin408 min  0      0.0     ->  0.0
ddmin409 min  0.0   -0       -> -0
ddmin410 min  0.0   -0.0     -> -0.0
ddmin411 min  0.00  -0.0     -> -0.0
ddmin412 min  0.0   -0.00    -> -0.00
ddmin413 min  0     -0.0     -> -0.0
ddmin414 min  0     -0       -> -0
ddmin415 min -0.0   -0       -> -0
ddmin416 min -0     -0.100   -> -0.100
ddmin417 min -0.100 -0.10    -> -0.10
ddmin418 min -0.10  -0.1     -> -0.1
ddmin419 min -0.1   -1.0     -> -1.0
ddmin420 min -1.0   -1       -> -1
ddmin421 min -1     -1.1     -> -1.1
ddmin423 min -1.1   -Inf     -> -Infinity
-- same with operands reversed
ddmin431 min  1.1    Inf     ->  1.1
ddmin432 min  1      1.1     ->  1
ddmin433 min  1.0    1       ->  1.0
ddmin434 min  0.1    1.0     ->  0.1
ddmin435 min  0.10   0.1     ->  0.10
ddmin436 min  0.100  0.10    ->  0.100
ddmin437 min  0      0.10    ->  0
ddmin438 min  0.0    0       ->  0.0
ddmin439 min -0      0.0     -> -0
ddmin440 min -0.0    0.0     -> -0.0
ddmin441 min -0.0    0.00    -> -0.0
ddmin442 min -0.00   0.0     -> -0.00
ddmin443 min -0.0    0       -> -0.0
ddmin444 min -0      0       -> -0
ddmin445 min -0     -0.0     -> -0
ddmin446 min -0.100 -0       -> -0.100
ddmin447 min -0.10  -0.100   -> -0.10
ddmin448 min -0.1   -0.10    -> -0.1
ddmin449 min -1.0   -0.1     -> -1.0
ddmin450 min -1     -1.0     -> -1
ddmin451 min -1.1   -1       -> -1.1
ddmin453 min -Inf   -1.1     -> -Infinity
-- largies
ddmin460 min  1000   1E+3    ->  1000
ddmin461 min  1E+3   1000    ->  1000
ddmin462 min  1000  -1E+3    -> -1E+3
ddmin463 min  1E+3  -384    -> -384
ddmin464 min -384   1E+3    -> -384
ddmin465 min -1E+3   1000    -> -1E+3
ddmin466 min -384  -1E+3    -> -1E+3
ddmin467 min -1E+3  -384    -> -1E+3

-- misalignment traps for little-endian
ddmin471 min      1.0       0.1  -> 0.1
ddmin472 min      0.1       1.0  -> 0.1
ddmin473 min     10.0       0.1  -> 0.1
ddmin474 min      0.1      10.0  -> 0.1
ddmin475 min      100       1.0  -> 1.0
ddmin476 min      1.0       100  -> 1.0
ddmin477 min     1000      10.0  -> 10.0
ddmin478 min     10.0      1000  -> 10.0
ddmin479 min    10000     100.0  -> 100.0
ddmin480 min    100.0     10000  -> 100.0
ddmin481 min   100000    1000.0  -> 1000.0
ddmin482 min   1000.0    100000  -> 1000.0
ddmin483 min  1000000   10000.0  -> 10000.0
ddmin484 min  10000.0   1000000  -> 10000.0

-- subnormals
ddmin510 min  1.00E-383       0  ->   0
ddmin511 min  0.1E-383        0  ->   0
ddmin512 min  0.10E-383       0  ->   0
ddmin513 min  0.100E-383      0  ->   0
ddmin514 min  0.01E-383       0  ->   0
ddmin515 min  0.999E-383      0  ->   0
ddmin516 min  0.099E-383      0  ->   0
ddmin517 min  0.009E-383      0  ->   0
ddmin518 min  0.001E-383      0  ->   0
ddmin519 min  0.0009E-383     0  ->   0
ddmin520 min  0.0001E-383     0  ->   0

ddmin530 min -1.00E-383       0  ->  -1.00E-383
ddmin531 min -0.1E-383        0  ->  -1E-384    Subnormal
ddmin532 min -0.10E-383       0  ->  -1.0E-384  Subnormal
ddmin533 min -0.100E-383      0  ->  -1.00E-384 Subnormal
ddmin534 min -0.01E-383       0  ->  -1E-385    Subnormal
ddmin535 min -0.999E-383      0  ->  -9.99E-384 Subnormal
ddmin536 min -0.099E-383      0  ->  -9.9E-385  Subnormal
ddmin537 min -0.009E-383      0  ->  -9E-386    Subnormal
ddmin538 min -0.001E-383      0  ->  -1E-386    Subnormal
ddmin539 min -0.0009E-383     0  ->  -9E-387    Subnormal
ddmin540 min -0.0001E-383     0  ->  -1E-387    Subnormal


-- Null tests
ddmin900 min 10  # -> NaN Invalid_operation
ddmin901 min  # 10 -> NaN Invalid_operation

Added test/dectest/ddMinMag.decTest.











































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
------------------------------------------------------------------------
-- ddMinMag.decTest -- decDouble minnummag                            --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks
ddmng001 minmag  -2  -2  -> -2
ddmng002 minmag  -2  -1  -> -1
ddmng003 minmag  -2   0  ->  0
ddmng004 minmag  -2   1  ->  1
ddmng005 minmag  -2   2  -> -2
ddmng006 minmag  -1  -2  -> -1
ddmng007 minmag  -1  -1  -> -1
ddmng008 minmag  -1   0  ->  0
ddmng009 minmag  -1   1  -> -1
ddmng010 minmag  -1   2  -> -1
ddmng011 minmag   0  -2  ->  0
ddmng012 minmag   0  -1  ->  0
ddmng013 minmag   0   0  ->  0
ddmng014 minmag   0   1  ->  0
ddmng015 minmag   0   2  ->  0
ddmng016 minmag   1  -2  ->  1
ddmng017 minmag   1  -1  -> -1
ddmng018 minmag   1   0  ->  0
ddmng019 minmag   1   1  ->  1
ddmng020 minmag   1   2  ->  1
ddmng021 minmag   2  -2  -> -2
ddmng022 minmag   2  -1  -> -1
ddmng023 minmag   2   0  ->  0
ddmng025 minmag   2   1  ->  1
ddmng026 minmag   2   2  ->  2

-- extended zeros
ddmng030 minmag   0     0   ->  0
ddmng031 minmag   0    -0   -> -0
ddmng032 minmag   0    -0.0 -> -0.0
ddmng033 minmag   0     0.0 ->  0.0
ddmng034 minmag  -0     0   -> -0
ddmng035 minmag  -0    -0   -> -0
ddmng036 minmag  -0    -0.0 -> -0
ddmng037 minmag  -0     0.0 -> -0
ddmng038 minmag   0.0   0   ->  0.0
ddmng039 minmag   0.0  -0   -> -0
ddmng040 minmag   0.0  -0.0 -> -0.0
ddmng041 minmag   0.0   0.0 ->  0.0
ddmng042 minmag  -0.0   0   -> -0.0
ddmng043 minmag  -0.0  -0   -> -0
ddmng044 minmag  -0.0  -0.0 -> -0.0
ddmng045 minmag  -0.0   0.0 -> -0.0

ddmng046 minmag   0E1  -0E1 -> -0E+1
ddmng047 minmag  -0E1   0E2 -> -0E+1
ddmng048 minmag   0E2   0E1 ->  0E+1
ddmng049 minmag   0E1   0E2 ->  0E+1
ddmng050 minmag  -0E3  -0E2 -> -0E+3
ddmng051 minmag  -0E2  -0E3 -> -0E+3

-- Specials
ddmng090 minmag  Inf  -Inf   -> -Infinity
ddmng091 minmag  Inf  -1000  -> -1000
ddmng092 minmag  Inf  -1     -> -1
ddmng093 minmag  Inf  -0     -> -0
ddmng094 minmag  Inf   0     ->  0
ddmng095 minmag  Inf   1     ->  1
ddmng096 minmag  Inf   1000  ->  1000
ddmng097 minmag  Inf   Inf   ->  Infinity
ddmng098 minmag -1000  Inf   -> -1000
ddmng099 minmag -Inf   Inf   -> -Infinity
ddmng100 minmag -1     Inf   -> -1
ddmng101 minmag -0     Inf   -> -0
ddmng102 minmag  0     Inf   ->  0
ddmng103 minmag  1     Inf   ->  1
ddmng104 minmag  1000  Inf   ->  1000
ddmng105 minmag  Inf   Inf   ->  Infinity

ddmng120 minmag -Inf  -Inf   -> -Infinity
ddmng121 minmag -Inf  -1000  -> -1000
ddmng122 minmag -Inf  -1     -> -1
ddmng123 minmag -Inf  -0     -> -0
ddmng124 minmag -Inf   0     ->  0
ddmng125 minmag -Inf   1     ->  1
ddmng126 minmag -Inf   1000  ->  1000
ddmng127 minmag -Inf   Inf   -> -Infinity
ddmng128 minmag -Inf  -Inf   -> -Infinity
ddmng129 minmag -1000 -Inf   -> -1000
ddmng130 minmag -1    -Inf   -> -1
ddmng131 minmag -0    -Inf   -> -0
ddmng132 minmag  0    -Inf   ->  0
ddmng133 minmag  1    -Inf   ->  1
ddmng134 minmag  1000 -Inf   ->  1000
ddmng135 minmag  Inf  -Inf   -> -Infinity

-- 2004.08.02 754r chooses number over NaN in mixed cases
ddmng141 minmag  NaN -Inf    ->  -Infinity
ddmng142 minmag  NaN -1000   ->  -1000
ddmng143 minmag  NaN -1      ->  -1
ddmng144 minmag  NaN -0      ->  -0
ddmng145 minmag  NaN  0      ->  0
ddmng146 minmag  NaN  1      ->  1
ddmng147 minmag  NaN  1000   ->  1000
ddmng148 minmag  NaN  Inf    ->  Infinity
ddmng149 minmag  NaN  NaN    ->  NaN
ddmng150 minmag -Inf  NaN    -> -Infinity
ddmng151 minmag -1000 NaN    -> -1000
ddmng152 minmag -1   -NaN    -> -1
ddmng153 minmag -0    NaN    -> -0
ddmng154 minmag  0   -NaN    ->  0
ddmng155 minmag  1    NaN    ->  1
ddmng156 minmag  1000 NaN    ->  1000
ddmng157 minmag  Inf  NaN    ->  Infinity

ddmng161 minmag  sNaN -Inf   ->  NaN  Invalid_operation
ddmng162 minmag  sNaN -1000  ->  NaN  Invalid_operation
ddmng163 minmag  sNaN -1     ->  NaN  Invalid_operation
ddmng164 minmag  sNaN -0     ->  NaN  Invalid_operation
ddmng165 minmag -sNaN  0     -> -NaN  Invalid_operation
ddmng166 minmag -sNaN  1     -> -NaN  Invalid_operation
ddmng167 minmag  sNaN  1000  ->  NaN  Invalid_operation
ddmng168 minmag  sNaN  NaN   ->  NaN  Invalid_operation
ddmng169 minmag  sNaN sNaN   ->  NaN  Invalid_operation
ddmng170 minmag  NaN  sNaN   ->  NaN  Invalid_operation
ddmng171 minmag -Inf  sNaN   ->  NaN  Invalid_operation
ddmng172 minmag -1000 sNaN   ->  NaN  Invalid_operation
ddmng173 minmag -1    sNaN   ->  NaN  Invalid_operation
ddmng174 minmag -0    sNaN   ->  NaN  Invalid_operation
ddmng175 minmag  0    sNaN   ->  NaN  Invalid_operation
ddmng176 minmag  1    sNaN   ->  NaN  Invalid_operation
ddmng177 minmag  1000 sNaN   ->  NaN  Invalid_operation
ddmng178 minmag  Inf  sNaN   ->  NaN  Invalid_operation
ddmng179 minmag  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddmng181 minmag  NaN9   -Inf   -> -Infinity
ddmng182 minmag -NaN8    9990  ->  9990
ddmng183 minmag  NaN71   Inf   ->  Infinity

ddmng184 minmag  NaN1    NaN54 ->  NaN1
ddmng185 minmag  NaN22  -NaN53 ->  NaN22
ddmng186 minmag -NaN3    NaN6  -> -NaN3
ddmng187 minmag -NaN44   NaN7  -> -NaN44

ddmng188 minmag -Inf     NaN41 -> -Infinity
ddmng189 minmag -9999   -NaN33 -> -9999
ddmng190 minmag  Inf     NaN2  ->  Infinity

ddmng191 minmag  sNaN99 -Inf    ->  NaN99 Invalid_operation
ddmng192 minmag  sNaN98 -11     ->  NaN98 Invalid_operation
ddmng193 minmag -sNaN97  NaN8   -> -NaN97 Invalid_operation
ddmng194 minmag  sNaN69 sNaN94  ->  NaN69 Invalid_operation
ddmng195 minmag  NaN95  sNaN93  ->  NaN93 Invalid_operation
ddmng196 minmag -Inf    sNaN92  ->  NaN92 Invalid_operation
ddmng197 minmag  088    sNaN91  ->  NaN91 Invalid_operation
ddmng198 minmag  Inf   -sNaN90  -> -NaN90 Invalid_operation
ddmng199 minmag  NaN    sNaN86  ->  NaN86 Invalid_operation

-- old rounding checks
ddmng221 minmag -12345678000 1  -> 1
ddmng222 minmag 1 -12345678000  -> 1
ddmng223 minmag -1234567800  1  -> 1
ddmng224 minmag 1 -1234567800   -> 1
ddmng225 minmag -1234567890  1  -> 1
ddmng226 minmag 1 -1234567890   -> 1
ddmng227 minmag -1234567891  1  -> 1
ddmng228 minmag 1 -1234567891   -> 1
ddmng229 minmag -12345678901 1  -> 1
ddmng230 minmag 1 -12345678901  -> 1
ddmng231 minmag -1234567896  1  -> 1
ddmng232 minmag 1 -1234567896   -> 1
ddmng233 minmag 1234567891  1   -> 1
ddmng234 minmag 1 1234567891    -> 1
ddmng235 minmag 12345678901 1   -> 1
ddmng236 minmag 1 12345678901   -> 1
ddmng237 minmag 1234567896  1   -> 1
ddmng238 minmag 1 1234567896    -> 1

-- from examples
ddmng280 minmag '3'   '2'  ->  '2'
ddmng281 minmag '-10' '3'  ->  '3'
ddmng282 minmag '1.0' '1'  ->  '1.0'
ddmng283 minmag '1' '1.0'  ->  '1.0'
ddmng284 minmag '7' 'NaN'  ->  '7'

-- expanded list from min/max 754r purple prose
-- [explicit tests for exponent ordering]
ddmng401 minmag  Inf    1.1     ->  1.1
ddmng402 minmag  1.1    1       ->  1
ddmng403 minmag  1      1.0     ->  1.0
ddmng404 minmag  1.0    0.1     ->  0.1
ddmng405 minmag  0.1    0.10    ->  0.10
ddmng406 minmag  0.10   0.100   ->  0.100
ddmng407 minmag  0.10   0       ->  0
ddmng408 minmag  0      0.0     ->  0.0
ddmng409 minmag  0.0   -0       -> -0
ddmng410 minmag  0.0   -0.0     -> -0.0
ddmng411 minmag  0.00  -0.0     -> -0.0
ddmng412 minmag  0.0   -0.00    -> -0.00
ddmng413 minmag  0     -0.0     -> -0.0
ddmng414 minmag  0     -0       -> -0
ddmng415 minmag -0.0   -0       -> -0
ddmng416 minmag -0     -0.100   -> -0
ddmng417 minmag -0.100 -0.10    -> -0.10
ddmng418 minmag -0.10  -0.1     -> -0.1
ddmng419 minmag -0.1   -1.0     -> -0.1
ddmng420 minmag -1.0   -1       -> -1
ddmng421 minmag -1     -1.1     -> -1
ddmng423 minmag -1.1   -Inf     -> -1.1
-- same with operands reversed
ddmng431 minmag  1.1    Inf     ->  1.1
ddmng432 minmag  1      1.1     ->  1
ddmng433 minmag  1.0    1       ->  1.0
ddmng434 minmag  0.1    1.0     ->  0.1
ddmng435 minmag  0.10   0.1     ->  0.10
ddmng436 minmag  0.100  0.10    ->  0.100
ddmng437 minmag  0      0.10    ->  0
ddmng438 minmag  0.0    0       ->  0.0
ddmng439 minmag -0      0.0     -> -0
ddmng440 minmag -0.0    0.0     -> -0.0
ddmng441 minmag -0.0    0.00    -> -0.0
ddmng442 minmag -0.00   0.0     -> -0.00
ddmng443 minmag -0.0    0       -> -0.0
ddmng444 minmag -0      0       -> -0
ddmng445 minmag -0     -0.0     -> -0
ddmng446 minmag -0.100 -0       -> -0
ddmng447 minmag -0.10  -0.100   -> -0.10
ddmng448 minmag -0.1   -0.10    -> -0.1
ddmng449 minmag -1.0   -0.1     -> -0.1
ddmng450 minmag -1     -1.0     -> -1
ddmng451 minmag -1.1   -1       -> -1
ddmng453 minmag -Inf   -1.1     -> -1.1
-- largies
ddmng460 minmag  1000   1E+3    ->  1000
ddmng461 minmag  1E+3   1000    ->  1000
ddmng462 minmag  1000  -1E+3    -> -1E+3
ddmng463 minmag  1E+3   -384    -> -384
ddmng464 minmag -384    1E+3    -> -384
ddmng465 minmag -1E+3   1000    -> -1E+3
ddmng466 minmag -384   -1E+3    -> -384
ddmng467 minmag -1E+3   -384    -> -384

-- subnormals
ddmng510 minmag  1.00E-383       0  ->   0
ddmng511 minmag  0.1E-383        0  ->   0
ddmng512 minmag  0.10E-383       0  ->   0
ddmng513 minmag  0.100E-383      0  ->   0
ddmng514 minmag  0.01E-383       0  ->   0
ddmng515 minmag  0.999E-383      0  ->   0
ddmng516 minmag  0.099E-383      0  ->   0
ddmng517 minmag  0.009E-383      0  ->   0
ddmng518 minmag  0.001E-383      0  ->   0
ddmng519 minmag  0.0009E-383     0  ->   0
ddmng520 minmag  0.0001E-383     0  ->   0

ddmng530 minmag -1.00E-383       0  ->   0
ddmng531 minmag -0.1E-383        0  ->   0
ddmng532 minmag -0.10E-383       0  ->   0
ddmng533 minmag -0.100E-383      0  ->   0
ddmng534 minmag -0.01E-383       0  ->   0
ddmng535 minmag -0.999E-383      0  ->   0
ddmng536 minmag -0.099E-383      0  ->   0
ddmng537 minmag -0.009E-383      0  ->   0
ddmng538 minmag -0.001E-383      0  ->   0
ddmng539 minmag -0.0009E-383     0  ->   0
ddmng540 minmag -0.0001E-383     0  ->   0


-- Null tests
ddmng900 minmag 10  # -> NaN Invalid_operation
ddmng901 minmag  # 10 -> NaN Invalid_operation

Added test/dectest/ddMinus.decTest.

















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
------------------------------------------------------------------------
-- ddMinus.decTest -- decDouble 0-x                                   --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check
ddmns001 minus       +7.50  -> -7.50

-- Infinities
ddmns011 minus  Infinity    -> -Infinity
ddmns012 minus  -Infinity   -> Infinity

-- NaNs, 0 payload
ddmns021 minus         NaN  -> NaN
ddmns022 minus        -NaN  -> -NaN
ddmns023 minus        sNaN  -> NaN  Invalid_operation
ddmns024 minus       -sNaN  -> -NaN Invalid_operation

-- NaNs, non-0 payload
ddmns031 minus       NaN13  -> NaN13
ddmns032 minus      -NaN13  -> -NaN13
ddmns033 minus      sNaN13  -> NaN13   Invalid_operation
ddmns034 minus     -sNaN13  -> -NaN13  Invalid_operation
ddmns035 minus       NaN70  -> NaN70
ddmns036 minus      -NaN70  -> -NaN70
ddmns037 minus      sNaN101 -> NaN101  Invalid_operation
ddmns038 minus     -sNaN101 -> -NaN101 Invalid_operation

-- finites
ddmns101 minus          7   -> -7
ddmns102 minus         -7   -> 7
ddmns103 minus         75   -> -75
ddmns104 minus        -75   -> 75
ddmns105 minus       7.50   -> -7.50
ddmns106 minus      -7.50   -> 7.50
ddmns107 minus       7.500  -> -7.500
ddmns108 minus      -7.500  -> 7.500

-- zeros
ddmns111 minus          0   -> 0
ddmns112 minus         -0   -> 0
ddmns113 minus       0E+4   -> 0E+4
ddmns114 minus      -0E+4   -> 0E+4
ddmns115 minus     0.0000   -> 0.0000
ddmns116 minus    -0.0000   -> 0.0000
ddmns117 minus      0E-141  -> 0E-141
ddmns118 minus     -0E-141  -> 0E-141

-- full coefficients, alternating bits
ddmns121 minus  2682682682682682         -> -2682682682682682
ddmns122 minus  -2682682682682682        -> 2682682682682682
ddmns123 minus  1341341341341341         -> -1341341341341341
ddmns124 minus  -1341341341341341        -> 1341341341341341

-- Nmax, Nmin, Ntiny
ddmns131 minus  9.999999999999999E+384   -> -9.999999999999999E+384
ddmns132 minus  1E-383                   -> -1E-383
ddmns133 minus  1.000000000000000E-383   -> -1.000000000000000E-383
ddmns134 minus  1E-398                   -> -1E-398 Subnormal

ddmns135 minus  -1E-398                  -> 1E-398 Subnormal
ddmns136 minus  -1.000000000000000E-383  -> 1.000000000000000E-383
ddmns137 minus  -1E-383                  -> 1E-383
ddmns138 minus  -9.999999999999999E+384  -> 9.999999999999999E+384

Added test/dectest/ddMultiply.decTest.































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
------------------------------------------------------------------------
-- ddMultiply.decTest -- decDouble multiplication                     --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests are for decDoubles only; all arguments are
-- representable in a decDouble
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks
ddmul000 multiply 2      2 -> 4
ddmul001 multiply 2      3 -> 6
ddmul002 multiply 5      1 -> 5
ddmul003 multiply 5      2 -> 10
ddmul004 multiply 1.20   2 -> 2.40
ddmul005 multiply 1.20   0 -> 0.00
ddmul006 multiply 1.20  -2 -> -2.40
ddmul007 multiply -1.20  2 -> -2.40
ddmul008 multiply -1.20  0 -> -0.00
ddmul009 multiply -1.20 -2 -> 2.40
ddmul010 multiply 5.09 7.1 -> 36.139
ddmul011 multiply 2.5    4 -> 10.0
ddmul012 multiply 2.50   4 -> 10.00
ddmul013 multiply 1.23456789 1.00000000 -> 1.234567890000000 Rounded
ddmul015 multiply 2.50   4 -> 10.00
ddmul016 multiply  9.999999999  9.999999999 ->  99.99999998000000 Inexact Rounded
ddmul017 multiply  9.999999999 -9.999999999 -> -99.99999998000000 Inexact Rounded
ddmul018 multiply -9.999999999  9.999999999 -> -99.99999998000000 Inexact Rounded
ddmul019 multiply -9.999999999 -9.999999999 ->  99.99999998000000 Inexact Rounded

-- zeros, etc.
ddmul021 multiply  0      0     ->  0
ddmul022 multiply  0     -0     -> -0
ddmul023 multiply -0      0     -> -0
ddmul024 multiply -0     -0     ->  0
ddmul025 multiply -0.0   -0.0   ->  0.00
ddmul026 multiply -0.0   -0.0   ->  0.00
ddmul027 multiply -0.0   -0.0   ->  0.00
ddmul028 multiply -0.0   -0.0   ->  0.00
ddmul030 multiply  5.00   1E-3  ->  0.00500
ddmul031 multiply  00.00  0.000 ->  0.00000
ddmul032 multiply  00.00  0E-3  ->  0.00000     -- rhs is 0
ddmul033 multiply  0E-3   00.00 ->  0.00000     -- lhs is 0
ddmul034 multiply -5.00   1E-3  -> -0.00500
ddmul035 multiply -00.00  0.000 -> -0.00000
ddmul036 multiply -00.00  0E-3  -> -0.00000     -- rhs is 0
ddmul037 multiply -0E-3   00.00 -> -0.00000     -- lhs is 0
ddmul038 multiply  5.00  -1E-3  -> -0.00500
ddmul039 multiply  00.00 -0.000 -> -0.00000
ddmul040 multiply  00.00 -0E-3  -> -0.00000     -- rhs is 0
ddmul041 multiply  0E-3  -00.00 -> -0.00000     -- lhs is 0
ddmul042 multiply -5.00  -1E-3  ->  0.00500
ddmul043 multiply -00.00 -0.000 ->  0.00000
ddmul044 multiply -00.00 -0E-3  ->  0.00000     -- rhs is 0
ddmul045 multiply -0E-3  -00.00 ->  0.00000     -- lhs is 0

-- examples from decarith
ddmul050 multiply 1.20 3        -> 3.60
ddmul051 multiply 7    3        -> 21
ddmul052 multiply 0.9  0.8      -> 0.72
ddmul053 multiply 0.9  -0       -> -0.0
ddmul054 multiply 654321 654321 -> 428135971041

ddmul060 multiply 123.45 1e7  ->  1.2345E+9
ddmul061 multiply 123.45 1e8  ->  1.2345E+10
ddmul062 multiply 123.45 1e+9 ->  1.2345E+11
ddmul063 multiply 123.45 1e10 ->  1.2345E+12
ddmul064 multiply 123.45 1e11 ->  1.2345E+13
ddmul065 multiply 123.45 1e12 ->  1.2345E+14
ddmul066 multiply 123.45 1e13 ->  1.2345E+15


-- test some intermediate lengths
--                    1234567890123456
ddmul080 multiply 0.1 1230123456456789     -> 123012345645678.9
ddmul084 multiply 0.1 1230123456456789     -> 123012345645678.9
ddmul090 multiply 1230123456456789     0.1 -> 123012345645678.9
ddmul094 multiply 1230123456456789     0.1 -> 123012345645678.9

-- test some more edge cases and carries
ddmul101 multiply 9 9   -> 81
ddmul102 multiply 9 90   -> 810
ddmul103 multiply 9 900   -> 8100
ddmul104 multiply 9 9000   -> 81000
ddmul105 multiply 9 90000   -> 810000
ddmul106 multiply 9 900000   -> 8100000
ddmul107 multiply 9 9000000   -> 81000000
ddmul108 multiply 9 90000000   -> 810000000
ddmul109 multiply 9 900000000   -> 8100000000
ddmul110 multiply 9 9000000000   -> 81000000000
ddmul111 multiply 9 90000000000   -> 810000000000
ddmul112 multiply 9 900000000000   -> 8100000000000
ddmul113 multiply 9 9000000000000   -> 81000000000000
ddmul114 multiply 9 90000000000000   -> 810000000000000
ddmul115 multiply 9 900000000000000   -> 8100000000000000
--ddmul116 multiply 9 9000000000000000   -> 81000000000000000
--ddmul117 multiply 9 90000000000000000   -> 810000000000000000
--ddmul118 multiply 9 900000000000000000   -> 8100000000000000000
--ddmul119 multiply 9 9000000000000000000   -> 81000000000000000000
--ddmul120 multiply 9 90000000000000000000   -> 810000000000000000000
--ddmul121 multiply 9 900000000000000000000   -> 8100000000000000000000
--ddmul122 multiply 9 9000000000000000000000   -> 81000000000000000000000
--ddmul123 multiply 9 90000000000000000000000   -> 810000000000000000000000
-- test some more edge cases without carries
ddmul131 multiply 3 3   -> 9
ddmul132 multiply 3 30   -> 90
ddmul133 multiply 3 300   -> 900
ddmul134 multiply 3 3000   -> 9000
ddmul135 multiply 3 30000   -> 90000
ddmul136 multiply 3 300000   -> 900000
ddmul137 multiply 3 3000000   -> 9000000
ddmul138 multiply 3 30000000   -> 90000000
ddmul139 multiply 3 300000000   -> 900000000
ddmul140 multiply 3 3000000000   -> 9000000000
ddmul141 multiply 3 30000000000   -> 90000000000
ddmul142 multiply 3 300000000000   -> 900000000000
ddmul143 multiply 3 3000000000000   -> 9000000000000
ddmul144 multiply 3 30000000000000   -> 90000000000000
ddmul145 multiply 3 300000000000000   -> 900000000000000

-- test some edge cases with exact rounding
ddmul301 multiply 9 9   -> 81
ddmul302 multiply 9 90   -> 810
ddmul303 multiply 9 900   -> 8100
ddmul304 multiply 9 9000   -> 81000
ddmul305 multiply 9 90000   -> 810000
ddmul306 multiply 9 900000   -> 8100000
ddmul307 multiply 9 9000000   -> 81000000
ddmul308 multiply 9 90000000   -> 810000000
ddmul309 multiply 9 900000000   -> 8100000000
ddmul310 multiply 9 9000000000   -> 81000000000
ddmul311 multiply 9 90000000000   -> 810000000000
ddmul312 multiply 9 900000000000   -> 8100000000000
ddmul313 multiply 9 9000000000000   -> 81000000000000
ddmul314 multiply 9 90000000000000   -> 810000000000000
ddmul315 multiply 9 900000000000000   -> 8100000000000000
ddmul316 multiply 9 9000000000000000   -> 8.100000000000000E+16  Rounded
ddmul317 multiply 90 9000000000000000   -> 8.100000000000000E+17  Rounded
ddmul318 multiply 900 9000000000000000   -> 8.100000000000000E+18  Rounded
ddmul319 multiply 9000 9000000000000000   -> 8.100000000000000E+19  Rounded
ddmul320 multiply 90000 9000000000000000   -> 8.100000000000000E+20  Rounded
ddmul321 multiply 900000 9000000000000000   -> 8.100000000000000E+21  Rounded
ddmul322 multiply 9000000 9000000000000000   -> 8.100000000000000E+22  Rounded
ddmul323 multiply 90000000 9000000000000000   -> 8.100000000000000E+23  Rounded

-- tryzeros cases
ddmul504  multiply  0E-260 1000E-260  -> 0E-398 Clamped
ddmul505  multiply  100E+260 0E+260   -> 0E+369 Clamped

-- mixed with zeros
ddmul541 multiply  0    -1     -> -0
ddmul542 multiply -0    -1     ->  0
ddmul543 multiply  0     1     ->  0
ddmul544 multiply -0     1     -> -0
ddmul545 multiply -1     0     -> -0
ddmul546 multiply -1    -0     ->  0
ddmul547 multiply  1     0     ->  0
ddmul548 multiply  1    -0     -> -0

ddmul551 multiply  0.0  -1     -> -0.0
ddmul552 multiply -0.0  -1     ->  0.0
ddmul553 multiply  0.0   1     ->  0.0
ddmul554 multiply -0.0   1     -> -0.0
ddmul555 multiply -1.0   0     -> -0.0
ddmul556 multiply -1.0  -0     ->  0.0
ddmul557 multiply  1.0   0     ->  0.0
ddmul558 multiply  1.0  -0     -> -0.0

ddmul561 multiply  0    -1.0   -> -0.0
ddmul562 multiply -0    -1.0   ->  0.0
ddmul563 multiply  0     1.0   ->  0.0
ddmul564 multiply -0     1.0   -> -0.0
ddmul565 multiply -1     0.0   -> -0.0
ddmul566 multiply -1    -0.0   ->  0.0
ddmul567 multiply  1     0.0   ->  0.0
ddmul568 multiply  1    -0.0   -> -0.0

ddmul571 multiply  0.0  -1.0   -> -0.00
ddmul572 multiply -0.0  -1.0   ->  0.00
ddmul573 multiply  0.0   1.0   ->  0.00
ddmul574 multiply -0.0   1.0   -> -0.00
ddmul575 multiply -1.0   0.0   -> -0.00
ddmul576 multiply -1.0  -0.0   ->  0.00
ddmul577 multiply  1.0   0.0   ->  0.00
ddmul578 multiply  1.0  -0.0   -> -0.00


-- Specials
ddmul580 multiply  Inf  -Inf   -> -Infinity
ddmul581 multiply  Inf  -1000  -> -Infinity
ddmul582 multiply  Inf  -1     -> -Infinity
ddmul583 multiply  Inf  -0     ->  NaN  Invalid_operation
ddmul584 multiply  Inf   0     ->  NaN  Invalid_operation
ddmul585 multiply  Inf   1     ->  Infinity
ddmul586 multiply  Inf   1000  ->  Infinity
ddmul587 multiply  Inf   Inf   ->  Infinity
ddmul588 multiply -1000  Inf   -> -Infinity
ddmul589 multiply -Inf   Inf   -> -Infinity
ddmul590 multiply -1     Inf   -> -Infinity
ddmul591 multiply -0     Inf   ->  NaN  Invalid_operation
ddmul592 multiply  0     Inf   ->  NaN  Invalid_operation
ddmul593 multiply  1     Inf   ->  Infinity
ddmul594 multiply  1000  Inf   ->  Infinity
ddmul595 multiply  Inf   Inf   ->  Infinity

ddmul600 multiply -Inf  -Inf   ->  Infinity
ddmul601 multiply -Inf  -1000  ->  Infinity
ddmul602 multiply -Inf  -1     ->  Infinity
ddmul603 multiply -Inf  -0     ->  NaN  Invalid_operation
ddmul604 multiply -Inf   0     ->  NaN  Invalid_operation
ddmul605 multiply -Inf   1     -> -Infinity
ddmul606 multiply -Inf   1000  -> -Infinity
ddmul607 multiply -Inf   Inf   -> -Infinity
ddmul608 multiply -1000  Inf   -> -Infinity
ddmul609 multiply -Inf  -Inf   ->  Infinity
ddmul610 multiply -1    -Inf   ->  Infinity
ddmul611 multiply -0    -Inf   ->  NaN  Invalid_operation
ddmul612 multiply  0    -Inf   ->  NaN  Invalid_operation
ddmul613 multiply  1    -Inf   -> -Infinity
ddmul614 multiply  1000 -Inf   -> -Infinity
ddmul615 multiply  Inf  -Inf   -> -Infinity

ddmul621 multiply  NaN -Inf    ->  NaN
ddmul622 multiply  NaN -1000   ->  NaN
ddmul623 multiply  NaN -1      ->  NaN
ddmul624 multiply  NaN -0      ->  NaN
ddmul625 multiply  NaN  0      ->  NaN
ddmul626 multiply  NaN  1      ->  NaN
ddmul627 multiply  NaN  1000   ->  NaN
ddmul628 multiply  NaN  Inf    ->  NaN
ddmul629 multiply  NaN  NaN    ->  NaN
ddmul630 multiply -Inf  NaN    ->  NaN
ddmul631 multiply -1000 NaN    ->  NaN
ddmul632 multiply -1    NaN    ->  NaN
ddmul633 multiply -0    NaN    ->  NaN
ddmul634 multiply  0    NaN    ->  NaN
ddmul635 multiply  1    NaN    ->  NaN
ddmul636 multiply  1000 NaN    ->  NaN
ddmul637 multiply  Inf  NaN    ->  NaN

ddmul641 multiply  sNaN -Inf   ->  NaN  Invalid_operation
ddmul642 multiply  sNaN -1000  ->  NaN  Invalid_operation
ddmul643 multiply  sNaN -1     ->  NaN  Invalid_operation
ddmul644 multiply  sNaN -0     ->  NaN  Invalid_operation
ddmul645 multiply  sNaN  0     ->  NaN  Invalid_operation
ddmul646 multiply  sNaN  1     ->  NaN  Invalid_operation
ddmul647 multiply  sNaN  1000  ->  NaN  Invalid_operation
ddmul648 multiply  sNaN  NaN   ->  NaN  Invalid_operation
ddmul649 multiply  sNaN sNaN   ->  NaN  Invalid_operation
ddmul650 multiply  NaN  sNaN   ->  NaN  Invalid_operation
ddmul651 multiply -Inf  sNaN   ->  NaN  Invalid_operation
ddmul652 multiply -1000 sNaN   ->  NaN  Invalid_operation
ddmul653 multiply -1    sNaN   ->  NaN  Invalid_operation
ddmul654 multiply -0    sNaN   ->  NaN  Invalid_operation
ddmul655 multiply  0    sNaN   ->  NaN  Invalid_operation
ddmul656 multiply  1    sNaN   ->  NaN  Invalid_operation
ddmul657 multiply  1000 sNaN   ->  NaN  Invalid_operation
ddmul658 multiply  Inf  sNaN   ->  NaN  Invalid_operation
ddmul659 multiply  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddmul661 multiply  NaN9 -Inf   ->  NaN9
ddmul662 multiply  NaN8  999   ->  NaN8
ddmul663 multiply  NaN71 Inf   ->  NaN71
ddmul664 multiply  NaN6  NaN5  ->  NaN6
ddmul665 multiply -Inf   NaN4  ->  NaN4
ddmul666 multiply -999   NaN33 ->  NaN33
ddmul667 multiply  Inf   NaN2  ->  NaN2

ddmul671 multiply  sNaN99 -Inf    ->  NaN99 Invalid_operation
ddmul672 multiply  sNaN98 -11     ->  NaN98 Invalid_operation
ddmul673 multiply  sNaN97  NaN    ->  NaN97 Invalid_operation
ddmul674 multiply  sNaN16 sNaN94  ->  NaN16 Invalid_operation
ddmul675 multiply  NaN95  sNaN93  ->  NaN93 Invalid_operation
ddmul676 multiply -Inf    sNaN92  ->  NaN92 Invalid_operation
ddmul677 multiply  088    sNaN91  ->  NaN91 Invalid_operation
ddmul678 multiply  Inf    sNaN90  ->  NaN90 Invalid_operation
ddmul679 multiply  NaN    sNaN89  ->  NaN89 Invalid_operation

ddmul681 multiply -NaN9 -Inf   -> -NaN9
ddmul682 multiply -NaN8  999   -> -NaN8
ddmul683 multiply -NaN71 Inf   -> -NaN71
ddmul684 multiply -NaN6 -NaN5  -> -NaN6
ddmul685 multiply -Inf  -NaN4  -> -NaN4
ddmul686 multiply -999  -NaN33 -> -NaN33
ddmul687 multiply  Inf  -NaN2  -> -NaN2

ddmul691 multiply -sNaN99 -Inf    -> -NaN99 Invalid_operation
ddmul692 multiply -sNaN98 -11     -> -NaN98 Invalid_operation
ddmul693 multiply -sNaN97  NaN    -> -NaN97 Invalid_operation
ddmul694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation
ddmul695 multiply -NaN95  -sNaN93 -> -NaN93 Invalid_operation
ddmul696 multiply -Inf    -sNaN92 -> -NaN92 Invalid_operation
ddmul697 multiply  088    -sNaN91 -> -NaN91 Invalid_operation
ddmul698 multiply  Inf    -sNaN90 -> -NaN90 Invalid_operation
ddmul699 multiply -NaN    -sNaN89 -> -NaN89 Invalid_operation

ddmul701 multiply -NaN  -Inf   -> -NaN
ddmul702 multiply -NaN   999   -> -NaN
ddmul703 multiply -NaN   Inf   -> -NaN
ddmul704 multiply -NaN  -NaN   -> -NaN
ddmul705 multiply -Inf  -NaN0  -> -NaN
ddmul706 multiply -999  -NaN   -> -NaN
ddmul707 multiply  Inf  -NaN   -> -NaN

ddmul711 multiply -sNaN   -Inf    -> -NaN Invalid_operation
ddmul712 multiply -sNaN   -11     -> -NaN Invalid_operation
ddmul713 multiply -sNaN00  NaN    -> -NaN Invalid_operation
ddmul714 multiply -sNaN   -sNaN   -> -NaN Invalid_operation
ddmul715 multiply -NaN    -sNaN   -> -NaN Invalid_operation
ddmul716 multiply -Inf    -sNaN   -> -NaN Invalid_operation
ddmul717 multiply  088    -sNaN   -> -NaN Invalid_operation
ddmul718 multiply  Inf    -sNaN   -> -NaN Invalid_operation
ddmul719 multiply -NaN    -sNaN   -> -NaN Invalid_operation

-- overflow and underflow tests .. note subnormal results
-- signs
ddmul751 multiply  1e+277  1e+311 ->  Infinity Overflow Inexact Rounded
ddmul752 multiply  1e+277 -1e+311 -> -Infinity Overflow Inexact Rounded
ddmul753 multiply -1e+277  1e+311 -> -Infinity Overflow Inexact Rounded
ddmul754 multiply -1e+277 -1e+311 ->  Infinity Overflow Inexact Rounded
ddmul755 multiply  1e-277  1e-311 ->  0E-398 Underflow Subnormal Inexact Rounded Clamped
ddmul756 multiply  1e-277 -1e-311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
ddmul757 multiply -1e-277  1e-311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
ddmul758 multiply -1e-277 -1e-311 ->  0E-398 Underflow Subnormal Inexact Rounded Clamped

-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
ddmul760 multiply 1e-291 1e-101 -> 1E-392 Subnormal
ddmul761 multiply 1e-291 1e-102 -> 1E-393 Subnormal
ddmul762 multiply 1e-291 1e-103 -> 1E-394 Subnormal
ddmul763 multiply 1e-291 1e-104 -> 1E-395 Subnormal
ddmul764 multiply 1e-291 1e-105 -> 1E-396 Subnormal
ddmul765 multiply 1e-291 1e-106 -> 1E-397 Subnormal
ddmul766 multiply 1e-291 1e-107 -> 1E-398 Subnormal
ddmul767 multiply 1e-291 1e-108 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
ddmul768 multiply 1e-291 1e-109 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
ddmul769 multiply 1e-291 1e-110 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-- [no equivalent of 'subnormal' for overflow]
ddmul770 multiply 1e+60 1e+321 -> 1.000000000000E+381  Clamped
ddmul771 multiply 1e+60 1e+322 -> 1.0000000000000E+382  Clamped
ddmul772 multiply 1e+60 1e+323 -> 1.00000000000000E+383  Clamped
ddmul773 multiply 1e+60 1e+324 -> 1.000000000000000E+384  Clamped
ddmul774 multiply 1e+60 1e+325 -> Infinity Overflow Inexact Rounded
ddmul775 multiply 1e+60 1e+326 -> Infinity Overflow Inexact Rounded
ddmul776 multiply 1e+60 1e+327 -> Infinity Overflow Inexact Rounded
ddmul777 multiply 1e+60 1e+328 -> Infinity Overflow Inexact Rounded
ddmul778 multiply 1e+60 1e+329 -> Infinity Overflow Inexact Rounded
ddmul779 multiply 1e+60 1e+330 -> Infinity Overflow Inexact Rounded

ddmul801 multiply  1.0000E-394  1     -> 1.0000E-394 Subnormal
ddmul802 multiply  1.000E-394   1e-1  -> 1.000E-395  Subnormal
ddmul803 multiply  1.00E-394    1e-2  -> 1.00E-396   Subnormal
ddmul804 multiply  1.0E-394     1e-3  -> 1.0E-397    Subnormal
ddmul805 multiply  1.0E-394     1e-4  -> 1E-398     Subnormal Rounded
ddmul806 multiply  1.3E-394     1e-4  -> 1E-398     Underflow Subnormal Inexact Rounded
ddmul807 multiply  1.5E-394     1e-4  -> 2E-398     Underflow Subnormal Inexact Rounded
ddmul808 multiply  1.7E-394     1e-4  -> 2E-398     Underflow Subnormal Inexact Rounded
ddmul809 multiply  2.3E-394     1e-4  -> 2E-398     Underflow Subnormal Inexact Rounded
ddmul810 multiply  2.5E-394     1e-4  -> 2E-398     Underflow Subnormal Inexact Rounded
ddmul811 multiply  2.7E-394     1e-4  -> 3E-398     Underflow Subnormal Inexact Rounded
ddmul812 multiply  1.49E-394    1e-4  -> 1E-398     Underflow Subnormal Inexact Rounded
ddmul813 multiply  1.50E-394    1e-4  -> 2E-398     Underflow Subnormal Inexact Rounded
ddmul814 multiply  1.51E-394    1e-4  -> 2E-398     Underflow Subnormal Inexact Rounded
ddmul815 multiply  2.49E-394    1e-4  -> 2E-398     Underflow Subnormal Inexact Rounded
ddmul816 multiply  2.50E-394    1e-4  -> 2E-398     Underflow Subnormal Inexact Rounded
ddmul817 multiply  2.51E-394    1e-4  -> 3E-398     Underflow Subnormal Inexact Rounded

ddmul818 multiply  1E-394       1e-4  -> 1E-398     Subnormal
ddmul819 multiply  3E-394       1e-5  -> 0E-398     Underflow Subnormal Inexact Rounded Clamped
ddmul820 multiply  5E-394       1e-5  -> 0E-398     Underflow Subnormal Inexact Rounded Clamped
ddmul821 multiply  7E-394       1e-5  -> 1E-398     Underflow Subnormal Inexact Rounded
ddmul822 multiply  9E-394       1e-5  -> 1E-398     Underflow Subnormal Inexact Rounded
ddmul823 multiply  9.9E-394     1e-5  -> 1E-398     Underflow Subnormal Inexact Rounded

ddmul824 multiply  1E-394      -1e-4  -> -1E-398    Subnormal
ddmul825 multiply  3E-394      -1e-5  -> -0E-398    Underflow Subnormal Inexact Rounded Clamped
ddmul826 multiply -5E-394       1e-5  -> -0E-398    Underflow Subnormal Inexact Rounded Clamped
ddmul827 multiply  7E-394      -1e-5  -> -1E-398    Underflow Subnormal Inexact Rounded
ddmul828 multiply -9E-394       1e-5  -> -1E-398    Underflow Subnormal Inexact Rounded
ddmul829 multiply  9.9E-394    -1e-5  -> -1E-398    Underflow Subnormal Inexact Rounded
ddmul830 multiply  3.0E-394    -1e-5  -> -0E-398    Underflow Subnormal Inexact Rounded Clamped

ddmul831 multiply  1.0E-199     1e-200 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
ddmul832 multiply  1.0E-199     1e-199 -> 1E-398    Subnormal Rounded
ddmul833 multiply  1.0E-199     1e-198 -> 1.0E-397    Subnormal
ddmul834 multiply  2.0E-199     2e-198 -> 4.0E-397    Subnormal
ddmul835 multiply  4.0E-199     4e-198 -> 1.60E-396   Subnormal
ddmul836 multiply 10.0E-199    10e-198 -> 1.000E-395  Subnormal
ddmul837 multiply 30.0E-199    30e-198 -> 9.000E-395  Subnormal
ddmul838 multiply 40.0E-199    40e-188 -> 1.6000E-384 Subnormal
ddmul839 multiply 40.0E-199    40e-187 -> 1.6000E-383
ddmul840 multiply 40.0E-199    40e-186 -> 1.6000E-382

-- Long operand overflow may be a different path
ddmul870 multiply 100  9.999E+383         ->  Infinity Inexact Overflow Rounded
ddmul871 multiply 100 -9.999E+383     -> -Infinity Inexact Overflow Rounded
ddmul872 multiply      9.999E+383 100 ->  Infinity Inexact Overflow Rounded
ddmul873 multiply     -9.999E+383 100 -> -Infinity Inexact Overflow Rounded

-- check for double-rounded subnormals
ddmul881 multiply  1.2347E-355 1.2347E-40  ->  1.524E-395 Inexact Rounded Subnormal Underflow
ddmul882 multiply  1.234E-355 1.234E-40    ->  1.523E-395 Inexact Rounded Subnormal Underflow
ddmul883 multiply  1.23E-355  1.23E-40     ->  1.513E-395 Inexact Rounded Subnormal Underflow
ddmul884 multiply  1.2E-355   1.2E-40      ->  1.44E-395  Subnormal
ddmul885 multiply  1.2E-355   1.2E-41      ->  1.44E-396  Subnormal
ddmul886 multiply  1.2E-355   1.2E-42      ->  1.4E-397   Subnormal Inexact Rounded Underflow
ddmul887 multiply  1.2E-355   1.3E-42      ->  1.6E-397   Subnormal Inexact Rounded Underflow
ddmul888 multiply  1.3E-355   1.3E-42      ->  1.7E-397   Subnormal Inexact Rounded Underflow
ddmul889 multiply  1.3E-355   1.3E-43      ->    2E-398   Subnormal Inexact Rounded Underflow
ddmul890 multiply  1.3E-356   1.3E-43      ->    0E-398   Clamped Subnormal Inexact Rounded Underflow

ddmul891 multiply  1.2345E-39   1.234E-355 ->  1.5234E-394 Inexact Rounded Subnormal Underflow
ddmul892 multiply  1.23456E-39  1.234E-355 ->  1.5234E-394 Inexact Rounded Subnormal Underflow
ddmul893 multiply  1.2345E-40   1.234E-355 ->  1.523E-395  Inexact Rounded Subnormal Underflow
ddmul894 multiply  1.23456E-40  1.234E-355 ->  1.523E-395  Inexact Rounded Subnormal Underflow
ddmul895 multiply  1.2345E-41   1.234E-355 ->  1.52E-396   Inexact Rounded Subnormal Underflow
ddmul896 multiply  1.23456E-41  1.234E-355 ->  1.52E-396   Inexact Rounded Subnormal Underflow

-- Now explore the case where we get a normal result with Underflow
--                                                        1 234567890123456
ddmul900 multiply  0.3000000000E-191 0.3000000000E-191 -> 9.00000000000000E-384 Subnormal Rounded
ddmul901 multiply  0.3000000001E-191 0.3000000001E-191 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
ddmul902 multiply  9.999999999999999E-383  0.0999999999999         -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
ddmul903 multiply  9.999999999999999E-383  0.09999999999999        -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
ddmul904 multiply  9.999999999999999E-383  0.099999999999999       -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
ddmul905 multiply  9.999999999999999E-383  0.0999999999999999      -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
-- prove operands are exact
ddmul906 multiply  9.999999999999999E-383  1                       -> 9.999999999999999E-383
ddmul907 multiply                       1  0.09999999999999999     -> 0.09999999999999999
-- the next rounds to Nmin
ddmul908 multiply  9.999999999999999E-383  0.09999999999999999     -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded

-- hugest
ddmul909 multiply  9999999999999999 9999999999999999 -> 9.999999999999998E+31 Inexact Rounded

-- Null tests
ddmul990 multiply 10  # -> NaN Invalid_operation
ddmul991 multiply  # 10 -> NaN Invalid_operation




Added test/dectest/ddNextMinus.decTest.





























































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
------------------------------------------------------------------------
-- ddNextMinus.decTest -- decDouble next that is less [754r nextdown] --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

ddnextm001 nextminus  0.9999999999999995 ->   0.9999999999999994
ddnextm002 nextminus  0.9999999999999996 ->   0.9999999999999995
ddnextm003 nextminus  0.9999999999999997 ->   0.9999999999999996
ddnextm004 nextminus  0.9999999999999998 ->   0.9999999999999997
ddnextm005 nextminus  0.9999999999999999 ->   0.9999999999999998
ddnextm006 nextminus  1.000000000000000  ->   0.9999999999999999
ddnextm007 nextminus  1.0         ->   0.9999999999999999
ddnextm008 nextminus  1           ->   0.9999999999999999
ddnextm009 nextminus  1.000000000000001  ->   1.000000000000000
ddnextm010 nextminus  1.000000000000002  ->   1.000000000000001
ddnextm011 nextminus  1.000000000000003  ->   1.000000000000002
ddnextm012 nextminus  1.000000000000004  ->   1.000000000000003
ddnextm013 nextminus  1.000000000000005  ->   1.000000000000004
ddnextm014 nextminus  1.000000000000006  ->   1.000000000000005
ddnextm015 nextminus  1.000000000000007  ->   1.000000000000006
ddnextm016 nextminus  1.000000000000008  ->   1.000000000000007
ddnextm017 nextminus  1.000000000000009  ->   1.000000000000008
ddnextm018 nextminus  1.000000000000010  ->   1.000000000000009
ddnextm019 nextminus  1.000000000000011  ->   1.000000000000010
ddnextm020 nextminus  1.000000000000012  ->   1.000000000000011

ddnextm021 nextminus -0.9999999999999995 ->  -0.9999999999999996
ddnextm022 nextminus -0.9999999999999996 ->  -0.9999999999999997
ddnextm023 nextminus -0.9999999999999997 ->  -0.9999999999999998
ddnextm024 nextminus -0.9999999999999998 ->  -0.9999999999999999
ddnextm025 nextminus -0.9999999999999999 ->  -1.000000000000000
ddnextm026 nextminus -1.000000000000000  ->  -1.000000000000001
ddnextm027 nextminus -1.0         ->  -1.000000000000001
ddnextm028 nextminus -1           ->  -1.000000000000001
ddnextm029 nextminus -1.000000000000001  ->  -1.000000000000002
ddnextm030 nextminus -1.000000000000002  ->  -1.000000000000003
ddnextm031 nextminus -1.000000000000003  ->  -1.000000000000004
ddnextm032 nextminus -1.000000000000004  ->  -1.000000000000005
ddnextm033 nextminus -1.000000000000005  ->  -1.000000000000006
ddnextm034 nextminus -1.000000000000006  ->  -1.000000000000007
ddnextm035 nextminus -1.000000000000007  ->  -1.000000000000008
ddnextm036 nextminus -1.000000000000008  ->  -1.000000000000009
ddnextm037 nextminus -1.000000000000009  ->  -1.000000000000010
ddnextm038 nextminus -1.000000000000010  ->  -1.000000000000011
ddnextm039 nextminus -1.000000000000011  ->  -1.000000000000012

-- ultra-tiny inputs
ddnextm062 nextminus  1E-398         ->   0E-398
ddnextm065 nextminus -1E-398         ->  -2E-398

-- Zeros
ddnextm100 nextminus -0           -> -1E-398
ddnextm101 nextminus  0           -> -1E-398
ddnextm102 nextminus  0.00        -> -1E-398
ddnextm103 nextminus -0.00        -> -1E-398
ddnextm104 nextminus  0E-300      -> -1E-398
ddnextm105 nextminus  0E+300      -> -1E-398
ddnextm106 nextminus  0E+30000    -> -1E-398
ddnextm107 nextminus -0E+30000    -> -1E-398

-- specials
ddnextm150 nextminus   Inf    ->  9.999999999999999E+384
ddnextm151 nextminus  -Inf    -> -Infinity
ddnextm152 nextminus   NaN    ->  NaN
ddnextm153 nextminus  sNaN    ->  NaN   Invalid_operation
ddnextm154 nextminus   NaN77  ->  NaN77
ddnextm155 nextminus  sNaN88  ->  NaN88 Invalid_operation
ddnextm156 nextminus  -NaN    -> -NaN
ddnextm157 nextminus -sNaN    -> -NaN   Invalid_operation
ddnextm158 nextminus  -NaN77  -> -NaN77
ddnextm159 nextminus -sNaN88  -> -NaN88 Invalid_operation

-- Nmax, Nmin, Ntiny, subnormals
ddnextm170 nextminus  9.999999999999999E+384   -> 9.999999999999998E+384
ddnextm171 nextminus  9.999999999999998E+384   -> 9.999999999999997E+384
ddnextm172 nextminus  1E-383                   -> 9.99999999999999E-384
ddnextm173 nextminus  1.000000000000000E-383   -> 9.99999999999999E-384
ddnextm174 nextminus  9E-398                   -> 8E-398
ddnextm175 nextminus  9.9E-397                 -> 9.8E-397
ddnextm176 nextminus  9.99999999999E-387       -> 9.99999999998E-387
ddnextm177 nextminus  9.99999999999999E-384    -> 9.99999999999998E-384
ddnextm178 nextminus  9.99999999999998E-384    -> 9.99999999999997E-384
ddnextm179 nextminus  9.99999999999997E-384    -> 9.99999999999996E-384
ddnextm180 nextminus  0E-398                   -> -1E-398
ddnextm181 nextminus  1E-398                   -> 0E-398
ddnextm182 nextminus  2E-398                   -> 1E-398

ddnextm183 nextminus  -0E-398                  -> -1E-398
ddnextm184 nextminus  -1E-398                  -> -2E-398
ddnextm185 nextminus  -2E-398                  -> -3E-398
ddnextm186 nextminus  -10E-398                 -> -1.1E-397
ddnextm187 nextminus  -100E-398                -> -1.01E-396
ddnextm188 nextminus  -100000E-398             -> -1.00001E-393
ddnextm189 nextminus  -1.00000000000E-383      -> -1.000000000000001E-383
ddnextm190 nextminus  -1.000000000000000E-383  -> -1.000000000000001E-383
ddnextm191 nextminus  -1E-383                  -> -1.000000000000001E-383
ddnextm192 nextminus  -9.999999999999998E+384  -> -9.999999999999999E+384
ddnextm193 nextminus  -9.999999999999999E+384  -> -Infinity

-- Null tests
ddnextm900 nextminus  # -> NaN Invalid_operation

Added test/dectest/ddNextPlus.decTest.

























































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
------------------------------------------------------------------------
-- ddNextPlus.decTest -- decDouble next that is greater [754r nextup] --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

ddnextp001 nextplus  0.9999999999999995 ->   0.9999999999999996
ddnextp002 nextplus  0.9999999999999996 ->   0.9999999999999997
ddnextp003 nextplus  0.9999999999999997 ->   0.9999999999999998
ddnextp004 nextplus  0.9999999999999998 ->   0.9999999999999999
ddnextp005 nextplus  0.9999999999999999 ->   1.000000000000000
ddnextp006 nextplus  1.000000000000000  ->   1.000000000000001
ddnextp007 nextplus  1.0         ->   1.000000000000001
ddnextp008 nextplus  1           ->   1.000000000000001
ddnextp009 nextplus  1.000000000000001  ->   1.000000000000002
ddnextp010 nextplus  1.000000000000002  ->   1.000000000000003
ddnextp011 nextplus  1.000000000000003  ->   1.000000000000004
ddnextp012 nextplus  1.000000000000004  ->   1.000000000000005
ddnextp013 nextplus  1.000000000000005  ->   1.000000000000006
ddnextp014 nextplus  1.000000000000006  ->   1.000000000000007
ddnextp015 nextplus  1.000000000000007  ->   1.000000000000008
ddnextp016 nextplus  1.000000000000008  ->   1.000000000000009
ddnextp017 nextplus  1.000000000000009  ->   1.000000000000010
ddnextp018 nextplus  1.000000000000010  ->   1.000000000000011
ddnextp019 nextplus  1.000000000000011  ->   1.000000000000012

ddnextp021 nextplus -0.9999999999999995 ->  -0.9999999999999994
ddnextp022 nextplus -0.9999999999999996 ->  -0.9999999999999995
ddnextp023 nextplus -0.9999999999999997 ->  -0.9999999999999996
ddnextp024 nextplus -0.9999999999999998 ->  -0.9999999999999997
ddnextp025 nextplus -0.9999999999999999 ->  -0.9999999999999998
ddnextp026 nextplus -1.000000000000000  ->  -0.9999999999999999
ddnextp027 nextplus -1.0         ->  -0.9999999999999999
ddnextp028 nextplus -1           ->  -0.9999999999999999
ddnextp029 nextplus -1.000000000000001  ->  -1.000000000000000
ddnextp030 nextplus -1.000000000000002  ->  -1.000000000000001
ddnextp031 nextplus -1.000000000000003  ->  -1.000000000000002
ddnextp032 nextplus -1.000000000000004  ->  -1.000000000000003
ddnextp033 nextplus -1.000000000000005  ->  -1.000000000000004
ddnextp034 nextplus -1.000000000000006  ->  -1.000000000000005
ddnextp035 nextplus -1.000000000000007  ->  -1.000000000000006
ddnextp036 nextplus -1.000000000000008  ->  -1.000000000000007
ddnextp037 nextplus -1.000000000000009  ->  -1.000000000000008
ddnextp038 nextplus -1.000000000000010  ->  -1.000000000000009
ddnextp039 nextplus -1.000000000000011  ->  -1.000000000000010
ddnextp040 nextplus -1.000000000000012  ->  -1.000000000000011

-- Zeros
ddnextp100 nextplus  0           ->  1E-398
ddnextp101 nextplus  0.00        ->  1E-398
ddnextp102 nextplus  0E-300      ->  1E-398
ddnextp103 nextplus  0E+300      ->  1E-398
ddnextp104 nextplus  0E+30000    ->  1E-398
ddnextp105 nextplus -0           ->  1E-398
ddnextp106 nextplus -0.00        ->  1E-398
ddnextp107 nextplus -0E-300      ->  1E-398
ddnextp108 nextplus -0E+300      ->  1E-398
ddnextp109 nextplus -0E+30000    ->  1E-398

-- specials
ddnextp150 nextplus   Inf    ->  Infinity
ddnextp151 nextplus  -Inf    -> -9.999999999999999E+384
ddnextp152 nextplus   NaN    ->  NaN
ddnextp153 nextplus  sNaN    ->  NaN   Invalid_operation
ddnextp154 nextplus   NaN77  ->  NaN77
ddnextp155 nextplus  sNaN88  ->  NaN88 Invalid_operation
ddnextp156 nextplus  -NaN    -> -NaN
ddnextp157 nextplus -sNaN    -> -NaN   Invalid_operation
ddnextp158 nextplus  -NaN77  -> -NaN77
ddnextp159 nextplus -sNaN88  -> -NaN88 Invalid_operation

-- Nmax, Nmin, Ntiny, subnormals
ddnextp170 nextplus  -9.999999999999999E+384  -> -9.999999999999998E+384
ddnextp171 nextplus  -9.999999999999998E+384  -> -9.999999999999997E+384
ddnextp172 nextplus  -1E-383                  -> -9.99999999999999E-384
ddnextp173 nextplus  -1.000000000000000E-383  -> -9.99999999999999E-384
ddnextp174 nextplus  -9E-398                  -> -8E-398
ddnextp175 nextplus  -9.9E-397                -> -9.8E-397
ddnextp176 nextplus  -9.99999999999E-387      -> -9.99999999998E-387
ddnextp177 nextplus  -9.99999999999999E-384   -> -9.99999999999998E-384
ddnextp178 nextplus  -9.99999999999998E-384   -> -9.99999999999997E-384
ddnextp179 nextplus  -9.99999999999997E-384   -> -9.99999999999996E-384
ddnextp180 nextplus  -0E-398                  ->  1E-398
ddnextp181 nextplus  -1E-398                  -> -0E-398
ddnextp182 nextplus  -2E-398                  -> -1E-398

ddnextp183 nextplus   0E-398                  ->  1E-398
ddnextp184 nextplus   1E-398                  ->  2E-398
ddnextp185 nextplus   2E-398                  ->  3E-398
ddnextp186 nextplus   10E-398                 ->  1.1E-397
ddnextp187 nextplus   100E-398                ->  1.01E-396
ddnextp188 nextplus   100000E-398             ->  1.00001E-393
ddnextp189 nextplus   1.00000000000E-383      ->  1.000000000000001E-383
ddnextp190 nextplus   1.000000000000000E-383  ->  1.000000000000001E-383
ddnextp191 nextplus   1E-383                  ->  1.000000000000001E-383
ddnextp192 nextplus   9.999999999999998E+384  ->  9.999999999999999E+384
ddnextp193 nextplus   9.999999999999999E+384  ->  Infinity

-- Null tests
ddnextp900 nextplus  # -> NaN Invalid_operation

Added test/dectest/ddNextToward.decTest.













































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
------------------------------------------------------------------------
-- ddNextToward.decTest -- decDouble next toward rhs [754r nextafter] --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check with a scattering of numerics
ddnextt001 nexttoward   10    10   ->  10
ddnextt002 nexttoward  -10   -10   -> -10
ddnextt003 nexttoward   1     10   ->  1.000000000000001
ddnextt004 nexttoward   1    -10   ->  0.9999999999999999
ddnextt005 nexttoward  -1     10   -> -0.9999999999999999
ddnextt006 nexttoward  -1    -10   -> -1.000000000000001
ddnextt007 nexttoward   0     10   ->  1E-398       Underflow Subnormal Inexact Rounded
ddnextt008 nexttoward   0    -10   -> -1E-398       Underflow Subnormal Inexact Rounded
ddnextt009 nexttoward   9.999999999999999E+384 +Infinity ->  Infinity Overflow Inexact Rounded
ddnextt010 nexttoward  -9.999999999999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
ddnextt011 nexttoward       9.999999999999999  10  ->  10.00000000000000
ddnextt012 nexttoward   10  9.999999999999999      ->  9.999999999999999
ddnextt013 nexttoward      -9.999999999999999 -10  -> -10.00000000000000
ddnextt014 nexttoward  -10 -9.999999999999999      -> -9.999999999999999
ddnextt015 nexttoward       9.999999999999998  10  ->  9.999999999999999
ddnextt016 nexttoward   10  9.999999999999998      ->  9.999999999999999
ddnextt017 nexttoward      -9.999999999999998 -10  -> -9.999999999999999
ddnextt018 nexttoward  -10 -9.999999999999998      -> -9.999999999999999

------- lhs=rhs
-- finites
ddnextt101 nexttoward          7       7 ->  7
ddnextt102 nexttoward         -7      -7 -> -7
ddnextt103 nexttoward         75      75 ->  75
ddnextt104 nexttoward        -75     -75 -> -75
ddnextt105 nexttoward       7.50     7.5 ->  7.50
ddnextt106 nexttoward      -7.50   -7.50 -> -7.50
ddnextt107 nexttoward       7.500 7.5000 ->  7.500
ddnextt108 nexttoward      -7.500   -7.5 -> -7.500

-- zeros
ddnextt111 nexttoward          0       0 ->  0
ddnextt112 nexttoward         -0      -0 -> -0
ddnextt113 nexttoward       0E+4       0 ->  0E+4
ddnextt114 nexttoward      -0E+4      -0 -> -0E+4
ddnextt115 nexttoward     0.00000000000   0.000000000000 ->  0E-11
ddnextt116 nexttoward    -0.00000000000  -0.00           -> -0E-11
ddnextt117 nexttoward      0E-141      0 ->  0E-141
ddnextt118 nexttoward     -0E-141   -000 -> -0E-141

-- full coefficients, alternating bits
ddnextt121 nexttoward   268268268    268268268 ->   268268268
ddnextt122 nexttoward  -268268268   -268268268 ->  -268268268
ddnextt123 nexttoward   134134134    134134134 ->   134134134
ddnextt124 nexttoward  -134134134   -134134134 ->  -134134134

-- Nmax, Nmin, Ntiny
ddnextt131 nexttoward  9.999999999999999E+384  9.999999999999999E+384   ->   9.999999999999999E+384
ddnextt132 nexttoward  1E-383           1E-383            ->   1E-383
ddnextt133 nexttoward  1.000000000000000E-383  1.000000000000000E-383   ->   1.000000000000000E-383
ddnextt134 nexttoward  1E-398           1E-398            ->   1E-398

ddnextt135 nexttoward  -1E-398          -1E-398           ->  -1E-398
ddnextt136 nexttoward  -1.000000000000000E-383 -1.000000000000000E-383  ->  -1.000000000000000E-383
ddnextt137 nexttoward  -1E-383          -1E-383           ->  -1E-383
ddnextt138 nexttoward  -9.999999999999999E+384 -9.999999999999999E+384  ->  -9.999999999999999E+384

------- lhs<rhs
ddnextt201 nexttoward  0.9999999999999995 Infinity ->   0.9999999999999996
ddnextt202 nexttoward  0.9999999999999996 Infinity ->   0.9999999999999997
ddnextt203 nexttoward  0.9999999999999997 Infinity ->   0.9999999999999998
ddnextt204 nexttoward  0.9999999999999998 Infinity ->   0.9999999999999999
ddnextt205 nexttoward  0.9999999999999999 Infinity ->   1.000000000000000
ddnextt206 nexttoward  1.000000000000000  Infinity ->   1.000000000000001
ddnextt207 nexttoward  1.0         Infinity ->   1.000000000000001
ddnextt208 nexttoward  1           Infinity ->   1.000000000000001
ddnextt209 nexttoward  1.000000000000001  Infinity ->   1.000000000000002
ddnextt210 nexttoward  1.000000000000002  Infinity ->   1.000000000000003
ddnextt211 nexttoward  1.000000000000003  Infinity ->   1.000000000000004
ddnextt212 nexttoward  1.000000000000004  Infinity ->   1.000000000000005
ddnextt213 nexttoward  1.000000000000005  Infinity ->   1.000000000000006
ddnextt214 nexttoward  1.000000000000006  Infinity ->   1.000000000000007
ddnextt215 nexttoward  1.000000000000007  Infinity ->   1.000000000000008
ddnextt216 nexttoward  1.000000000000008  Infinity ->   1.000000000000009
ddnextt217 nexttoward  1.000000000000009  Infinity ->   1.000000000000010
ddnextt218 nexttoward  1.000000000000010  Infinity ->   1.000000000000011
ddnextt219 nexttoward  1.000000000000011  Infinity ->   1.000000000000012

ddnextt221 nexttoward -0.9999999999999995 Infinity ->  -0.9999999999999994
ddnextt222 nexttoward -0.9999999999999996 Infinity ->  -0.9999999999999995
ddnextt223 nexttoward -0.9999999999999997 Infinity ->  -0.9999999999999996
ddnextt224 nexttoward -0.9999999999999998 Infinity ->  -0.9999999999999997
ddnextt225 nexttoward -0.9999999999999999 Infinity ->  -0.9999999999999998
ddnextt226 nexttoward -1.000000000000000  Infinity ->  -0.9999999999999999
ddnextt227 nexttoward -1.0         Infinity ->  -0.9999999999999999
ddnextt228 nexttoward -1           Infinity ->  -0.9999999999999999
ddnextt229 nexttoward -1.000000000000001  Infinity ->  -1.000000000000000
ddnextt230 nexttoward -1.000000000000002  Infinity ->  -1.000000000000001
ddnextt231 nexttoward -1.000000000000003  Infinity ->  -1.000000000000002
ddnextt232 nexttoward -1.000000000000004  Infinity ->  -1.000000000000003
ddnextt233 nexttoward -1.000000000000005  Infinity ->  -1.000000000000004
ddnextt234 nexttoward -1.000000000000006  Infinity ->  -1.000000000000005
ddnextt235 nexttoward -1.000000000000007  Infinity ->  -1.000000000000006
ddnextt236 nexttoward -1.000000000000008  Infinity ->  -1.000000000000007
ddnextt237 nexttoward -1.000000000000009  Infinity ->  -1.000000000000008
ddnextt238 nexttoward -1.000000000000010  Infinity ->  -1.000000000000009
ddnextt239 nexttoward -1.000000000000011  Infinity ->  -1.000000000000010
ddnextt240 nexttoward -1.000000000000012  Infinity ->  -1.000000000000011

-- Zeros
ddnextt300 nexttoward  0           Infinity ->  1E-398              Underflow Subnormal Inexact Rounded
ddnextt301 nexttoward  0.00        Infinity ->  1E-398              Underflow Subnormal Inexact Rounded
ddnextt302 nexttoward  0E-300      Infinity ->  1E-398              Underflow Subnormal Inexact Rounded
ddnextt303 nexttoward  0E+300      Infinity ->  1E-398              Underflow Subnormal Inexact Rounded
ddnextt304 nexttoward  0E+30000    Infinity ->  1E-398              Underflow Subnormal Inexact Rounded
ddnextt305 nexttoward -0           Infinity ->  1E-398              Underflow Subnormal Inexact Rounded
ddnextt306 nexttoward -0.00        Infinity ->  1E-398              Underflow Subnormal Inexact Rounded
ddnextt307 nexttoward -0E-300      Infinity ->  1E-398              Underflow Subnormal Inexact Rounded
ddnextt308 nexttoward -0E+300      Infinity ->  1E-398              Underflow Subnormal Inexact Rounded
ddnextt309 nexttoward -0E+30000    Infinity ->  1E-398              Underflow Subnormal Inexact Rounded

-- specials
ddnextt350 nexttoward   Inf    Infinity ->  Infinity
ddnextt351 nexttoward  -Inf    Infinity -> -9.999999999999999E+384
ddnextt352 nexttoward   NaN    Infinity ->  NaN
ddnextt353 nexttoward  sNaN    Infinity ->  NaN   Invalid_operation
ddnextt354 nexttoward   NaN77  Infinity ->  NaN77
ddnextt355 nexttoward  sNaN88  Infinity ->  NaN88 Invalid_operation
ddnextt356 nexttoward  -NaN    Infinity -> -NaN
ddnextt357 nexttoward -sNaN    Infinity -> -NaN   Invalid_operation
ddnextt358 nexttoward  -NaN77  Infinity -> -NaN77
ddnextt359 nexttoward -sNaN88  Infinity -> -NaN88 Invalid_operation

-- Nmax, Nmin, Ntiny, subnormals
ddnextt370 nexttoward  -9.999999999999999E+384  Infinity  -> -9.999999999999998E+384
ddnextt371 nexttoward  -9.999999999999998E+384  Infinity  -> -9.999999999999997E+384
ddnextt372 nexttoward  -1E-383                  Infinity  -> -9.99999999999999E-384  Underflow Subnormal Inexact Rounded
ddnextt373 nexttoward  -1.000000000000000E-383  Infinity  -> -9.99999999999999E-384  Underflow Subnormal Inexact Rounded
ddnextt374 nexttoward  -9E-398                  Infinity  -> -8E-398                 Underflow Subnormal Inexact Rounded
ddnextt375 nexttoward  -9.9E-397                Infinity  -> -9.8E-397               Underflow Subnormal Inexact Rounded
ddnextt376 nexttoward  -9.99999999999E-387      Infinity  -> -9.99999999998E-387     Underflow Subnormal Inexact Rounded
ddnextt377 nexttoward  -9.99999999999999E-384   Infinity  -> -9.99999999999998E-384  Underflow Subnormal Inexact Rounded
ddnextt378 nexttoward  -9.99999999999998E-384   Infinity  -> -9.99999999999997E-384  Underflow Subnormal Inexact Rounded
ddnextt379 nexttoward  -9.99999999999997E-384   Infinity  -> -9.99999999999996E-384  Underflow Subnormal Inexact Rounded
ddnextt380 nexttoward  -0E-398                  Infinity  ->  1E-398                 Underflow Subnormal Inexact Rounded
ddnextt381 nexttoward  -1E-398                  Infinity  -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
ddnextt382 nexttoward  -2E-398                  Infinity  -> -1E-398                 Underflow Subnormal Inexact Rounded

ddnextt383 nexttoward   0E-398                  Infinity  ->  1E-398                 Underflow Subnormal Inexact Rounded
ddnextt384 nexttoward   1E-398                  Infinity  ->  2E-398                 Underflow Subnormal Inexact Rounded
ddnextt385 nexttoward   2E-398                  Infinity  ->  3E-398                 Underflow Subnormal Inexact Rounded
ddnextt386 nexttoward   10E-398                 Infinity  ->  1.1E-397               Underflow Subnormal Inexact Rounded
ddnextt387 nexttoward   100E-398                Infinity  ->  1.01E-396              Underflow Subnormal Inexact Rounded
ddnextt388 nexttoward   100000E-398             Infinity  ->  1.00001E-393           Underflow Subnormal Inexact Rounded
ddnextt389 nexttoward   1.00000000000E-383      Infinity  ->  1.000000000000001E-383
ddnextt390 nexttoward   1.000000000000000E-383  Infinity  ->  1.000000000000001E-383
ddnextt391 nexttoward   1E-383                  Infinity  ->  1.000000000000001E-383
ddnextt392 nexttoward   9.999999999999997E+384  Infinity  ->  9.999999999999998E+384
ddnextt393 nexttoward   9.999999999999998E+384  Infinity  ->  9.999999999999999E+384
ddnextt394 nexttoward   9.999999999999999E+384  Infinity  ->  Infinity               Overflow Inexact Rounded

------- lhs>rhs
ddnextt401 nexttoward  0.9999999999999995  -Infinity ->   0.9999999999999994
ddnextt402 nexttoward  0.9999999999999996  -Infinity ->   0.9999999999999995
ddnextt403 nexttoward  0.9999999999999997  -Infinity ->   0.9999999999999996
ddnextt404 nexttoward  0.9999999999999998  -Infinity ->   0.9999999999999997
ddnextt405 nexttoward  0.9999999999999999  -Infinity ->   0.9999999999999998
ddnextt406 nexttoward  1.000000000000000   -Infinity ->   0.9999999999999999
ddnextt407 nexttoward  1.0          -Infinity ->   0.9999999999999999
ddnextt408 nexttoward  1            -Infinity ->   0.9999999999999999
ddnextt409 nexttoward  1.000000000000001   -Infinity ->   1.000000000000000
ddnextt410 nexttoward  1.000000000000002   -Infinity ->   1.000000000000001
ddnextt411 nexttoward  1.000000000000003   -Infinity ->   1.000000000000002
ddnextt412 nexttoward  1.000000000000004   -Infinity ->   1.000000000000003
ddnextt413 nexttoward  1.000000000000005   -Infinity ->   1.000000000000004
ddnextt414 nexttoward  1.000000000000006   -Infinity ->   1.000000000000005
ddnextt415 nexttoward  1.000000000000007   -Infinity ->   1.000000000000006
ddnextt416 nexttoward  1.000000000000008   -Infinity ->   1.000000000000007
ddnextt417 nexttoward  1.000000000000009   -Infinity ->   1.000000000000008
ddnextt418 nexttoward  1.000000000000010   -Infinity ->   1.000000000000009
ddnextt419 nexttoward  1.000000000000011   -Infinity ->   1.000000000000010
ddnextt420 nexttoward  1.000000000000012   -Infinity ->   1.000000000000011

ddnextt421 nexttoward -0.9999999999999995  -Infinity ->  -0.9999999999999996
ddnextt422 nexttoward -0.9999999999999996  -Infinity ->  -0.9999999999999997
ddnextt423 nexttoward -0.9999999999999997  -Infinity ->  -0.9999999999999998
ddnextt424 nexttoward -0.9999999999999998  -Infinity ->  -0.9999999999999999
ddnextt425 nexttoward -0.9999999999999999  -Infinity ->  -1.000000000000000
ddnextt426 nexttoward -1.000000000000000   -Infinity ->  -1.000000000000001
ddnextt427 nexttoward -1.0          -Infinity ->  -1.000000000000001
ddnextt428 nexttoward -1            -Infinity ->  -1.000000000000001
ddnextt429 nexttoward -1.000000000000001   -Infinity ->  -1.000000000000002
ddnextt430 nexttoward -1.000000000000002   -Infinity ->  -1.000000000000003
ddnextt431 nexttoward -1.000000000000003   -Infinity ->  -1.000000000000004
ddnextt432 nexttoward -1.000000000000004   -Infinity ->  -1.000000000000005
ddnextt433 nexttoward -1.000000000000005   -Infinity ->  -1.000000000000006
ddnextt434 nexttoward -1.000000000000006   -Infinity ->  -1.000000000000007
ddnextt435 nexttoward -1.000000000000007   -Infinity ->  -1.000000000000008
ddnextt436 nexttoward -1.000000000000008   -Infinity ->  -1.000000000000009
ddnextt437 nexttoward -1.000000000000009   -Infinity ->  -1.000000000000010
ddnextt438 nexttoward -1.000000000000010   -Infinity ->  -1.000000000000011
ddnextt439 nexttoward -1.000000000000011   -Infinity ->  -1.000000000000012

-- Zeros
ddnextt500 nexttoward -0            -Infinity -> -1E-398         Underflow Subnormal Inexact Rounded
ddnextt501 nexttoward  0            -Infinity -> -1E-398         Underflow Subnormal Inexact Rounded
ddnextt502 nexttoward  0.00         -Infinity -> -1E-398         Underflow Subnormal Inexact Rounded
ddnextt503 nexttoward -0.00         -Infinity -> -1E-398         Underflow Subnormal Inexact Rounded
ddnextt504 nexttoward  0E-300       -Infinity -> -1E-398         Underflow Subnormal Inexact Rounded
ddnextt505 nexttoward  0E+300       -Infinity -> -1E-398         Underflow Subnormal Inexact Rounded
ddnextt506 nexttoward  0E+30000     -Infinity -> -1E-398         Underflow Subnormal Inexact Rounded
ddnextt507 nexttoward -0E+30000     -Infinity -> -1E-398         Underflow Subnormal Inexact Rounded

-- specials
ddnextt550 nexttoward   Inf     -Infinity ->  9.999999999999999E+384
ddnextt551 nexttoward  -Inf     -Infinity -> -Infinity
ddnextt552 nexttoward   NaN     -Infinity ->  NaN
ddnextt553 nexttoward  sNaN     -Infinity ->  NaN   Invalid_operation
ddnextt554 nexttoward   NaN77   -Infinity ->  NaN77
ddnextt555 nexttoward  sNaN88   -Infinity ->  NaN88 Invalid_operation
ddnextt556 nexttoward  -NaN     -Infinity -> -NaN
ddnextt557 nexttoward -sNaN     -Infinity -> -NaN   Invalid_operation
ddnextt558 nexttoward  -NaN77   -Infinity -> -NaN77
ddnextt559 nexttoward -sNaN88   -Infinity -> -NaN88 Invalid_operation

-- Nmax, Nmin, Ntiny, subnormals
ddnextt670 nexttoward  9.999999999999999E+384   -Infinity  -> 9.999999999999998E+384
ddnextt671 nexttoward  9.999999999999998E+384   -Infinity  -> 9.999999999999997E+384
ddnextt672 nexttoward  1E-383                   -Infinity  -> 9.99999999999999E-384   Underflow Subnormal  Inexact Rounded
ddnextt673 nexttoward  1.000000000000000E-383   -Infinity  -> 9.99999999999999E-384   Underflow Subnormal  Inexact Rounded
ddnextt674 nexttoward  9E-398                   -Infinity  -> 8E-398                  Underflow Subnormal  Inexact Rounded
ddnextt675 nexttoward  9.9E-397                 -Infinity  -> 9.8E-397                Underflow Subnormal  Inexact Rounded
ddnextt676 nexttoward  9.99999999999E-387       -Infinity  -> 9.99999999998E-387      Underflow Subnormal  Inexact Rounded
ddnextt677 nexttoward  9.99999999999999E-384    -Infinity  -> 9.99999999999998E-384   Underflow Subnormal  Inexact Rounded
ddnextt678 nexttoward  9.99999999999998E-384    -Infinity  -> 9.99999999999997E-384   Underflow Subnormal  Inexact Rounded
ddnextt679 nexttoward  9.99999999999997E-384    -Infinity  -> 9.99999999999996E-384   Underflow Subnormal  Inexact Rounded
ddnextt680 nexttoward  0E-398                   -Infinity  -> -1E-398                 Underflow Subnormal  Inexact Rounded
ddnextt681 nexttoward  1E-398                   -Infinity  -> 0E-398                  Underflow Subnormal  Inexact Rounded Clamped
ddnextt682 nexttoward  2E-398                   -Infinity  -> 1E-398                  Underflow Subnormal  Inexact Rounded

ddnextt683 nexttoward  -0E-398                  -Infinity  -> -1E-398                 Underflow Subnormal  Inexact Rounded
ddnextt684 nexttoward  -1E-398                  -Infinity  -> -2E-398                 Underflow Subnormal  Inexact Rounded
ddnextt685 nexttoward  -2E-398                  -Infinity  -> -3E-398                 Underflow Subnormal  Inexact Rounded
ddnextt686 nexttoward  -10E-398                 -Infinity  -> -1.1E-397               Underflow Subnormal  Inexact Rounded
ddnextt687 nexttoward  -100E-398                -Infinity  -> -1.01E-396              Underflow Subnormal  Inexact Rounded
ddnextt688 nexttoward  -100000E-398             -Infinity  -> -1.00001E-393           Underflow Subnormal  Inexact Rounded
ddnextt689 nexttoward  -1.00000000000E-383      -Infinity  -> -1.000000000000001E-383
ddnextt690 nexttoward  -1.000000000000000E-383  -Infinity  -> -1.000000000000001E-383
ddnextt691 nexttoward  -1E-383                  -Infinity  -> -1.000000000000001E-383
ddnextt692 nexttoward  -9.999999999999998E+384  -Infinity  -> -9.999999999999999E+384
ddnextt693 nexttoward  -9.999999999999999E+384  -Infinity  -> -Infinity               Overflow Inexact Rounded

------- Specials
ddnextt780 nexttoward -Inf  -Inf   -> -Infinity
ddnextt781 nexttoward -Inf  -1000  -> -9.999999999999999E+384
ddnextt782 nexttoward -Inf  -1     -> -9.999999999999999E+384
ddnextt783 nexttoward -Inf  -0     -> -9.999999999999999E+384
ddnextt784 nexttoward -Inf   0     -> -9.999999999999999E+384
ddnextt785 nexttoward -Inf   1     -> -9.999999999999999E+384
ddnextt786 nexttoward -Inf   1000  -> -9.999999999999999E+384
ddnextt787 nexttoward -1000 -Inf   -> -1000.000000000001
ddnextt788 nexttoward -Inf  -Inf   -> -Infinity
ddnextt789 nexttoward -1    -Inf   -> -1.000000000000001
ddnextt790 nexttoward -0    -Inf   -> -1E-398           Underflow Subnormal Inexact Rounded
ddnextt791 nexttoward  0    -Inf   -> -1E-398           Underflow Subnormal Inexact Rounded
ddnextt792 nexttoward  1    -Inf   ->  0.9999999999999999
ddnextt793 nexttoward  1000 -Inf   ->  999.9999999999999
ddnextt794 nexttoward  Inf  -Inf   ->  9.999999999999999E+384

ddnextt800 nexttoward  Inf  -Inf   ->  9.999999999999999E+384
ddnextt801 nexttoward  Inf  -1000  ->  9.999999999999999E+384
ddnextt802 nexttoward  Inf  -1     ->  9.999999999999999E+384
ddnextt803 nexttoward  Inf  -0     ->  9.999999999999999E+384
ddnextt804 nexttoward  Inf   0     ->  9.999999999999999E+384
ddnextt805 nexttoward  Inf   1     ->  9.999999999999999E+384
ddnextt806 nexttoward  Inf   1000  ->  9.999999999999999E+384
ddnextt807 nexttoward  Inf   Inf   ->  Infinity
ddnextt808 nexttoward -1000  Inf   -> -999.9999999999999
ddnextt809 nexttoward -Inf   Inf   -> -9.999999999999999E+384
ddnextt810 nexttoward -1     Inf   -> -0.9999999999999999
ddnextt811 nexttoward -0     Inf   ->  1E-398           Underflow Subnormal Inexact Rounded
ddnextt812 nexttoward  0     Inf   ->  1E-398           Underflow Subnormal Inexact Rounded
ddnextt813 nexttoward  1     Inf   ->  1.000000000000001
ddnextt814 nexttoward  1000  Inf   ->  1000.000000000001
ddnextt815 nexttoward  Inf   Inf   ->  Infinity

ddnextt821 nexttoward  NaN -Inf    ->  NaN
ddnextt822 nexttoward  NaN -1000   ->  NaN
ddnextt823 nexttoward  NaN -1      ->  NaN
ddnextt824 nexttoward  NaN -0      ->  NaN
ddnextt825 nexttoward  NaN  0      ->  NaN
ddnextt826 nexttoward  NaN  1      ->  NaN
ddnextt827 nexttoward  NaN  1000   ->  NaN
ddnextt828 nexttoward  NaN  Inf    ->  NaN
ddnextt829 nexttoward  NaN  NaN    ->  NaN
ddnextt830 nexttoward -Inf  NaN    ->  NaN
ddnextt831 nexttoward -1000 NaN    ->  NaN
ddnextt832 nexttoward -1    NaN    ->  NaN
ddnextt833 nexttoward -0    NaN    ->  NaN
ddnextt834 nexttoward  0    NaN    ->  NaN
ddnextt835 nexttoward  1    NaN    ->  NaN
ddnextt836 nexttoward  1000 NaN    ->  NaN
ddnextt837 nexttoward  Inf  NaN    ->  NaN

ddnextt841 nexttoward  sNaN -Inf   ->  NaN  Invalid_operation
ddnextt842 nexttoward  sNaN -1000  ->  NaN  Invalid_operation
ddnextt843 nexttoward  sNaN -1     ->  NaN  Invalid_operation
ddnextt844 nexttoward  sNaN -0     ->  NaN  Invalid_operation
ddnextt845 nexttoward  sNaN  0     ->  NaN  Invalid_operation
ddnextt846 nexttoward  sNaN  1     ->  NaN  Invalid_operation
ddnextt847 nexttoward  sNaN  1000  ->  NaN  Invalid_operation
ddnextt848 nexttoward  sNaN  NaN   ->  NaN  Invalid_operation
ddnextt849 nexttoward  sNaN sNaN   ->  NaN  Invalid_operation
ddnextt850 nexttoward  NaN  sNaN   ->  NaN  Invalid_operation
ddnextt851 nexttoward -Inf  sNaN   ->  NaN  Invalid_operation
ddnextt852 nexttoward -1000 sNaN   ->  NaN  Invalid_operation
ddnextt853 nexttoward -1    sNaN   ->  NaN  Invalid_operation
ddnextt854 nexttoward -0    sNaN   ->  NaN  Invalid_operation
ddnextt855 nexttoward  0    sNaN   ->  NaN  Invalid_operation
ddnextt856 nexttoward  1    sNaN   ->  NaN  Invalid_operation
ddnextt857 nexttoward  1000 sNaN   ->  NaN  Invalid_operation
ddnextt858 nexttoward  Inf  sNaN   ->  NaN  Invalid_operation
ddnextt859 nexttoward  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddnextt861 nexttoward  NaN1   -Inf    ->  NaN1
ddnextt862 nexttoward +NaN2   -1000   ->  NaN2
ddnextt863 nexttoward  NaN3    1000   ->  NaN3
ddnextt864 nexttoward  NaN4    Inf    ->  NaN4
ddnextt865 nexttoward  NaN5   +NaN6   ->  NaN5
ddnextt866 nexttoward -Inf     NaN7   ->  NaN7
ddnextt867 nexttoward -1000    NaN8   ->  NaN8
ddnextt868 nexttoward  1000    NaN9   ->  NaN9
ddnextt869 nexttoward  Inf    +NaN10  ->  NaN10
ddnextt871 nexttoward  sNaN11  -Inf   ->  NaN11  Invalid_operation
ddnextt872 nexttoward  sNaN12  -1000  ->  NaN12  Invalid_operation
ddnextt873 nexttoward  sNaN13   1000  ->  NaN13  Invalid_operation
ddnextt874 nexttoward  sNaN14   NaN17 ->  NaN14  Invalid_operation
ddnextt875 nexttoward  sNaN15  sNaN18 ->  NaN15  Invalid_operation
ddnextt876 nexttoward  NaN16   sNaN19 ->  NaN19  Invalid_operation
ddnextt877 nexttoward -Inf    +sNaN20 ->  NaN20  Invalid_operation
ddnextt878 nexttoward -1000    sNaN21 ->  NaN21  Invalid_operation
ddnextt879 nexttoward  1000    sNaN22 ->  NaN22  Invalid_operation
ddnextt880 nexttoward  Inf     sNaN23 ->  NaN23  Invalid_operation
ddnextt881 nexttoward +NaN25  +sNaN24 ->  NaN24  Invalid_operation
ddnextt882 nexttoward -NaN26    NaN28 -> -NaN26
ddnextt883 nexttoward -sNaN27  sNaN29 -> -NaN27  Invalid_operation
ddnextt884 nexttoward  1000    -NaN30 -> -NaN30
ddnextt885 nexttoward  1000   -sNaN31 -> -NaN31  Invalid_operation

-- Null tests
ddnextt900 nexttoward 1  # -> NaN Invalid_operation
ddnextt901 nexttoward #  1 -> NaN Invalid_operation

Added test/dectest/ddOr.decTest.









































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
------------------------------------------------------------------------
-- ddOr.decTest -- digitwise logical OR for decDoubles                --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check (truth table)
ddor001 or             0    0 ->    0
ddor002 or             0    1 ->    1
ddor003 or             1    0 ->    1
ddor004 or             1    1 ->    1
ddor005 or          1100 1010 -> 1110
-- and at msd and msd-1
ddor006 or 0000000000000000 0000000000000000 ->           0
ddor007 or 0000000000000000 1000000000000000 ->   1000000000000000
ddor008 or 1000000000000000 0000000000000000 ->   1000000000000000
ddor009 or 1000000000000000 1000000000000000 ->   1000000000000000
ddor010 or 0000000000000000 0000000000000000 ->           0
ddor011 or 0000000000000000 0100000000000000 ->    100000000000000
ddor012 or 0100000000000000 0000000000000000 ->    100000000000000
ddor013 or 0100000000000000 0100000000000000 ->    100000000000000

-- Various lengths
--         1234567890123456     1234567890123456 1234567890123456
ddor020 or 1111111111111111     1111111111111111  ->  1111111111111111
ddor021 or  111111111111111      111111111111111  ->   111111111111111
ddor022 or   11111111111111       11111111111111  ->    11111111111111
ddor023 or    1111111111111        1111111111111  ->     1111111111111
ddor024 or     111111111111         111111111111  ->      111111111111
ddor025 or      11111111111          11111111111  ->       11111111111
ddor026 or       1111111111           1111111111  ->        1111111111
ddor027 or        111111111            111111111  ->         111111111
ddor028 or         11111111             11111111  ->          11111111
ddor029 or          1111111              1111111  ->           1111111
ddor030 or           111111               111111  ->            111111
ddor031 or            11111                11111  ->             11111
ddor032 or             1111                 1111  ->              1111
ddor033 or              111                  111  ->               111
ddor034 or               11                   11  ->                11
ddor035 or                1                    1  ->                 1
ddor036 or                0                    0  ->                 0

ddor042 or  111111110000000     1111111110000000  ->  1111111110000000
ddor043 or   11111110000000     1000000100000000  ->  1011111110000000
ddor044 or    1111110000000     1000001000000000  ->  1001111110000000
ddor045 or     111110000000     1000010000000000  ->  1000111110000000
ddor046 or      11110000000     1000100000000000  ->  1000111110000000
ddor047 or       1110000000     1001000000000000  ->  1001001110000000
ddor048 or        110000000     1010000000000000  ->  1010000110000000
ddor049 or         10000000     1100000000000000  ->  1100000010000000

ddor090 or 011111111  111101111  ->  111111111
ddor091 or 101111111  111101111  ->  111111111
ddor092 or 110111111  111101111  ->  111111111
ddor093 or 111011111  111101111  ->  111111111
ddor094 or 111101111  111101111  ->  111101111
ddor095 or 111110111  111101111  ->  111111111
ddor096 or 111111011  111101111  ->  111111111
ddor097 or 111111101  111101111  ->  111111111
ddor098 or 111111110  111101111  ->  111111111

ddor100 or 111101111  011111111  ->  111111111
ddor101 or 111101111  101111111  ->  111111111
ddor102 or 111101111  110111111  ->  111111111
ddor103 or 111101111  111011111  ->  111111111
ddor104 or 111101111  111101111  ->  111101111
ddor105 or 111101111  111110111  ->  111111111
ddor106 or 111101111  111111011  ->  111111111
ddor107 or 111101111  111111101  ->  111111111
ddor108 or 111101111  111111110  ->  111111111

-- non-0/1 should not be accepted, nor should signs
ddor220 or 111111112  111111111  ->  NaN Invalid_operation
ddor221 or 333333333  333333333  ->  NaN Invalid_operation
ddor222 or 555555555  555555555  ->  NaN Invalid_operation
ddor223 or 777777777  777777777  ->  NaN Invalid_operation
ddor224 or 999999999  999999999  ->  NaN Invalid_operation
ddor225 or 222222222  999999999  ->  NaN Invalid_operation
ddor226 or 444444444  999999999  ->  NaN Invalid_operation
ddor227 or 666666666  999999999  ->  NaN Invalid_operation
ddor228 or 888888888  999999999  ->  NaN Invalid_operation
ddor229 or 999999999  222222222  ->  NaN Invalid_operation
ddor230 or 999999999  444444444  ->  NaN Invalid_operation
ddor231 or 999999999  666666666  ->  NaN Invalid_operation
ddor232 or 999999999  888888888  ->  NaN Invalid_operation
-- a few randoms
ddor240 or  567468689 -934981942 ->  NaN Invalid_operation
ddor241 or  567367689  934981942 ->  NaN Invalid_operation
ddor242 or -631917772 -706014634 ->  NaN Invalid_operation
ddor243 or -756253257  138579234 ->  NaN Invalid_operation
ddor244 or  835590149  567435400 ->  NaN Invalid_operation
-- test MSD
ddor250 or  2000000000000000 1000000000000000 ->  NaN Invalid_operation
ddor251 or  7000000000000000 1000000000000000 ->  NaN Invalid_operation
ddor252 or  8000000000000000 1000000000000000 ->  NaN Invalid_operation
ddor253 or  9000000000000000 1000000000000000 ->  NaN Invalid_operation
ddor254 or  2000000000000000 0000000000000000 ->  NaN Invalid_operation
ddor255 or  7000000000000000 0000000000000000 ->  NaN Invalid_operation
ddor256 or  8000000000000000 0000000000000000 ->  NaN Invalid_operation
ddor257 or  9000000000000000 0000000000000000 ->  NaN Invalid_operation
ddor258 or  1000000000000000 2000000000000000 ->  NaN Invalid_operation
ddor259 or  1000000000000000 7000000000000000 ->  NaN Invalid_operation
ddor260 or  1000000000000000 8000000000000000 ->  NaN Invalid_operation
ddor261 or  1000000000000000 9000000000000000 ->  NaN Invalid_operation
ddor262 or  0000000000000000 2000000000000000 ->  NaN Invalid_operation
ddor263 or  0000000000000000 7000000000000000 ->  NaN Invalid_operation
ddor264 or  0000000000000000 8000000000000000 ->  NaN Invalid_operation
ddor265 or  0000000000000000 9000000000000000 ->  NaN Invalid_operation
-- test MSD-1
ddor270 or  0200001000000000 1000100000000010 ->  NaN Invalid_operation
ddor271 or  0700000100000000 1000010000000100 ->  NaN Invalid_operation
ddor272 or  0800000010000000 1000001000001000 ->  NaN Invalid_operation
ddor273 or  0900000001000000 1000000100010000 ->  NaN Invalid_operation
ddor274 or  1000000000100000 0200000010100000 ->  NaN Invalid_operation
ddor275 or  1000000000010000 0700000001000000 ->  NaN Invalid_operation
ddor276 or  1000000000001000 0800000010100000 ->  NaN Invalid_operation
ddor277 or  1000000000000100 0900000000010000 ->  NaN Invalid_operation
-- test LSD
ddor280 or  0010000000000002 1000000100000001 ->  NaN Invalid_operation
ddor281 or  0001000000000007 1000001000000011 ->  NaN Invalid_operation
ddor282 or  0000100000000008 1000010000000001 ->  NaN Invalid_operation
ddor283 or  0000010000000009 1000100000000001 ->  NaN Invalid_operation
ddor284 or  1000001000000000 0001000000000002 ->  NaN Invalid_operation
ddor285 or  1000000100000000 0010000000000007 ->  NaN Invalid_operation
ddor286 or  1000000010000000 0100000000000008 ->  NaN Invalid_operation
ddor287 or  1000000001000000 1000000000000009 ->  NaN Invalid_operation
-- test Middie
ddor288 or  0010000020000000 1000001000000000 ->  NaN Invalid_operation
ddor289 or  0001000070000001 1000000100000000 ->  NaN Invalid_operation
ddor290 or  0000100080000010 1000000010000000 ->  NaN Invalid_operation
ddor291 or  0000010090000100 1000000001000000 ->  NaN Invalid_operation
ddor292 or  1000001000001000 0000000020100000 ->  NaN Invalid_operation
ddor293 or  1000000100010000 0000000070010000 ->  NaN Invalid_operation
ddor294 or  1000000010100000 0000000080001000 ->  NaN Invalid_operation
ddor295 or  1000000001000000 0000000090000100 ->  NaN Invalid_operation
-- signs
ddor296 or -1000000001000000 -0000010000000100 ->  NaN Invalid_operation
ddor297 or -1000000001000000  0000000010000100 ->  NaN Invalid_operation
ddor298 or  1000000001000000 -0000001000000100 ->  NaN Invalid_operation
ddor299 or  1000000001000000  0000000011000100 ->  1000000011000100

-- Nmax, Nmin, Ntiny-like
ddor331 or  2   9.99999999E+199     -> NaN Invalid_operation
ddor332 or  3   1E-199              -> NaN Invalid_operation
ddor333 or  4   1.00000000E-199     -> NaN Invalid_operation
ddor334 or  5   1E-100              -> NaN Invalid_operation
ddor335 or  6   -1E-100             -> NaN Invalid_operation
ddor336 or  7   -1.00000000E-199    -> NaN Invalid_operation
ddor337 or  8   -1E-199             -> NaN Invalid_operation
ddor338 or  9   -9.99999999E+199    -> NaN Invalid_operation
ddor341 or  9.99999999E+299     -18 -> NaN Invalid_operation
ddor342 or  1E-299               01 -> NaN Invalid_operation
ddor343 or  1.00000000E-299     -18 -> NaN Invalid_operation
ddor344 or  1E-100               18 -> NaN Invalid_operation
ddor345 or  -1E-100             -10 -> NaN Invalid_operation
ddor346 or  -1.00000000E-299     18 -> NaN Invalid_operation
ddor347 or  -1E-299              10 -> NaN Invalid_operation
ddor348 or  -9.99999999E+299    -18 -> NaN Invalid_operation

-- A few other non-integers
ddor361 or  1.0                  1  -> NaN Invalid_operation
ddor362 or  1E+1                 1  -> NaN Invalid_operation
ddor363 or  0.0                  1  -> NaN Invalid_operation
ddor364 or  0E+1                 1  -> NaN Invalid_operation
ddor365 or  9.9                  1  -> NaN Invalid_operation
ddor366 or  9E+1                 1  -> NaN Invalid_operation
ddor371 or  0 1.0                   -> NaN Invalid_operation
ddor372 or  0 1E+1                  -> NaN Invalid_operation
ddor373 or  0 0.0                   -> NaN Invalid_operation
ddor374 or  0 0E+1                  -> NaN Invalid_operation
ddor375 or  0 9.9                   -> NaN Invalid_operation
ddor376 or  0 9E+1                  -> NaN Invalid_operation

-- All Specials are in error
ddor780 or -Inf  -Inf   -> NaN Invalid_operation
ddor781 or -Inf  -1000  -> NaN Invalid_operation
ddor782 or -Inf  -1     -> NaN Invalid_operation
ddor783 or -Inf  -0     -> NaN Invalid_operation
ddor784 or -Inf   0     -> NaN Invalid_operation
ddor785 or -Inf   1     -> NaN Invalid_operation
ddor786 or -Inf   1000  -> NaN Invalid_operation
ddor787 or -1000 -Inf   -> NaN Invalid_operation
ddor788 or -Inf  -Inf   -> NaN Invalid_operation
ddor789 or -1    -Inf   -> NaN Invalid_operation
ddor790 or -0    -Inf   -> NaN Invalid_operation
ddor791 or  0    -Inf   -> NaN Invalid_operation
ddor792 or  1    -Inf   -> NaN Invalid_operation
ddor793 or  1000 -Inf   -> NaN Invalid_operation
ddor794 or  Inf  -Inf   -> NaN Invalid_operation

ddor800 or  Inf  -Inf   -> NaN Invalid_operation
ddor801 or  Inf  -1000  -> NaN Invalid_operation
ddor802 or  Inf  -1     -> NaN Invalid_operation
ddor803 or  Inf  -0     -> NaN Invalid_operation
ddor804 or  Inf   0     -> NaN Invalid_operation
ddor805 or  Inf   1     -> NaN Invalid_operation
ddor806 or  Inf   1000  -> NaN Invalid_operation
ddor807 or  Inf   Inf   -> NaN Invalid_operation
ddor808 or -1000  Inf   -> NaN Invalid_operation
ddor809 or -Inf   Inf   -> NaN Invalid_operation
ddor810 or -1     Inf   -> NaN Invalid_operation
ddor811 or -0     Inf   -> NaN Invalid_operation
ddor812 or  0     Inf   -> NaN Invalid_operation
ddor813 or  1     Inf   -> NaN Invalid_operation
ddor814 or  1000  Inf   -> NaN Invalid_operation
ddor815 or  Inf   Inf   -> NaN Invalid_operation

ddor821 or  NaN -Inf    -> NaN Invalid_operation
ddor822 or  NaN -1000   -> NaN Invalid_operation
ddor823 or  NaN -1      -> NaN Invalid_operation
ddor824 or  NaN -0      -> NaN Invalid_operation
ddor825 or  NaN  0      -> NaN Invalid_operation
ddor826 or  NaN  1      -> NaN Invalid_operation
ddor827 or  NaN  1000   -> NaN Invalid_operation
ddor828 or  NaN  Inf    -> NaN Invalid_operation
ddor829 or  NaN  NaN    -> NaN Invalid_operation
ddor830 or -Inf  NaN    -> NaN Invalid_operation
ddor831 or -1000 NaN    -> NaN Invalid_operation
ddor832 or -1    NaN    -> NaN Invalid_operation
ddor833 or -0    NaN    -> NaN Invalid_operation
ddor834 or  0    NaN    -> NaN Invalid_operation
ddor835 or  1    NaN    -> NaN Invalid_operation
ddor836 or  1000 NaN    -> NaN Invalid_operation
ddor837 or  Inf  NaN    -> NaN Invalid_operation

ddor841 or  sNaN -Inf   ->  NaN  Invalid_operation
ddor842 or  sNaN -1000  ->  NaN  Invalid_operation
ddor843 or  sNaN -1     ->  NaN  Invalid_operation
ddor844 or  sNaN -0     ->  NaN  Invalid_operation
ddor845 or  sNaN  0     ->  NaN  Invalid_operation
ddor846 or  sNaN  1     ->  NaN  Invalid_operation
ddor847 or  sNaN  1000  ->  NaN  Invalid_operation
ddor848 or  sNaN  NaN   ->  NaN  Invalid_operation
ddor849 or  sNaN sNaN   ->  NaN  Invalid_operation
ddor850 or  NaN  sNaN   ->  NaN  Invalid_operation
ddor851 or -Inf  sNaN   ->  NaN  Invalid_operation
ddor852 or -1000 sNaN   ->  NaN  Invalid_operation
ddor853 or -1    sNaN   ->  NaN  Invalid_operation
ddor854 or -0    sNaN   ->  NaN  Invalid_operation
ddor855 or  0    sNaN   ->  NaN  Invalid_operation
ddor856 or  1    sNaN   ->  NaN  Invalid_operation
ddor857 or  1000 sNaN   ->  NaN  Invalid_operation
ddor858 or  Inf  sNaN   ->  NaN  Invalid_operation
ddor859 or  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddor861 or  NaN1   -Inf    -> NaN Invalid_operation
ddor862 or +NaN2   -1000   -> NaN Invalid_operation
ddor863 or  NaN3    1000   -> NaN Invalid_operation
ddor864 or  NaN4    Inf    -> NaN Invalid_operation
ddor865 or  NaN5   +NaN6   -> NaN Invalid_operation
ddor866 or -Inf     NaN7   -> NaN Invalid_operation
ddor867 or -1000    NaN8   -> NaN Invalid_operation
ddor868 or  1000    NaN9   -> NaN Invalid_operation
ddor869 or  Inf    +NaN10  -> NaN Invalid_operation
ddor871 or  sNaN11  -Inf   -> NaN Invalid_operation
ddor872 or  sNaN12  -1000  -> NaN Invalid_operation
ddor873 or  sNaN13   1000  -> NaN Invalid_operation
ddor874 or  sNaN14   NaN17 -> NaN Invalid_operation
ddor875 or  sNaN15  sNaN18 -> NaN Invalid_operation
ddor876 or  NaN16   sNaN19 -> NaN Invalid_operation
ddor877 or -Inf    +sNaN20 -> NaN Invalid_operation
ddor878 or -1000    sNaN21 -> NaN Invalid_operation
ddor879 or  1000    sNaN22 -> NaN Invalid_operation
ddor880 or  Inf     sNaN23 -> NaN Invalid_operation
ddor881 or +NaN25  +sNaN24 -> NaN Invalid_operation
ddor882 or -NaN26    NaN28 -> NaN Invalid_operation
ddor883 or -sNaN27  sNaN29 -> NaN Invalid_operation
ddor884 or  1000    -NaN30 -> NaN Invalid_operation
ddor885 or  1000   -sNaN31 -> NaN Invalid_operation

Added test/dectest/ddPlus.decTest.

















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
------------------------------------------------------------------------
-- ddPlus.decTest -- decDouble 0+x                                    --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check
ddpls001 plus       +7.50  -> 7.50

-- Infinities
ddpls011 plus  Infinity    -> Infinity
ddpls012 plus  -Infinity   -> -Infinity

-- NaNs, 0 payload
ddpls021 plus         NaN  -> NaN
ddpls022 plus        -NaN  -> -NaN
ddpls023 plus        sNaN  -> NaN  Invalid_operation
ddpls024 plus       -sNaN  -> -NaN Invalid_operation

-- NaNs, non-0 payload
ddpls031 plus       NaN13  -> NaN13
ddpls032 plus      -NaN13  -> -NaN13
ddpls033 plus      sNaN13  -> NaN13   Invalid_operation
ddpls034 plus     -sNaN13  -> -NaN13  Invalid_operation
ddpls035 plus       NaN70  -> NaN70
ddpls036 plus      -NaN70  -> -NaN70
ddpls037 plus      sNaN101 -> NaN101  Invalid_operation
ddpls038 plus     -sNaN101 -> -NaN101 Invalid_operation

-- finites
ddpls101 plus          7   -> 7
ddpls102 plus         -7   -> -7
ddpls103 plus         75   -> 75
ddpls104 plus        -75   -> -75
ddpls105 plus       7.50   -> 7.50
ddpls106 plus      -7.50   -> -7.50
ddpls107 plus       7.500  -> 7.500
ddpls108 plus      -7.500  -> -7.500

-- zeros
ddpls111 plus          0   -> 0
ddpls112 plus         -0   -> 0
ddpls113 plus       0E+4   -> 0E+4
ddpls114 plus      -0E+4   -> 0E+4
ddpls115 plus     0.0000   -> 0.0000
ddpls116 plus    -0.0000   -> 0.0000
ddpls117 plus      0E-141  -> 0E-141
ddpls118 plus     -0E-141  -> 0E-141

-- full coefficients, alternating bits
ddpls121 plus  2682682682682682         -> 2682682682682682
ddpls122 plus  -2682682682682682        -> -2682682682682682
ddpls123 plus  1341341341341341         -> 1341341341341341
ddpls124 plus  -1341341341341341        -> -1341341341341341

-- Nmax, Nmin, Ntiny
ddpls131 plus  9.999999999999999E+384   -> 9.999999999999999E+384
ddpls132 plus  1E-383                   -> 1E-383
ddpls133 plus  1.000000000000000E-383   -> 1.000000000000000E-383
ddpls134 plus  1E-398                   -> 1E-398 Subnormal

ddpls135 plus  -1E-398                  -> -1E-398 Subnormal
ddpls136 plus  -1.000000000000000E-383  -> -1.000000000000000E-383
ddpls137 plus  -1E-383                  -> -1E-383
ddpls138 plus  -9.999999999999999E+384  -> -9.999999999999999E+384

Added test/dectest/ddQuantize.decTest.



















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
------------------------------------------------------------------------
-- ddQuantize.decTest -- decDouble quantize operation                 --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Most of the tests here assume a "regular pattern", where the
-- sign and coefficient are +1.
-- 2004.03.15 Underflow for quantize is suppressed
-- 2005.06.08 More extensive tests for 'does not fit'
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks
ddqua001 quantize 0       1e0   -> 0
ddqua002 quantize 1       1e0   -> 1
ddqua003 quantize 0.1    1e+2   -> 0E+2 Inexact Rounded
ddqua005 quantize 0.1    1e+1   -> 0E+1 Inexact Rounded
ddqua006 quantize 0.1     1e0   -> 0 Inexact Rounded
ddqua007 quantize 0.1    1e-1   -> 0.1
ddqua008 quantize 0.1    1e-2   -> 0.10
ddqua009 quantize 0.1    1e-3   -> 0.100
ddqua010 quantize 0.9    1e+2   -> 0E+2 Inexact Rounded
ddqua011 quantize 0.9    1e+1   -> 0E+1 Inexact Rounded
ddqua012 quantize 0.9    1e+0   -> 1 Inexact Rounded
ddqua013 quantize 0.9    1e-1   -> 0.9
ddqua014 quantize 0.9    1e-2   -> 0.90
ddqua015 quantize 0.9    1e-3   -> 0.900
-- negatives
ddqua021 quantize -0      1e0   -> -0
ddqua022 quantize -1      1e0   -> -1
ddqua023 quantize -0.1   1e+2   -> -0E+2 Inexact Rounded
ddqua025 quantize -0.1   1e+1   -> -0E+1 Inexact Rounded
ddqua026 quantize -0.1    1e0   -> -0 Inexact Rounded
ddqua027 quantize -0.1   1e-1   -> -0.1
ddqua028 quantize -0.1   1e-2   -> -0.10
ddqua029 quantize -0.1   1e-3   -> -0.100
ddqua030 quantize -0.9   1e+2   -> -0E+2 Inexact Rounded
ddqua031 quantize -0.9   1e+1   -> -0E+1 Inexact Rounded
ddqua032 quantize -0.9   1e+0   -> -1 Inexact Rounded
ddqua033 quantize -0.9   1e-1   -> -0.9
ddqua034 quantize -0.9   1e-2   -> -0.90
ddqua035 quantize -0.9   1e-3   -> -0.900
ddqua036 quantize -0.5   1e+2   -> -0E+2 Inexact Rounded
ddqua037 quantize -0.5   1e+1   -> -0E+1 Inexact Rounded
ddqua038 quantize -0.5   1e+0   -> -0 Inexact Rounded
ddqua039 quantize -0.5   1e-1   -> -0.5
ddqua040 quantize -0.5   1e-2   -> -0.50
ddqua041 quantize -0.5   1e-3   -> -0.500
ddqua042 quantize -0.9   1e+2   -> -0E+2 Inexact Rounded
ddqua043 quantize -0.9   1e+1   -> -0E+1 Inexact Rounded
ddqua044 quantize -0.9   1e+0   -> -1 Inexact Rounded
ddqua045 quantize -0.9   1e-1   -> -0.9
ddqua046 quantize -0.9   1e-2   -> -0.90
ddqua047 quantize -0.9   1e-3   -> -0.900

-- examples from Specification
ddqua060 quantize 2.17   0.001  -> 2.170
ddqua061 quantize 2.17   0.01   -> 2.17
ddqua062 quantize 2.17   0.1    -> 2.2 Inexact Rounded
ddqua063 quantize 2.17   1e+0   -> 2 Inexact Rounded
ddqua064 quantize 2.17   1e+1   -> 0E+1 Inexact Rounded
ddqua065 quantize -Inf    Inf   -> -Infinity
ddqua066 quantize 2       Inf   -> NaN Invalid_operation
ddqua067 quantize -0.1    1     -> -0 Inexact Rounded
ddqua068 quantize -0      1e+5     -> -0E+5
ddqua069 quantize +123456789012345.6 1e-2 -> NaN Invalid_operation
ddqua070 quantize -987654335236450.6 1e-2 -> NaN Invalid_operation
ddqua071 quantize 217    1e-1   -> 217.0
ddqua072 quantize 217    1e+0   -> 217
ddqua073 quantize 217    1e+1   -> 2.2E+2 Inexact Rounded
ddqua074 quantize 217    1e+2   -> 2E+2 Inexact Rounded

-- general tests ..
ddqua089 quantize 12     1e+4   -> 0E+4 Inexact Rounded
ddqua090 quantize 12     1e+3   -> 0E+3 Inexact Rounded
ddqua091 quantize 12     1e+2   -> 0E+2 Inexact Rounded
ddqua092 quantize 12     1e+1   -> 1E+1 Inexact Rounded
ddqua093 quantize 1.2345 1e-2   -> 1.23 Inexact Rounded
ddqua094 quantize 1.2355 1e-2   -> 1.24 Inexact Rounded
ddqua095 quantize 1.2345 1e-6   -> 1.234500
ddqua096 quantize 9.9999 1e-2   -> 10.00 Inexact Rounded
ddqua097 quantize 0.0001 1e-2   -> 0.00 Inexact Rounded
ddqua098 quantize 0.001  1e-2   -> 0.00 Inexact Rounded
ddqua099 quantize 0.009  1e-2   -> 0.01 Inexact Rounded
ddqua100 quantize 92     1e+2   -> 1E+2 Inexact Rounded

ddqua101 quantize -1      1e0   ->  -1
ddqua102 quantize -1     1e-1   ->  -1.0
ddqua103 quantize -1     1e-2   ->  -1.00
ddqua104 quantize  0      1e0   ->  0
ddqua105 quantize  0     1e-1   ->  0.0
ddqua106 quantize  0     1e-2   ->  0.00
ddqua107 quantize  0.00   1e0   ->  0
ddqua108 quantize  0     1e+1   ->  0E+1
ddqua109 quantize  0     1e+2   ->  0E+2
ddqua110 quantize +1      1e0   ->  1
ddqua111 quantize +1     1e-1   ->  1.0
ddqua112 quantize +1     1e-2   ->  1.00

ddqua120 quantize   1.04  1e-3 ->  1.040
ddqua121 quantize   1.04  1e-2 ->  1.04
ddqua122 quantize   1.04  1e-1 ->  1.0 Inexact Rounded
ddqua123 quantize   1.04   1e0 ->  1 Inexact Rounded
ddqua124 quantize   1.05  1e-3 ->  1.050
ddqua125 quantize   1.05  1e-2 ->  1.05
ddqua126 quantize   1.05  1e-1 ->  1.0 Inexact Rounded
ddqua131 quantize   1.05   1e0 ->  1 Inexact Rounded
ddqua132 quantize   1.06  1e-3 ->  1.060
ddqua133 quantize   1.06  1e-2 ->  1.06
ddqua134 quantize   1.06  1e-1 ->  1.1 Inexact Rounded
ddqua135 quantize   1.06   1e0 ->  1 Inexact Rounded

ddqua140 quantize   -10    1e-2  ->  -10.00
ddqua141 quantize   +1     1e-2  ->  1.00
ddqua142 quantize   +10    1e-2  ->  10.00
ddqua143 quantize   1E+17  1e-2  ->  NaN Invalid_operation
ddqua144 quantize   1E-17  1e-2  ->  0.00 Inexact Rounded
ddqua145 quantize   1E-3   1e-2  ->  0.00 Inexact Rounded
ddqua146 quantize   1E-2   1e-2  ->  0.01
ddqua147 quantize   1E-1   1e-2  ->  0.10
ddqua148 quantize   0E-17  1e-2  ->  0.00

ddqua150 quantize   1.0600 1e-5 ->  1.06000
ddqua151 quantize   1.0600 1e-4 ->  1.0600
ddqua152 quantize   1.0600 1e-3 ->  1.060 Rounded
ddqua153 quantize   1.0600 1e-2 ->  1.06 Rounded
ddqua154 quantize   1.0600 1e-1 ->  1.1 Inexact Rounded
ddqua155 quantize   1.0600  1e0 ->  1 Inexact Rounded

-- a couple where rounding was different in base tests
rounding:    half_up
ddqua157 quantize -0.5   1e+0   -> -1 Inexact Rounded
ddqua158 quantize   1.05  1e-1 ->  1.1 Inexact Rounded
ddqua159 quantize   1.06   1e0 ->  1 Inexact Rounded
rounding:    half_even

-- base tests with non-1 coefficients
ddqua161 quantize 0      -9e0   -> 0
ddqua162 quantize 1      -7e0   -> 1
ddqua163 quantize 0.1   -1e+2   -> 0E+2 Inexact Rounded
ddqua165 quantize 0.1    0e+1   -> 0E+1 Inexact Rounded
ddqua166 quantize 0.1     2e0   -> 0 Inexact Rounded
ddqua167 quantize 0.1    3e-1   -> 0.1
ddqua168 quantize 0.1   44e-2   -> 0.10
ddqua169 quantize 0.1  555e-3   -> 0.100
ddqua170 quantize 0.9 6666e+2   -> 0E+2 Inexact Rounded
ddqua171 quantize 0.9 -777e+1   -> 0E+1 Inexact Rounded
ddqua172 quantize 0.9  -88e+0   -> 1 Inexact Rounded
ddqua173 quantize 0.9   -9e-1   -> 0.9
ddqua174 quantize 0.9    0e-2   -> 0.90
ddqua175 quantize 0.9  1.1e-3   -> 0.9000
-- negatives
ddqua181 quantize -0    1.1e0   -> -0.0
ddqua182 quantize -1     -1e0   -> -1
ddqua183 quantize -0.1  11e+2   -> -0E+2 Inexact Rounded
ddqua185 quantize -0.1 111e+1   -> -0E+1 Inexact Rounded
ddqua186 quantize -0.1   71e0   -> -0 Inexact Rounded
ddqua187 quantize -0.1 -91e-1   -> -0.1
ddqua188 quantize -0.1 -.1e-2   -> -0.100
ddqua189 quantize -0.1  -1e-3   -> -0.100
ddqua190 quantize -0.9   0e+2   -> -0E+2 Inexact Rounded
ddqua191 quantize -0.9  -0e+1   -> -0E+1 Inexact Rounded
ddqua192 quantize -0.9 -10e+0   -> -1 Inexact Rounded
ddqua193 quantize -0.9 100e-1   -> -0.9
ddqua194 quantize -0.9 999e-2   -> -0.90

-- +ve exponents ..
ddqua201 quantize   -1   1e+0 ->  -1
ddqua202 quantize   -1   1e+1 ->  -0E+1 Inexact Rounded
ddqua203 quantize   -1   1e+2 ->  -0E+2 Inexact Rounded
ddqua204 quantize    0   1e+0 ->  0
ddqua205 quantize    0   1e+1 ->  0E+1
ddqua206 quantize    0   1e+2 ->  0E+2
ddqua207 quantize   +1   1e+0 ->  1
ddqua208 quantize   +1   1e+1 ->  0E+1 Inexact Rounded
ddqua209 quantize   +1   1e+2 ->  0E+2 Inexact Rounded

ddqua220 quantize   1.04 1e+3 ->  0E+3 Inexact Rounded
ddqua221 quantize   1.04 1e+2 ->  0E+2 Inexact Rounded
ddqua222 quantize   1.04 1e+1 ->  0E+1 Inexact Rounded
ddqua223 quantize   1.04 1e+0 ->  1 Inexact Rounded
ddqua224 quantize   1.05 1e+3 ->  0E+3 Inexact Rounded
ddqua225 quantize   1.05 1e+2 ->  0E+2 Inexact Rounded
ddqua226 quantize   1.05 1e+1 ->  0E+1 Inexact Rounded
ddqua227 quantize   1.05 1e+0 ->  1 Inexact Rounded
ddqua228 quantize   1.05 1e+3 ->  0E+3 Inexact Rounded
ddqua229 quantize   1.05 1e+2 ->  0E+2 Inexact Rounded
ddqua230 quantize   1.05 1e+1 ->  0E+1 Inexact Rounded
ddqua231 quantize   1.05 1e+0 ->  1 Inexact Rounded
ddqua232 quantize   1.06 1e+3 ->  0E+3 Inexact Rounded
ddqua233 quantize   1.06 1e+2 ->  0E+2 Inexact Rounded
ddqua234 quantize   1.06 1e+1 ->  0E+1 Inexact Rounded
ddqua235 quantize   1.06 1e+0 ->  1 Inexact Rounded

ddqua240 quantize   -10   1e+1  ->  -1E+1 Rounded
ddqua241 quantize   +1    1e+1  ->  0E+1 Inexact Rounded
ddqua242 quantize   +10   1e+1  ->  1E+1 Rounded
ddqua243 quantize   1E+1  1e+1  ->  1E+1          -- underneath this is E+1
ddqua244 quantize   1E+2  1e+1  ->  1.0E+2        -- underneath this is E+1
ddqua245 quantize   1E+3  1e+1  ->  1.00E+3       -- underneath this is E+1
ddqua246 quantize   1E+4  1e+1  ->  1.000E+4      -- underneath this is E+1
ddqua247 quantize   1E+5  1e+1  ->  1.0000E+5     -- underneath this is E+1
ddqua248 quantize   1E+6  1e+1  ->  1.00000E+6    -- underneath this is E+1
ddqua249 quantize   1E+7  1e+1  ->  1.000000E+7   -- underneath this is E+1
ddqua250 quantize   1E+8  1e+1  ->  1.0000000E+8  -- underneath this is E+1
ddqua251 quantize   1E+9  1e+1  ->  1.00000000E+9 -- underneath this is E+1
-- next one tries to add 9 zeros
ddqua252 quantize   1E+17 1e+1  ->  NaN Invalid_operation
ddqua253 quantize   1E-17 1e+1  ->  0E+1 Inexact Rounded
ddqua254 quantize   1E-2  1e+1  ->  0E+1 Inexact Rounded
ddqua255 quantize   0E-17 1e+1  ->  0E+1
ddqua256 quantize  -0E-17 1e+1  -> -0E+1
ddqua257 quantize  -0E-1  1e+1  -> -0E+1
ddqua258 quantize  -0     1e+1  -> -0E+1
ddqua259 quantize  -0E+1  1e+1  -> -0E+1

ddqua260 quantize   -10   1e+2  ->  -0E+2 Inexact Rounded
ddqua261 quantize   +1    1e+2  ->  0E+2 Inexact Rounded
ddqua262 quantize   +10   1e+2  ->  0E+2 Inexact Rounded
ddqua263 quantize   1E+1  1e+2  ->  0E+2 Inexact Rounded
ddqua264 quantize   1E+2  1e+2  ->  1E+2
ddqua265 quantize   1E+3  1e+2  ->  1.0E+3
ddqua266 quantize   1E+4  1e+2  ->  1.00E+4
ddqua267 quantize   1E+5  1e+2  ->  1.000E+5
ddqua268 quantize   1E+6  1e+2  ->  1.0000E+6
ddqua269 quantize   1E+7  1e+2  ->  1.00000E+7
ddqua270 quantize   1E+8  1e+2  ->  1.000000E+8
ddqua271 quantize   1E+9  1e+2  ->  1.0000000E+9
ddqua272 quantize   1E+10 1e+2  ->  1.00000000E+10
ddqua273 quantize   1E-10 1e+2  ->  0E+2 Inexact Rounded
ddqua274 quantize   1E-2  1e+2  ->  0E+2 Inexact Rounded
ddqua275 quantize   0E-10 1e+2  ->  0E+2

ddqua280 quantize   -10   1e+3  ->  -0E+3 Inexact Rounded
ddqua281 quantize   +1    1e+3  ->  0E+3 Inexact Rounded
ddqua282 quantize   +10   1e+3  ->  0E+3 Inexact Rounded
ddqua283 quantize   1E+1  1e+3  ->  0E+3 Inexact Rounded
ddqua284 quantize   1E+2  1e+3  ->  0E+3 Inexact Rounded
ddqua285 quantize   1E+3  1e+3  ->  1E+3
ddqua286 quantize   1E+4  1e+3  ->  1.0E+4
ddqua287 quantize   1E+5  1e+3  ->  1.00E+5
ddqua288 quantize   1E+6  1e+3  ->  1.000E+6
ddqua289 quantize   1E+7  1e+3  ->  1.0000E+7
ddqua290 quantize   1E+8  1e+3  ->  1.00000E+8
ddqua291 quantize   1E+9  1e+3  ->  1.000000E+9
ddqua292 quantize   1E+10 1e+3  ->  1.0000000E+10
ddqua293 quantize   1E-10 1e+3  ->  0E+3 Inexact Rounded
ddqua294 quantize   1E-2  1e+3  ->  0E+3 Inexact Rounded
ddqua295 quantize   0E-10 1e+3  ->  0E+3

-- round up from below [sign wrong in JIT compiler once]
ddqua300 quantize   0.0078 1e-5 ->  0.00780
ddqua301 quantize   0.0078 1e-4 ->  0.0078
ddqua302 quantize   0.0078 1e-3 ->  0.008 Inexact Rounded
ddqua303 quantize   0.0078 1e-2 ->  0.01 Inexact Rounded
ddqua304 quantize   0.0078 1e-1 ->  0.0 Inexact Rounded
ddqua305 quantize   0.0078  1e0 ->  0 Inexact Rounded
ddqua306 quantize   0.0078 1e+1 ->  0E+1 Inexact Rounded
ddqua307 quantize   0.0078 1e+2 ->  0E+2 Inexact Rounded

ddqua310 quantize  -0.0078 1e-5 -> -0.00780
ddqua311 quantize  -0.0078 1e-4 -> -0.0078
ddqua312 quantize  -0.0078 1e-3 -> -0.008 Inexact Rounded
ddqua313 quantize  -0.0078 1e-2 -> -0.01 Inexact Rounded
ddqua314 quantize  -0.0078 1e-1 -> -0.0 Inexact Rounded
ddqua315 quantize  -0.0078  1e0 -> -0 Inexact Rounded
ddqua316 quantize  -0.0078 1e+1 -> -0E+1 Inexact Rounded
ddqua317 quantize  -0.0078 1e+2 -> -0E+2 Inexact Rounded

ddqua320 quantize   0.078 1e-5 ->  0.07800
ddqua321 quantize   0.078 1e-4 ->  0.0780
ddqua322 quantize   0.078 1e-3 ->  0.078
ddqua323 quantize   0.078 1e-2 ->  0.08 Inexact Rounded
ddqua324 quantize   0.078 1e-1 ->  0.1 Inexact Rounded
ddqua325 quantize   0.078  1e0 ->  0 Inexact Rounded
ddqua326 quantize   0.078 1e+1 ->  0E+1 Inexact Rounded
ddqua327 quantize   0.078 1e+2 ->  0E+2 Inexact Rounded

ddqua330 quantize  -0.078 1e-5 -> -0.07800
ddqua331 quantize  -0.078 1e-4 -> -0.0780
ddqua332 quantize  -0.078 1e-3 -> -0.078
ddqua333 quantize  -0.078 1e-2 -> -0.08 Inexact Rounded
ddqua334 quantize  -0.078 1e-1 -> -0.1 Inexact Rounded
ddqua335 quantize  -0.078  1e0 -> -0 Inexact Rounded
ddqua336 quantize  -0.078 1e+1 -> -0E+1 Inexact Rounded
ddqua337 quantize  -0.078 1e+2 -> -0E+2 Inexact Rounded

ddqua340 quantize   0.78 1e-5 ->  0.78000
ddqua341 quantize   0.78 1e-4 ->  0.7800
ddqua342 quantize   0.78 1e-3 ->  0.780
ddqua343 quantize   0.78 1e-2 ->  0.78
ddqua344 quantize   0.78 1e-1 ->  0.8 Inexact Rounded
ddqua345 quantize   0.78  1e0 ->  1 Inexact Rounded
ddqua346 quantize   0.78 1e+1 ->  0E+1 Inexact Rounded
ddqua347 quantize   0.78 1e+2 ->  0E+2 Inexact Rounded

ddqua350 quantize  -0.78 1e-5 -> -0.78000
ddqua351 quantize  -0.78 1e-4 -> -0.7800
ddqua352 quantize  -0.78 1e-3 -> -0.780
ddqua353 quantize  -0.78 1e-2 -> -0.78
ddqua354 quantize  -0.78 1e-1 -> -0.8 Inexact Rounded
ddqua355 quantize  -0.78  1e0 -> -1 Inexact Rounded
ddqua356 quantize  -0.78 1e+1 -> -0E+1 Inexact Rounded
ddqua357 quantize  -0.78 1e+2 -> -0E+2 Inexact Rounded

ddqua360 quantize   7.8 1e-5 ->  7.80000
ddqua361 quantize   7.8 1e-4 ->  7.8000
ddqua362 quantize   7.8 1e-3 ->  7.800
ddqua363 quantize   7.8 1e-2 ->  7.80
ddqua364 quantize   7.8 1e-1 ->  7.8
ddqua365 quantize   7.8  1e0 ->  8 Inexact Rounded
ddqua366 quantize   7.8 1e+1 ->  1E+1 Inexact Rounded
ddqua367 quantize   7.8 1e+2 ->  0E+2 Inexact Rounded
ddqua368 quantize   7.8 1e+3 ->  0E+3 Inexact Rounded

ddqua370 quantize  -7.8 1e-5 -> -7.80000
ddqua371 quantize  -7.8 1e-4 -> -7.8000
ddqua372 quantize  -7.8 1e-3 -> -7.800
ddqua373 quantize  -7.8 1e-2 -> -7.80
ddqua374 quantize  -7.8 1e-1 -> -7.8
ddqua375 quantize  -7.8  1e0 -> -8 Inexact Rounded
ddqua376 quantize  -7.8 1e+1 -> -1E+1 Inexact Rounded
ddqua377 quantize  -7.8 1e+2 -> -0E+2 Inexact Rounded
ddqua378 quantize  -7.8 1e+3 -> -0E+3 Inexact Rounded

-- some individuals
ddqua380 quantize   1234567352364.506 1e-2 -> 1234567352364.51 Inexact Rounded
ddqua381 quantize   12345673523645.06 1e-2 -> 12345673523645.06
ddqua382 quantize   123456735236450.6 1e-2 -> NaN Invalid_operation
ddqua383 quantize   1234567352364506  1e-2 -> NaN Invalid_operation
ddqua384 quantize  -1234567352364.506 1e-2 -> -1234567352364.51 Inexact Rounded
ddqua385 quantize  -12345673523645.06 1e-2 -> -12345673523645.06
ddqua386 quantize  -123456735236450.6 1e-2 -> NaN Invalid_operation
ddqua387 quantize  -1234567352364506  1e-2 -> NaN Invalid_operation

rounding: down
ddqua389 quantize   123456735236450.6 1e-2 -> NaN Invalid_operation
-- ? should that one instead have been:
-- ddqua389 quantize   123456735236450.6 1e-2 -> NaN Invalid_operation
rounding: half_up

-- and a few more from e-mail discussions
ddqua391 quantize  12345678912.34567  1e-3 -> 12345678912.346   Inexact Rounded
ddqua392 quantize  123456789123.4567  1e-3 -> 123456789123.457  Inexact Rounded
ddqua393 quantize  1234567891234.567  1e-3 -> 1234567891234.567
ddqua394 quantize  12345678912345.67  1e-3 -> NaN Invalid_operation
ddqua395 quantize  123456789123456.7  1e-3 -> NaN Invalid_operation
ddqua396 quantize  1234567891234567.  1e-3 -> NaN Invalid_operation

-- some 9999 round-up cases
ddqua400 quantize   9.999        1e-5  ->  9.99900
ddqua401 quantize   9.999        1e-4  ->  9.9990
ddqua402 quantize   9.999        1e-3  ->  9.999
ddqua403 quantize   9.999        1e-2  -> 10.00     Inexact Rounded
ddqua404 quantize   9.999        1e-1  -> 10.0      Inexact Rounded
ddqua405 quantize   9.999         1e0  -> 10        Inexact Rounded
ddqua406 quantize   9.999         1e1  -> 1E+1      Inexact Rounded
ddqua407 quantize   9.999         1e2  -> 0E+2      Inexact Rounded

ddqua410 quantize   0.999        1e-5  ->  0.99900
ddqua411 quantize   0.999        1e-4  ->  0.9990
ddqua412 quantize   0.999        1e-3  ->  0.999
ddqua413 quantize   0.999        1e-2  ->  1.00     Inexact Rounded
ddqua414 quantize   0.999        1e-1  ->  1.0      Inexact Rounded
ddqua415 quantize   0.999         1e0  ->  1        Inexact Rounded
ddqua416 quantize   0.999         1e1  -> 0E+1      Inexact Rounded

ddqua420 quantize   0.0999       1e-5  ->  0.09990
ddqua421 quantize   0.0999       1e-4  ->  0.0999
ddqua422 quantize   0.0999       1e-3  ->  0.100    Inexact Rounded
ddqua423 quantize   0.0999       1e-2  ->  0.10     Inexact Rounded
ddqua424 quantize   0.0999       1e-1  ->  0.1      Inexact Rounded
ddqua425 quantize   0.0999        1e0  ->  0        Inexact Rounded
ddqua426 quantize   0.0999        1e1  -> 0E+1      Inexact Rounded

ddqua430 quantize   0.00999      1e-5  ->  0.00999
ddqua431 quantize   0.00999      1e-4  ->  0.0100   Inexact Rounded
ddqua432 quantize   0.00999      1e-3  ->  0.010    Inexact Rounded
ddqua433 quantize   0.00999      1e-2  ->  0.01     Inexact Rounded
ddqua434 quantize   0.00999      1e-1  ->  0.0      Inexact Rounded
ddqua435 quantize   0.00999       1e0  ->  0        Inexact Rounded
ddqua436 quantize   0.00999       1e1  -> 0E+1      Inexact Rounded

ddqua440 quantize   0.000999     1e-5  ->  0.00100  Inexact Rounded
ddqua441 quantize   0.000999     1e-4  ->  0.0010   Inexact Rounded
ddqua442 quantize   0.000999     1e-3  ->  0.001    Inexact Rounded
ddqua443 quantize   0.000999     1e-2  ->  0.00     Inexact Rounded
ddqua444 quantize   0.000999     1e-1  ->  0.0      Inexact Rounded
ddqua445 quantize   0.000999      1e0  ->  0        Inexact Rounded
ddqua446 quantize   0.000999      1e1  -> 0E+1      Inexact Rounded

ddqua1001 quantize  0.000        0.001 ->  0.000
ddqua1002 quantize  0.001        0.001 ->  0.001
ddqua1003 quantize  0.0012       0.001 ->  0.001     Inexact Rounded
ddqua1004 quantize  0.0018       0.001 ->  0.002     Inexact Rounded
ddqua1005 quantize  0.501        0.001 ->  0.501
ddqua1006 quantize  0.5012       0.001 ->  0.501     Inexact Rounded
ddqua1007 quantize  0.5018       0.001 ->  0.502     Inexact Rounded
ddqua1008 quantize  0.999        0.001 ->  0.999

ddqua481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
ddqua482 quantize 1234567800  1e+1 -> 1.23456780E+9 Rounded
ddqua483 quantize 1234567890  1e+1 -> 1.23456789E+9 Rounded
ddqua484 quantize 1234567891  1e+1 -> 1.23456789E+9 Inexact Rounded
ddqua485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
ddqua486 quantize 1234567896  1e+1 -> 1.23456790E+9 Inexact Rounded
-- a potential double-round
ddqua487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
ddqua488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded

ddqua491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
ddqua492 quantize 1234567800  1e+1 -> 1.23456780E+9 Rounded
ddqua493 quantize 1234567890  1e+1 -> 1.23456789E+9 Rounded
ddqua494 quantize 1234567891  1e+1 -> 1.23456789E+9 Inexact Rounded
ddqua495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
ddqua496 quantize 1234567896  1e+1 -> 1.23456790E+9 Inexact Rounded
ddqua497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
ddqua498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded

-- Zeros
ddqua500 quantize   0     1e1 ->  0E+1
ddqua501 quantize   0     1e0 ->  0
ddqua502 quantize   0    1e-1 ->  0.0
ddqua503 quantize   0.0  1e-1 ->  0.0
ddqua504 quantize   0.0   1e0 ->  0
ddqua505 quantize   0.0  1e+1 ->  0E+1
ddqua506 quantize   0E+1 1e-1 ->  0.0
ddqua507 quantize   0E+1  1e0 ->  0
ddqua508 quantize   0E+1 1e+1 ->  0E+1
ddqua509 quantize  -0     1e1 -> -0E+1
ddqua510 quantize  -0     1e0 -> -0
ddqua511 quantize  -0    1e-1 -> -0.0
ddqua512 quantize  -0.0  1e-1 -> -0.0
ddqua513 quantize  -0.0   1e0 -> -0
ddqua514 quantize  -0.0  1e+1 -> -0E+1
ddqua515 quantize  -0E+1 1e-1 -> -0.0
ddqua516 quantize  -0E+1  1e0 -> -0
ddqua517 quantize  -0E+1 1e+1 -> -0E+1

-- Suspicious RHS values
ddqua520 quantize   1.234    1e359 -> 0E+359 Inexact Rounded
ddqua521 quantize 123.456    1e359 -> 0E+359 Inexact Rounded
ddqua522 quantize   1.234    1e359 -> 0E+359 Inexact Rounded
ddqua523 quantize 123.456    1e359 -> 0E+359 Inexact Rounded
-- next four are "won't fit" overfl
ddqua526 quantize   1.234   1e-299 -> NaN Invalid_operation
ddqua527 quantize 123.456   1e-299 -> NaN Invalid_operation
ddqua528 quantize   1.234   1e-299 -> NaN Invalid_operation
ddqua529 quantize 123.456   1e-299 -> NaN Invalid_operation

ddqua532 quantize   1.234E+299    1e299 -> 1E+299    Inexact Rounded
ddqua533 quantize   1.234E+298    1e299 -> 0E+299    Inexact Rounded
ddqua534 quantize   1.234         1e299 -> 0E+299    Inexact Rounded
ddqua537 quantize   0            1e-299 -> 0E-299
-- next two are "won't fit" overflows
ddqua538 quantize   1.234        1e-299 -> NaN Invalid_operation
ddqua539 quantize   1.234        1e-300 -> NaN Invalid_operation
-- [more below]

-- Specials
ddqua580 quantize  Inf    -Inf   ->  Infinity
ddqua581 quantize  Inf  1e-299   ->  NaN  Invalid_operation
ddqua582 quantize  Inf  1e-1     ->  NaN  Invalid_operation
ddqua583 quantize  Inf   1e0     ->  NaN  Invalid_operation
ddqua584 quantize  Inf   1e1     ->  NaN  Invalid_operation
ddqua585 quantize  Inf   1e299   ->  NaN  Invalid_operation
ddqua586 quantize  Inf     Inf   ->  Infinity
ddqua587 quantize -1000    Inf   ->  NaN  Invalid_operation
ddqua588 quantize -Inf     Inf   ->  -Infinity
ddqua589 quantize -1       Inf   ->  NaN  Invalid_operation
ddqua590 quantize  0       Inf   ->  NaN  Invalid_operation
ddqua591 quantize  1       Inf   ->  NaN  Invalid_operation
ddqua592 quantize  1000    Inf   ->  NaN  Invalid_operation
ddqua593 quantize  Inf     Inf   ->  Infinity
ddqua594 quantize  Inf  1e-0     ->  NaN  Invalid_operation
ddqua595 quantize -0       Inf   ->  NaN  Invalid_operation

ddqua600 quantize -Inf    -Inf   ->  -Infinity
ddqua601 quantize -Inf  1e-299   ->  NaN  Invalid_operation
ddqua602 quantize -Inf  1e-1     ->  NaN  Invalid_operation
ddqua603 quantize -Inf   1e0     ->  NaN  Invalid_operation
ddqua604 quantize -Inf   1e1     ->  NaN  Invalid_operation
ddqua605 quantize -Inf   1e299   ->  NaN  Invalid_operation
ddqua606 quantize -Inf     Inf   ->  -Infinity
ddqua607 quantize -1000    Inf   ->  NaN  Invalid_operation
ddqua608 quantize -Inf    -Inf   ->  -Infinity
ddqua609 quantize -1      -Inf   ->  NaN  Invalid_operation
ddqua610 quantize  0      -Inf   ->  NaN  Invalid_operation
ddqua611 quantize  1      -Inf   ->  NaN  Invalid_operation
ddqua612 quantize  1000   -Inf   ->  NaN  Invalid_operation
ddqua613 quantize  Inf    -Inf   ->  Infinity
ddqua614 quantize -Inf  1e-0     ->  NaN  Invalid_operation
ddqua615 quantize -0      -Inf   ->  NaN  Invalid_operation

ddqua621 quantize  NaN   -Inf    ->  NaN
ddqua622 quantize  NaN 1e-299    ->  NaN
ddqua623 quantize  NaN 1e-1      ->  NaN
ddqua624 quantize  NaN  1e0      ->  NaN
ddqua625 quantize  NaN  1e1      ->  NaN
ddqua626 quantize  NaN  1e299    ->  NaN
ddqua627 quantize  NaN    Inf    ->  NaN
ddqua628 quantize  NaN    NaN    ->  NaN
ddqua629 quantize -Inf    NaN    ->  NaN
ddqua630 quantize -1000   NaN    ->  NaN
ddqua631 quantize -1      NaN    ->  NaN
ddqua632 quantize  0      NaN    ->  NaN
ddqua633 quantize  1      NaN    ->  NaN
ddqua634 quantize  1000   NaN    ->  NaN
ddqua635 quantize  Inf    NaN    ->  NaN
ddqua636 quantize  NaN 1e-0      ->  NaN
ddqua637 quantize -0      NaN    ->  NaN

ddqua641 quantize  sNaN   -Inf   ->  NaN  Invalid_operation
ddqua642 quantize  sNaN 1e-299   ->  NaN  Invalid_operation
ddqua643 quantize  sNaN 1e-1     ->  NaN  Invalid_operation
ddqua644 quantize  sNaN  1e0     ->  NaN  Invalid_operation
ddqua645 quantize  sNaN  1e1     ->  NaN  Invalid_operation
ddqua646 quantize  sNaN  1e299   ->  NaN  Invalid_operation
ddqua647 quantize  sNaN    NaN   ->  NaN  Invalid_operation
ddqua648 quantize  sNaN   sNaN   ->  NaN  Invalid_operation
ddqua649 quantize  NaN    sNaN   ->  NaN  Invalid_operation
ddqua650 quantize -Inf    sNaN   ->  NaN  Invalid_operation
ddqua651 quantize -1000   sNaN   ->  NaN  Invalid_operation
ddqua652 quantize -1      sNaN   ->  NaN  Invalid_operation
ddqua653 quantize  0      sNaN   ->  NaN  Invalid_operation
ddqua654 quantize  1      sNaN   ->  NaN  Invalid_operation
ddqua655 quantize  1000   sNaN   ->  NaN  Invalid_operation
ddqua656 quantize  Inf    sNaN   ->  NaN  Invalid_operation
ddqua657 quantize  NaN    sNaN   ->  NaN  Invalid_operation
ddqua658 quantize  sNaN 1e-0     ->  NaN  Invalid_operation
ddqua659 quantize -0      sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddqua661 quantize  NaN9 -Inf   ->  NaN9
ddqua662 quantize  NaN8  919   ->  NaN8
ddqua663 quantize  NaN71 Inf   ->  NaN71
ddqua664 quantize  NaN6  NaN5  ->  NaN6
ddqua665 quantize -Inf   NaN4  ->  NaN4
ddqua666 quantize -919   NaN31 ->  NaN31
ddqua667 quantize  Inf   NaN2  ->  NaN2

ddqua671 quantize  sNaN99 -Inf    ->  NaN99 Invalid_operation
ddqua672 quantize  sNaN98 -11     ->  NaN98 Invalid_operation
ddqua673 quantize  sNaN97  NaN    ->  NaN97 Invalid_operation
ddqua674 quantize  sNaN16 sNaN94  ->  NaN16 Invalid_operation
ddqua675 quantize  NaN95  sNaN93  ->  NaN93 Invalid_operation
ddqua676 quantize -Inf    sNaN92  ->  NaN92 Invalid_operation
ddqua677 quantize  088    sNaN91  ->  NaN91 Invalid_operation
ddqua678 quantize  Inf    sNaN90  ->  NaN90 Invalid_operation
ddqua679 quantize  NaN    sNaN88  ->  NaN88 Invalid_operation

ddqua681 quantize -NaN9 -Inf   -> -NaN9
ddqua682 quantize -NaN8  919   -> -NaN8
ddqua683 quantize -NaN71 Inf   -> -NaN71
ddqua684 quantize -NaN6 -NaN5  -> -NaN6
ddqua685 quantize -Inf  -NaN4  -> -NaN4
ddqua686 quantize -919  -NaN31 -> -NaN31
ddqua687 quantize  Inf  -NaN2  -> -NaN2

ddqua691 quantize -sNaN99 -Inf    -> -NaN99 Invalid_operation
ddqua692 quantize -sNaN98 -11     -> -NaN98 Invalid_operation
ddqua693 quantize -sNaN97  NaN    -> -NaN97 Invalid_operation
ddqua694 quantize -sNaN16 sNaN94  -> -NaN16 Invalid_operation
ddqua695 quantize -NaN95 -sNaN93  -> -NaN93 Invalid_operation
ddqua696 quantize -Inf   -sNaN92  -> -NaN92 Invalid_operation
ddqua697 quantize  088   -sNaN91  -> -NaN91 Invalid_operation
ddqua698 quantize  Inf   -sNaN90  -> -NaN90 Invalid_operation
ddqua699 quantize  NaN   -sNaN88  -> -NaN88 Invalid_operation

-- subnormals and underflow
ddqua710 quantize  1.00E-383    1e-383  ->   1E-383    Rounded
ddqua711 quantize  0.1E-383    2e-384  ->   1E-384   Subnormal
ddqua712 quantize  0.10E-383   3e-384  ->   1E-384   Subnormal Rounded
ddqua713 quantize  0.100E-383  4e-384  ->   1E-384   Subnormal Rounded
ddqua714 quantize  0.01E-383   5e-385  ->   1E-385   Subnormal
-- next is rounded to Emin
ddqua715 quantize  0.999E-383   1e-383  ->   1E-383    Inexact Rounded
ddqua716 quantize  0.099E-383 10e-384  ->   1E-384   Inexact Rounded Subnormal

ddqua717 quantize  0.009E-383  1e-385  ->   1E-385   Inexact Rounded Subnormal
ddqua718 quantize  0.001E-383  1e-385  ->   0E-385   Inexact Rounded
ddqua719 quantize  0.0009E-383 1e-385  ->   0E-385   Inexact Rounded
ddqua720 quantize  0.0001E-383 1e-385  ->   0E-385   Inexact Rounded

ddqua730 quantize -1.00E-383   1e-383  ->  -1E-383     Rounded
ddqua731 quantize -0.1E-383    1e-383  ->  -0E-383     Rounded Inexact
ddqua732 quantize -0.10E-383   1e-383  ->  -0E-383     Rounded Inexact
ddqua733 quantize -0.100E-383  1e-383  ->  -0E-383     Rounded Inexact
ddqua734 quantize -0.01E-383   1e-383  ->  -0E-383     Inexact Rounded
-- next is rounded to Emin
ddqua735 quantize -0.999E-383 90e-383  ->  -1E-383     Inexact Rounded
ddqua736 quantize -0.099E-383 -1e-383  ->  -0E-383     Inexact Rounded
ddqua737 quantize -0.009E-383 -1e-383  ->  -0E-383     Inexact Rounded
ddqua738 quantize -0.001E-383 -0e-383  ->  -0E-383     Inexact Rounded
ddqua739 quantize -0.0001E-383 0e-383  ->  -0E-383     Inexact Rounded

ddqua740 quantize -1.00E-383   1e-384 ->  -1.0E-383   Rounded
ddqua741 quantize -0.1E-383    1e-384 ->  -1E-384    Subnormal
ddqua742 quantize -0.10E-383   1e-384 ->  -1E-384    Subnormal Rounded
ddqua743 quantize -0.100E-383  1e-384 ->  -1E-384    Subnormal Rounded
ddqua744 quantize -0.01E-383   1e-384 ->  -0E-384    Inexact Rounded
-- next is rounded to Emin
ddqua745 quantize -0.999E-383  1e-384 ->  -1.0E-383   Inexact Rounded
ddqua746 quantize -0.099E-383  1e-384 ->  -1E-384    Inexact Rounded Subnormal
ddqua747 quantize -0.009E-383  1e-384 ->  -0E-384    Inexact Rounded
ddqua748 quantize -0.001E-383  1e-384 ->  -0E-384    Inexact Rounded
ddqua749 quantize -0.0001E-383 1e-384 ->  -0E-384    Inexact Rounded

ddqua750 quantize -1.00E-383   1e-385 ->  -1.00E-383
ddqua751 quantize -0.1E-383    1e-385 ->  -1.0E-384  Subnormal
ddqua752 quantize -0.10E-383   1e-385 ->  -1.0E-384  Subnormal
ddqua753 quantize -0.100E-383  1e-385 ->  -1.0E-384  Subnormal Rounded
ddqua754 quantize -0.01E-383   1e-385 ->  -1E-385    Subnormal
-- next is rounded to Emin
ddqua755 quantize -0.999E-383  1e-385 ->  -1.00E-383  Inexact Rounded
ddqua756 quantize -0.099E-383  1e-385 ->  -1.0E-384  Inexact Rounded Subnormal
ddqua757 quantize -0.009E-383  1e-385 ->  -1E-385    Inexact Rounded Subnormal
ddqua758 quantize -0.001E-383  1e-385 ->  -0E-385    Inexact Rounded
ddqua759 quantize -0.0001E-383 1e-385 ->  -0E-385    Inexact Rounded

ddqua760 quantize -1.00E-383   1e-386 ->  -1.000E-383
ddqua761 quantize -0.1E-383    1e-386 ->  -1.00E-384  Subnormal
ddqua762 quantize -0.10E-383   1e-386 ->  -1.00E-384  Subnormal
ddqua763 quantize -0.100E-383  1e-386 ->  -1.00E-384  Subnormal
ddqua764 quantize -0.01E-383   1e-386 ->  -1.0E-385   Subnormal
ddqua765 quantize -0.999E-383  1e-386 ->  -9.99E-384  Subnormal
ddqua766 quantize -0.099E-383  1e-386 ->  -9.9E-385   Subnormal
ddqua767 quantize -0.009E-383  1e-386 ->  -9E-386     Subnormal
ddqua768 quantize -0.001E-383  1e-386 ->  -1E-386     Subnormal
ddqua769 quantize -0.0001E-383 1e-386 ->  -0E-386     Inexact Rounded

-- More from Fung Lee
ddqua1021 quantize  8.666666666666000E+384  1.000000000000000E+384 ->  8.666666666666000E+384
ddqua1022 quantize -8.666666666666000E+384  1.000000000000000E+384 -> -8.666666666666000E+384
ddqua1027 quantize 8.666666666666000E+323  1E+31    -> NaN Invalid_operation
ddqua1030 quantize 8.66666666E+3           1E+3     -> 9E+3 Inexact Rounded

-- Int and uInt32 edge values for testing conversions
ddqua1040 quantize -2147483646     0 -> -2147483646
ddqua1041 quantize -2147483647     0 -> -2147483647
ddqua1042 quantize -2147483648     0 -> -2147483648
ddqua1043 quantize -2147483649     0 -> -2147483649
ddqua1044 quantize  2147483646     0 ->  2147483646
ddqua1045 quantize  2147483647     0 ->  2147483647
ddqua1046 quantize  2147483648     0 ->  2147483648
ddqua1047 quantize  2147483649     0 ->  2147483649
ddqua1048 quantize  4294967294     0 ->  4294967294
ddqua1049 quantize  4294967295     0 ->  4294967295
ddqua1050 quantize  4294967296     0 ->  4294967296
ddqua1051 quantize  4294967297     0 ->  4294967297

-- Rounding swathe
rounding: half_even
ddqua1100 quantize  1.2300    1.00    ->  1.23  Rounded
ddqua1101 quantize  1.2301    1.00    ->  1.23  Inexact Rounded
ddqua1102 quantize  1.2310    1.00    ->  1.23  Inexact Rounded
ddqua1103 quantize  1.2350    1.00    ->  1.24  Inexact Rounded
ddqua1104 quantize  1.2351    1.00    ->  1.24  Inexact Rounded
ddqua1105 quantize  1.2450    1.00    ->  1.24  Inexact Rounded
ddqua1106 quantize  1.2451    1.00    ->  1.25  Inexact Rounded
ddqua1107 quantize  1.2360    1.00    ->  1.24  Inexact Rounded
ddqua1108 quantize  1.2370    1.00    ->  1.24  Inexact Rounded
ddqua1109 quantize  1.2399    1.00    ->  1.24  Inexact Rounded

rounding: half_up
ddqua1200 quantize  1.2300    1.00    ->  1.23  Rounded
ddqua1201 quantize  1.2301    1.00    ->  1.23  Inexact Rounded
ddqua1202 quantize  1.2310    1.00    ->  1.23  Inexact Rounded
ddqua1203 quantize  1.2350    1.00    ->  1.24  Inexact Rounded
ddqua1204 quantize  1.2351    1.00    ->  1.24  Inexact Rounded
ddqua1205 quantize  1.2450    1.00    ->  1.25  Inexact Rounded
ddqua1206 quantize  1.2451    1.00    ->  1.25  Inexact Rounded
ddqua1207 quantize  1.2360    1.00    ->  1.24  Inexact Rounded
ddqua1208 quantize  1.2370    1.00    ->  1.24  Inexact Rounded
ddqua1209 quantize  1.2399    1.00    ->  1.24  Inexact Rounded

rounding: half_down
ddqua1300 quantize  1.2300    1.00    ->  1.23  Rounded
ddqua1301 quantize  1.2301    1.00    ->  1.23  Inexact Rounded
ddqua1302 quantize  1.2310    1.00    ->  1.23  Inexact Rounded
ddqua1303 quantize  1.2350    1.00    ->  1.23  Inexact Rounded
ddqua1304 quantize  1.2351    1.00    ->  1.24  Inexact Rounded
ddqua1305 quantize  1.2450    1.00    ->  1.24  Inexact Rounded
ddqua1306 quantize  1.2451    1.00    ->  1.25  Inexact Rounded
ddqua1307 quantize  1.2360    1.00    ->  1.24  Inexact Rounded
ddqua1308 quantize  1.2370    1.00    ->  1.24  Inexact Rounded
ddqua1309 quantize  1.2399    1.00    ->  1.24  Inexact Rounded

rounding: up
ddqua1400 quantize  1.2300    1.00    ->  1.23  Rounded
ddqua1401 quantize  1.2301    1.00    ->  1.24  Inexact Rounded
ddqua1402 quantize  1.2310    1.00    ->  1.24  Inexact Rounded
ddqua1403 quantize  1.2350    1.00    ->  1.24  Inexact Rounded
ddqua1404 quantize  1.2351    1.00    ->  1.24  Inexact Rounded
ddqua1405 quantize  1.2450    1.00    ->  1.25  Inexact Rounded
ddqua1406 quantize  1.2451    1.00    ->  1.25  Inexact Rounded
ddqua1407 quantize  1.2360    1.00    ->  1.24  Inexact Rounded
ddqua1408 quantize  1.2370    1.00    ->  1.24  Inexact Rounded
ddqua1409 quantize  1.2399    1.00    ->  1.24  Inexact Rounded
ddqua1411 quantize -1.2399    1.00    -> -1.24  Inexact Rounded

rounding: down
ddqua1500 quantize  1.2300    1.00    ->  1.23  Rounded
ddqua1501 quantize  1.2301    1.00    ->  1.23  Inexact Rounded
ddqua1502 quantize  1.2310    1.00    ->  1.23  Inexact Rounded
ddqua1503 quantize  1.2350    1.00    ->  1.23  Inexact Rounded
ddqua1504 quantize  1.2351    1.00    ->  1.23  Inexact Rounded
ddqua1505 quantize  1.2450    1.00    ->  1.24  Inexact Rounded
ddqua1506 quantize  1.2451    1.00    ->  1.24  Inexact Rounded
ddqua1507 quantize  1.2360    1.00    ->  1.23  Inexact Rounded
ddqua1508 quantize  1.2370    1.00    ->  1.23  Inexact Rounded
ddqua1509 quantize  1.2399    1.00    ->  1.23  Inexact Rounded
ddqua1511 quantize -1.2399    1.00    -> -1.23  Inexact Rounded

rounding: ceiling
ddqua1600 quantize  1.2300    1.00    ->  1.23  Rounded
ddqua1601 quantize  1.2301    1.00    ->  1.24  Inexact Rounded
ddqua1602 quantize  1.2310    1.00    ->  1.24  Inexact Rounded
ddqua1603 quantize  1.2350    1.00    ->  1.24  Inexact Rounded
ddqua1604 quantize  1.2351    1.00    ->  1.24  Inexact Rounded
ddqua1605 quantize  1.2450    1.00    ->  1.25  Inexact Rounded
ddqua1606 quantize  1.2451    1.00    ->  1.25  Inexact Rounded
ddqua1607 quantize  1.2360    1.00    ->  1.24  Inexact Rounded
ddqua1608 quantize  1.2370    1.00    ->  1.24  Inexact Rounded
ddqua1609 quantize  1.2399    1.00    ->  1.24  Inexact Rounded
ddqua1611 quantize -1.2399    1.00    -> -1.23  Inexact Rounded

rounding: floor
ddqua1700 quantize  1.2300    1.00    ->  1.23  Rounded
ddqua1701 quantize  1.2301    1.00    ->  1.23  Inexact Rounded
ddqua1702 quantize  1.2310    1.00    ->  1.23  Inexact Rounded
ddqua1703 quantize  1.2350    1.00    ->  1.23  Inexact Rounded
ddqua1704 quantize  1.2351    1.00    ->  1.23  Inexact Rounded
ddqua1705 quantize  1.2450    1.00    ->  1.24  Inexact Rounded
ddqua1706 quantize  1.2451    1.00    ->  1.24  Inexact Rounded
ddqua1707 quantize  1.2360    1.00    ->  1.23  Inexact Rounded
ddqua1708 quantize  1.2370    1.00    ->  1.23  Inexact Rounded
ddqua1709 quantize  1.2399    1.00    ->  1.23  Inexact Rounded
ddqua1711 quantize -1.2399    1.00    -> -1.24  Inexact Rounded

rounding: 05up
ddqua1800 quantize  1.2000    1.00    ->  1.20  Rounded
ddqua1801 quantize  1.2001    1.00    ->  1.21  Inexact Rounded
ddqua1802 quantize  1.2010    1.00    ->  1.21  Inexact Rounded
ddqua1803 quantize  1.2050    1.00    ->  1.21  Inexact Rounded
ddqua1804 quantize  1.2051    1.00    ->  1.21  Inexact Rounded
ddqua1807 quantize  1.2060    1.00    ->  1.21  Inexact Rounded
ddqua1808 quantize  1.2070    1.00    ->  1.21  Inexact Rounded
ddqua1809 quantize  1.2099    1.00    ->  1.21  Inexact Rounded
ddqua1811 quantize -1.2099    1.00    -> -1.21  Inexact Rounded

ddqua1900 quantize  1.2100    1.00    ->  1.21  Rounded
ddqua1901 quantize  1.2101    1.00    ->  1.21  Inexact Rounded
ddqua1902 quantize  1.2110    1.00    ->  1.21  Inexact Rounded
ddqua1903 quantize  1.2150    1.00    ->  1.21  Inexact Rounded
ddqua1904 quantize  1.2151    1.00    ->  1.21  Inexact Rounded
ddqua1907 quantize  1.2160    1.00    ->  1.21  Inexact Rounded
ddqua1908 quantize  1.2170    1.00    ->  1.21  Inexact Rounded
ddqua1909 quantize  1.2199    1.00    ->  1.21  Inexact Rounded
ddqua1911 quantize -1.2199    1.00    -> -1.21  Inexact Rounded

ddqua2000 quantize  1.2400    1.00    ->  1.24  Rounded
ddqua2001 quantize  1.2401    1.00    ->  1.24  Inexact Rounded
ddqua2002 quantize  1.2410    1.00    ->  1.24  Inexact Rounded
ddqua2003 quantize  1.2450    1.00    ->  1.24  Inexact Rounded
ddqua2004 quantize  1.2451    1.00    ->  1.24  Inexact Rounded
ddqua2007 quantize  1.2460    1.00    ->  1.24  Inexact Rounded
ddqua2008 quantize  1.2470    1.00    ->  1.24  Inexact Rounded
ddqua2009 quantize  1.2499    1.00    ->  1.24  Inexact Rounded
ddqua2011 quantize -1.2499    1.00    -> -1.24  Inexact Rounded

ddqua2100 quantize  1.2500    1.00    ->  1.25  Rounded
ddqua2101 quantize  1.2501    1.00    ->  1.26  Inexact Rounded
ddqua2102 quantize  1.2510    1.00    ->  1.26  Inexact Rounded
ddqua2103 quantize  1.2550    1.00    ->  1.26  Inexact Rounded
ddqua2104 quantize  1.2551    1.00    ->  1.26  Inexact Rounded
ddqua2107 quantize  1.2560    1.00    ->  1.26  Inexact Rounded
ddqua2108 quantize  1.2570    1.00    ->  1.26  Inexact Rounded
ddqua2109 quantize  1.2599    1.00    ->  1.26  Inexact Rounded
ddqua2111 quantize -1.2599    1.00    -> -1.26  Inexact Rounded

ddqua2200 quantize  1.2600    1.00    ->  1.26  Rounded
ddqua2201 quantize  1.2601    1.00    ->  1.26  Inexact Rounded
ddqua2202 quantize  1.2610    1.00    ->  1.26  Inexact Rounded
ddqua2203 quantize  1.2650    1.00    ->  1.26  Inexact Rounded
ddqua2204 quantize  1.2651    1.00    ->  1.26  Inexact Rounded
ddqua2207 quantize  1.2660    1.00    ->  1.26  Inexact Rounded
ddqua2208 quantize  1.2670    1.00    ->  1.26  Inexact Rounded
ddqua2209 quantize  1.2699    1.00    ->  1.26  Inexact Rounded
ddqua2211 quantize -1.2699    1.00    -> -1.26  Inexact Rounded

ddqua2300 quantize  1.2900    1.00    ->  1.29  Rounded
ddqua2301 quantize  1.2901    1.00    ->  1.29  Inexact Rounded
ddqua2302 quantize  1.2910    1.00    ->  1.29  Inexact Rounded
ddqua2303 quantize  1.2950    1.00    ->  1.29  Inexact Rounded
ddqua2304 quantize  1.2951    1.00    ->  1.29  Inexact Rounded
ddqua2307 quantize  1.2960    1.00    ->  1.29  Inexact Rounded
ddqua2308 quantize  1.2970    1.00    ->  1.29  Inexact Rounded
ddqua2309 quantize  1.2999    1.00    ->  1.29  Inexact Rounded
ddqua2311 quantize -1.2999    1.00    -> -1.29  Inexact Rounded

-- Null tests
rounding:    half_even
ddqua998 quantize 10    # -> NaN Invalid_operation
ddqua999 quantize  # 1e10 -> NaN Invalid_operation

Added test/dectest/ddReduce.decTest.













































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
------------------------------------------------------------------------
-- ddReduce.decTest -- remove trailing zeros from a decDouble         --
-- Copyright (c) IBM Corporation, 2003, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

ddred001 reduce '1'      -> '1'
ddred002 reduce '-1'     -> '-1'
ddred003 reduce '1.00'   -> '1'
ddred004 reduce '-1.00'  -> '-1'
ddred005 reduce '0'      -> '0'
ddred006 reduce '0.00'   -> '0'
ddred007 reduce '00.0'   -> '0'
ddred008 reduce '00.00'  -> '0'
ddred009 reduce '00'     -> '0'
ddred010 reduce '0E+1'   -> '0'
ddred011 reduce '0E+5'   -> '0'

ddred012 reduce '-2'     -> '-2'
ddred013 reduce '2'      -> '2'
ddred014 reduce '-2.00'  -> '-2'
ddred015 reduce '2.00'   -> '2'
ddred016 reduce '-0'     -> '-0'
ddred017 reduce '-0.00'  -> '-0'
ddred018 reduce '-00.0'  -> '-0'
ddred019 reduce '-00.00' -> '-0'
ddred020 reduce '-00'    -> '-0'
ddred021 reduce '-0E+5'   -> '-0'
ddred022 reduce '-0E+1'  -> '-0'

ddred030 reduce '+0.1'            -> '0.1'
ddred031 reduce '-0.1'            -> '-0.1'
ddred032 reduce '+0.01'           -> '0.01'
ddred033 reduce '-0.01'           -> '-0.01'
ddred034 reduce '+0.001'          -> '0.001'
ddred035 reduce '-0.001'          -> '-0.001'
ddred036 reduce '+0.000001'       -> '0.000001'
ddred037 reduce '-0.000001'       -> '-0.000001'
ddred038 reduce '+0.000000000001' -> '1E-12'
ddred039 reduce '-0.000000000001' -> '-1E-12'

ddred041 reduce 1.1        -> 1.1
ddred042 reduce 1.10       -> 1.1
ddred043 reduce 1.100      -> 1.1
ddred044 reduce 1.110      -> 1.11
ddred045 reduce -1.1       -> -1.1
ddred046 reduce -1.10      -> -1.1
ddred047 reduce -1.100     -> -1.1
ddred048 reduce -1.110     -> -1.11
ddred049 reduce 9.9        -> 9.9
ddred050 reduce 9.90       -> 9.9
ddred051 reduce 9.900      -> 9.9
ddred052 reduce 9.990      -> 9.99
ddred053 reduce -9.9       -> -9.9
ddred054 reduce -9.90      -> -9.9
ddred055 reduce -9.900     -> -9.9
ddred056 reduce -9.990     -> -9.99

-- some trailing fractional zeros with zeros in units
ddred060 reduce  10.0        -> 1E+1
ddred061 reduce  10.00       -> 1E+1
ddred062 reduce  100.0       -> 1E+2
ddred063 reduce  100.00      -> 1E+2
ddred064 reduce  1.1000E+3   -> 1.1E+3
ddred065 reduce  1.10000E+3  -> 1.1E+3
ddred066 reduce -10.0        -> -1E+1
ddred067 reduce -10.00       -> -1E+1
ddred068 reduce -100.0       -> -1E+2
ddred069 reduce -100.00      -> -1E+2
ddred070 reduce -1.1000E+3   -> -1.1E+3
ddred071 reduce -1.10000E+3  -> -1.1E+3

-- some insignificant trailing zeros with positive exponent
ddred080 reduce  10E+1       -> 1E+2
ddred081 reduce  100E+1      -> 1E+3
ddred082 reduce  1.0E+2      -> 1E+2
ddred083 reduce  1.0E+3      -> 1E+3
ddred084 reduce  1.1E+3      -> 1.1E+3
ddred085 reduce  1.00E+3     -> 1E+3
ddred086 reduce  1.10E+3     -> 1.1E+3
ddred087 reduce -10E+1       -> -1E+2
ddred088 reduce -100E+1      -> -1E+3
ddred089 reduce -1.0E+2      -> -1E+2
ddred090 reduce -1.0E+3      -> -1E+3
ddred091 reduce -1.1E+3      -> -1.1E+3
ddred092 reduce -1.00E+3     -> -1E+3
ddred093 reduce -1.10E+3     -> -1.1E+3

-- some significant trailing zeros, were we to be trimming
ddred100 reduce  11          -> 11
ddred101 reduce  10          -> 1E+1
ddred102 reduce  10.         -> 1E+1
ddred103 reduce  1.1E+1      -> 11
ddred104 reduce  1.0E+1      -> 1E+1
ddred105 reduce  1.10E+2     -> 1.1E+2
ddred106 reduce  1.00E+2     -> 1E+2
ddred107 reduce  1.100E+3    -> 1.1E+3
ddred108 reduce  1.000E+3    -> 1E+3
ddred109 reduce  1.000000E+6 -> 1E+6
ddred110 reduce -11          -> -11
ddred111 reduce -10          -> -1E+1
ddred112 reduce -10.         -> -1E+1
ddred113 reduce -1.1E+1      -> -11
ddred114 reduce -1.0E+1      -> -1E+1
ddred115 reduce -1.10E+2     -> -1.1E+2
ddred116 reduce -1.00E+2     -> -1E+2
ddred117 reduce -1.100E+3    -> -1.1E+3
ddred118 reduce -1.000E+3    -> -1E+3
ddred119 reduce -1.00000E+5  -> -1E+5
ddred120 reduce -1.000000E+6 -> -1E+6
ddred121 reduce -10.00000E+6 -> -1E+7
ddred122 reduce -100.0000E+6 -> -1E+8
ddred123 reduce -1000.000E+6 -> -1E+9
ddred124 reduce -10000.00E+6 -> -1E+10
ddred125 reduce -100000.0E+6 -> -1E+11
ddred126 reduce -1000000.E+6 -> -1E+12

-- examples from decArith
ddred140 reduce '2.1'     ->  '2.1'
ddred141 reduce '-2.0'    ->  '-2'
ddred142 reduce '1.200'   ->  '1.2'
ddred143 reduce '-120'    ->  '-1.2E+2'
ddred144 reduce '120.00'  ->  '1.2E+2'
ddred145 reduce '0.00'    ->  '0'

-- Nmax, Nmin, Ntiny
-- note origami effect on some of these
ddred151 reduce  9.999999999999999E+384   -> 9.999999999999999E+384
ddred152 reduce  9.999999000000000E+380   -> 9.99999900000E+380
ddred153 reduce  9.999999999990000E+384   -> 9.999999999990000E+384
ddred154 reduce  1E-383                   -> 1E-383
ddred155 reduce  1.000000000000000E-383   -> 1E-383
ddred156 reduce  2.000E-395               -> 2E-395   Subnormal
ddred157 reduce  1E-398                   -> 1E-398   Subnormal

ddred161 reduce  -1E-398                  -> -1E-398  Subnormal
ddred162 reduce  -2.000E-395              -> -2E-395  Subnormal
ddred163 reduce  -1.000000000000000E-383  -> -1E-383
ddred164 reduce  -1E-383                  -> -1E-383
ddred165 reduce  -9.999999000000000E+380  -> -9.99999900000E+380
ddred166 reduce  -9.999999999990000E+384  -> -9.999999999990000E+384
ddred167 reduce  -9.999999999999990E+384  -> -9.999999999999990E+384
ddred168 reduce  -9.999999999999999E+384  -> -9.999999999999999E+384
ddred169 reduce  -9.999999999999990E+384  -> -9.999999999999990E+384


-- specials (reduce does not affect payload)
ddred820 reduce 'Inf'    -> 'Infinity'
ddred821 reduce '-Inf'   -> '-Infinity'
ddred822 reduce   NaN    ->  NaN
ddred823 reduce  sNaN    ->  NaN    Invalid_operation
ddred824 reduce   NaN101 ->  NaN101
ddred825 reduce  sNaN010 ->  NaN10  Invalid_operation
ddred827 reduce  -NaN    -> -NaN
ddred828 reduce -sNaN    -> -NaN    Invalid_operation
ddred829 reduce  -NaN101 -> -NaN101
ddred830 reduce -sNaN010 -> -NaN10  Invalid_operation

-- Null test
ddred900 reduce  # -> NaN Invalid_operation

Added test/dectest/ddRemainder.decTest.































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
------------------------------------------------------------------------
-- ddRemainder.decTest -- decDouble remainder                         --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks (as base, above)
ddrem001 remainder  1     1    ->  0
ddrem002 remainder  2     1    ->  0
ddrem003 remainder  1     2    ->  1
ddrem004 remainder  2     2    ->  0
ddrem005 remainder  0     1    ->  0
ddrem006 remainder  0     2    ->  0
ddrem007 remainder  1     3    ->  1
ddrem008 remainder  2     3    ->  2
ddrem009 remainder  3     3    ->  0

ddrem010 remainder  2.4   1    ->  0.4
ddrem011 remainder  2.4   -1   ->  0.4
ddrem012 remainder  -2.4  1    ->  -0.4
ddrem013 remainder  -2.4  -1   ->  -0.4
ddrem014 remainder  2.40  1    ->  0.40
ddrem015 remainder  2.400 1    ->  0.400
ddrem016 remainder  2.4   2    ->  0.4
ddrem017 remainder  2.400 2    ->  0.400
ddrem018 remainder  2.    2    ->  0
ddrem019 remainder  20    20   ->  0

ddrem020 remainder  187   187    ->  0
ddrem021 remainder  5     2      ->  1
ddrem022 remainder  5     2.0    ->  1.0
ddrem023 remainder  5     2.000  ->  1.000
ddrem024 remainder  5     0.200  ->  0.000
ddrem025 remainder  5     0.200  ->  0.000

ddrem030 remainder  1     2      ->  1
ddrem031 remainder  1     4      ->  1
ddrem032 remainder  1     8      ->  1

ddrem033 remainder  1     16     ->  1
ddrem034 remainder  1     32     ->  1
ddrem035 remainder  1     64     ->  1
ddrem040 remainder  1    -2      ->  1
ddrem041 remainder  1    -4      ->  1
ddrem042 remainder  1    -8      ->  1
ddrem043 remainder  1    -16     ->  1
ddrem044 remainder  1    -32     ->  1
ddrem045 remainder  1    -64     ->  1
ddrem050 remainder -1     2      ->  -1
ddrem051 remainder -1     4      ->  -1
ddrem052 remainder -1     8      ->  -1
ddrem053 remainder -1     16     ->  -1
ddrem054 remainder -1     32     ->  -1
ddrem055 remainder -1     64     ->  -1
ddrem060 remainder -1    -2      ->  -1
ddrem061 remainder -1    -4      ->  -1
ddrem062 remainder -1    -8      ->  -1
ddrem063 remainder -1    -16     ->  -1
ddrem064 remainder -1    -32     ->  -1
ddrem065 remainder -1    -64     ->  -1

ddrem066 remainder  999999999     1  -> 0
ddrem067 remainder  999999999.4   1  -> 0.4
ddrem068 remainder  999999999.5   1  -> 0.5
ddrem069 remainder  999999999.9   1  -> 0.9
ddrem070 remainder  999999999.999 1  -> 0.999
ddrem071 remainder  999999.999999 1  -> 0.999999
ddrem072 remainder  9             1  -> 0
ddrem073 remainder  9999999999999999 1  -> 0
ddrem074 remainder  9999999999999999 2  -> 1
ddrem075 remainder  9999999999999999 3  -> 0
ddrem076 remainder  9999999999999999 4  -> 3

ddrem080 remainder  0.            1  -> 0
ddrem081 remainder  .0            1  -> 0.0
ddrem082 remainder  0.00          1  -> 0.00
ddrem083 remainder  0.00E+9       1  -> 0
ddrem084 remainder  0.00E+3       1  -> 0
ddrem085 remainder  0.00E+2       1  -> 0
ddrem086 remainder  0.00E+1       1  -> 0.0
ddrem087 remainder  0.00E+0       1  -> 0.00
ddrem088 remainder  0.00E-0       1  -> 0.00
ddrem089 remainder  0.00E-1       1  -> 0.000
ddrem090 remainder  0.00E-2       1  -> 0.0000
ddrem091 remainder  0.00E-3       1  -> 0.00000
ddrem092 remainder  0.00E-4       1  -> 0.000000
ddrem093 remainder  0.00E-5       1  -> 0E-7
ddrem094 remainder  0.00E-6       1  -> 0E-8
ddrem095 remainder  0.0000E-50    1  -> 0E-54

-- Various flavours of remainder by 0
ddrem101 remainder  0       0   -> NaN Division_undefined
ddrem102 remainder  0      -0   -> NaN Division_undefined
ddrem103 remainder -0       0   -> NaN Division_undefined
ddrem104 remainder -0      -0   -> NaN Division_undefined
ddrem105 remainder  0.0E5   0   -> NaN Division_undefined
ddrem106 remainder  0.000   0   -> NaN Division_undefined
-- [Some think this next group should be Division_by_zero exception, but
-- IEEE 854 is explicit that it is Invalid operation .. for
-- remainder-near, anyway]
ddrem107 remainder  0.0001  0   -> NaN Invalid_operation
ddrem108 remainder  0.01    0   -> NaN Invalid_operation
ddrem109 remainder  0.1     0   -> NaN Invalid_operation
ddrem110 remainder  1       0   -> NaN Invalid_operation
ddrem111 remainder  1       0.0 -> NaN Invalid_operation
ddrem112 remainder 10       0.0 -> NaN Invalid_operation
ddrem113 remainder 1E+100   0.0 -> NaN Invalid_operation
ddrem114 remainder 1E+380   0   -> NaN Invalid_operation
ddrem115 remainder  0.0001 -0   -> NaN Invalid_operation
ddrem116 remainder  0.01   -0   -> NaN Invalid_operation
ddrem119 remainder  0.1    -0   -> NaN Invalid_operation
ddrem120 remainder  1      -0   -> NaN Invalid_operation
ddrem121 remainder  1      -0.0 -> NaN Invalid_operation
ddrem122 remainder 10      -0.0 -> NaN Invalid_operation
ddrem123 remainder 1E+100  -0.0 -> NaN Invalid_operation
ddrem124 remainder 1E+384  -0   -> NaN Invalid_operation
-- and zeros on left
ddrem130 remainder  0      1   ->  0
ddrem131 remainder  0     -1   ->  0
ddrem132 remainder  0.0    1   ->  0.0
ddrem133 remainder  0.0   -1   ->  0.0
ddrem134 remainder -0      1   -> -0
ddrem135 remainder -0     -1   -> -0
ddrem136 remainder -0.0    1   -> -0.0
ddrem137 remainder -0.0   -1   -> -0.0

-- 0.5ers
ddrem143 remainder   0.5  2     ->  0.5
ddrem144 remainder   0.5  2.1   ->  0.5
ddrem145 remainder   0.5  2.01  ->  0.50
ddrem146 remainder   0.5  2.001 ->  0.500
ddrem147 remainder   0.50 2     ->  0.50
ddrem148 remainder   0.50 2.01  ->  0.50
ddrem149 remainder   0.50 2.001 ->  0.500

-- steadies
ddrem150 remainder  1  1   -> 0
ddrem151 remainder  1  2   -> 1
ddrem152 remainder  1  3   -> 1
ddrem153 remainder  1  4   -> 1
ddrem154 remainder  1  5   -> 1
ddrem155 remainder  1  6   -> 1
ddrem156 remainder  1  7   -> 1
ddrem157 remainder  1  8   -> 1
ddrem158 remainder  1  9   -> 1
ddrem159 remainder  1  10  -> 1
ddrem160 remainder  1  1   -> 0
ddrem161 remainder  2  1   -> 0
ddrem162 remainder  3  1   -> 0
ddrem163 remainder  4  1   -> 0
ddrem164 remainder  5  1   -> 0
ddrem165 remainder  6  1   -> 0
ddrem166 remainder  7  1   -> 0
ddrem167 remainder  8  1   -> 0
ddrem168 remainder  9  1   -> 0
ddrem169 remainder  10 1   -> 0

-- some differences from remainderNear
ddrem171 remainder   0.4  1.020 ->  0.400
ddrem172 remainder   0.50 1.020 ->  0.500
ddrem173 remainder   0.51 1.020 ->  0.510
ddrem174 remainder   0.52 1.020 ->  0.520
ddrem175 remainder   0.6  1.020 ->  0.600

-- More flavours of remainder by 0
ddrem201 remainder  0      0   -> NaN Division_undefined
ddrem202 remainder  0.0E5  0   -> NaN Division_undefined
ddrem203 remainder  0.000  0   -> NaN Division_undefined
ddrem204 remainder  0.0001 0   -> NaN Invalid_operation
ddrem205 remainder  0.01   0   -> NaN Invalid_operation
ddrem206 remainder  0.1    0   -> NaN Invalid_operation
ddrem207 remainder  1      0   -> NaN Invalid_operation
ddrem208 remainder  1      0.0 -> NaN Invalid_operation
ddrem209 remainder 10      0.0 -> NaN Invalid_operation
ddrem210 remainder 1E+100  0.0 -> NaN Invalid_operation
ddrem211 remainder 1E+380  0   -> NaN Invalid_operation

-- some differences from remainderNear
ddrem231 remainder  -0.4  1.020 -> -0.400
ddrem232 remainder  -0.50 1.020 -> -0.500
ddrem233 remainder  -0.51 1.020 -> -0.510
ddrem234 remainder  -0.52 1.020 -> -0.520
ddrem235 remainder  -0.6  1.020 -> -0.600

-- high Xs
ddrem240 remainder  1E+2  1.00  ->  0.00

-- ddrem3xx are from DiagBigDecimal
ddrem301 remainder   1    3     ->  1
ddrem302 remainder   5    5     ->  0
ddrem303 remainder   13   10    ->  3
ddrem304 remainder   13   50    ->  13
ddrem305 remainder   13   100   ->  13
ddrem306 remainder   13   1000  ->  13
ddrem307 remainder   .13    1   ->  0.13
ddrem308 remainder   0.133  1   ->  0.133
ddrem309 remainder   0.1033 1   ->  0.1033
ddrem310 remainder   1.033  1   ->  0.033
ddrem311 remainder   10.33  1   ->  0.33
ddrem312 remainder   10.33 10   ->  0.33
ddrem313 remainder   103.3  1   ->  0.3
ddrem314 remainder   133   10   ->  3
ddrem315 remainder   1033  10   ->  3
ddrem316 remainder   1033  50   ->  33
ddrem317 remainder   101.0  3   ->  2.0
ddrem318 remainder   102.0  3   ->  0.0
ddrem319 remainder   103.0  3   ->  1.0
ddrem320 remainder   2.40   1   ->  0.40
ddrem321 remainder   2.400  1   ->  0.400
ddrem322 remainder   2.4    1   ->  0.4
ddrem323 remainder   2.4    2   ->  0.4
ddrem324 remainder   2.400  2   ->  0.400
ddrem325 remainder   1   0.3    ->  0.1
ddrem326 remainder   1   0.30   ->  0.10
ddrem327 remainder   1   0.300  ->  0.100
ddrem328 remainder   1   0.3000 ->  0.1000
ddrem329 remainder   1.0    0.3 ->  0.1
ddrem330 remainder   1.00   0.3 ->  0.10
ddrem331 remainder   1.000  0.3 ->  0.100
ddrem332 remainder   1.0000 0.3 ->  0.1000
ddrem333 remainder   0.5  2     ->  0.5
ddrem334 remainder   0.5  2.1   ->  0.5
ddrem335 remainder   0.5  2.01  ->  0.50
ddrem336 remainder   0.5  2.001 ->  0.500
ddrem337 remainder   0.50 2     ->  0.50
ddrem338 remainder   0.50 2.01  ->  0.50
ddrem339 remainder   0.50 2.001 ->  0.500

ddrem340 remainder   0.5   0.5000001    ->  0.5000000
ddrem341 remainder   0.5   0.50000001    ->  0.50000000
ddrem342 remainder   0.5   0.500000001    ->  0.500000000
ddrem343 remainder   0.5   0.5000000001    ->  0.5000000000
ddrem344 remainder   0.5   0.50000000001    ->  0.50000000000
ddrem345 remainder   0.5   0.4999999    ->  1E-7
ddrem346 remainder   0.5   0.49999999    ->  1E-8
ddrem347 remainder   0.5   0.499999999    ->  1E-9
ddrem348 remainder   0.5   0.4999999999    ->  1E-10
ddrem349 remainder   0.5   0.49999999999    ->  1E-11
ddrem350 remainder   0.5   0.499999999999    ->  1E-12

ddrem351 remainder   0.03  7  ->  0.03
ddrem352 remainder   5   2    ->  1
ddrem353 remainder   4.1   2    ->  0.1
ddrem354 remainder   4.01   2    ->  0.01
ddrem355 remainder   4.001   2    ->  0.001
ddrem356 remainder   4.0001   2    ->  0.0001
ddrem357 remainder   4.00001   2    ->  0.00001
ddrem358 remainder   4.000001   2    ->  0.000001
ddrem359 remainder   4.0000001   2    ->  1E-7

ddrem360 remainder   1.2   0.7345 ->  0.4655
ddrem361 remainder   0.8   12     ->  0.8
ddrem362 remainder   0.8   0.2    ->  0.0
ddrem363 remainder   0.8   0.3    ->  0.2
ddrem364 remainder   0.800   12   ->  0.800
ddrem365 remainder   0.800   1.7  ->  0.800
ddrem366 remainder   2.400   2    ->  0.400

ddrem371 remainder   2.400  2        ->  0.400

ddrem381 remainder 12345  1         ->  0
ddrem382 remainder 12345  1.0001    ->  0.7657
ddrem383 remainder 12345  1.001     ->  0.668
ddrem384 remainder 12345  1.01      ->  0.78
ddrem385 remainder 12345  1.1       ->  0.8
ddrem386 remainder 12355  4         ->  3
ddrem387 remainder 12345  4         ->  1
ddrem388 remainder 12355  4.0001    ->  2.6912
ddrem389 remainder 12345  4.0001    ->  0.6914
ddrem390 remainder 12345  4.9       ->  1.9
ddrem391 remainder 12345  4.99      ->  4.73
ddrem392 remainder 12345  4.999     ->  2.469
ddrem393 remainder 12345  4.9999    ->  0.2469
ddrem394 remainder 12345  5         ->  0
ddrem395 remainder 12345  5.0001    ->  4.7532
ddrem396 remainder 12345  5.001     ->  2.532
ddrem397 remainder 12345  5.01      ->  0.36
ddrem398 remainder 12345  5.1       ->  3.0

-- the nasty division-by-1 cases
ddrem401 remainder   0.5         1   ->  0.5
ddrem402 remainder   0.55        1   ->  0.55
ddrem403 remainder   0.555       1   ->  0.555
ddrem404 remainder   0.5555      1   ->  0.5555
ddrem405 remainder   0.55555     1   ->  0.55555
ddrem406 remainder   0.555555    1   ->  0.555555
ddrem407 remainder   0.5555555   1   ->  0.5555555
ddrem408 remainder   0.55555555  1   ->  0.55555555
ddrem409 remainder   0.555555555 1   ->  0.555555555

-- folddowns
ddrem421 remainder   1E+384       1  ->   NaN Division_impossible
ddrem422 remainder   1E+384  1E+383  ->   0E+369 Clamped
ddrem423 remainder   1E+384  2E+383  ->   0E+369 Clamped
ddrem424 remainder   1E+384  3E+383  ->   1.00000000000000E+383 Clamped
ddrem425 remainder   1E+384  4E+383  ->   2.00000000000000E+383 Clamped
ddrem426 remainder   1E+384  5E+383  ->   0E+369 Clamped
ddrem427 remainder   1E+384  6E+383  ->   4.00000000000000E+383 Clamped
ddrem428 remainder   1E+384  7E+383  ->   3.00000000000000E+383 Clamped
ddrem429 remainder   1E+384  8E+383  ->   2.00000000000000E+383 Clamped
ddrem430 remainder   1E+384  9E+383  ->   1.00000000000000E+383 Clamped
-- tinies
ddrem431 remainder   1E-397  1E-398  ->   0E-398
ddrem432 remainder   1E-397  2E-398  ->   0E-398
ddrem433 remainder   1E-397  3E-398  ->   1E-398 Subnormal
ddrem434 remainder   1E-397  4E-398  ->   2E-398 Subnormal
ddrem435 remainder   1E-397  5E-398  ->   0E-398
ddrem436 remainder   1E-397  6E-398  ->   4E-398 Subnormal
ddrem437 remainder   1E-397  7E-398  ->   3E-398 Subnormal
ddrem438 remainder   1E-397  8E-398  ->   2E-398 Subnormal
ddrem439 remainder   1E-397  9E-398  ->   1E-398 Subnormal
ddrem440 remainder   1E-397 10E-398  ->   0E-398
ddrem441 remainder   1E-397 11E-398  -> 1.0E-397 Subnormal
ddrem442 remainder 100E-397 11E-398  -> 1.0E-397 Subnormal
ddrem443 remainder 100E-397 20E-398  ->   0E-398
ddrem444 remainder 100E-397 21E-398  -> 1.3E-397 Subnormal
ddrem445 remainder 100E-397 30E-398  -> 1.0E-397 Subnormal

-- Specials
ddrem680 remainder  Inf  -Inf   ->  NaN Invalid_operation
ddrem681 remainder  Inf  -1000  ->  NaN Invalid_operation
ddrem682 remainder  Inf  -1     ->  NaN Invalid_operation
ddrem683 remainder  Inf   0     ->  NaN Invalid_operation
ddrem684 remainder  Inf  -0     ->  NaN Invalid_operation
ddrem685 remainder  Inf   1     ->  NaN Invalid_operation
ddrem686 remainder  Inf   1000  ->  NaN Invalid_operation
ddrem687 remainder  Inf   Inf   ->  NaN Invalid_operation
ddrem688 remainder -1000  Inf   -> -1000
ddrem689 remainder -Inf   Inf   ->  NaN Invalid_operation
ddrem691 remainder -1     Inf   -> -1
ddrem692 remainder  0     Inf   ->  0
ddrem693 remainder -0     Inf   -> -0
ddrem694 remainder  1     Inf   ->  1
ddrem695 remainder  1000  Inf   ->  1000
ddrem696 remainder  Inf   Inf   ->  NaN Invalid_operation

ddrem700 remainder -Inf  -Inf   ->  NaN Invalid_operation
ddrem701 remainder -Inf  -1000  ->  NaN Invalid_operation
ddrem702 remainder -Inf  -1     ->  NaN Invalid_operation
ddrem703 remainder -Inf  -0     ->  NaN Invalid_operation
ddrem704 remainder -Inf   0     ->  NaN Invalid_operation
ddrem705 remainder -Inf   1     ->  NaN Invalid_operation
ddrem706 remainder -Inf   1000  ->  NaN Invalid_operation
ddrem707 remainder -Inf   Inf   ->  NaN Invalid_operation
ddrem708 remainder -Inf  -Inf   ->  NaN Invalid_operation
ddrem709 remainder -1000  Inf   -> -1000
ddrem710 remainder -1    -Inf   -> -1
ddrem711 remainder -0    -Inf   -> -0
ddrem712 remainder  0    -Inf   ->  0
ddrem713 remainder  1    -Inf   ->  1
ddrem714 remainder  1000 -Inf   ->  1000
ddrem715 remainder  Inf  -Inf   ->  NaN Invalid_operation

ddrem721 remainder  NaN -Inf    ->  NaN
ddrem722 remainder  NaN -1000   ->  NaN
ddrem723 remainder  NaN -1      ->  NaN
ddrem724 remainder  NaN -0      ->  NaN
ddrem725 remainder -NaN  0      -> -NaN
ddrem726 remainder  NaN  1      ->  NaN
ddrem727 remainder  NaN  1000   ->  NaN
ddrem728 remainder  NaN  Inf    ->  NaN
ddrem729 remainder  NaN -NaN    ->  NaN
ddrem730 remainder -Inf  NaN    ->  NaN
ddrem731 remainder -1000 NaN    ->  NaN
ddrem732 remainder -1    NaN    ->  NaN
ddrem733 remainder -0   -NaN    -> -NaN
ddrem734 remainder  0    NaN    ->  NaN
ddrem735 remainder  1   -NaN    -> -NaN
ddrem736 remainder  1000 NaN    ->  NaN
ddrem737 remainder  Inf  NaN    ->  NaN

ddrem741 remainder  sNaN -Inf   ->  NaN  Invalid_operation
ddrem742 remainder  sNaN -1000  ->  NaN  Invalid_operation
ddrem743 remainder -sNaN -1     -> -NaN  Invalid_operation
ddrem744 remainder  sNaN -0     ->  NaN  Invalid_operation
ddrem745 remainder  sNaN  0     ->  NaN  Invalid_operation
ddrem746 remainder  sNaN  1     ->  NaN  Invalid_operation
ddrem747 remainder  sNaN  1000  ->  NaN  Invalid_operation
ddrem749 remainder  sNaN  NaN   ->  NaN  Invalid_operation
ddrem750 remainder  sNaN sNaN   ->  NaN  Invalid_operation
ddrem751 remainder  NaN  sNaN   ->  NaN  Invalid_operation
ddrem752 remainder -Inf  sNaN   ->  NaN  Invalid_operation
ddrem753 remainder -1000 sNaN   ->  NaN  Invalid_operation
ddrem754 remainder -1    sNaN   ->  NaN  Invalid_operation
ddrem755 remainder -0    sNaN   ->  NaN  Invalid_operation
ddrem756 remainder  0    sNaN   ->  NaN  Invalid_operation
ddrem757 remainder  1    sNaN   ->  NaN  Invalid_operation
ddrem758 remainder  1000 sNaN   ->  NaN  Invalid_operation
ddrem759 remainder  Inf -sNaN   -> -NaN  Invalid_operation

-- propaging NaNs
ddrem760 remainder  NaN1   NaN7   ->  NaN1
ddrem761 remainder sNaN2   NaN8   ->  NaN2 Invalid_operation
ddrem762 remainder  NaN3  sNaN9   ->  NaN9 Invalid_operation
ddrem763 remainder sNaN4  sNaN10  ->  NaN4 Invalid_operation
ddrem764 remainder    15   NaN11  ->  NaN11
ddrem765 remainder  NaN6   NaN12  ->  NaN6
ddrem766 remainder  Inf    NaN13  ->  NaN13
ddrem767 remainder  NaN14  -Inf   ->  NaN14
ddrem768 remainder    0    NaN15  ->  NaN15
ddrem769 remainder  NaN16   -0    ->  NaN16

-- edge cases of impossible
ddrem770  remainder  1234567890123456  10    ->  6
ddrem771  remainder  1234567890123456   1    ->  0
ddrem772  remainder  1234567890123456   0.1  ->  NaN Division_impossible
ddrem773  remainder  1234567890123456   0.01 ->  NaN Division_impossible

-- long operand checks
ddrem801 remainder 12345678000 100 -> 0
ddrem802 remainder 1 12345678000   -> 1
ddrem803 remainder 1234567800  10  -> 0
ddrem804 remainder 1 1234567800    -> 1
ddrem805 remainder 1234567890  10  -> 0
ddrem806 remainder 1 1234567890    -> 1
ddrem807 remainder 1234567891  10  -> 1
ddrem808 remainder 1 1234567891    -> 1
ddrem809 remainder 12345678901 100 -> 1
ddrem810 remainder 1 12345678901   -> 1
ddrem811 remainder 1234567896  10  -> 6
ddrem812 remainder 1 1234567896    -> 1

ddrem821 remainder 12345678000 100 -> 0
ddrem822 remainder 1 12345678000   -> 1
ddrem823 remainder 1234567800  10  -> 0
ddrem824 remainder 1 1234567800    -> 1
ddrem825 remainder 1234567890  10  -> 0
ddrem826 remainder 1 1234567890    -> 1
ddrem827 remainder 1234567891  10  -> 1
ddrem828 remainder 1 1234567891    -> 1
ddrem829 remainder 12345678901 100 -> 1
ddrem830 remainder 1 12345678901   -> 1
ddrem831 remainder 1234567896  10  -> 6
ddrem832 remainder 1 1234567896    -> 1

-- from divideint
ddrem840 remainder  100000000.0   1  ->  0.0
ddrem841 remainder  100000000.4   1  ->  0.4
ddrem842 remainder  100000000.5   1  ->  0.5
ddrem843 remainder  100000000.9   1  ->  0.9
ddrem844 remainder  100000000.999 1  ->  0.999
ddrem850 remainder  100000003     5  ->  3
ddrem851 remainder  10000003      5  ->  3
ddrem852 remainder  1000003       5  ->  3
ddrem853 remainder  100003        5  ->  3
ddrem854 remainder  10003         5  ->  3
ddrem855 remainder  1003          5  ->  3
ddrem856 remainder  103           5  ->  3
ddrem857 remainder  13            5  ->  3
ddrem858 remainder  1             5  ->  1

-- Vladimir's cases         1234567890123456
ddrem860 remainder 123.0e1 1000000000000000  -> 1230
ddrem861 remainder 1230    1000000000000000  -> 1230
ddrem862 remainder 12.3e2  1000000000000000  -> 1230
ddrem863 remainder 1.23e3  1000000000000000  -> 1230
ddrem864 remainder 123e1   1000000000000000  -> 1230
ddrem870 remainder 123e1    1000000000000000 -> 1230
ddrem871 remainder 123e1     100000000000000 -> 1230
ddrem872 remainder 123e1      10000000000000 -> 1230
ddrem873 remainder 123e1       1000000000000 -> 1230
ddrem874 remainder 123e1        100000000000 -> 1230
ddrem875 remainder 123e1         10000000000 -> 1230
ddrem876 remainder 123e1          1000000000 -> 1230
ddrem877 remainder 123e1           100000000 -> 1230
ddrem878 remainder 1230            100000000 -> 1230
ddrem879 remainder 123e1            10000000 -> 1230
ddrem880 remainder 123e1             1000000 -> 1230
ddrem881 remainder 123e1              100000 -> 1230
ddrem882 remainder 123e1               10000 -> 1230
ddrem883 remainder 123e1                1000 ->  230
ddrem884 remainder 123e1                 100 ->   30
ddrem885 remainder 123e1                  10 ->    0
ddrem886 remainder 123e1                   1 ->    0

ddrem890 remainder 123e1    2000000000000000 -> 1230
ddrem891 remainder 123e1     200000000000000 -> 1230
ddrem892 remainder 123e1      20000000000000 -> 1230
ddrem893 remainder 123e1       2000000000000 -> 1230
ddrem894 remainder 123e1        200000000000 -> 1230
ddrem895 remainder 123e1         20000000000 -> 1230
ddrem896 remainder 123e1          2000000000 -> 1230
ddrem897 remainder 123e1           200000000 -> 1230
ddrem899 remainder 123e1            20000000 -> 1230
ddrem900 remainder 123e1             2000000 -> 1230
ddrem901 remainder 123e1              200000 -> 1230
ddrem902 remainder 123e1               20000 -> 1230
ddrem903 remainder 123e1                2000 -> 1230
ddrem904 remainder 123e1                 200 ->   30
ddrem905 remainder 123e1                  20 ->   10
ddrem906 remainder 123e1                   2 ->    0

ddrem910 remainder 123e1    5000000000000000 -> 1230
ddrem911 remainder 123e1     500000000000000 -> 1230
ddrem912 remainder 123e1      50000000000000 -> 1230
ddrem913 remainder 123e1       5000000000000 -> 1230
ddrem914 remainder 123e1        500000000000 -> 1230
ddrem915 remainder 123e1         50000000000 -> 1230
ddrem916 remainder 123e1          5000000000 -> 1230
ddrem917 remainder 123e1           500000000 -> 1230
ddrem919 remainder 123e1            50000000 -> 1230
ddrem920 remainder 123e1             5000000 -> 1230
ddrem921 remainder 123e1              500000 -> 1230
ddrem922 remainder 123e1               50000 -> 1230
ddrem923 remainder 123e1                5000 -> 1230
ddrem924 remainder 123e1                 500 ->  230
ddrem925 remainder 123e1                  50 ->   30
ddrem926 remainder 123e1                   5 ->    0

ddrem930 remainder 123e1    9000000000000000 -> 1230
ddrem931 remainder 123e1     900000000000000 -> 1230
ddrem932 remainder 123e1      90000000000000 -> 1230
ddrem933 remainder 123e1       9000000000000 -> 1230
ddrem934 remainder 123e1        900000000000 -> 1230
ddrem935 remainder 123e1         90000000000 -> 1230
ddrem936 remainder 123e1          9000000000 -> 1230
ddrem937 remainder 123e1           900000000 -> 1230
ddrem939 remainder 123e1            90000000 -> 1230
ddrem940 remainder 123e1             9000000 -> 1230
ddrem941 remainder 123e1              900000 -> 1230
ddrem942 remainder 123e1               90000 -> 1230
ddrem943 remainder 123e1                9000 -> 1230
ddrem944 remainder 123e1                 900 ->  330
ddrem945 remainder 123e1                  90 ->   60
ddrem946 remainder 123e1                   9 ->    6

ddrem950 remainder 123e1   1000000000000000 -> 1230
ddrem961 remainder 123e1   2999999999999999 -> 1230
ddrem962 remainder 123e1   3999999999999999 -> 1230
ddrem963 remainder 123e1   4999999999999999 -> 1230
ddrem964 remainder 123e1   5999999999999999 -> 1230
ddrem965 remainder 123e1   6999999999999999 -> 1230
ddrem966 remainder 123e1   7999999999999999 -> 1230
ddrem967 remainder 123e1   8999999999999999 -> 1230
ddrem968 remainder 123e1   9999999999999999 -> 1230
ddrem969 remainder 123e1   9876543210987654 -> 1230

ddrem980 remainder 123e1 1000E299 -> 1.23E+3  -- 123E+1 internally

-- overflow and underflow tests [from divide]
ddrem1051 remainder  1e+277  1e-311 ->  NaN Division_impossible
ddrem1052 remainder  1e+277 -1e-311 ->  NaN Division_impossible
ddrem1053 remainder -1e+277  1e-311 ->  NaN Division_impossible
ddrem1054 remainder -1e+277 -1e-311 ->  NaN Division_impossible
ddrem1055 remainder  1e-277  1e+311 ->  1E-277
ddrem1056 remainder  1e-277 -1e+311 ->  1E-277
ddrem1057 remainder -1e-277  1e+311 -> -1E-277
ddrem1058 remainder -1e-277 -1e+311 -> -1E-277

-- Null tests
ddrem1000 remainder 10  # -> NaN Invalid_operation
ddrem1001 remainder  # 10 -> NaN Invalid_operation

Added test/dectest/ddRemainderNear.decTest.























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
------------------------------------------------------------------------
-- ddRemainderNear.decTest -- decDouble remainder-near                --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- sanity checks (as base, above)
ddrmn001 remaindernear  1     1    ->  0
ddrmn002 remaindernear  2     1    ->  0
ddrmn003 remaindernear  1     2    ->  1
ddrmn004 remaindernear  2     2    ->  0
ddrmn005 remaindernear  0     1    ->  0
ddrmn006 remaindernear  0     2    ->  0
ddrmn007 remaindernear  1     3    ->  1
ddrmn008 remaindernear  2     3    -> -1
ddrmn009 remaindernear  3     3    ->  0

ddrmn010 remaindernear  2.4   1    ->  0.4
ddrmn011 remaindernear  2.4   -1   ->  0.4
ddrmn012 remaindernear  -2.4  1    ->  -0.4
ddrmn013 remaindernear  -2.4  -1   ->  -0.4
ddrmn014 remaindernear  2.40  1    ->  0.40
ddrmn015 remaindernear  2.400 1    ->  0.400
ddrmn016 remaindernear  2.4   2    ->  0.4
ddrmn017 remaindernear  2.400 2    ->  0.400
ddrmn018 remaindernear  2.    2    ->  0
ddrmn019 remaindernear  20    20   ->  0

ddrmn020 remaindernear  187   187    ->  0
ddrmn021 remaindernear  5     2      ->  1
ddrmn022 remaindernear  5     2.0    ->  1.0
ddrmn023 remaindernear  5     2.000  ->  1.000
ddrmn024 remaindernear  5     0.200  ->  0.000
ddrmn025 remaindernear  5     0.200  ->  0.000

ddrmn030 remaindernear  1     2      ->  1
ddrmn031 remaindernear  1     4      ->  1
ddrmn032 remaindernear  1     8      ->  1

ddrmn033 remaindernear  1     16     ->  1
ddrmn034 remaindernear  1     32     ->  1
ddrmn035 remaindernear  1     64     ->  1
ddrmn040 remaindernear  1    -2      ->  1
ddrmn041 remaindernear  1    -4      ->  1
ddrmn042 remaindernear  1    -8      ->  1
ddrmn043 remaindernear  1    -16     ->  1
ddrmn044 remaindernear  1    -32     ->  1
ddrmn045 remaindernear  1    -64     ->  1
ddrmn050 remaindernear -1     2      ->  -1
ddrmn051 remaindernear -1     4      ->  -1
ddrmn052 remaindernear -1     8      ->  -1
ddrmn053 remaindernear -1     16     ->  -1
ddrmn054 remaindernear -1     32     ->  -1
ddrmn055 remaindernear -1     64     ->  -1
ddrmn060 remaindernear -1    -2      ->  -1
ddrmn061 remaindernear -1    -4      ->  -1
ddrmn062 remaindernear -1    -8      ->  -1
ddrmn063 remaindernear -1    -16     ->  -1
ddrmn064 remaindernear -1    -32     ->  -1
ddrmn065 remaindernear -1    -64     ->  -1

ddrmn066 remaindernear          9.9   1  -> -0.1
ddrmn067 remaindernear         99.7   1  -> -0.3
ddrmn068 remaindernear  999999999     1  -> 0
ddrmn069 remaindernear  999999999.4   1  -> 0.4
ddrmn070 remaindernear  999999999.5   1  -> -0.5
ddrmn071 remaindernear  999999999.9   1  -> -0.1
ddrmn072 remaindernear  999999999.999 1  -> -0.001
ddrmn073 remaindernear  999999.999999 1  -> -0.000001
ddrmn074 remaindernear  9             1  -> 0
ddrmn075 remaindernear  9999999999999999 1  -> 0
ddrmn076 remaindernear  9999999999999999 2  -> -1
ddrmn077 remaindernear  9999999999999999 3  -> 0
ddrmn078 remaindernear  9999999999999999 4  -> -1

ddrmn080 remaindernear  0.            1  -> 0
ddrmn081 remaindernear  .0            1  -> 0.0
ddrmn082 remaindernear  0.00          1  -> 0.00
ddrmn083 remaindernear  0.00E+9       1  -> 0
ddrmn084 remaindernear  0.00E+3       1  -> 0
ddrmn085 remaindernear  0.00E+2       1  -> 0
ddrmn086 remaindernear  0.00E+1       1  -> 0.0
ddrmn087 remaindernear  0.00E+0       1  -> 0.00
ddrmn088 remaindernear  0.00E-0       1  -> 0.00
ddrmn089 remaindernear  0.00E-1       1  -> 0.000
ddrmn090 remaindernear  0.00E-2       1  -> 0.0000
ddrmn091 remaindernear  0.00E-3       1  -> 0.00000
ddrmn092 remaindernear  0.00E-4       1  -> 0.000000
ddrmn093 remaindernear  0.00E-5       1  -> 0E-7
ddrmn094 remaindernear  0.00E-6       1  -> 0E-8
ddrmn095 remaindernear  0.0000E-50    1  -> 0E-54

-- Various flavours of remaindernear by 0
ddrmn101 remaindernear  0       0   -> NaN Division_undefined
ddrmn102 remaindernear  0      -0   -> NaN Division_undefined
ddrmn103 remaindernear -0       0   -> NaN Division_undefined
ddrmn104 remaindernear -0      -0   -> NaN Division_undefined
ddrmn105 remaindernear  0.0E5   0   -> NaN Division_undefined
ddrmn106 remaindernear  0.000   0   -> NaN Division_undefined
-- [Some think this next group should be Division_by_zero exception, but
-- IEEE 854 is explicit that it is Invalid operation .. for
-- remainder-near, anyway]
ddrmn107 remaindernear  0.0001  0   -> NaN Invalid_operation
ddrmn108 remaindernear  0.01    0   -> NaN Invalid_operation
ddrmn109 remaindernear  0.1     0   -> NaN Invalid_operation
ddrmn110 remaindernear  1       0   -> NaN Invalid_operation
ddrmn111 remaindernear  1       0.0 -> NaN Invalid_operation
ddrmn112 remaindernear 10       0.0 -> NaN Invalid_operation
ddrmn113 remaindernear 1E+100   0.0 -> NaN Invalid_operation
ddrmn114 remaindernear 1E+380   0   -> NaN Invalid_operation
ddrmn115 remaindernear  0.0001 -0   -> NaN Invalid_operation
ddrmn116 remaindernear  0.01   -0   -> NaN Invalid_operation
ddrmn119 remaindernear  0.1    -0   -> NaN Invalid_operation
ddrmn120 remaindernear  1      -0   -> NaN Invalid_operation
ddrmn121 remaindernear  1      -0.0 -> NaN Invalid_operation
ddrmn122 remaindernear 10      -0.0 -> NaN Invalid_operation
ddrmn123 remaindernear 1E+100  -0.0 -> NaN Invalid_operation
ddrmn124 remaindernear 1E+384  -0   -> NaN Invalid_operation
-- and zeros on left
ddrmn130 remaindernear  0      1   ->  0
ddrmn131 remaindernear  0     -1   ->  0
ddrmn132 remaindernear  0.0    1   ->  0.0
ddrmn133 remaindernear  0.0   -1   ->  0.0
ddrmn134 remaindernear -0      1   -> -0
ddrmn135 remaindernear -0     -1   -> -0
ddrmn136 remaindernear -0.0    1   -> -0.0
ddrmn137 remaindernear -0.0   -1   -> -0.0

-- 0.5ers
ddrmn143 remaindernear   0.5  2     ->  0.5
ddrmn144 remaindernear   0.5  2.1   ->  0.5
ddrmn145 remaindernear   0.5  2.01  ->  0.50
ddrmn146 remaindernear   0.5  2.001 ->  0.500
ddrmn147 remaindernear   0.50 2     ->  0.50
ddrmn148 remaindernear   0.50 2.01  ->  0.50
ddrmn149 remaindernear   0.50 2.001 ->  0.500

-- steadies
ddrmn150 remaindernear  1  1   -> 0
ddrmn151 remaindernear  1  2   -> 1
ddrmn152 remaindernear  1  3   -> 1
ddrmn153 remaindernear  1  4   -> 1
ddrmn154 remaindernear  1  5   -> 1
ddrmn155 remaindernear  1  6   -> 1
ddrmn156 remaindernear  1  7   -> 1
ddrmn157 remaindernear  1  8   -> 1
ddrmn158 remaindernear  1  9   -> 1
ddrmn159 remaindernear  1  10  -> 1
ddrmn160 remaindernear  1  1   -> 0
ddrmn161 remaindernear  2  1   -> 0
ddrmn162 remaindernear  3  1   -> 0
ddrmn163 remaindernear  4  1   -> 0
ddrmn164 remaindernear  5  1   -> 0
ddrmn165 remaindernear  6  1   -> 0
ddrmn166 remaindernear  7  1   -> 0
ddrmn167 remaindernear  8  1   -> 0
ddrmn168 remaindernear  9  1   -> 0
ddrmn169 remaindernear  10 1   -> 0

-- some differences from remainder
ddrmn171 remaindernear   0.4  1.020 ->  0.400
ddrmn172 remaindernear   0.50 1.020 ->  0.500
ddrmn173 remaindernear   0.51 1.020 ->  0.510
ddrmn174 remaindernear   0.52 1.020 -> -0.500
ddrmn175 remaindernear   0.6  1.020 -> -0.420

-- More flavours of remaindernear by 0
ddrmn201 remaindernear  0      0   -> NaN Division_undefined
ddrmn202 remaindernear  0.0E5  0   -> NaN Division_undefined
ddrmn203 remaindernear  0.000  0   -> NaN Division_undefined
ddrmn204 remaindernear  0.0001 0   -> NaN Invalid_operation
ddrmn205 remaindernear  0.01   0   -> NaN Invalid_operation
ddrmn206 remaindernear  0.1    0   -> NaN Invalid_operation
ddrmn207 remaindernear  1      0   -> NaN Invalid_operation
ddrmn208 remaindernear  1      0.0 -> NaN Invalid_operation
ddrmn209 remaindernear 10      0.0 -> NaN Invalid_operation
ddrmn210 remaindernear 1E+100  0.0 -> NaN Invalid_operation
ddrmn211 remaindernear 1E+380  0   -> NaN Invalid_operation

-- tests from the extended specification
ddrmn221 remaindernear 2.1     3   -> -0.9
ddrmn222 remaindernear  10     6   -> -2
ddrmn223 remaindernear  10     3   ->  1
ddrmn224 remaindernear -10     3   -> -1
ddrmn225 remaindernear  10.2   1   -> 0.2
ddrmn226 remaindernear  10     0.3 -> 0.1
ddrmn227 remaindernear   3.6   1.3 -> -0.3

-- some differences from remainder
ddrmn231 remaindernear  -0.4  1.020 -> -0.400
ddrmn232 remaindernear  -0.50 1.020 -> -0.500
ddrmn233 remaindernear  -0.51 1.020 -> -0.510
ddrmn234 remaindernear  -0.52 1.020 ->  0.500
ddrmn235 remaindernear  -0.6  1.020 ->  0.420

-- high Xs
ddrmn240 remaindernear  1E+2  1.00  ->  0.00

-- ddrmn3xx are from DiagBigDecimal
ddrmn301 remaindernear   1    3     ->  1
ddrmn302 remaindernear   5    5     ->  0
ddrmn303 remaindernear   13   10    ->  3
ddrmn304 remaindernear   13   50    ->  13
ddrmn305 remaindernear   13   100   ->  13
ddrmn306 remaindernear   13   1000  ->  13
ddrmn307 remaindernear   .13    1   ->  0.13
ddrmn308 remaindernear   0.133  1   ->  0.133
ddrmn309 remaindernear   0.1033 1   ->  0.1033
ddrmn310 remaindernear   1.033  1   ->  0.033
ddrmn311 remaindernear   10.33  1   ->  0.33
ddrmn312 remaindernear   10.33 10   ->  0.33
ddrmn313 remaindernear   103.3  1   ->  0.3
ddrmn314 remaindernear   133   10   ->  3
ddrmn315 remaindernear   1033  10   ->  3
ddrmn316 remaindernear   1033  50   -> -17
ddrmn317 remaindernear   101.0  3   -> -1.0
ddrmn318 remaindernear   102.0  3   ->  0.0
ddrmn319 remaindernear   103.0  3   ->  1.0
ddrmn320 remaindernear   2.40   1   ->  0.40
ddrmn321 remaindernear   2.400  1   ->  0.400
ddrmn322 remaindernear   2.4    1   ->  0.4
ddrmn323 remaindernear   2.4    2   ->  0.4
ddrmn324 remaindernear   2.400  2   ->  0.400
ddrmn325 remaindernear   1   0.3    ->  0.1
ddrmn326 remaindernear   1   0.30   ->  0.10
ddrmn327 remaindernear   1   0.300  ->  0.100
ddrmn328 remaindernear   1   0.3000 ->  0.1000
ddrmn329 remaindernear   1.0    0.3 ->  0.1
ddrmn330 remaindernear   1.00   0.3 ->  0.10
ddrmn331 remaindernear   1.000  0.3 ->  0.100
ddrmn332 remaindernear   1.0000 0.3 ->  0.1000
ddrmn333 remaindernear   0.5  2     ->  0.5
ddrmn334 remaindernear   0.5  2.1   ->  0.5
ddrmn335 remaindernear   0.5  2.01  ->  0.50
ddrmn336 remaindernear   0.5  2.001 ->  0.500
ddrmn337 remaindernear   0.50 2     ->  0.50
ddrmn338 remaindernear   0.50 2.01  ->  0.50
ddrmn339 remaindernear   0.50 2.001 ->  0.500

ddrmn340 remaindernear   0.5   0.5000001    ->  -1E-7
ddrmn341 remaindernear   0.5   0.50000001    ->  -1E-8
ddrmn342 remaindernear   0.5   0.500000001    ->  -1E-9
ddrmn343 remaindernear   0.5   0.5000000001    ->  -1E-10
ddrmn344 remaindernear   0.5   0.50000000001    ->  -1E-11
ddrmn345 remaindernear   0.5   0.4999999    ->  1E-7
ddrmn346 remaindernear   0.5   0.49999999    ->  1E-8
ddrmn347 remaindernear   0.5   0.499999999    ->  1E-9
ddrmn348 remaindernear   0.5   0.4999999999    ->  1E-10
ddrmn349 remaindernear   0.5   0.49999999999    ->  1E-11
ddrmn350 remaindernear   0.5   0.499999999999    ->  1E-12

ddrmn351 remaindernear   0.03  7  ->  0.03
ddrmn352 remaindernear   5   2    ->  1
ddrmn353 remaindernear   4.1   2    ->  0.1
ddrmn354 remaindernear   4.01   2    ->  0.01
ddrmn355 remaindernear   4.001   2    ->  0.001
ddrmn356 remaindernear   4.0001   2    ->  0.0001
ddrmn357 remaindernear   4.00001   2    ->  0.00001
ddrmn358 remaindernear   4.000001   2    ->  0.000001
ddrmn359 remaindernear   4.0000001   2    ->  1E-7

ddrmn360 remaindernear   1.2   0.7345 -> -0.2690
ddrmn361 remaindernear   0.8   12     ->  0.8
ddrmn362 remaindernear   0.8   0.2    ->  0.0
ddrmn363 remaindernear   0.8   0.3    -> -0.1
ddrmn364 remaindernear   0.800   12   ->  0.800
ddrmn365 remaindernear   0.800   1.7  ->  0.800
ddrmn366 remaindernear   2.400   2    ->  0.400

-- round to even
ddrmn371 remaindernear   121     2    ->  1
ddrmn372 remaindernear   122     2    ->  0
ddrmn373 remaindernear   123     2    -> -1
ddrmn374 remaindernear   124     2    ->  0
ddrmn375 remaindernear   125     2    ->  1
ddrmn376 remaindernear   126     2    ->  0
ddrmn377 remaindernear   127     2    -> -1

ddrmn381 remaindernear 12345  1         ->  0
ddrmn382 remaindernear 12345  1.0001    -> -0.2344
ddrmn383 remaindernear 12345  1.001     -> -0.333
ddrmn384 remaindernear 12345  1.01      -> -0.23
ddrmn385 remaindernear 12345  1.1       -> -0.3
ddrmn386 remaindernear 12355  4         -> -1
ddrmn387 remaindernear 12345  4         ->  1
ddrmn388 remaindernear 12355  4.0001    -> -1.3089
ddrmn389 remaindernear 12345  4.0001    ->  0.6914
ddrmn390 remaindernear 12345  4.9       ->  1.9
ddrmn391 remaindernear 12345  4.99      -> -0.26
ddrmn392 remaindernear 12345  4.999     ->  2.469
ddrmn393 remaindernear 12345  4.9999    ->  0.2469
ddrmn394 remaindernear 12345  5         ->  0
ddrmn395 remaindernear 12345  5.0001    -> -0.2469
ddrmn396 remaindernear 12345  5.001     -> -2.469
ddrmn397 remaindernear 12345  5.01      ->  0.36
ddrmn398 remaindernear 12345  5.1       -> -2.1

-- the nasty division-by-1 cases
ddrmn401 remaindernear   0.4         1   ->  0.4
ddrmn402 remaindernear   0.45        1   ->  0.45
ddrmn403 remaindernear   0.455       1   ->  0.455
ddrmn404 remaindernear   0.4555      1   ->  0.4555
ddrmn405 remaindernear   0.45555     1   ->  0.45555
ddrmn406 remaindernear   0.455555    1   ->  0.455555
ddrmn407 remaindernear   0.4555555   1   ->  0.4555555
ddrmn408 remaindernear   0.45555555  1   ->  0.45555555
ddrmn409 remaindernear   0.455555555 1   ->  0.455555555
-- with spill... [412 exercises sticktab loop]
ddrmn411 remaindernear   0.5         1   ->  0.5
ddrmn412 remaindernear   0.55        1   -> -0.45
ddrmn413 remaindernear   0.555       1   -> -0.445
ddrmn414 remaindernear   0.5555      1   -> -0.4445
ddrmn415 remaindernear   0.55555     1   -> -0.44445
ddrmn416 remaindernear   0.555555    1   -> -0.444445
ddrmn417 remaindernear   0.5555555   1   -> -0.4444445
ddrmn418 remaindernear   0.55555555  1   -> -0.44444445
ddrmn419 remaindernear   0.555555555 1   -> -0.444444445

-- folddowns
ddrmn421 remaindernear   1E+384       1  ->   NaN Division_impossible
ddrmn422 remaindernear   1E+384  1E+383  ->   0E+369 Clamped
ddrmn423 remaindernear   1E+384  2E+383  ->   0E+369 Clamped
ddrmn424 remaindernear   1E+384  3E+383  ->   1.00000000000000E+383 Clamped
ddrmn425 remaindernear   1E+384  4E+383  ->   2.00000000000000E+383 Clamped
ddrmn426 remaindernear   1E+384  5E+383  ->   0E+369 Clamped
ddrmn427 remaindernear   1E+384  6E+383  ->  -2.00000000000000E+383 Clamped
ddrmn428 remaindernear   1E+384  7E+383  ->   3.00000000000000E+383 Clamped
ddrmn429 remaindernear   1E+384  8E+383  ->   2.00000000000000E+383 Clamped
ddrmn430 remaindernear   1E+384  9E+383  ->   1.00000000000000E+383 Clamped
-- tinies
ddrmn431 remaindernear   1E-397  1E-398  ->   0E-398
ddrmn432 remaindernear   1E-397  2E-398  ->   0E-398
ddrmn433 remaindernear   1E-397  3E-398  ->   1E-398 Subnormal
ddrmn434 remaindernear   1E-397  4E-398  ->   2E-398 Subnormal
ddrmn435 remaindernear   1E-397  5E-398  ->   0E-398
ddrmn436 remaindernear   1E-397  6E-398  ->  -2E-398 Subnormal
ddrmn437 remaindernear   1E-397  7E-398  ->   3E-398 Subnormal
ddrmn438 remaindernear   1E-397  8E-398  ->   2E-398 Subnormal
ddrmn439 remaindernear   1E-397  9E-398  ->   1E-398 Subnormal
ddrmn440 remaindernear   1E-397 10E-398  ->   0E-398
ddrmn441 remaindernear   1E-397 11E-398  ->  -1E-398 Subnormal
ddrmn442 remaindernear 100E-397 11E-398  ->  -1E-398 Subnormal
ddrmn443 remaindernear 100E-397 20E-398  ->   0E-398
ddrmn444 remaindernear 100E-397 21E-398  ->  -8E-398 Subnormal
ddrmn445 remaindernear 100E-397 30E-398  -> 1.0E-397 Subnormal

-- Specials
ddrmn680 remaindernear  Inf  -Inf   ->  NaN Invalid_operation
ddrmn681 remaindernear  Inf  -1000  ->  NaN Invalid_operation
ddrmn682 remaindernear  Inf  -1     ->  NaN Invalid_operation
ddrmn683 remaindernear  Inf   0     ->  NaN Invalid_operation
ddrmn684 remaindernear  Inf  -0     ->  NaN Invalid_operation
ddrmn685 remaindernear  Inf   1     ->  NaN Invalid_operation
ddrmn686 remaindernear  Inf   1000  ->  NaN Invalid_operation
ddrmn687 remaindernear  Inf   Inf   ->  NaN Invalid_operation
ddrmn688 remaindernear -1000  Inf   -> -1000
ddrmn689 remaindernear -Inf   Inf   ->  NaN Invalid_operation
ddrmn691 remaindernear -1     Inf   -> -1
ddrmn692 remaindernear  0     Inf   ->  0
ddrmn693 remaindernear -0     Inf   -> -0
ddrmn694 remaindernear  1     Inf   ->  1
ddrmn695 remaindernear  1000  Inf   ->  1000
ddrmn696 remaindernear  Inf   Inf   ->  NaN Invalid_operation

ddrmn700 remaindernear -Inf  -Inf   ->  NaN Invalid_operation
ddrmn701 remaindernear -Inf  -1000  ->  NaN Invalid_operation
ddrmn702 remaindernear -Inf  -1     ->  NaN Invalid_operation
ddrmn703 remaindernear -Inf  -0     ->  NaN Invalid_operation
ddrmn704 remaindernear -Inf   0     ->  NaN Invalid_operation
ddrmn705 remaindernear -Inf   1     ->  NaN Invalid_operation
ddrmn706 remaindernear -Inf   1000  ->  NaN Invalid_operation
ddrmn707 remaindernear -Inf   Inf   ->  NaN Invalid_operation
ddrmn708 remaindernear -Inf  -Inf   ->  NaN Invalid_operation
ddrmn709 remaindernear -1000  Inf   -> -1000
ddrmn710 remaindernear -1    -Inf   -> -1
ddrmn711 remaindernear -0    -Inf   -> -0
ddrmn712 remaindernear  0    -Inf   ->  0
ddrmn713 remaindernear  1    -Inf   ->  1
ddrmn714 remaindernear  1000 -Inf   ->  1000
ddrmn715 remaindernear  Inf  -Inf   ->  NaN Invalid_operation

ddrmn721 remaindernear  NaN -Inf    ->  NaN
ddrmn722 remaindernear  NaN -1000   ->  NaN
ddrmn723 remaindernear  NaN -1      ->  NaN
ddrmn724 remaindernear  NaN -0      ->  NaN
ddrmn725 remaindernear -NaN  0      -> -NaN
ddrmn726 remaindernear  NaN  1      ->  NaN
ddrmn727 remaindernear  NaN  1000   ->  NaN
ddrmn728 remaindernear  NaN  Inf    ->  NaN
ddrmn729 remaindernear  NaN -NaN    ->  NaN
ddrmn730 remaindernear -Inf  NaN    ->  NaN
ddrmn731 remaindernear -1000 NaN    ->  NaN
ddrmn732 remaindernear -1    NaN    ->  NaN
ddrmn733 remaindernear -0   -NaN    -> -NaN
ddrmn734 remaindernear  0    NaN    ->  NaN
ddrmn735 remaindernear  1   -NaN    -> -NaN
ddrmn736 remaindernear  1000 NaN    ->  NaN
ddrmn737 remaindernear  Inf  NaN    ->  NaN

ddrmn741 remaindernear  sNaN -Inf   ->  NaN  Invalid_operation
ddrmn742 remaindernear  sNaN -1000  ->  NaN  Invalid_operation
ddrmn743 remaindernear -sNaN -1     -> -NaN  Invalid_operation
ddrmn744 remaindernear  sNaN -0     ->  NaN  Invalid_operation
ddrmn745 remaindernear  sNaN  0     ->  NaN  Invalid_operation
ddrmn746 remaindernear  sNaN  1     ->  NaN  Invalid_operation
ddrmn747 remaindernear  sNaN  1000  ->  NaN  Invalid_operation
ddrmn749 remaindernear  sNaN  NaN   ->  NaN  Invalid_operation
ddrmn750 remaindernear  sNaN sNaN   ->  NaN  Invalid_operation
ddrmn751 remaindernear  NaN  sNaN   ->  NaN  Invalid_operation
ddrmn752 remaindernear -Inf  sNaN   ->  NaN  Invalid_operation
ddrmn753 remaindernear -1000 sNaN   ->  NaN  Invalid_operation
ddrmn754 remaindernear -1    sNaN   ->  NaN  Invalid_operation
ddrmn755 remaindernear -0    sNaN   ->  NaN  Invalid_operation
ddrmn756 remaindernear  0    sNaN   ->  NaN  Invalid_operation
ddrmn757 remaindernear  1    sNaN   ->  NaN  Invalid_operation
ddrmn758 remaindernear  1000 sNaN   ->  NaN  Invalid_operation
ddrmn759 remaindernear  Inf -sNaN   -> -NaN  Invalid_operation

-- propaging NaNs
ddrmn760 remaindernear  NaN1   NaN7   ->  NaN1
ddrmn761 remaindernear sNaN2   NaN8   ->  NaN2 Invalid_operation
ddrmn762 remaindernear  NaN3  sNaN9   ->  NaN9 Invalid_operation
ddrmn763 remaindernear sNaN4  sNaN10  ->  NaN4 Invalid_operation
ddrmn764 remaindernear    15   NaN11  ->  NaN11
ddrmn765 remaindernear  NaN6   NaN12  ->  NaN6
ddrmn766 remaindernear  Inf    NaN13  ->  NaN13
ddrmn767 remaindernear  NaN14  -Inf   ->  NaN14
ddrmn768 remaindernear    0    NaN15  ->  NaN15
ddrmn769 remaindernear  NaN16   -0    ->  NaN16

-- edge cases of impossible
ddrmn770  remaindernear  1234567890123456  10    -> -4
ddrmn771  remaindernear  1234567890123456   1    ->  0
ddrmn772  remaindernear  1234567890123456   0.1  ->  NaN Division_impossible
ddrmn773  remaindernear  1234567890123456   0.01 ->  NaN Division_impossible

-- long operand checks
ddrmn801 remaindernear 12345678000 100 -> 0
ddrmn802 remaindernear 1 12345678000   -> 1
ddrmn803 remaindernear 1234567800  10  -> 0
ddrmn804 remaindernear 1 1234567800    -> 1
ddrmn805 remaindernear 1234567890  10  -> 0
ddrmn806 remaindernear 1 1234567890    -> 1
ddrmn807 remaindernear 1234567891  10  -> 1
ddrmn808 remaindernear 1 1234567891    -> 1
ddrmn809 remaindernear 12345678901 100 -> 1
ddrmn810 remaindernear 1 12345678901   -> 1
ddrmn811 remaindernear 1234567896  10  -> -4
ddrmn812 remaindernear 1 1234567896    -> 1

ddrmn821 remaindernear 12345678000 100 -> 0
ddrmn822 remaindernear 1 12345678000   -> 1
ddrmn823 remaindernear 1234567800  10  -> 0
ddrmn824 remaindernear 1 1234567800    -> 1
ddrmn825 remaindernear 1234567890  10  -> 0
ddrmn826 remaindernear 1 1234567890    -> 1
ddrmn827 remaindernear 1234567891  10  -> 1
ddrmn828 remaindernear 1 1234567891    -> 1
ddrmn829 remaindernear 12345678901 100 -> 1
ddrmn830 remaindernear 1 12345678901   -> 1
ddrmn831 remaindernear 1234567896  10  -> -4
ddrmn832 remaindernear 1 1234567896    -> 1

-- from divideint
ddrmn840 remaindernear  100000000.0   1  ->  0.0
ddrmn841 remaindernear  100000000.4   1  ->  0.4
ddrmn842 remaindernear  100000000.5   1  ->  0.5
ddrmn843 remaindernear  100000000.9   1  -> -0.1
ddrmn844 remaindernear  100000000.999 1  -> -0.001
ddrmn850 remaindernear  100000003     5  -> -2
ddrmn851 remaindernear  10000003      5  -> -2
ddrmn852 remaindernear  1000003       5  -> -2
ddrmn853 remaindernear  100003        5  -> -2
ddrmn854 remaindernear  10003         5  -> -2
ddrmn855 remaindernear  1003          5  -> -2
ddrmn856 remaindernear  103           5  -> -2
ddrmn857 remaindernear  13            5  -> -2
ddrmn858 remaindernear  1             5  ->  1

-- Vladimir's cases         1234567890123456
ddrmn860 remaindernear 123.0e1 1000000000000000  -> 1230
ddrmn861 remaindernear 1230    1000000000000000  -> 1230
ddrmn862 remaindernear 12.3e2  1000000000000000  -> 1230
ddrmn863 remaindernear 1.23e3  1000000000000000  -> 1230
ddrmn864 remaindernear 123e1   1000000000000000  -> 1230
ddrmn870 remaindernear 123e1    1000000000000000 -> 1230
ddrmn871 remaindernear 123e1     100000000000000 -> 1230
ddrmn872 remaindernear 123e1      10000000000000 -> 1230
ddrmn873 remaindernear 123e1       1000000000000 -> 1230
ddrmn874 remaindernear 123e1        100000000000 -> 1230
ddrmn875 remaindernear 123e1         10000000000 -> 1230
ddrmn876 remaindernear 123e1          1000000000 -> 1230
ddrmn877 remaindernear 123e1           100000000 -> 1230
ddrmn878 remaindernear 1230            100000000 -> 1230
ddrmn879 remaindernear 123e1            10000000 -> 1230
ddrmn880 remaindernear 123e1             1000000 -> 1230
ddrmn881 remaindernear 123e1              100000 -> 1230
ddrmn882 remaindernear 123e1               10000 -> 1230
ddrmn883 remaindernear 123e1                1000 ->  230
ddrmn884 remaindernear 123e1                 100 ->   30
ddrmn885 remaindernear 123e1                  10 ->    0
ddrmn886 remaindernear 123e1                   1 ->    0

ddrmn890 remaindernear 123e1    2000000000000000 -> 1230
ddrmn891 remaindernear 123e1     200000000000000 -> 1230
ddrmn892 remaindernear 123e1      20000000000000 -> 1230
ddrmn893 remaindernear 123e1       2000000000000 -> 1230
ddrmn894 remaindernear 123e1        200000000000 -> 1230
ddrmn895 remaindernear 123e1         20000000000 -> 1230
ddrmn896 remaindernear 123e1          2000000000 -> 1230
ddrmn897 remaindernear 123e1           200000000 -> 1230
ddrmn899 remaindernear 123e1            20000000 -> 1230
ddrmn900 remaindernear 123e1             2000000 -> 1230
ddrmn901 remaindernear 123e1              200000 -> 1230
ddrmn902 remaindernear 123e1               20000 -> 1230
ddrmn903 remaindernear 123e1                2000 -> -770
ddrmn904 remaindernear 123e1                 200 ->   30
ddrmn905 remaindernear 123e1                  20 ->  -10
ddrmn906 remaindernear 123e1                   2 ->    0

ddrmn910 remaindernear 123e1    5000000000000000 -> 1230
ddrmn911 remaindernear 123e1     500000000000000 -> 1230
ddrmn912 remaindernear 123e1      50000000000000 -> 1230
ddrmn913 remaindernear 123e1       5000000000000 -> 1230
ddrmn914 remaindernear 123e1        500000000000 -> 1230
ddrmn915 remaindernear 123e1         50000000000 -> 1230
ddrmn916 remaindernear 123e1          5000000000 -> 1230
ddrmn917 remaindernear 123e1           500000000 -> 1230
ddrmn919 remaindernear 123e1            50000000 -> 1230
ddrmn920 remaindernear 123e1             5000000 -> 1230
ddrmn921 remaindernear 123e1              500000 -> 1230
ddrmn922 remaindernear 123e1               50000 -> 1230
ddrmn923 remaindernear 123e1                5000 -> 1230
ddrmn924 remaindernear 123e1                 500 ->  230
ddrmn925 remaindernear 123e1                  50 ->  -20
ddrmn926 remaindernear 123e1                   5 ->    0

ddrmn930 remaindernear 123e1    9000000000000000 -> 1230
ddrmn931 remaindernear 123e1     900000000000000 -> 1230
ddrmn932 remaindernear 123e1      90000000000000 -> 1230
ddrmn933 remaindernear 123e1       9000000000000 -> 1230
ddrmn934 remaindernear 123e1        900000000000 -> 1230
ddrmn935 remaindernear 123e1         90000000000 -> 1230
ddrmn936 remaindernear 123e1          9000000000 -> 1230
ddrmn937 remaindernear 123e1           900000000 -> 1230
ddrmn939 remaindernear 123e1            90000000 -> 1230
ddrmn940 remaindernear 123e1             9000000 -> 1230
ddrmn941 remaindernear 123e1              900000 -> 1230
ddrmn942 remaindernear 123e1               90000 -> 1230
ddrmn943 remaindernear 123e1                9000 -> 1230
ddrmn944 remaindernear 123e1                 900 ->  330
ddrmn945 remaindernear 123e1                  90 ->  -30
ddrmn946 remaindernear 123e1                   9 ->   -3

ddrmn950 remaindernear 123e1   1000000000000000 -> 1230
ddrmn961 remaindernear 123e1   2999999999999999 -> 1230
ddrmn962 remaindernear 123e1   3999999999999999 -> 1230
ddrmn963 remaindernear 123e1   4999999999999999 -> 1230
ddrmn964 remaindernear 123e1   5999999999999999 -> 1230
ddrmn965 remaindernear 123e1   6999999999999999 -> 1230
ddrmn966 remaindernear 123e1   7999999999999999 -> 1230
ddrmn967 remaindernear 123e1   8999999999999999 -> 1230
ddrmn968 remaindernear 123e1   9999999999999999 -> 1230
ddrmn969 remaindernear 123e1   9876543210987654 -> 1230

ddrmn980 remaindernear 123e1 1000E299 -> 1.23E+3  -- 123E+1 internally

-- overflow and underflow tests [from divide]
ddrmn1051 remaindernear  1e+277  1e-311 ->  NaN Division_impossible
ddrmn1052 remaindernear  1e+277 -1e-311 ->  NaN Division_impossible
ddrmn1053 remaindernear -1e+277  1e-311 ->  NaN Division_impossible
ddrmn1054 remaindernear -1e+277 -1e-311 ->  NaN Division_impossible
ddrmn1055 remaindernear  1e-277  1e+311 ->  1E-277
ddrmn1056 remaindernear  1e-277 -1e+311 ->  1E-277
ddrmn1057 remaindernear -1e-277  1e+311 -> -1E-277
ddrmn1058 remaindernear -1e-277 -1e+311 -> -1E-277

-- Null tests
ddrmn1000 remaindernear 10  # -> NaN Invalid_operation
ddrmn1001 remaindernear  # 10 -> NaN Invalid_operation

Added test/dectest/ddRotate.decTest.













































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
------------------------------------------------------------------------
-- ddRotate.decTest -- rotate a decDouble coefficient left or right   --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check
ddrot001 rotate                 0    0  ->  0
ddrot002 rotate                 0    2  ->  0
ddrot003 rotate                 1    2  ->  100
ddrot004 rotate                 1   15  ->  1000000000000000
ddrot005 rotate                 1   16  ->  1
ddrot006 rotate                 1   -1  ->  1000000000000000
ddrot007 rotate                 0   -2  ->  0
ddrot008 rotate  1234567890123456   -1  ->  6123456789012345
ddrot009 rotate  1234567890123456   -15 ->  2345678901234561
ddrot010 rotate  1234567890123456   -16 ->  1234567890123456
ddrot011 rotate  9934567890123456   -15 ->  9345678901234569
ddrot012 rotate  9934567890123456   -16 ->  9934567890123456

-- rhs must be an integer
ddrot015 rotate        1    1.5    -> NaN Invalid_operation
ddrot016 rotate        1    1.0    -> NaN Invalid_operation
ddrot017 rotate        1    0.1    -> NaN Invalid_operation
ddrot018 rotate        1    0.0    -> NaN Invalid_operation
ddrot019 rotate        1    1E+1   -> NaN Invalid_operation
ddrot020 rotate        1    1E+99  -> NaN Invalid_operation
ddrot021 rotate        1    Inf    -> NaN Invalid_operation
ddrot022 rotate        1    -Inf   -> NaN Invalid_operation
-- and |rhs| <= precision
ddrot025 rotate        1    -1000  -> NaN Invalid_operation
ddrot026 rotate        1    -17    -> NaN Invalid_operation
ddrot027 rotate        1     17    -> NaN Invalid_operation
ddrot028 rotate        1     1000  -> NaN Invalid_operation

-- full pattern
ddrot030 rotate  1234567890123456         -16  -> 1234567890123456
ddrot031 rotate  1234567890123456         -15  -> 2345678901234561
ddrot032 rotate  1234567890123456         -14  -> 3456789012345612
ddrot033 rotate  1234567890123456         -13  -> 4567890123456123
ddrot034 rotate  1234567890123456         -12  -> 5678901234561234
ddrot035 rotate  1234567890123456         -11  -> 6789012345612345
ddrot036 rotate  1234567890123456         -10  -> 7890123456123456
ddrot037 rotate  1234567890123456         -9   -> 8901234561234567
ddrot038 rotate  1234567890123456         -8   -> 9012345612345678
ddrot039 rotate  1234567890123456         -7   ->  123456123456789
ddrot040 rotate  1234567890123456         -6   -> 1234561234567890
ddrot041 rotate  1234567890123456         -5   -> 2345612345678901
ddrot042 rotate  1234567890123456         -4   -> 3456123456789012
ddrot043 rotate  1234567890123456         -3   -> 4561234567890123
ddrot044 rotate  1234567890123456         -2   -> 5612345678901234
ddrot045 rotate  1234567890123456         -1   -> 6123456789012345
ddrot046 rotate  1234567890123456         -0   -> 1234567890123456

ddrot047 rotate  1234567890123456         +0   -> 1234567890123456
ddrot048 rotate  1234567890123456         +1   -> 2345678901234561
ddrot049 rotate  1234567890123456         +2   -> 3456789012345612
ddrot050 rotate  1234567890123456         +3   -> 4567890123456123
ddrot051 rotate  1234567890123456         +4   -> 5678901234561234
ddrot052 rotate  1234567890123456         +5   -> 6789012345612345
ddrot053 rotate  1234567890123456         +6   -> 7890123456123456
ddrot054 rotate  1234567890123456         +7   -> 8901234561234567
ddrot055 rotate  1234567890123456         +8   -> 9012345612345678
ddrot056 rotate  1234567890123456         +9   ->  123456123456789
ddrot057 rotate  1234567890123456         +10  -> 1234561234567890
ddrot058 rotate  1234567890123456         +11  -> 2345612345678901
ddrot059 rotate  1234567890123456         +12  -> 3456123456789012
ddrot060 rotate  1234567890123456         +13  -> 4561234567890123
ddrot061 rotate  1234567890123456         +14  -> 5612345678901234
ddrot062 rotate  1234567890123456         +15  -> 6123456789012345
ddrot063 rotate  1234567890123456         +16  -> 1234567890123456

-- zeros
ddrot070 rotate  0E-10              +9   ->   0E-10
ddrot071 rotate  0E-10              -9   ->   0E-10
ddrot072 rotate  0.000              +9   ->   0.000
ddrot073 rotate  0.000              -9   ->   0.000
ddrot074 rotate  0E+10              +9   ->   0E+10
ddrot075 rotate  0E+10              -9   ->   0E+10
ddrot076 rotate -0E-10              +9   ->  -0E-10
ddrot077 rotate -0E-10              -9   ->  -0E-10
ddrot078 rotate -0.000              +9   ->  -0.000
ddrot079 rotate -0.000              -9   ->  -0.000
ddrot080 rotate -0E+10              +9   ->  -0E+10
ddrot081 rotate -0E+10              -9   ->  -0E+10

-- Nmax, Nmin, Ntiny
ddrot141 rotate  9.999999999999999E+384     -1  -> 9.999999999999999E+384
ddrot142 rotate  9.999999999999999E+384     -15 -> 9.999999999999999E+384
ddrot143 rotate  9.999999999999999E+384      1  -> 9.999999999999999E+384
ddrot144 rotate  9.999999999999999E+384      15 -> 9.999999999999999E+384
ddrot145 rotate  1E-383                     -1  -> 1.000000000000000E-368
ddrot146 rotate  1E-383                     -15 -> 1.0E-382
ddrot147 rotate  1E-383                      1  -> 1.0E-382
ddrot148 rotate  1E-383                      15 -> 1.000000000000000E-368
ddrot151 rotate  1.000000000000000E-383     -1  -> 1.00000000000000E-384
ddrot152 rotate  1.000000000000000E-383     -15 -> 1E-398
ddrot153 rotate  1.000000000000000E-383      1  -> 1E-398
ddrot154 rotate  1.000000000000000E-383      15 -> 1.00000000000000E-384
ddrot155 rotate  9.000000000000000E-383     -1  -> 9.00000000000000E-384
ddrot156 rotate  9.000000000000000E-383     -15 -> 9E-398
ddrot157 rotate  9.000000000000000E-383      1  -> 9E-398
ddrot158 rotate  9.000000000000000E-383      15 -> 9.00000000000000E-384
ddrot160 rotate  1E-398                     -1  -> 1.000000000000000E-383
ddrot161 rotate  1E-398                     -15 -> 1.0E-397
ddrot162 rotate  1E-398                      1  -> 1.0E-397
ddrot163 rotate  1E-398                      15 -> 1.000000000000000E-383
--  negatives
ddrot171 rotate -9.999999999999999E+384     -1  -> -9.999999999999999E+384
ddrot172 rotate -9.999999999999999E+384     -15 -> -9.999999999999999E+384
ddrot173 rotate -9.999999999999999E+384      1  -> -9.999999999999999E+384
ddrot174 rotate -9.999999999999999E+384      15 -> -9.999999999999999E+384
ddrot175 rotate -1E-383                     -1  -> -1.000000000000000E-368
ddrot176 rotate -1E-383                     -15 -> -1.0E-382
ddrot177 rotate -1E-383                      1  -> -1.0E-382
ddrot178 rotate -1E-383                      15 -> -1.000000000000000E-368
ddrot181 rotate -1.000000000000000E-383     -1  -> -1.00000000000000E-384
ddrot182 rotate -1.000000000000000E-383     -15 -> -1E-398
ddrot183 rotate -1.000000000000000E-383      1  -> -1E-398
ddrot184 rotate -1.000000000000000E-383      15 -> -1.00000000000000E-384
ddrot185 rotate -9.000000000000000E-383     -1  -> -9.00000000000000E-384
ddrot186 rotate -9.000000000000000E-383     -15 -> -9E-398
ddrot187 rotate -9.000000000000000E-383      1  -> -9E-398
ddrot188 rotate -9.000000000000000E-383      15 -> -9.00000000000000E-384
ddrot190 rotate -1E-398                     -1  -> -1.000000000000000E-383
ddrot191 rotate -1E-398                     -15 -> -1.0E-397
ddrot192 rotate -1E-398                      1  -> -1.0E-397
ddrot193 rotate -1E-398                      15 -> -1.000000000000000E-383

-- more negatives (of sanities)
ddrot201 rotate                -0    0  -> -0
ddrot202 rotate                -0    2  -> -0
ddrot203 rotate                -1    2  -> -100
ddrot204 rotate                -1   15  -> -1000000000000000
ddrot205 rotate                -1   16  -> -1
ddrot206 rotate                -1   -1  -> -1000000000000000
ddrot207 rotate                -0   -2  -> -0
ddrot208 rotate -1234567890123456   -1  -> -6123456789012345
ddrot209 rotate -1234567890123456   -15 -> -2345678901234561
ddrot210 rotate -1234567890123456   -16 -> -1234567890123456
ddrot211 rotate -9934567890123456   -15 -> -9345678901234569
ddrot212 rotate -9934567890123456   -16 -> -9934567890123456


-- Specials; NaNs are handled as usual
ddrot781 rotate -Inf  -8     -> -Infinity
ddrot782 rotate -Inf  -1     -> -Infinity
ddrot783 rotate -Inf  -0     -> -Infinity
ddrot784 rotate -Inf   0     -> -Infinity
ddrot785 rotate -Inf   1     -> -Infinity
ddrot786 rotate -Inf   8     -> -Infinity
ddrot787 rotate -1000 -Inf   -> NaN Invalid_operation
ddrot788 rotate -Inf  -Inf   -> NaN Invalid_operation
ddrot789 rotate -1    -Inf   -> NaN Invalid_operation
ddrot790 rotate -0    -Inf   -> NaN Invalid_operation
ddrot791 rotate  0    -Inf   -> NaN Invalid_operation
ddrot792 rotate  1    -Inf   -> NaN Invalid_operation
ddrot793 rotate  1000 -Inf   -> NaN Invalid_operation
ddrot794 rotate  Inf  -Inf   -> NaN Invalid_operation

ddrot800 rotate  Inf  -Inf   -> NaN Invalid_operation
ddrot801 rotate  Inf  -8     -> Infinity
ddrot802 rotate  Inf  -1     -> Infinity
ddrot803 rotate  Inf  -0     -> Infinity
ddrot804 rotate  Inf   0     -> Infinity
ddrot805 rotate  Inf   1     -> Infinity
ddrot806 rotate  Inf   8     -> Infinity
ddrot807 rotate  Inf   Inf   -> NaN Invalid_operation
ddrot808 rotate -1000  Inf   -> NaN Invalid_operation
ddrot809 rotate -Inf   Inf   -> NaN Invalid_operation
ddrot810 rotate -1     Inf   -> NaN Invalid_operation
ddrot811 rotate -0     Inf   -> NaN Invalid_operation
ddrot812 rotate  0     Inf   -> NaN Invalid_operation
ddrot813 rotate  1     Inf   -> NaN Invalid_operation
ddrot814 rotate  1000  Inf   -> NaN Invalid_operation
ddrot815 rotate  Inf   Inf   -> NaN Invalid_operation

ddrot821 rotate  NaN -Inf    ->  NaN
ddrot822 rotate  NaN -1000   ->  NaN
ddrot823 rotate  NaN -1      ->  NaN
ddrot824 rotate  NaN -0      ->  NaN
ddrot825 rotate  NaN  0      ->  NaN
ddrot826 rotate  NaN  1      ->  NaN
ddrot827 rotate  NaN  1000   ->  NaN
ddrot828 rotate  NaN  Inf    ->  NaN
ddrot829 rotate  NaN  NaN    ->  NaN
ddrot830 rotate -Inf  NaN    ->  NaN
ddrot831 rotate -1000 NaN    ->  NaN
ddrot832 rotate -1    NaN    ->  NaN
ddrot833 rotate -0    NaN    ->  NaN
ddrot834 rotate  0    NaN    ->  NaN
ddrot835 rotate  1    NaN    ->  NaN
ddrot836 rotate  1000 NaN    ->  NaN
ddrot837 rotate  Inf  NaN    ->  NaN

ddrot841 rotate  sNaN -Inf   ->  NaN  Invalid_operation
ddrot842 rotate  sNaN -1000  ->  NaN  Invalid_operation
ddrot843 rotate  sNaN -1     ->  NaN  Invalid_operation
ddrot844 rotate  sNaN -0     ->  NaN  Invalid_operation
ddrot845 rotate  sNaN  0     ->  NaN  Invalid_operation
ddrot846 rotate  sNaN  1     ->  NaN  Invalid_operation
ddrot847 rotate  sNaN  1000  ->  NaN  Invalid_operation
ddrot848 rotate  sNaN  NaN   ->  NaN  Invalid_operation
ddrot849 rotate  sNaN sNaN   ->  NaN  Invalid_operation
ddrot850 rotate  NaN  sNaN   ->  NaN  Invalid_operation
ddrot851 rotate -Inf  sNaN   ->  NaN  Invalid_operation
ddrot852 rotate -1000 sNaN   ->  NaN  Invalid_operation
ddrot853 rotate -1    sNaN   ->  NaN  Invalid_operation
ddrot854 rotate -0    sNaN   ->  NaN  Invalid_operation
ddrot855 rotate  0    sNaN   ->  NaN  Invalid_operation
ddrot856 rotate  1    sNaN   ->  NaN  Invalid_operation
ddrot857 rotate  1000 sNaN   ->  NaN  Invalid_operation
ddrot858 rotate  Inf  sNaN   ->  NaN  Invalid_operation
ddrot859 rotate  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddrot861 rotate  NaN1   -Inf    ->  NaN1
ddrot862 rotate +NaN2   -1000   ->  NaN2
ddrot863 rotate  NaN3    1000   ->  NaN3
ddrot864 rotate  NaN4    Inf    ->  NaN4
ddrot865 rotate  NaN5   +NaN6   ->  NaN5
ddrot866 rotate -Inf     NaN7   ->  NaN7
ddrot867 rotate -1000    NaN8   ->  NaN8
ddrot868 rotate  1000    NaN9   ->  NaN9
ddrot869 rotate  Inf    +NaN10  ->  NaN10
ddrot871 rotate  sNaN11  -Inf   ->  NaN11  Invalid_operation
ddrot872 rotate  sNaN12  -1000  ->  NaN12  Invalid_operation
ddrot873 rotate  sNaN13   1000  ->  NaN13  Invalid_operation
ddrot874 rotate  sNaN14   NaN17 ->  NaN14  Invalid_operation
ddrot875 rotate  sNaN15  sNaN18 ->  NaN15  Invalid_operation
ddrot876 rotate  NaN16   sNaN19 ->  NaN19  Invalid_operation
ddrot877 rotate -Inf    +sNaN20 ->  NaN20  Invalid_operation
ddrot878 rotate -1000    sNaN21 ->  NaN21  Invalid_operation
ddrot879 rotate  1000    sNaN22 ->  NaN22  Invalid_operation
ddrot880 rotate  Inf     sNaN23 ->  NaN23  Invalid_operation
ddrot881 rotate +NaN25  +sNaN24 ->  NaN24  Invalid_operation
ddrot882 rotate -NaN26    NaN28 -> -NaN26
ddrot883 rotate -sNaN27  sNaN29 -> -NaN27  Invalid_operation
ddrot884 rotate  1000    -NaN30 -> -NaN30
ddrot885 rotate  1000   -sNaN31 -> -NaN31  Invalid_operation

Added test/dectest/ddSameQuantum.decTest.











































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
------------------------------------------------------------------------
-- ddSameQuantum.decTest -- check decDouble quantums match            --
-- Copyright (c) IBM Corporation, 2001, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decDoubles.
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

ddsamq001 samequantum  0      0      ->  1
ddsamq002 samequantum  0      1      ->  1
ddsamq003 samequantum  1      0      ->  1
ddsamq004 samequantum  1      1      ->  1

ddsamq011 samequantum  10     1E+1   -> 0
ddsamq012 samequantum  10E+1  10E+1  -> 1
ddsamq013 samequantum  100    10E+1  -> 0
ddsamq014 samequantum  100    1E+2   -> 0
ddsamq015 samequantum  0.1    1E-2   -> 0
ddsamq016 samequantum  0.1    1E-1   -> 1
ddsamq017 samequantum  0.1    1E-0   -> 0
ddsamq018 samequantum  999    999    -> 1
ddsamq019 samequantum  999E-1 99.9   -> 1
ddsamq020 samequantum  111E-1 22.2   -> 1
ddsamq021 samequantum  111E-1 1234.2 -> 1

-- zeros
ddsamq030 samequantum  0.0    1.1    -> 1
ddsamq031 samequantum  0.0    1.11   -> 0
ddsamq032 samequantum  0.0    0      -> 0
ddsamq033 samequantum  0.0    0.0    -> 1
ddsamq034 samequantum  0.0    0.00   -> 0
ddsamq035 samequantum  0E+1   0E+0   -> 0
ddsamq036 samequantum  0E+1   0E+1   -> 1
ddsamq037 samequantum  0E+1   0E+2   -> 0
ddsamq038 samequantum  0E-17  0E-16  -> 0
ddsamq039 samequantum  0E-17  0E-17  -> 1
ddsamq040 samequantum  0E-17  0E-18  -> 0
ddsamq041 samequantum  0E-17  0.0E-15 -> 0
ddsamq042 samequantum  0E-17  0.0E-16 -> 1
ddsamq043 samequantum  0E-17  0.0E-17 -> 0
ddsamq044 samequantum -0E-17  0.0E-16 -> 1
ddsamq045 samequantum  0E-17 -0.0E-17 -> 0
ddsamq046 samequantum  0E-17 -0.0E-16 -> 1
ddsamq047 samequantum -0E-17  0.0E-17 -> 0
ddsamq048 samequantum -0E-17 -0.0E-16 -> 1
ddsamq049 samequantum -0E-17 -0.0E-17 -> 0

-- Nmax, Nmin, Ntiny
ddsamq051 samequantum  9.999999999999999E+384    9.999999999999999E+384  -> 1
ddsamq052 samequantum  1E-383             1E-383           -> 1
ddsamq053 samequantum  1.000000000000000E-383    1.000000000000000E-383  -> 1
ddsamq054 samequantum  1E-398             1E-398           -> 1
ddsamq055 samequantum  9.999999999999999E+384    9.999999999999999E+384  -> 1
ddsamq056 samequantum  1E-383             1E-383           -> 1
ddsamq057 samequantum  1.000000000000000E-383    1.000000000000000E-383  -> 1
ddsamq058 samequantum  1E-398             1E-398           -> 1

ddsamq061 samequantum  -1E-398            -1E-398          -> 1
ddsamq062 samequantum  -1.000000000000000E-383   -1.000000000000000E-383 -> 1
ddsamq063 samequantum  -1E-383            -1E-383          -> 1
ddsamq064 samequantum  -9.999999999999999E+384   -9.999999999999999E+384 -> 1
ddsamq065 samequantum  -1E-398            -1E-398          -> 1
ddsamq066 samequantum  -1.000000000000000E-383   -1.000000000000000E-383 -> 1
ddsamq067 samequantum  -1E-383            -1E-383          -> 1
ddsamq068 samequantum  -9.999999999999999E+384   -9.999999999999999E+384 -> 1

ddsamq071 samequantum  -4E-398            -1E-398          -> 1
ddsamq072 samequantum  -4.000000000000000E-383   -1.000040000000000E-383 -> 1
ddsamq073 samequantum  -4E-383            -1E-383          -> 1
ddsamq074 samequantum  -4.999999999999999E+384   -9.999999999949999E+384 -> 1
ddsamq075 samequantum  -4E-398            -1E-398          -> 1
ddsamq076 samequantum  -4.000000000000000E-383   -1.004000000000000E-383 -> 1
ddsamq077 samequantum  -4E-383            -1E-383          -> 1
ddsamq078 samequantum  -4.999999999999999E+384   -9.949999999999999E+384 -> 1

ddsamq081 samequantum  -4E-397            -1E-398          -> 0
ddsamq082 samequantum  -4.000000000000000E-383   -1.000040000000000E-336 -> 0
ddsamq083 samequantum  -4E-346            -1E-383          -> 0
ddsamq084 samequantum  -4.999999999999999E+384   -9.999499999999999E+336 -> 0
ddsamq085 samequantum  -4E-397            -1E-398          -> 0
ddsamq086 samequantum  -4.000000000000000E-383   -1.004000000000000E-336 -> 0
ddsamq087 samequantum  -4E-346            -1E-383          -> 0
ddsamq088 samequantum  -4.999999999999999E+384   -9.949999999999999E+336 -> 0

-- specials & combinations
ddsamq0110 samequantum  -Inf    -Inf   -> 1
ddsamq0111 samequantum  -Inf     Inf   -> 1
ddsamq0112 samequantum  -Inf     NaN   -> 0
ddsamq0113 samequantum  -Inf    -7E+3  -> 0
ddsamq0114 samequantum  -Inf    -7     -> 0
ddsamq0115 samequantum  -Inf    -7E-3  -> 0
ddsamq0116 samequantum  -Inf    -0E-3  -> 0
ddsamq0117 samequantum  -Inf    -0     -> 0
ddsamq0118 samequantum  -Inf    -0E+3  -> 0
ddsamq0119 samequantum  -Inf     0E-3  -> 0
ddsamq0120 samequantum  -Inf     0     -> 0
ddsamq0121 samequantum  -Inf     0E+3  -> 0
ddsamq0122 samequantum  -Inf     7E-3  -> 0
ddsamq0123 samequantum  -Inf     7     -> 0
ddsamq0124 samequantum  -Inf     7E+3  -> 0
ddsamq0125 samequantum  -Inf     sNaN  -> 0

ddsamq0210 samequantum   Inf    -Inf   -> 1
ddsamq0211 samequantum   Inf     Inf   -> 1
ddsamq0212 samequantum   Inf     NaN   -> 0
ddsamq0213 samequantum   Inf    -7E+3  -> 0
ddsamq0214 samequantum   Inf    -7     -> 0
ddsamq0215 samequantum   Inf    -7E-3  -> 0
ddsamq0216 samequantum   Inf    -0E-3  -> 0
ddsamq0217 samequantum   Inf    -0     -> 0
ddsamq0218 samequantum   Inf    -0E+3  -> 0
ddsamq0219 samequantum   Inf     0E-3  -> 0
ddsamq0220 samequantum   Inf     0     -> 0
ddsamq0221 samequantum   Inf     0E+3  -> 0
ddsamq0222 samequantum   Inf     7E-3  -> 0
ddsamq0223 samequantum   Inf     7     -> 0
ddsamq0224 samequantum   Inf     7E+3  -> 0
ddsamq0225 samequantum   Inf     sNaN  -> 0

ddsamq0310 samequantum   NaN    -Inf   -> 0
ddsamq0311 samequantum   NaN     Inf   -> 0
ddsamq0312 samequantum   NaN     NaN   -> 1
ddsamq0313 samequantum   NaN    -7E+3  -> 0
ddsamq0314 samequantum   NaN    -7     -> 0
ddsamq0315 samequantum   NaN    -7E-3  -> 0
ddsamq0316 samequantum   NaN    -0E-3  -> 0
ddsamq0317 samequantum   NaN    -0     -> 0
ddsamq0318 samequantum   NaN    -0E+3  -> 0
ddsamq0319 samequantum   NaN     0E-3  -> 0
ddsamq0320 samequantum   NaN     0     -> 0
ddsamq0321 samequantum   NaN     0E+3  -> 0
ddsamq0322 samequantum   NaN     7E-3  -> 0
ddsamq0323 samequantum   NaN     7     -> 0
ddsamq0324 samequantum   NaN     7E+3  -> 0
ddsamq0325 samequantum   NaN     sNaN  -> 1

ddsamq0410 samequantum  -7E+3    -Inf   -> 0
ddsamq0411 samequantum  -7E+3     Inf   -> 0
ddsamq0412 samequantum  -7E+3     NaN   -> 0
ddsamq0413 samequantum  -7E+3    -7E+3  -> 1
ddsamq0414 samequantum  -7E+3    -7     -> 0
ddsamq0415 samequantum  -7E+3    -7E-3  -> 0
ddsamq0416 samequantum  -7E+3    -0E-3  -> 0
ddsamq0417 samequantum  -7E+3    -0     -> 0
ddsamq0418 samequantum  -7E+3    -0E+3  -> 1
ddsamq0419 samequantum  -7E+3     0E-3  -> 0
ddsamq0420 samequantum  -7E+3     0     -> 0
ddsamq0421 samequantum  -7E+3     0E+3  -> 1
ddsamq0422 samequantum  -7E+3     7E-3  -> 0
ddsamq0423 samequantum  -7E+3     7     -> 0
ddsamq0424 samequantum  -7E+3     7E+3  -> 1
ddsamq0425 samequantum  -7E+3     sNaN  -> 0

ddsamq0510 samequantum  -7      -Inf   -> 0
ddsamq0511 samequantum  -7       Inf   -> 0
ddsamq0512 samequantum  -7       NaN   -> 0
ddsamq0513 samequantum  -7      -7E+3  -> 0
ddsamq0514 samequantum  -7      -7     -> 1
ddsamq0515 samequantum  -7      -7E-3  -> 0
ddsamq0516 samequantum  -7      -0E-3  -> 0
ddsamq0517 samequantum  -7      -0     -> 1
ddsamq0518 samequantum  -7      -0E+3  -> 0
ddsamq0519 samequantum  -7       0E-3  -> 0
ddsamq0520 samequantum  -7       0     -> 1
ddsamq0521 samequantum  -7       0E+3  -> 0
ddsamq0522 samequantum  -7       7E-3  -> 0
ddsamq0523 samequantum  -7       7     -> 1
ddsamq0524 samequantum  -7       7E+3  -> 0
ddsamq0525 samequantum  -7       sNaN  -> 0

ddsamq0610 samequantum  -7E-3    -Inf   -> 0
ddsamq0611 samequantum  -7E-3     Inf   -> 0
ddsamq0612 samequantum  -7E-3     NaN   -> 0
ddsamq0613 samequantum  -7E-3    -7E+3  -> 0
ddsamq0614 samequantum  -7E-3    -7     -> 0
ddsamq0615 samequantum  -7E-3    -7E-3  -> 1
ddsamq0616 samequantum  -7E-3    -0E-3  -> 1
ddsamq0617 samequantum  -7E-3    -0     -> 0
ddsamq0618 samequantum  -7E-3    -0E+3  -> 0
ddsamq0619 samequantum  -7E-3     0E-3  -> 1
ddsamq0620 samequantum  -7E-3     0     -> 0
ddsamq0621 samequantum  -7E-3     0E+3  -> 0
ddsamq0622 samequantum  -7E-3     7E-3  -> 1
ddsamq0623 samequantum  -7E-3     7     -> 0
ddsamq0624 samequantum  -7E-3     7E+3  -> 0
ddsamq0625 samequantum  -7E-3     sNaN  -> 0

ddsamq0710 samequantum  -0E-3    -Inf   -> 0
ddsamq0711 samequantum  -0E-3     Inf   -> 0
ddsamq0712 samequantum  -0E-3     NaN   -> 0
ddsamq0713 samequantum  -0E-3    -7E+3  -> 0
ddsamq0714 samequantum  -0E-3    -7     -> 0
ddsamq0715 samequantum  -0E-3    -7E-3  -> 1
ddsamq0716 samequantum  -0E-3    -0E-3  -> 1
ddsamq0717 samequantum  -0E-3    -0     -> 0
ddsamq0718 samequantum  -0E-3    -0E+3  -> 0
ddsamq0719 samequantum  -0E-3     0E-3  -> 1
ddsamq0720 samequantum  -0E-3     0     -> 0
ddsamq0721 samequantum  -0E-3     0E+3  -> 0
ddsamq0722 samequantum  -0E-3     7E-3  -> 1
ddsamq0723 samequantum  -0E-3     7     -> 0
ddsamq0724 samequantum  -0E-3     7E+3  -> 0
ddsamq0725 samequantum  -0E-3     sNaN  -> 0

ddsamq0810 samequantum  -0      -Inf   -> 0
ddsamq0811 samequantum  -0       Inf   -> 0
ddsamq0812 samequantum  -0       NaN   -> 0
ddsamq0813 samequantum  -0      -7E+3  -> 0
ddsamq0814 samequantum  -0      -7     -> 1
ddsamq0815 samequantum  -0      -7E-3  -> 0
ddsamq0816 samequantum  -0      -0E-3  -> 0
ddsamq0817 samequantum  -0      -0     -> 1
ddsamq0818 samequantum  -0      -0E+3  -> 0
ddsamq0819 samequantum  -0       0E-3  -> 0
ddsamq0820 samequantum  -0       0     -> 1
ddsamq0821 samequantum  -0       0E+3  -> 0
ddsamq0822 samequantum  -0       7E-3  -> 0
ddsamq0823 samequantum  -0       7     -> 1
ddsamq0824 samequantum  -0       7E+3  -> 0
ddsamq0825 samequantum  -0       sNaN  -> 0

ddsamq0910 samequantum  -0E+3    -Inf   -> 0
ddsamq0911 samequantum  -0E+3     Inf   -> 0
ddsamq0912 samequantum  -0E+3     NaN   -> 0
ddsamq0913 samequantum  -0E+3    -7E+3  -> 1
ddsamq0914 samequantum  -0E+3    -7     -> 0
ddsamq0915 samequantum  -0E+3    -7E-3  -> 0
ddsamq0916 samequantum  -0E+3    -0E-3  -> 0
ddsamq0917 samequantum  -0E+3    -0     -> 0
ddsamq0918 samequantum  -0E+3    -0E+3  -> 1
ddsamq0919 samequantum  -0E+3     0E-3  -> 0
ddsamq0920 samequantum  -0E+3     0     -> 0
ddsamq0921 samequantum  -0E+3     0E+3  -> 1
ddsamq0922 samequantum  -0E+3     7E-3  -> 0
ddsamq0923 samequantum  -0E+3     7     -> 0
ddsamq0924 samequantum  -0E+3     7E+3  -> 1
ddsamq0925 samequantum  -0E+3     sNaN  -> 0

ddsamq1110 samequantum  0E-3    -Inf   -> 0
ddsamq1111 samequantum  0E-3     Inf   -> 0
ddsamq1112 samequantum  0E-3     NaN   -> 0
ddsamq1113 samequantum  0E-3    -7E+3  -> 0
ddsamq1114 samequantum  0E-3    -7     -> 0
ddsamq1115 samequantum  0E-3    -7E-3  -> 1
ddsamq1116 samequantum  0E-3    -0E-3  -> 1
ddsamq1117 samequantum  0E-3    -0     -> 0
ddsamq1118 samequantum  0E-3    -0E+3  -> 0
ddsamq1119 samequantum  0E-3     0E-3  -> 1
ddsamq1120 samequantum  0E-3     0     -> 0
ddsamq1121 samequantum  0E-3     0E+3  -> 0
ddsamq1122 samequantum  0E-3     7E-3  -> 1
ddsamq1123 samequantum  0E-3     7     -> 0
ddsamq1124 samequantum  0E-3     7E+3  -> 0
ddsamq1125 samequantum  0E-3     sNaN  -> 0

ddsamq1210 samequantum  0       -Inf   -> 0
ddsamq1211 samequantum  0        Inf   -> 0
ddsamq1212 samequantum  0        NaN   -> 0
ddsamq1213 samequantum  0       -7E+3  -> 0
ddsamq1214 samequantum  0       -7     -> 1
ddsamq1215 samequantum  0       -7E-3  -> 0
ddsamq1216 samequantum  0       -0E-3  -> 0
ddsamq1217 samequantum  0       -0     -> 1
ddsamq1218 samequantum  0       -0E+3  -> 0
ddsamq1219 samequantum  0        0E-3  -> 0
ddsamq1220 samequantum  0        0     -> 1
ddsamq1221 samequantum  0        0E+3  -> 0
ddsamq1222 samequantum  0        7E-3  -> 0
ddsamq1223 samequantum  0        7     -> 1
ddsamq1224 samequantum  0        7E+3  -> 0
ddsamq1225 samequantum  0        sNaN  -> 0

ddsamq1310 samequantum  0E+3    -Inf   -> 0
ddsamq1311 samequantum  0E+3     Inf   -> 0
ddsamq1312 samequantum  0E+3     NaN   -> 0
ddsamq1313 samequantum  0E+3    -7E+3  -> 1
ddsamq1314 samequantum  0E+3    -7     -> 0
ddsamq1315 samequantum  0E+3    -7E-3  -> 0
ddsamq1316 samequantum  0E+3    -0E-3  -> 0
ddsamq1317 samequantum  0E+3    -0     -> 0
ddsamq1318 samequantum  0E+3    -0E+3  -> 1
ddsamq1319 samequantum  0E+3     0E-3  -> 0
ddsamq1320 samequantum  0E+3     0     -> 0
ddsamq1321 samequantum  0E+3     0E+3  -> 1
ddsamq1322 samequantum  0E+3     7E-3  -> 0
ddsamq1323 samequantum  0E+3     7     -> 0
ddsamq1324 samequantum  0E+3     7E+3  -> 1
ddsamq1325 samequantum  0E+3     sNaN  -> 0

ddsamq1410 samequantum  7E-3    -Inf   -> 0
ddsamq1411 samequantum  7E-3     Inf   -> 0
ddsamq1412 samequantum  7E-3     NaN   -> 0
ddsamq1413 samequantum  7E-3    -7E+3  -> 0
ddsamq1414 samequantum  7E-3    -7     -> 0
ddsamq1415 samequantum  7E-3    -7E-3  -> 1
ddsamq1416 samequantum  7E-3    -0E-3  -> 1
ddsamq1417 samequantum  7E-3    -0     -> 0
ddsamq1418 samequantum  7E-3    -0E+3  -> 0
ddsamq1419 samequantum  7E-3     0E-3  -> 1
ddsamq1420 samequantum  7E-3     0     -> 0
ddsamq1421 samequantum  7E-3     0E+3  -> 0
ddsamq1422 samequantum  7E-3     7E-3  -> 1
ddsamq1423 samequantum  7E-3     7     -> 0
ddsamq1424 samequantum  7E-3     7E+3  -> 0
ddsamq1425 samequantum  7E-3     sNaN  -> 0

ddsamq1510 samequantum  7      -Inf   -> 0
ddsamq1511 samequantum  7       Inf   -> 0
ddsamq1512 samequantum  7       NaN   -> 0
ddsamq1513 samequantum  7      -7E+3  -> 0
ddsamq1514 samequantum  7      -7     -> 1
ddsamq1515 samequantum  7      -7E-3  -> 0
ddsamq1516 samequantum  7      -0E-3  -> 0
ddsamq1517 samequantum  7      -0     -> 1
ddsamq1518 samequantum  7      -0E+3  -> 0
ddsamq1519 samequantum  7       0E-3  -> 0
ddsamq1520 samequantum  7       0     -> 1
ddsamq1521 samequantum  7       0E+3  -> 0
ddsamq1522 samequantum  7       7E-3  -> 0
ddsamq1523 samequantum  7       7     -> 1
ddsamq1524 samequantum  7       7E+3  -> 0
ddsamq1525 samequantum  7       sNaN  -> 0

ddsamq1610 samequantum  7E+3    -Inf   -> 0
ddsamq1611 samequantum  7E+3     Inf   -> 0
ddsamq1612 samequantum  7E+3     NaN   -> 0
ddsamq1613 samequantum  7E+3    -7E+3  -> 1
ddsamq1614 samequantum  7E+3    -7     -> 0
ddsamq1615 samequantum  7E+3    -7E-3  -> 0
ddsamq1616 samequantum  7E+3    -0E-3  -> 0
ddsamq1617 samequantum  7E+3    -0     -> 0
ddsamq1618 samequantum  7E+3    -0E+3  -> 1
ddsamq1619 samequantum  7E+3     0E-3  -> 0
ddsamq1620 samequantum  7E+3     0     -> 0
ddsamq1621 samequantum  7E+3     0E+3  -> 1
ddsamq1622 samequantum  7E+3     7E-3  -> 0
ddsamq1623 samequantum  7E+3     7     -> 0
ddsamq1624 samequantum  7E+3     7E+3  -> 1
ddsamq1625 samequantum  7E+3     sNaN  -> 0

ddsamq1710 samequantum  sNaN    -Inf   -> 0
ddsamq1711 samequantum  sNaN     Inf   -> 0
ddsamq1712 samequantum  sNaN     NaN   -> 1
ddsamq1713 samequantum  sNaN    -7E+3  -> 0
ddsamq1714 samequantum  sNaN    -7     -> 0
ddsamq1715 samequantum  sNaN    -7E-3  -> 0
ddsamq1716 samequantum  sNaN    -0E-3  -> 0
ddsamq1717 samequantum  sNaN    -0     -> 0
ddsamq1718 samequantum  sNaN    -0E+3  -> 0
ddsamq1719 samequantum  sNaN     0E-3  -> 0
ddsamq1720 samequantum  sNaN     0     -> 0
ddsamq1721 samequantum  sNaN     0E+3  -> 0
ddsamq1722 samequantum  sNaN     7E-3  -> 0
ddsamq1723 samequantum  sNaN     7     -> 0
ddsamq1724 samequantum  sNaN     7E+3  -> 0
ddsamq1725 samequantum  sNaN     sNaN  -> 1
-- noisy NaNs
ddsamq1730 samequantum  sNaN3    sNaN3 -> 1
ddsamq1731 samequantum  sNaN3    sNaN4 -> 1
ddsamq1732 samequantum   NaN3     NaN3 -> 1
ddsamq1733 samequantum   NaN3     NaN4 -> 1
ddsamq1734 samequantum  sNaN3     3    -> 0
ddsamq1735 samequantum   NaN3     3    -> 0
ddsamq1736 samequantum      4    sNaN4 -> 0
ddsamq1737 samequantum      3     NaN3 -> 0
ddsamq1738 samequantum    Inf    sNaN4 -> 0
ddsamq1739 samequantum   -Inf     NaN3 -> 0

Added test/dectest/ddScaleB.decTest.







































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
------------------------------------------------------------------------
-- ddScalebB.decTest -- scale a decDouble by powers of 10             --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Max |rhs| is 2*(384+16) = 800

-- Sanity checks
ddscb001 scaleb       7.50   10 -> 7.50E+10
ddscb002 scaleb       7.50    3 -> 7.50E+3
ddscb003 scaleb       7.50    2 -> 750
ddscb004 scaleb       7.50    1 -> 75.0
ddscb005 scaleb       7.50    0 -> 7.50
ddscb006 scaleb       7.50   -1 -> 0.750
ddscb007 scaleb       7.50   -2 -> 0.0750
ddscb008 scaleb       7.50  -10 -> 7.50E-10
ddscb009 scaleb      -7.50    3 -> -7.50E+3
ddscb010 scaleb      -7.50    2 -> -750
ddscb011 scaleb      -7.50    1 -> -75.0
ddscb012 scaleb      -7.50    0 -> -7.50
ddscb013 scaleb      -7.50   -1 -> -0.750

-- Infinities
ddscb014 scaleb  Infinity   1 -> Infinity
ddscb015 scaleb  -Infinity  2 -> -Infinity
ddscb016 scaleb  Infinity  -1 -> Infinity
ddscb017 scaleb  -Infinity -2 -> -Infinity

-- Next two are somewhat undefined in 754r; treat as non-integer
ddscb018 scaleb  10  Infinity -> NaN Invalid_operation
ddscb019 scaleb  10 -Infinity -> NaN Invalid_operation

-- NaNs are undefined in 754r; assume usual processing
-- NaNs, 0 payload
ddscb021 scaleb         NaN  1 -> NaN
ddscb022 scaleb        -NaN -1 -> -NaN
ddscb023 scaleb        sNaN  1 -> NaN Invalid_operation
ddscb024 scaleb       -sNaN  1 -> -NaN Invalid_operation
ddscb025 scaleb    4    NaN    -> NaN
ddscb026 scaleb -Inf   -NaN    -> -NaN
ddscb027 scaleb    4   sNaN    -> NaN Invalid_operation
ddscb028 scaleb  Inf  -sNaN    -> -NaN Invalid_operation

-- non-integer RHS
ddscb030 scaleb  1.23    1    ->  12.3
ddscb031 scaleb  1.23    1.00 ->  NaN Invalid_operation
ddscb032 scaleb  1.23    1.1  ->  NaN Invalid_operation
ddscb033 scaleb  1.23    1.01 ->  NaN Invalid_operation
ddscb034 scaleb  1.23    0.01 ->  NaN Invalid_operation
ddscb035 scaleb  1.23    0.11 ->  NaN Invalid_operation
ddscb036 scaleb  1.23    0.999999999 ->  NaN Invalid_operation
ddscb037 scaleb  1.23   -1    ->  0.123
ddscb038 scaleb  1.23   -1.00 ->  NaN Invalid_operation
ddscb039 scaleb  1.23   -1.1  ->  NaN Invalid_operation
ddscb040 scaleb  1.23   -1.01 ->  NaN Invalid_operation
ddscb041 scaleb  1.23   -0.01 ->  NaN Invalid_operation
ddscb042 scaleb  1.23   -0.11 ->  NaN Invalid_operation
ddscb043 scaleb  1.23   -0.999999999 ->  NaN Invalid_operation
ddscb044 scaleb  1.23    0.1         ->  NaN Invalid_operation
ddscb045 scaleb  1.23    1E+1        ->  NaN Invalid_operation
ddscb046 scaleb  1.23    1.1234E+6   ->  NaN Invalid_operation
ddscb047 scaleb  1.23    1.123E+4    ->  NaN Invalid_operation

-- out-of range RHS
ddscb120 scaleb  1.23    799         ->  Infinity Overflow Inexact Rounded
ddscb121 scaleb  1.23    800         ->  Infinity Overflow Inexact Rounded
ddscb122 scaleb  1.23    801         ->  NaN Invalid_operation
ddscb123 scaleb  1.23    802         ->  NaN Invalid_operation
ddscb124 scaleb  1.23   -799         ->  0E-398 Underflow Subnormal Inexact Rounded Clamped
ddscb125 scaleb  1.23   -800         ->  0E-398 Underflow Subnormal Inexact Rounded Clamped
ddscb126 scaleb  1.23   -801         ->  NaN Invalid_operation
ddscb127 scaleb  1.23   -802         ->  NaN Invalid_operation

-- NaNs, non-0 payload
-- propagating NaNs
ddscb861 scaleb  NaN01   -Inf     ->  NaN1
ddscb862 scaleb -NaN02   -1000    -> -NaN2
ddscb863 scaleb  NaN03    1000    ->  NaN3
ddscb864 scaleb  NaN04    Inf     ->  NaN4
ddscb865 scaleb  NaN05    NaN61   ->  NaN5
ddscb866 scaleb -Inf     -NaN71   -> -NaN71
ddscb867 scaleb -1000     NaN81   ->  NaN81
ddscb868 scaleb  1000     NaN91   ->  NaN91
ddscb869 scaleb  Inf      NaN101  ->  NaN101
ddscb871 scaleb  sNaN011  -Inf    ->  NaN11  Invalid_operation
ddscb872 scaleb  sNaN012  -1000   ->  NaN12  Invalid_operation
ddscb873 scaleb -sNaN013   1000   -> -NaN13  Invalid_operation
ddscb874 scaleb  sNaN014   NaN171 ->  NaN14  Invalid_operation
ddscb875 scaleb  sNaN015  sNaN181 ->  NaN15  Invalid_operation
ddscb876 scaleb  NaN016   sNaN191 ->  NaN191 Invalid_operation
ddscb877 scaleb -Inf      sNaN201 ->  NaN201 Invalid_operation
ddscb878 scaleb -1000     sNaN211 ->  NaN211 Invalid_operation
ddscb879 scaleb  1000    -sNaN221 -> -NaN221 Invalid_operation
ddscb880 scaleb  Inf      sNaN231 ->  NaN231 Invalid_operation
ddscb881 scaleb  NaN025   sNaN241 ->  NaN241 Invalid_operation

-- finites
ddscb051 scaleb          7   -2  -> 0.07
ddscb052 scaleb         -7   -2  -> -0.07
ddscb053 scaleb         75   -2  -> 0.75
ddscb054 scaleb        -75   -2  -> -0.75
ddscb055 scaleb       7.50   -2  -> 0.0750
ddscb056 scaleb      -7.50   -2  -> -0.0750
ddscb057 scaleb       7.500  -2  -> 0.07500
ddscb058 scaleb      -7.500  -2  -> -0.07500
ddscb061 scaleb          7   -1  -> 0.7
ddscb062 scaleb         -7   -1  -> -0.7
ddscb063 scaleb         75   -1  -> 7.5
ddscb064 scaleb        -75   -1  -> -7.5
ddscb065 scaleb       7.50   -1  -> 0.750
ddscb066 scaleb      -7.50   -1  -> -0.750
ddscb067 scaleb       7.500  -1  -> 0.7500
ddscb068 scaleb      -7.500  -1  -> -0.7500
ddscb071 scaleb          7    0  -> 7
ddscb072 scaleb         -7    0  -> -7
ddscb073 scaleb         75    0  -> 75
ddscb074 scaleb        -75    0  -> -75
ddscb075 scaleb       7.50    0  -> 7.50
ddscb076 scaleb      -7.50    0  -> -7.50
ddscb077 scaleb       7.500   0  -> 7.500
ddscb078 scaleb      -7.500   0  -> -7.500
ddscb081 scaleb          7    1  -> 7E+1
ddscb082 scaleb         -7    1  -> -7E+1
ddscb083 scaleb         75    1  -> 7.5E+2
ddscb084 scaleb        -75    1  -> -7.5E+2
ddscb085 scaleb       7.50    1  -> 75.0
ddscb086 scaleb      -7.50    1  -> -75.0
ddscb087 scaleb       7.500   1  -> 75.00
ddscb088 scaleb      -7.500   1  -> -75.00
ddscb091 scaleb          7    2  -> 7E+2
ddscb092 scaleb         -7    2  -> -7E+2
ddscb093 scaleb         75    2  -> 7.5E+3
ddscb094 scaleb        -75    2  -> -7.5E+3
ddscb095 scaleb       7.50    2  -> 750
ddscb096 scaleb      -7.50    2  -> -750
ddscb097 scaleb       7.500   2  -> 750.0
ddscb098 scaleb      -7.500   2  -> -750.0

-- zeros
ddscb111 scaleb          0  1 -> 0E+1
ddscb112 scaleb         -0  2 -> -0E+2
ddscb113 scaleb       0E+4  3 -> 0E+7
ddscb114 scaleb      -0E+4  4 -> -0E+8
ddscb115 scaleb     0.0000  5 -> 0E+1
ddscb116 scaleb    -0.0000  6 -> -0E+2
ddscb117 scaleb      0E-141 7 -> 0E-134
ddscb118 scaleb     -0E-141 8 -> -0E-133

-- Nmax, Nmin, Ntiny
ddscb132 scaleb  9.999999999999999E+384  +384 -> Infinity    Overflow Inexact Rounded
ddscb133 scaleb  9.999999999999999E+384  +10 -> Infinity     Overflow Inexact Rounded
ddscb134 scaleb  9.999999999999999E+384  +1  -> Infinity     Overflow Inexact Rounded
ddscb135 scaleb  9.999999999999999E+384   0  -> 9.999999999999999E+384
ddscb136 scaleb  9.999999999999999E+384  -1  -> 9.999999999999999E+383
ddscb137 scaleb  1E-383           +1  -> 1E-382
ddscb138 scaleb  1E-383           -0  -> 1E-383
ddscb139 scaleb  1E-383           -1  -> 1E-384          Subnormal
ddscb140 scaleb  1.000000000000000E-383  +1  -> 1.000000000000000E-382
ddscb141 scaleb  1.000000000000000E-383   0  -> 1.000000000000000E-383
ddscb142 scaleb  1.000000000000000E-383  -1  -> 1.00000000000000E-384 Subnormal Rounded
ddscb143 scaleb  1E-398          +1  -> 1E-397          Subnormal
ddscb144 scaleb  1E-398          -0  -> 1E-398         Subnormal
ddscb145 scaleb  1E-398          -1  -> 0E-398         Underflow Subnormal Inexact Rounded Clamped

ddscb150 scaleb  -1E-398         +1  -> -1E-397         Subnormal
ddscb151 scaleb  -1E-398         -0  -> -1E-398        Subnormal
ddscb152 scaleb  -1E-398         -1  -> -0E-398        Underflow Subnormal Inexact Rounded Clamped
ddscb153 scaleb  -1.000000000000000E-383 +1  -> -1.000000000000000E-382
ddscb154 scaleb  -1.000000000000000E-383 +0  -> -1.000000000000000E-383
ddscb155 scaleb  -1.000000000000000E-383 -1  -> -1.00000000000000E-384 Subnormal Rounded
ddscb156 scaleb  -1E-383          +1  -> -1E-382
ddscb157 scaleb  -1E-383          -0  -> -1E-383
ddscb158 scaleb  -1E-383          -1  -> -1E-384          Subnormal
ddscb159 scaleb  -9.999999999999999E+384 +1  -> -Infinity        Overflow Inexact Rounded
ddscb160 scaleb  -9.999999999999999E+384 +0  -> -9.999999999999999E+384
ddscb161 scaleb  -9.999999999999999E+384 -1  -> -9.999999999999999E+383
ddscb162 scaleb  -9E+384          +1  -> -Infinity        Overflow Inexact Rounded
ddscb163 scaleb  -1E+384          +1  -> -Infinity        Overflow Inexact Rounded

-- some Origami
-- (these check that overflow is being done correctly)
ddscb171 scaleb   1000E+365  +1 -> 1.000E+369
ddscb172 scaleb   1000E+366  +1 -> 1.000E+370
ddscb173 scaleb   1000E+367  +1 -> 1.000E+371
ddscb174 scaleb   1000E+368  +1 -> 1.000E+372
ddscb175 scaleb   1000E+369  +1 -> 1.0000E+373                  Clamped
ddscb176 scaleb   1000E+370  +1 -> 1.00000E+374                 Clamped
ddscb177 scaleb   1000E+371  +1 -> 1.000000E+375                Clamped
ddscb178 scaleb   1000E+372  +1 -> 1.0000000E+376               Clamped
ddscb179 scaleb   1000E+373  +1 -> 1.00000000E+377              Clamped
ddscb180 scaleb   1000E+374  +1 -> 1.000000000E+378             Clamped
ddscb181 scaleb   1000E+375  +1 -> 1.0000000000E+379            Clamped
ddscb182 scaleb   1000E+376  +1 -> 1.00000000000E+380           Clamped
ddscb183 scaleb   1000E+377  +1 -> 1.000000000000E+381          Clamped
ddscb184 scaleb   1000E+378  +1 -> 1.0000000000000E+382         Clamped
ddscb185 scaleb   1000E+379  +1 -> 1.00000000000000E+383        Clamped
ddscb186 scaleb   1000E+380  +1 -> 1.000000000000000E+384       Clamped
ddscb187 scaleb   1000E+381  +1 -> Infinity    Overflow Inexact Rounded

-- and a few more subnormal truncations
-- (these check that underflow is being done correctly)
ddscb201 scaleb  1.000000000000000E-383   0  -> 1.000000000000000E-383
ddscb202 scaleb  1.000000000000000E-383  -1  -> 1.00000000000000E-384 Subnormal Rounded
ddscb203 scaleb  1.000000000000000E-383  -2  -> 1.0000000000000E-385 Subnormal Rounded
ddscb204 scaleb  1.000000000000000E-383  -3  -> 1.000000000000E-386 Subnormal Rounded
ddscb205 scaleb  1.000000000000000E-383  -4  -> 1.00000000000E-387 Subnormal Rounded
ddscb206 scaleb  1.000000000000000E-383  -5  -> 1.0000000000E-388 Subnormal Rounded
ddscb207 scaleb  1.000000000000000E-383  -6  -> 1.000000000E-389 Subnormal Rounded
ddscb208 scaleb  1.000000000000000E-383  -7  -> 1.00000000E-390 Subnormal Rounded
ddscb209 scaleb  1.000000000000000E-383  -8  -> 1.0000000E-391 Subnormal Rounded
ddscb210 scaleb  1.000000000000000E-383  -9  -> 1.000000E-392 Subnormal Rounded
ddscb211 scaleb  1.000000000000000E-383  -10 -> 1.00000E-393 Subnormal Rounded
ddscb212 scaleb  1.000000000000000E-383  -11 -> 1.0000E-394 Subnormal Rounded
ddscb213 scaleb  1.000000000000000E-383  -12 -> 1.000E-395 Subnormal Rounded
ddscb214 scaleb  1.000000000000000E-383  -13 -> 1.00E-396 Subnormal Rounded
ddscb215 scaleb  1.000000000000000E-383  -14 -> 1.0E-397 Subnormal Rounded
ddscb216 scaleb  1.000000000000000E-383  -15 -> 1E-398 Subnormal Rounded
ddscb217 scaleb  1.000000000000000E-383  -16 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
ddscb218 scaleb  1.000000000000000E-383  -17 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped

Added test/dectest/ddShift.decTest.













































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
------------------------------------------------------------------------
-- ddShift.decTest -- shift decDouble coefficient left or right       --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check
ddshi001 shift                 0    0  ->  0
ddshi002 shift                 0    2  ->  0
ddshi003 shift                 1    2  ->  100
ddshi004 shift                 1   15  ->  1000000000000000
ddshi005 shift                 1   16  ->  0
ddshi006 shift                 1   -1  ->  0
ddshi007 shift                 0   -2  ->  0
ddshi008 shift  1234567890123456   -1  ->  123456789012345
ddshi009 shift  1234567890123456   -15 ->  1
ddshi010 shift  1234567890123456   -16 ->  0
ddshi011 shift  9934567890123456   -15 ->  9
ddshi012 shift  9934567890123456   -16 ->  0

-- rhs must be an integer
ddshi015 shift        1    1.5    -> NaN Invalid_operation
ddshi016 shift        1    1.0    -> NaN Invalid_operation
ddshi017 shift        1    0.1    -> NaN Invalid_operation
ddshi018 shift        1    0.0    -> NaN Invalid_operation
ddshi019 shift        1    1E+1   -> NaN Invalid_operation
ddshi020 shift        1    1E+99  -> NaN Invalid_operation
ddshi021 shift        1    Inf    -> NaN Invalid_operation
ddshi022 shift        1    -Inf   -> NaN Invalid_operation
-- and |rhs| <= precision
ddshi025 shift        1    -1000  -> NaN Invalid_operation
ddshi026 shift        1    -17    -> NaN Invalid_operation
ddshi027 shift        1     17    -> NaN Invalid_operation
ddshi028 shift        1     1000  -> NaN Invalid_operation

-- full shifting pattern
ddshi030 shift  1234567890123456         -16  -> 0
ddshi031 shift  1234567890123456         -15  -> 1
ddshi032 shift  1234567890123456         -14  -> 12
ddshi033 shift  1234567890123456         -13  -> 123
ddshi034 shift  1234567890123456         -12  -> 1234
ddshi035 shift  1234567890123456         -11  -> 12345
ddshi036 shift  1234567890123456         -10  -> 123456
ddshi037 shift  1234567890123456         -9   -> 1234567
ddshi038 shift  1234567890123456         -8   -> 12345678
ddshi039 shift  1234567890123456         -7   -> 123456789
ddshi040 shift  1234567890123456         -6   -> 1234567890
ddshi041 shift  1234567890123456         -5   -> 12345678901
ddshi042 shift  1234567890123456         -4   -> 123456789012
ddshi043 shift  1234567890123456         -3   -> 1234567890123
ddshi044 shift  1234567890123456         -2   -> 12345678901234
ddshi045 shift  1234567890123456         -1   -> 123456789012345
ddshi046 shift  1234567890123456         -0   -> 1234567890123456

ddshi047 shift  1234567890123456         +0   -> 1234567890123456
ddshi048 shift  1234567890123456         +1   -> 2345678901234560
ddshi049 shift  1234567890123456         +2   -> 3456789012345600
ddshi050 shift  1234567890123456         +3   -> 4567890123456000
ddshi051 shift  1234567890123456         +4   -> 5678901234560000
ddshi052 shift  1234567890123456         +5   -> 6789012345600000
ddshi053 shift  1234567890123456         +6   -> 7890123456000000
ddshi054 shift  1234567890123456         +7   -> 8901234560000000
ddshi055 shift  1234567890123456         +8   -> 9012345600000000
ddshi056 shift  1234567890123456         +9   ->  123456000000000
ddshi057 shift  1234567890123456         +10  -> 1234560000000000
ddshi058 shift  1234567890123456         +11  -> 2345600000000000
ddshi059 shift  1234567890123456         +12  -> 3456000000000000
ddshi060 shift  1234567890123456         +13  -> 4560000000000000
ddshi061 shift  1234567890123456         +14  -> 5600000000000000
ddshi062 shift  1234567890123456         +15  -> 6000000000000000
ddshi063 shift  1234567890123456         +16  -> 0

-- zeros
ddshi070 shift  0E-10              +9   ->   0E-10
ddshi071 shift  0E-10              -9   ->   0E-10
ddshi072 shift  0.000              +9   ->   0.000
ddshi073 shift  0.000              -9   ->   0.000
ddshi074 shift  0E+10              +9   ->   0E+10
ddshi075 shift  0E+10              -9   ->   0E+10
ddshi076 shift -0E-10              +9   ->  -0E-10
ddshi077 shift -0E-10              -9   ->  -0E-10
ddshi078 shift -0.000              +9   ->  -0.000
ddshi079 shift -0.000              -9   ->  -0.000
ddshi080 shift -0E+10              +9   ->  -0E+10
ddshi081 shift -0E+10              -9   ->  -0E+10

-- Nmax, Nmin, Ntiny
ddshi141 shift  9.999999999999999E+384     -1  -> 9.99999999999999E+383
ddshi142 shift  9.999999999999999E+384     -15 -> 9E+369
ddshi143 shift  9.999999999999999E+384      1  -> 9.999999999999990E+384
ddshi144 shift  9.999999999999999E+384      15 -> 9.000000000000000E+384
ddshi145 shift  1E-383                     -1  -> 0E-383
ddshi146 shift  1E-383                     -15 -> 0E-383
ddshi147 shift  1E-383                      1  -> 1.0E-382
ddshi148 shift  1E-383                      15 -> 1.000000000000000E-368
ddshi151 shift  1.000000000000000E-383     -1  -> 1.00000000000000E-384
ddshi152 shift  1.000000000000000E-383     -15 -> 1E-398
ddshi153 shift  1.000000000000000E-383      1  -> 0E-398
ddshi154 shift  1.000000000000000E-383      15 -> 0E-398
ddshi155 shift  9.000000000000000E-383     -1  -> 9.00000000000000E-384
ddshi156 shift  9.000000000000000E-383     -15 -> 9E-398
ddshi157 shift  9.000000000000000E-383      1  -> 0E-398
ddshi158 shift  9.000000000000000E-383      15 -> 0E-398
ddshi160 shift  1E-398                     -1  -> 0E-398
ddshi161 shift  1E-398                     -15 -> 0E-398
ddshi162 shift  1E-398                      1  -> 1.0E-397
ddshi163 shift  1E-398                      15 -> 1.000000000000000E-383
--  negatives
ddshi171 shift -9.999999999999999E+384     -1  -> -9.99999999999999E+383
ddshi172 shift -9.999999999999999E+384     -15 -> -9E+369
ddshi173 shift -9.999999999999999E+384      1  -> -9.999999999999990E+384
ddshi174 shift -9.999999999999999E+384      15 -> -9.000000000000000E+384
ddshi175 shift -1E-383                     -1  -> -0E-383
ddshi176 shift -1E-383                     -15 -> -0E-383
ddshi177 shift -1E-383                      1  -> -1.0E-382
ddshi178 shift -1E-383                      15 -> -1.000000000000000E-368
ddshi181 shift -1.000000000000000E-383     -1  -> -1.00000000000000E-384
ddshi182 shift -1.000000000000000E-383     -15 -> -1E-398
ddshi183 shift -1.000000000000000E-383      1  -> -0E-398
ddshi184 shift -1.000000000000000E-383      15 -> -0E-398
ddshi185 shift -9.000000000000000E-383     -1  -> -9.00000000000000E-384
ddshi186 shift -9.000000000000000E-383     -15 -> -9E-398
ddshi187 shift -9.000000000000000E-383      1  -> -0E-398
ddshi188 shift -9.000000000000000E-383      15 -> -0E-398
ddshi190 shift -1E-398                     -1  -> -0E-398
ddshi191 shift -1E-398                     -15 -> -0E-398
ddshi192 shift -1E-398                      1  -> -1.0E-397
ddshi193 shift -1E-398                      15 -> -1.000000000000000E-383

-- more negatives (of sanities)
ddshi201 shift                -0    0  -> -0
ddshi202 shift                -0    2  -> -0
ddshi203 shift                -1    2  -> -100
ddshi204 shift                -1   15  -> -1000000000000000
ddshi205 shift                -1   16  -> -0
ddshi206 shift                -1   -1  -> -0
ddshi207 shift                -0   -2  -> -0
ddshi208 shift -1234567890123456   -1  -> -123456789012345
ddshi209 shift -1234567890123456   -15 -> -1
ddshi210 shift -1234567890123456   -16 -> -0
ddshi211 shift -9934567890123456   -15 -> -9
ddshi212 shift -9934567890123456   -16 -> -0


-- Specials; NaNs are handled as usual
ddshi781 shift -Inf  -8     -> -Infinity
ddshi782 shift -Inf  -1     -> -Infinity
ddshi783 shift -Inf  -0     -> -Infinity
ddshi784 shift -Inf   0     -> -Infinity
ddshi785 shift -Inf   1     -> -Infinity
ddshi786 shift -Inf   8     -> -Infinity
ddshi787 shift -1000 -Inf   -> NaN Invalid_operation
ddshi788 shift -Inf  -Inf   -> NaN Invalid_operation
ddshi789 shift -1    -Inf   -> NaN Invalid_operation
ddshi790 shift -0    -Inf   -> NaN Invalid_operation
ddshi791 shift  0    -Inf   -> NaN Invalid_operation
ddshi792 shift  1    -Inf   -> NaN Invalid_operation
ddshi793 shift  1000 -Inf   -> NaN Invalid_operation
ddshi794 shift  Inf  -Inf   -> NaN Invalid_operation

ddshi800 shift  Inf  -Inf   -> NaN Invalid_operation
ddshi801 shift  Inf  -8     -> Infinity
ddshi802 shift  Inf  -1     -> Infinity
ddshi803 shift  Inf  -0     -> Infinity
ddshi804 shift  Inf   0     -> Infinity
ddshi805 shift  Inf   1     -> Infinity
ddshi806 shift  Inf   8     -> Infinity
ddshi807 shift  Inf   Inf   -> NaN Invalid_operation
ddshi808 shift -1000  Inf   -> NaN Invalid_operation
ddshi809 shift -Inf   Inf   -> NaN Invalid_operation
ddshi810 shift -1     Inf   -> NaN Invalid_operation
ddshi811 shift -0     Inf   -> NaN Invalid_operation
ddshi812 shift  0     Inf   -> NaN Invalid_operation
ddshi813 shift  1     Inf   -> NaN Invalid_operation
ddshi814 shift  1000  Inf   -> NaN Invalid_operation
ddshi815 shift  Inf   Inf   -> NaN Invalid_operation

ddshi821 shift  NaN -Inf    ->  NaN
ddshi822 shift  NaN -1000   ->  NaN
ddshi823 shift  NaN -1      ->  NaN
ddshi824 shift  NaN -0      ->  NaN
ddshi825 shift  NaN  0      ->  NaN
ddshi826 shift  NaN  1      ->  NaN
ddshi827 shift  NaN  1000   ->  NaN
ddshi828 shift  NaN  Inf    ->  NaN
ddshi829 shift  NaN  NaN    ->  NaN
ddshi830 shift -Inf  NaN    ->  NaN
ddshi831 shift -1000 NaN    ->  NaN
ddshi832 shift -1    NaN    ->  NaN
ddshi833 shift -0    NaN    ->  NaN
ddshi834 shift  0    NaN    ->  NaN
ddshi835 shift  1    NaN    ->  NaN
ddshi836 shift  1000 NaN    ->  NaN
ddshi837 shift  Inf  NaN    ->  NaN

ddshi841 shift  sNaN -Inf   ->  NaN  Invalid_operation
ddshi842 shift  sNaN -1000  ->  NaN  Invalid_operation
ddshi843 shift  sNaN -1     ->  NaN  Invalid_operation
ddshi844 shift  sNaN -0     ->  NaN  Invalid_operation
ddshi845 shift  sNaN  0     ->  NaN  Invalid_operation
ddshi846 shift  sNaN  1     ->  NaN  Invalid_operation
ddshi847 shift  sNaN  1000  ->  NaN  Invalid_operation
ddshi848 shift  sNaN  NaN   ->  NaN  Invalid_operation
ddshi849 shift  sNaN sNaN   ->  NaN  Invalid_operation
ddshi850 shift  NaN  sNaN   ->  NaN  Invalid_operation
ddshi851 shift -Inf  sNaN   ->  NaN  Invalid_operation
ddshi852 shift -1000 sNaN   ->  NaN  Invalid_operation
ddshi853 shift -1    sNaN   ->  NaN  Invalid_operation
ddshi854 shift -0    sNaN   ->  NaN  Invalid_operation
ddshi855 shift  0    sNaN   ->  NaN  Invalid_operation
ddshi856 shift  1    sNaN   ->  NaN  Invalid_operation
ddshi857 shift  1000 sNaN   ->  NaN  Invalid_operation
ddshi858 shift  Inf  sNaN   ->  NaN  Invalid_operation
ddshi859 shift  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddshi861 shift  NaN1   -Inf    ->  NaN1
ddshi862 shift +NaN2   -1000   ->  NaN2
ddshi863 shift  NaN3    1000   ->  NaN3
ddshi864 shift  NaN4    Inf    ->  NaN4
ddshi865 shift  NaN5   +NaN6   ->  NaN5
ddshi866 shift -Inf     NaN7   ->  NaN7
ddshi867 shift -1000    NaN8   ->  NaN8
ddshi868 shift  1000    NaN9   ->  NaN9
ddshi869 shift  Inf    +NaN10  ->  NaN10
ddshi871 shift  sNaN11  -Inf   ->  NaN11  Invalid_operation
ddshi872 shift  sNaN12  -1000  ->  NaN12  Invalid_operation
ddshi873 shift  sNaN13   1000  ->  NaN13  Invalid_operation
ddshi874 shift  sNaN14   NaN17 ->  NaN14  Invalid_operation
ddshi875 shift  sNaN15  sNaN18 ->  NaN15  Invalid_operation
ddshi876 shift  NaN16   sNaN19 ->  NaN19  Invalid_operation
ddshi877 shift -Inf    +sNaN20 ->  NaN20  Invalid_operation
ddshi878 shift -1000    sNaN21 ->  NaN21  Invalid_operation
ddshi879 shift  1000    sNaN22 ->  NaN22  Invalid_operation
ddshi880 shift  Inf     sNaN23 ->  NaN23  Invalid_operation
ddshi881 shift +NaN25  +sNaN24 ->  NaN24  Invalid_operation
ddshi882 shift -NaN26    NaN28 -> -NaN26
ddshi883 shift -sNaN27  sNaN29 -> -NaN27  Invalid_operation
ddshi884 shift  1000    -NaN30 -> -NaN30
ddshi885 shift  1000   -sNaN31 -> -NaN31  Invalid_operation

Added test/dectest/ddSubtract.decTest.











































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
------------------------------------------------------------------------
-- ddSubtract.decTest -- decDouble subtraction                        --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests are for decDoubles only; all arguments are
-- representable in a decDouble
precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- [first group are 'quick confidence check']
ddsub001 subtract  0   0  -> '0'
ddsub002 subtract  1   1  -> '0'
ddsub003 subtract  1   2  -> '-1'
ddsub004 subtract  2   1  -> '1'
ddsub005 subtract  2   2  -> '0'
ddsub006 subtract  3   2  -> '1'
ddsub007 subtract  2   3  -> '-1'

ddsub011 subtract -0   0  -> '-0'
ddsub012 subtract -1   1  -> '-2'
ddsub013 subtract -1   2  -> '-3'
ddsub014 subtract -2   1  -> '-3'
ddsub015 subtract -2   2  -> '-4'
ddsub016 subtract -3   2  -> '-5'
ddsub017 subtract -2   3  -> '-5'

ddsub021 subtract  0  -0  -> '0'
ddsub022 subtract  1  -1  -> '2'
ddsub023 subtract  1  -2  -> '3'
ddsub024 subtract  2  -1  -> '3'
ddsub025 subtract  2  -2  -> '4'
ddsub026 subtract  3  -2  -> '5'
ddsub027 subtract  2  -3  -> '5'

ddsub030 subtract  11  1  -> 10
ddsub031 subtract  10  1  ->  9
ddsub032 subtract  9   1  ->  8
ddsub033 subtract  1   1  ->  0
ddsub034 subtract  0   1  -> -1
ddsub035 subtract -1   1  -> -2
ddsub036 subtract -9   1  -> -10
ddsub037 subtract -10  1  -> -11
ddsub038 subtract -11  1  -> -12

ddsub040 subtract '5.75' '3.3'  -> '2.45'
ddsub041 subtract '5'    '-3'   -> '8'
ddsub042 subtract '-5'   '-3'   -> '-2'
ddsub043 subtract '-7'   '2.5'  -> '-9.5'
ddsub044 subtract '0.7'  '0.3'  -> '0.4'
ddsub045 subtract '1.3'  '0.3'  -> '1.0'
ddsub046 subtract '1.25' '1.25' -> '0.00'

ddsub050 subtract '1.23456789'    '1.00000000' -> '0.23456789'
ddsub051 subtract '1.23456789'    '1.00000089' -> '0.23456700'

ddsub060 subtract '70'    '10000e+16' -> '-1.000000000000000E+20' Inexact Rounded
ddsub061 subtract '700'    '10000e+16' -> '-1.000000000000000E+20' Inexact Rounded
ddsub062 subtract '7000'    '10000e+16' -> '-9.999999999999999E+19' Inexact Rounded
ddsub063 subtract '70000'    '10000e+16' -> '-9.999999999999993E+19' Rounded
ddsub064 subtract '700000'    '10000e+16' -> '-9.999999999999930E+19' Rounded
  -- symmetry:
ddsub065 subtract '10000e+16'    '70' -> '1.000000000000000E+20' Inexact Rounded
ddsub066 subtract '10000e+16'    '700' -> '1.000000000000000E+20' Inexact Rounded
ddsub067 subtract '10000e+16'    '7000' -> '9.999999999999999E+19' Inexact Rounded
ddsub068 subtract '10000e+16'    '70000' -> '9.999999999999993E+19' Rounded
ddsub069 subtract '10000e+16'    '700000' -> '9.999999999999930E+19' Rounded

  -- some of the next group are really constructor tests
ddsub090 subtract '00.0'    '0.0'  -> '0.0'
ddsub091 subtract '00.0'    '0.00' -> '0.00'
ddsub092 subtract '0.00'    '00.0' -> '0.00'
ddsub093 subtract '00.0'    '0.00' -> '0.00'
ddsub094 subtract '0.00'    '00.0' -> '0.00'
ddsub095 subtract '3'    '.3'   -> '2.7'
ddsub096 subtract '3.'   '.3'   -> '2.7'
ddsub097 subtract '3.0'  '.3'   -> '2.7'
ddsub098 subtract '3.00' '.3'   -> '2.70'
ddsub099 subtract '3'    '3'    -> '0'
ddsub100 subtract '3'    '+3'   -> '0'
ddsub101 subtract '3'    '-3'   -> '6'
ddsub102 subtract '3'    '0.3'  -> '2.7'
ddsub103 subtract '3.'   '0.3'  -> '2.7'
ddsub104 subtract '3.0'  '0.3'  -> '2.7'
ddsub105 subtract '3.00' '0.3'  -> '2.70'
ddsub106 subtract '3'    '3.0'  -> '0.0'
ddsub107 subtract '3'    '+3.0' -> '0.0'
ddsub108 subtract '3'    '-3.0' -> '6.0'

-- the above all from add; massaged and extended.  Now some new ones...
-- [particularly important for comparisons]
-- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7
-- with input rounding.
ddsub120 subtract  '10.23456784'    '10.23456789'  -> '-5E-8'
ddsub121 subtract  '10.23456785'    '10.23456789'  -> '-4E-8'
ddsub122 subtract  '10.23456786'    '10.23456789'  -> '-3E-8'
ddsub123 subtract  '10.23456787'    '10.23456789'  -> '-2E-8'
ddsub124 subtract  '10.23456788'    '10.23456789'  -> '-1E-8'
ddsub125 subtract  '10.23456789'    '10.23456789'  -> '0E-8'
ddsub126 subtract  '10.23456790'    '10.23456789'  -> '1E-8'
ddsub127 subtract  '10.23456791'    '10.23456789'  -> '2E-8'
ddsub128 subtract  '10.23456792'    '10.23456789'  -> '3E-8'
ddsub129 subtract  '10.23456793'    '10.23456789'  -> '4E-8'
ddsub130 subtract  '10.23456794'    '10.23456789'  -> '5E-8'
ddsub131 subtract  '10.23456781'    '10.23456786'  -> '-5E-8'
ddsub132 subtract  '10.23456782'    '10.23456786'  -> '-4E-8'
ddsub133 subtract  '10.23456783'    '10.23456786'  -> '-3E-8'
ddsub134 subtract  '10.23456784'    '10.23456786'  -> '-2E-8'
ddsub135 subtract  '10.23456785'    '10.23456786'  -> '-1E-8'
ddsub136 subtract  '10.23456786'    '10.23456786'  -> '0E-8'
ddsub137 subtract  '10.23456787'    '10.23456786'  -> '1E-8'
ddsub138 subtract  '10.23456788'    '10.23456786'  -> '2E-8'
ddsub139 subtract  '10.23456789'    '10.23456786'  -> '3E-8'
ddsub140 subtract  '10.23456790'    '10.23456786'  -> '4E-8'
ddsub141 subtract  '10.23456791'    '10.23456786'  -> '5E-8'
ddsub142 subtract  '1'              '0.999999999'  -> '1E-9'
ddsub143 subtract  '0.999999999'    '1'            -> '-1E-9'
ddsub144 subtract  '-10.23456780'   '-10.23456786' -> '6E-8'
ddsub145 subtract  '-10.23456790'   '-10.23456786' -> '-4E-8'
ddsub146 subtract  '-10.23456791'   '-10.23456786' -> '-5E-8'

-- additional scaled arithmetic tests [0.97 problem]
ddsub160 subtract '0'     '.1'      -> '-0.1'
ddsub161 subtract '00'    '.97983'  -> '-0.97983'
ddsub162 subtract '0'     '.9'      -> '-0.9'
ddsub163 subtract '0'     '0.102'   -> '-0.102'
ddsub164 subtract '0'     '.4'      -> '-0.4'
ddsub165 subtract '0'     '.307'    -> '-0.307'
ddsub166 subtract '0'     '.43822'  -> '-0.43822'
ddsub167 subtract '0'     '.911'    -> '-0.911'
ddsub168 subtract '.0'    '.02'     -> '-0.02'
ddsub169 subtract '00'    '.392'    -> '-0.392'
ddsub170 subtract '0'     '.26'     -> '-0.26'
ddsub171 subtract '0'     '0.51'    -> '-0.51'
ddsub172 subtract '0'     '.2234'   -> '-0.2234'
ddsub173 subtract '0'     '.2'      -> '-0.2'
ddsub174 subtract '.0'    '.0008'   -> '-0.0008'
-- 0. on left
ddsub180 subtract '0.0'     '-.1'      -> '0.1'
ddsub181 subtract '0.00'    '-.97983'  -> '0.97983'
ddsub182 subtract '0.0'     '-.9'      -> '0.9'
ddsub183 subtract '0.0'     '-0.102'   -> '0.102'
ddsub184 subtract '0.0'     '-.4'      -> '0.4'
ddsub185 subtract '0.0'     '-.307'    -> '0.307'
ddsub186 subtract '0.0'     '-.43822'  -> '0.43822'
ddsub187 subtract '0.0'     '-.911'    -> '0.911'
ddsub188 subtract '0.0'     '-.02'     -> '0.02'
ddsub189 subtract '0.00'    '-.392'    -> '0.392'
ddsub190 subtract '0.0'     '-.26'     -> '0.26'
ddsub191 subtract '0.0'     '-0.51'    -> '0.51'
ddsub192 subtract '0.0'     '-.2234'   -> '0.2234'
ddsub193 subtract '0.0'     '-.2'      -> '0.2'
ddsub194 subtract '0.0'     '-.0008'   -> '0.0008'
-- negatives of same
ddsub200 subtract '0'     '-.1'      -> '0.1'
ddsub201 subtract '00'    '-.97983'  -> '0.97983'
ddsub202 subtract '0'     '-.9'      -> '0.9'
ddsub203 subtract '0'     '-0.102'   -> '0.102'
ddsub204 subtract '0'     '-.4'      -> '0.4'
ddsub205 subtract '0'     '-.307'    -> '0.307'
ddsub206 subtract '0'     '-.43822'  -> '0.43822'
ddsub207 subtract '0'     '-.911'    -> '0.911'
ddsub208 subtract '.0'    '-.02'     -> '0.02'
ddsub209 subtract '00'    '-.392'    -> '0.392'
ddsub210 subtract '0'     '-.26'     -> '0.26'
ddsub211 subtract '0'     '-0.51'    -> '0.51'
ddsub212 subtract '0'     '-.2234'   -> '0.2234'
ddsub213 subtract '0'     '-.2'      -> '0.2'
ddsub214 subtract '.0'    '-.0008'   -> '0.0008'

-- more fixed, LHS swaps [really the same as testcases under add]
ddsub220 subtract '-56267E-12' 0  -> '-5.6267E-8'
ddsub221 subtract '-56267E-11' 0  -> '-5.6267E-7'
ddsub222 subtract '-56267E-10' 0  -> '-0.0000056267'
ddsub223 subtract '-56267E-9'  0  -> '-0.000056267'
ddsub224 subtract '-56267E-8'  0  -> '-0.00056267'
ddsub225 subtract '-56267E-7'  0  -> '-0.0056267'
ddsub226 subtract '-56267E-6'  0  -> '-0.056267'
ddsub227 subtract '-56267E-5'  0  -> '-0.56267'
ddsub228 subtract '-56267E-2'  0  -> '-562.67'
ddsub229 subtract '-56267E-1'  0  -> '-5626.7'
ddsub230 subtract '-56267E-0'  0  -> '-56267'
-- symmetry ...
ddsub240 subtract 0 '-56267E-12'  -> '5.6267E-8'
ddsub241 subtract 0 '-56267E-11'  -> '5.6267E-7'
ddsub242 subtract 0 '-56267E-10'  -> '0.0000056267'
ddsub243 subtract 0 '-56267E-9'   -> '0.000056267'
ddsub244 subtract 0 '-56267E-8'   -> '0.00056267'
ddsub245 subtract 0 '-56267E-7'   -> '0.0056267'
ddsub246 subtract 0 '-56267E-6'   -> '0.056267'
ddsub247 subtract 0 '-56267E-5'   -> '0.56267'
ddsub248 subtract 0 '-56267E-2'   -> '562.67'
ddsub249 subtract 0 '-56267E-1'   -> '5626.7'
ddsub250 subtract 0 '-56267E-0'   -> '56267'

-- now some more from the 'new' add
ddsub301 subtract '1.23456789'  '1.00000000' -> '0.23456789'
ddsub302 subtract '1.23456789'  '1.00000011' -> '0.23456778'

-- some carrying effects
ddsub321 subtract '0.9998'  '0.0000' -> '0.9998'
ddsub322 subtract '0.9998'  '0.0001' -> '0.9997'
ddsub323 subtract '0.9998'  '0.0002' -> '0.9996'
ddsub324 subtract '0.9998'  '0.0003' -> '0.9995'
ddsub325 subtract '0.9998'  '-0.0000' -> '0.9998'
ddsub326 subtract '0.9998'  '-0.0001' -> '0.9999'
ddsub327 subtract '0.9998'  '-0.0002' -> '1.0000'
ddsub328 subtract '0.9998'  '-0.0003' -> '1.0001'

-- internal boundaries
ddsub346 subtract '10000e+9'  '7'   -> '9999999999993'
ddsub347 subtract '10000e+9'  '70'   -> '9999999999930'
ddsub348 subtract '10000e+9'  '700'   -> '9999999999300'
ddsub349 subtract '10000e+9'  '7000'   -> '9999999993000'
ddsub350 subtract '10000e+9'  '70000'   -> '9999999930000'
ddsub351 subtract '10000e+9'  '700000'   -> '9999999300000'
ddsub352 subtract '7' '10000e+9'   -> '-9999999999993'
ddsub353 subtract '70' '10000e+9'   -> '-9999999999930'
ddsub354 subtract '700' '10000e+9'   -> '-9999999999300'
ddsub355 subtract '7000' '10000e+9'   -> '-9999999993000'
ddsub356 subtract '70000' '10000e+9'   -> '-9999999930000'
ddsub357 subtract '700000' '10000e+9'   -> '-9999999300000'

-- zero preservation
ddsub361 subtract 1 '0.0001' -> '0.9999'
ddsub362 subtract 1 '0.00001' -> '0.99999'
ddsub363 subtract 1 '0.000001' -> '0.999999'
ddsub364 subtract 1 '0.0000000000000001' -> '0.9999999999999999'
ddsub365 subtract 1 '0.00000000000000001' -> '1.000000000000000' Inexact Rounded
ddsub366 subtract 1 '0.000000000000000001' -> '1.000000000000000' Inexact Rounded

-- some funny zeros [in case of bad signum]
ddsub370 subtract 1  0  -> 1
ddsub371 subtract 1 0.  -> 1
ddsub372 subtract 1  .0 -> 1.0
ddsub373 subtract 1 0.0 -> 1.0
ddsub374 subtract  0  1 -> -1
ddsub375 subtract 0.  1 -> -1
ddsub376 subtract  .0 1 -> -1.0
ddsub377 subtract 0.0 1 -> -1.0

-- leading 0 digit before round
ddsub910 subtract -103519362 -51897955.3 -> -51621406.7
ddsub911 subtract 159579.444 89827.5229 -> 69751.9211

ddsub920 subtract 333.0000000123456 33.00000001234566 -> 299.9999999999999 Inexact Rounded
ddsub921 subtract 333.0000000123456 33.00000001234565 -> 300.0000000000000 Inexact Rounded
ddsub922 subtract 133.0000000123456 33.00000001234565 ->  99.99999999999995
ddsub923 subtract 133.0000000123456 33.00000001234564 ->  99.99999999999996
ddsub924 subtract 133.0000000123456 33.00000001234540 -> 100.0000000000002 Rounded
ddsub925 subtract 133.0000000123456 43.00000001234560 ->  90.00000000000000
ddsub926 subtract 133.0000000123456 43.00000001234561 ->  89.99999999999999
ddsub927 subtract 133.0000000123456 43.00000001234566 ->  89.99999999999994
ddsub928 subtract 101.0000000123456 91.00000001234566 ->   9.99999999999994
ddsub929 subtract 101.0000000123456 99.00000001234566 ->   1.99999999999994

-- more LHS swaps [were fixed]
ddsub390 subtract '-56267E-10'   0 ->  '-0.0000056267'
ddsub391 subtract '-56267E-6'    0 ->  '-0.056267'
ddsub392 subtract '-56267E-5'    0 ->  '-0.56267'
ddsub393 subtract '-56267E-4'    0 ->  '-5.6267'
ddsub394 subtract '-56267E-3'    0 ->  '-56.267'
ddsub395 subtract '-56267E-2'    0 ->  '-562.67'
ddsub396 subtract '-56267E-1'    0 ->  '-5626.7'
ddsub397 subtract '-56267E-0'    0 ->  '-56267'
ddsub398 subtract '-5E-10'       0 ->  '-5E-10'
ddsub399 subtract '-5E-7'        0 ->  '-5E-7'
ddsub400 subtract '-5E-6'        0 ->  '-0.000005'
ddsub401 subtract '-5E-5'        0 ->  '-0.00005'
ddsub402 subtract '-5E-4'        0 ->  '-0.0005'
ddsub403 subtract '-5E-1'        0 ->  '-0.5'
ddsub404 subtract '-5E0'         0 ->  '-5'
ddsub405 subtract '-5E1'         0 ->  '-50'
ddsub406 subtract '-5E5'         0 ->  '-500000'
ddsub407 subtract '-5E15'        0 ->  '-5000000000000000'
ddsub408 subtract '-5E16'        0 ->  '-5.000000000000000E+16'  Rounded
ddsub409 subtract '-5E17'        0 ->  '-5.000000000000000E+17'  Rounded
ddsub410 subtract '-5E18'        0 ->  '-5.000000000000000E+18'  Rounded
ddsub411 subtract '-5E100'       0 ->  '-5.000000000000000E+100' Rounded

-- more RHS swaps [were fixed]
ddsub420 subtract 0  '-56267E-10' ->  '0.0000056267'
ddsub421 subtract 0  '-56267E-6'  ->  '0.056267'
ddsub422 subtract 0  '-56267E-5'  ->  '0.56267'
ddsub423 subtract 0  '-56267E-4'  ->  '5.6267'
ddsub424 subtract 0  '-56267E-3'  ->  '56.267'
ddsub425 subtract 0  '-56267E-2'  ->  '562.67'
ddsub426 subtract 0  '-56267E-1'  ->  '5626.7'
ddsub427 subtract 0  '-56267E-0'  ->  '56267'
ddsub428 subtract 0  '-5E-10'     ->  '5E-10'
ddsub429 subtract 0  '-5E-7'      ->  '5E-7'
ddsub430 subtract 0  '-5E-6'      ->  '0.000005'
ddsub431 subtract 0  '-5E-5'      ->  '0.00005'
ddsub432 subtract 0  '-5E-4'      ->  '0.0005'
ddsub433 subtract 0  '-5E-1'      ->  '0.5'
ddsub434 subtract 0  '-5E0'       ->  '5'
ddsub435 subtract 0  '-5E1'       ->  '50'
ddsub436 subtract 0  '-5E5'       ->  '500000'
ddsub437 subtract 0  '-5E15'      ->  '5000000000000000'
ddsub438 subtract 0  '-5E16'      ->  '5.000000000000000E+16'   Rounded
ddsub439 subtract 0  '-5E17'      ->  '5.000000000000000E+17'   Rounded
ddsub440 subtract 0  '-5E18'      ->  '5.000000000000000E+18'   Rounded
ddsub441 subtract 0  '-5E100'     ->  '5.000000000000000E+100'  Rounded


-- try borderline precision, with carries, etc.
ddsub461 subtract '1E+16' '1'        -> '9999999999999999'
ddsub462 subtract '1E+12' '-1.111'   -> '1000000000001.111'
ddsub463 subtract '1.111'  '-1E+12'  -> '1000000000001.111'
ddsub464 subtract '-1'    '-1E+16'   -> '9999999999999999'
ddsub465 subtract '7E+15' '1'        -> '6999999999999999'
ddsub466 subtract '7E+12' '-1.111'   -> '7000000000001.111'
ddsub467 subtract '1.111'  '-7E+12'  -> '7000000000001.111'
ddsub468 subtract '-1'    '-7E+15'   -> '6999999999999999'

--                  1234567890123456       1234567890123456      1 23456789012345
ddsub470 subtract '0.4444444444444444'  '-0.5555555555555563' -> '1.000000000000001' Inexact Rounded
ddsub471 subtract '0.4444444444444444'  '-0.5555555555555562' -> '1.000000000000001' Inexact Rounded
ddsub472 subtract '0.4444444444444444'  '-0.5555555555555561' -> '1.000000000000000' Inexact Rounded
ddsub473 subtract '0.4444444444444444'  '-0.5555555555555560' -> '1.000000000000000' Inexact Rounded
ddsub474 subtract '0.4444444444444444'  '-0.5555555555555559' -> '1.000000000000000' Inexact Rounded
ddsub475 subtract '0.4444444444444444'  '-0.5555555555555558' -> '1.000000000000000' Inexact Rounded
ddsub476 subtract '0.4444444444444444'  '-0.5555555555555557' -> '1.000000000000000' Inexact Rounded
ddsub477 subtract '0.4444444444444444'  '-0.5555555555555556' -> '1.000000000000000' Rounded
ddsub478 subtract '0.4444444444444444'  '-0.5555555555555555' -> '0.9999999999999999'
ddsub479 subtract '0.4444444444444444'  '-0.5555555555555554' -> '0.9999999999999998'
ddsub480 subtract '0.4444444444444444'  '-0.5555555555555553' -> '0.9999999999999997'
ddsub481 subtract '0.4444444444444444'  '-0.5555555555555552' -> '0.9999999999999996'
ddsub482 subtract '0.4444444444444444'  '-0.5555555555555551' -> '0.9999999999999995'
ddsub483 subtract '0.4444444444444444'  '-0.5555555555555550' -> '0.9999999999999994'

-- and some more, including residue effects and different roundings
rounding: half_up
ddsub500 subtract '1231234567456789' 0             -> '1231234567456789'
ddsub501 subtract '1231234567456789' 0.000000001   -> '1231234567456789' Inexact Rounded
ddsub502 subtract '1231234567456789' 0.000001      -> '1231234567456789' Inexact Rounded
ddsub503 subtract '1231234567456789' 0.1           -> '1231234567456789' Inexact Rounded
ddsub504 subtract '1231234567456789' 0.4           -> '1231234567456789' Inexact Rounded
ddsub505 subtract '1231234567456789' 0.49          -> '1231234567456789' Inexact Rounded
ddsub506 subtract '1231234567456789' 0.499999      -> '1231234567456789' Inexact Rounded
ddsub507 subtract '1231234567456789' 0.499999999   -> '1231234567456789' Inexact Rounded
ddsub508 subtract '1231234567456789' 0.5           -> '1231234567456789' Inexact Rounded
ddsub509 subtract '1231234567456789' 0.500000001   -> '1231234567456788' Inexact Rounded
ddsub510 subtract '1231234567456789' 0.500001      -> '1231234567456788' Inexact Rounded
ddsub511 subtract '1231234567456789' 0.51          -> '1231234567456788' Inexact Rounded
ddsub512 subtract '1231234567456789' 0.6           -> '1231234567456788' Inexact Rounded
ddsub513 subtract '1231234567456789' 0.9           -> '1231234567456788' Inexact Rounded
ddsub514 subtract '1231234567456789' 0.99999       -> '1231234567456788' Inexact Rounded
ddsub515 subtract '1231234567456789' 0.999999999   -> '1231234567456788' Inexact Rounded
ddsub516 subtract '1231234567456789' 1             -> '1231234567456788'
ddsub517 subtract '1231234567456789' 1.000000001   -> '1231234567456788' Inexact Rounded
ddsub518 subtract '1231234567456789' 1.00001       -> '1231234567456788' Inexact Rounded
ddsub519 subtract '1231234567456789' 1.1           -> '1231234567456788' Inexact Rounded

rounding: half_even
ddsub520 subtract '1231234567456789' 0             -> '1231234567456789'
ddsub521 subtract '1231234567456789' 0.000000001   -> '1231234567456789' Inexact Rounded
ddsub522 subtract '1231234567456789' 0.000001      -> '1231234567456789' Inexact Rounded
ddsub523 subtract '1231234567456789' 0.1           -> '1231234567456789' Inexact Rounded
ddsub524 subtract '1231234567456789' 0.4           -> '1231234567456789' Inexact Rounded
ddsub525 subtract '1231234567456789' 0.49          -> '1231234567456789' Inexact Rounded
ddsub526 subtract '1231234567456789' 0.499999      -> '1231234567456789' Inexact Rounded
ddsub527 subtract '1231234567456789' 0.499999999   -> '1231234567456789' Inexact Rounded
ddsub528 subtract '1231234567456789' 0.5           -> '1231234567456788' Inexact Rounded
ddsub529 subtract '1231234567456789' 0.500000001   -> '1231234567456788' Inexact Rounded
ddsub530 subtract '1231234567456789' 0.500001      -> '1231234567456788' Inexact Rounded
ddsub531 subtract '1231234567456789' 0.51          -> '1231234567456788' Inexact Rounded
ddsub532 subtract '1231234567456789' 0.6           -> '1231234567456788' Inexact Rounded
ddsub533 subtract '1231234567456789' 0.9           -> '1231234567456788' Inexact Rounded
ddsub534 subtract '1231234567456789' 0.99999       -> '1231234567456788' Inexact Rounded
ddsub535 subtract '1231234567456789' 0.999999999   -> '1231234567456788' Inexact Rounded
ddsub536 subtract '1231234567456789' 1             -> '1231234567456788'
ddsub537 subtract '1231234567456789' 1.00000001    -> '1231234567456788' Inexact Rounded
ddsub538 subtract '1231234567456789' 1.00001       -> '1231234567456788' Inexact Rounded
ddsub539 subtract '1231234567456789' 1.1           -> '1231234567456788' Inexact Rounded
-- critical few with even bottom digit...
ddsub540 subtract '1231234567456788' 0.499999999   -> '1231234567456788' Inexact Rounded
ddsub541 subtract '1231234567456788' 0.5           -> '1231234567456788' Inexact Rounded
ddsub542 subtract '1231234567456788' 0.500000001   -> '1231234567456787' Inexact Rounded

rounding: down
ddsub550 subtract '1231234567456789' 0             -> '1231234567456789'
ddsub551 subtract '1231234567456789' 0.000000001   -> '1231234567456788' Inexact Rounded
ddsub552 subtract '1231234567456789' 0.000001      -> '1231234567456788' Inexact Rounded
ddsub553 subtract '1231234567456789' 0.1           -> '1231234567456788' Inexact Rounded
ddsub554 subtract '1231234567456789' 0.4           -> '1231234567456788' Inexact Rounded
ddsub555 subtract '1231234567456789' 0.49          -> '1231234567456788' Inexact Rounded
ddsub556 subtract '1231234567456789' 0.499999      -> '1231234567456788' Inexact Rounded
ddsub557 subtract '1231234567456789' 0.499999999   -> '1231234567456788' Inexact Rounded
ddsub558 subtract '1231234567456789' 0.5           -> '1231234567456788' Inexact Rounded
ddsub559 subtract '1231234567456789' 0.500000001   -> '1231234567456788' Inexact Rounded
ddsub560 subtract '1231234567456789' 0.500001      -> '1231234567456788' Inexact Rounded
ddsub561 subtract '1231234567456789' 0.51          -> '1231234567456788' Inexact Rounded
ddsub562 subtract '1231234567456789' 0.6           -> '1231234567456788' Inexact Rounded
ddsub563 subtract '1231234567456789' 0.9           -> '1231234567456788' Inexact Rounded
ddsub564 subtract '1231234567456789' 0.99999       -> '1231234567456788' Inexact Rounded
ddsub565 subtract '1231234567456789' 0.999999999   -> '1231234567456788' Inexact Rounded
ddsub566 subtract '1231234567456789' 1             -> '1231234567456788'
ddsub567 subtract '1231234567456789' 1.00000001    -> '1231234567456787' Inexact Rounded
ddsub568 subtract '1231234567456789' 1.00001       -> '1231234567456787' Inexact Rounded
ddsub569 subtract '1231234567456789' 1.1           -> '1231234567456787' Inexact Rounded

-- symmetry...
rounding: half_up
ddsub600 subtract 0             '1231234567456789' -> '-1231234567456789'
ddsub601 subtract 0.000000001   '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub602 subtract 0.000001      '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub603 subtract 0.1           '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub604 subtract 0.4           '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub605 subtract 0.49          '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub606 subtract 0.499999      '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub607 subtract 0.499999999   '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub608 subtract 0.5           '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub609 subtract 0.500000001   '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub610 subtract 0.500001      '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub611 subtract 0.51          '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub612 subtract 0.6           '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub613 subtract 0.9           '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub614 subtract 0.99999       '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub615 subtract 0.999999999   '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub616 subtract 1             '1231234567456789' -> '-1231234567456788'
ddsub617 subtract 1.000000001   '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub618 subtract 1.00001       '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub619 subtract 1.1           '1231234567456789' -> '-1231234567456788' Inexact Rounded

rounding: half_even
ddsub620 subtract 0             '1231234567456789' -> '-1231234567456789'
ddsub621 subtract 0.000000001   '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub622 subtract 0.000001      '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub623 subtract 0.1           '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub624 subtract 0.4           '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub625 subtract 0.49          '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub626 subtract 0.499999      '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub627 subtract 0.499999999   '1231234567456789' -> '-1231234567456789' Inexact Rounded
ddsub628 subtract 0.5           '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub629 subtract 0.500000001   '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub630 subtract 0.500001      '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub631 subtract 0.51          '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub632 subtract 0.6           '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub633 subtract 0.9           '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub634 subtract 0.99999       '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub635 subtract 0.999999999   '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub636 subtract 1             '1231234567456789' -> '-1231234567456788'
ddsub637 subtract 1.00000001    '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub638 subtract 1.00001       '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub639 subtract 1.1           '1231234567456789' -> '-1231234567456788' Inexact Rounded
-- critical few with even bottom digit...
ddsub640 subtract 0.499999999   '1231234567456788' -> '-1231234567456788' Inexact Rounded
ddsub641 subtract 0.5           '1231234567456788' -> '-1231234567456788' Inexact Rounded
ddsub642 subtract 0.500000001   '1231234567456788' -> '-1231234567456787' Inexact Rounded

rounding: down
ddsub650 subtract 0             '1231234567456789' -> '-1231234567456789'
ddsub651 subtract 0.000000001   '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub652 subtract 0.000001      '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub653 subtract 0.1           '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub654 subtract 0.4           '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub655 subtract 0.49          '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub656 subtract 0.499999      '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub657 subtract 0.499999999   '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub658 subtract 0.5           '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub659 subtract 0.500000001   '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub660 subtract 0.500001      '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub661 subtract 0.51          '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub662 subtract 0.6           '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub663 subtract 0.9           '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub664 subtract 0.99999       '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub665 subtract 0.999999999   '1231234567456789' -> '-1231234567456788' Inexact Rounded
ddsub666 subtract 1             '1231234567456789' -> '-1231234567456788'
ddsub667 subtract 1.00000001    '1231234567456789' -> '-1231234567456787' Inexact Rounded
ddsub668 subtract 1.00001       '1231234567456789' -> '-1231234567456787' Inexact Rounded
ddsub669 subtract 1.1           '1231234567456789' -> '-1231234567456787' Inexact Rounded


-- lots of leading zeros in intermediate result, and showing effects of
-- input rounding would have affected the following
rounding: half_up
ddsub670 subtract '1234567456789' '1234567456788.1' -> 0.9
ddsub671 subtract '1234567456789' '1234567456788.9' -> 0.1
ddsub672 subtract '1234567456789' '1234567456789.1' -> -0.1
ddsub673 subtract '1234567456789' '1234567456789.5' -> -0.5
ddsub674 subtract '1234567456789' '1234567456789.9' -> -0.9

rounding: half_even
ddsub680 subtract '1234567456789' '1234567456788.1' -> 0.9
ddsub681 subtract '1234567456789' '1234567456788.9' -> 0.1
ddsub682 subtract '1234567456789' '1234567456789.1' -> -0.1
ddsub683 subtract '1234567456789' '1234567456789.5' -> -0.5
ddsub684 subtract '1234567456789' '1234567456789.9' -> -0.9

ddsub685 subtract '1234567456788' '1234567456787.1' -> 0.9
ddsub686 subtract '1234567456788' '1234567456787.9' -> 0.1
ddsub687 subtract '1234567456788' '1234567456788.1' -> -0.1
ddsub688 subtract '1234567456788' '1234567456788.5' -> -0.5
ddsub689 subtract '1234567456788' '1234567456788.9' -> -0.9

rounding: down
ddsub690 subtract '1234567456789' '1234567456788.1' -> 0.9
ddsub691 subtract '1234567456789' '1234567456788.9' -> 0.1
ddsub692 subtract '1234567456789' '1234567456789.1' -> -0.1
ddsub693 subtract '1234567456789' '1234567456789.5' -> -0.5
ddsub694 subtract '1234567456789' '1234567456789.9' -> -0.9

-- Specials
ddsub780 subtract -Inf   Inf   -> -Infinity
ddsub781 subtract -Inf   1000  -> -Infinity
ddsub782 subtract -Inf   1     -> -Infinity
ddsub783 subtract -Inf  -0     -> -Infinity
ddsub784 subtract -Inf  -1     -> -Infinity
ddsub785 subtract -Inf  -1000  -> -Infinity
ddsub787 subtract -1000  Inf   -> -Infinity
ddsub788 subtract -Inf   Inf   -> -Infinity
ddsub789 subtract -1     Inf   -> -Infinity
ddsub790 subtract  0     Inf   -> -Infinity
ddsub791 subtract  1     Inf   -> -Infinity
ddsub792 subtract  1000  Inf   -> -Infinity

ddsub800 subtract  Inf   Inf   ->  NaN  Invalid_operation
ddsub801 subtract  Inf   1000  ->  Infinity
ddsub802 subtract  Inf   1     ->  Infinity
ddsub803 subtract  Inf   0     ->  Infinity
ddsub804 subtract  Inf  -0     ->  Infinity
ddsub805 subtract  Inf  -1     ->  Infinity
ddsub806 subtract  Inf  -1000  ->  Infinity
ddsub807 subtract  Inf  -Inf   ->  Infinity
ddsub808 subtract -1000 -Inf   ->  Infinity
ddsub809 subtract -Inf  -Inf   ->  NaN  Invalid_operation
ddsub810 subtract -1    -Inf   ->  Infinity
ddsub811 subtract -0    -Inf   ->  Infinity
ddsub812 subtract  0    -Inf   ->  Infinity
ddsub813 subtract  1    -Inf   ->  Infinity
ddsub814 subtract  1000 -Inf   ->  Infinity
ddsub815 subtract  Inf  -Inf   ->  Infinity

ddsub821 subtract  NaN   Inf   ->  NaN
ddsub822 subtract -NaN   1000  -> -NaN
ddsub823 subtract  NaN   1     ->  NaN
ddsub824 subtract  NaN   0     ->  NaN
ddsub825 subtract  NaN  -0     ->  NaN
ddsub826 subtract  NaN  -1     ->  NaN
ddsub827 subtract  NaN  -1000  ->  NaN
ddsub828 subtract  NaN  -Inf   ->  NaN
ddsub829 subtract -NaN   NaN   -> -NaN
ddsub830 subtract -Inf   NaN   ->  NaN
ddsub831 subtract -1000  NaN   ->  NaN
ddsub832 subtract -1     NaN   ->  NaN
ddsub833 subtract -0     NaN   ->  NaN
ddsub834 subtract  0     NaN   ->  NaN
ddsub835 subtract  1     NaN   ->  NaN
ddsub836 subtract  1000 -NaN   -> -NaN
ddsub837 subtract  Inf   NaN   ->  NaN

ddsub841 subtract  sNaN  Inf   ->  NaN  Invalid_operation
ddsub842 subtract -sNaN  1000  -> -NaN  Invalid_operation
ddsub843 subtract  sNaN  1     ->  NaN  Invalid_operation
ddsub844 subtract  sNaN  0     ->  NaN  Invalid_operation
ddsub845 subtract  sNaN -0     ->  NaN  Invalid_operation
ddsub846 subtract  sNaN -1     ->  NaN  Invalid_operation
ddsub847 subtract  sNaN -1000  ->  NaN  Invalid_operation
ddsub848 subtract  sNaN  NaN   ->  NaN  Invalid_operation
ddsub849 subtract  sNaN sNaN   ->  NaN  Invalid_operation
ddsub850 subtract  NaN  sNaN   ->  NaN  Invalid_operation
ddsub851 subtract -Inf -sNaN   -> -NaN  Invalid_operation
ddsub852 subtract -1000 sNaN   ->  NaN  Invalid_operation
ddsub853 subtract -1    sNaN   ->  NaN  Invalid_operation
ddsub854 subtract -0    sNaN   ->  NaN  Invalid_operation
ddsub855 subtract  0    sNaN   ->  NaN  Invalid_operation
ddsub856 subtract  1    sNaN   ->  NaN  Invalid_operation
ddsub857 subtract  1000 sNaN   ->  NaN  Invalid_operation
ddsub858 subtract  Inf  sNaN   ->  NaN  Invalid_operation
ddsub859 subtract  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddsub861 subtract  NaN01   -Inf     ->  NaN1
ddsub862 subtract -NaN02   -1000    -> -NaN2
ddsub863 subtract  NaN03    1000    ->  NaN3
ddsub864 subtract  NaN04    Inf     ->  NaN4
ddsub865 subtract  NaN05    NaN61   ->  NaN5
ddsub866 subtract -Inf     -NaN71   -> -NaN71
ddsub867 subtract -1000     NaN81   ->  NaN81
ddsub868 subtract  1000     NaN91   ->  NaN91
ddsub869 subtract  Inf      NaN101  ->  NaN101
ddsub871 subtract  sNaN011  -Inf    ->  NaN11  Invalid_operation
ddsub872 subtract  sNaN012  -1000   ->  NaN12  Invalid_operation
ddsub873 subtract -sNaN013   1000   -> -NaN13  Invalid_operation
ddsub874 subtract  sNaN014   NaN171 ->  NaN14  Invalid_operation
ddsub875 subtract  sNaN015  sNaN181 ->  NaN15  Invalid_operation
ddsub876 subtract  NaN016   sNaN191 ->  NaN191 Invalid_operation
ddsub877 subtract -Inf      sNaN201 ->  NaN201 Invalid_operation
ddsub878 subtract -1000     sNaN211 ->  NaN211 Invalid_operation
ddsub879 subtract  1000    -sNaN221 -> -NaN221 Invalid_operation
ddsub880 subtract  Inf      sNaN231 ->  NaN231 Invalid_operation
ddsub881 subtract  NaN025   sNaN241 ->  NaN241 Invalid_operation

-- edge case spills
ddsub901 subtract  2.E-3  1.002  -> -1.000
ddsub902 subtract  2.0E-3  1.002  -> -1.0000
ddsub903 subtract  2.00E-3  1.0020  -> -1.00000
ddsub904 subtract  2.000E-3  1.00200  -> -1.000000
ddsub905 subtract  2.0000E-3  1.002000  -> -1.0000000
ddsub906 subtract  2.00000E-3  1.0020000  -> -1.00000000
ddsub907 subtract  2.000000E-3  1.00200000  -> -1.000000000
ddsub908 subtract  2.0000000E-3  1.002000000  -> -1.0000000000

-- subnormals and overflows covered under Add

-- Null tests
ddsub9990 subtract 10  # -> NaN Invalid_operation
ddsub9991 subtract  # 10 -> NaN Invalid_operation

Added test/dectest/ddToIntegral.decTest.



































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
------------------------------------------------------------------------
-- ddToIntegral.decTest -- round Double to integral value             --
-- Copyright (c) IBM Corporation, 2001, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests tests the extended specification 'round-to-integral
-- value-exact' operations (from IEEE 854, later modified in 754r).
-- All non-zero results are defined as being those from either copy or
-- quantize, so those are assumed to have been tested extensively
-- elsewhere; the tests here are for integrity, rounding mode, etc.
-- Also, it is assumed the test harness will use these tests for both
-- ToIntegralExact (which does set Inexact) and the fixed-name
-- functions (which do not set Inexact).

-- Note that decNumber implements an earlier definition of toIntegral
-- which never sets Inexact; the decTest operator for that is called
-- 'tointegral' instead of 'tointegralx'.

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

ddintx001 tointegralx      0     ->  0
ddintx002 tointegralx      0.0   ->  0
ddintx003 tointegralx      0.1   ->  0  Inexact Rounded
ddintx004 tointegralx      0.2   ->  0  Inexact Rounded
ddintx005 tointegralx      0.3   ->  0  Inexact Rounded
ddintx006 tointegralx      0.4   ->  0  Inexact Rounded
ddintx007 tointegralx      0.5   ->  0  Inexact Rounded
ddintx008 tointegralx      0.6   ->  1  Inexact Rounded
ddintx009 tointegralx      0.7   ->  1  Inexact Rounded
ddintx010 tointegralx      0.8   ->  1  Inexact Rounded
ddintx011 tointegralx      0.9   ->  1  Inexact Rounded
ddintx012 tointegralx      1     ->  1
ddintx013 tointegralx      1.0   ->  1  Rounded
ddintx014 tointegralx      1.1   ->  1  Inexact Rounded
ddintx015 tointegralx      1.2   ->  1  Inexact Rounded
ddintx016 tointegralx      1.3   ->  1  Inexact Rounded
ddintx017 tointegralx      1.4   ->  1  Inexact Rounded
ddintx018 tointegralx      1.5   ->  2  Inexact Rounded
ddintx019 tointegralx      1.6   ->  2  Inexact Rounded
ddintx020 tointegralx      1.7   ->  2  Inexact Rounded
ddintx021 tointegralx      1.8   ->  2  Inexact Rounded
ddintx022 tointegralx      1.9   ->  2  Inexact Rounded
-- negatives
ddintx031 tointegralx     -0     -> -0
ddintx032 tointegralx     -0.0   -> -0
ddintx033 tointegralx     -0.1   -> -0  Inexact Rounded
ddintx034 tointegralx     -0.2   -> -0  Inexact Rounded
ddintx035 tointegralx     -0.3   -> -0  Inexact Rounded
ddintx036 tointegralx     -0.4   -> -0  Inexact Rounded
ddintx037 tointegralx     -0.5   -> -0  Inexact Rounded
ddintx038 tointegralx     -0.6   -> -1  Inexact Rounded
ddintx039 tointegralx     -0.7   -> -1  Inexact Rounded
ddintx040 tointegralx     -0.8   -> -1  Inexact Rounded
ddintx041 tointegralx     -0.9   -> -1  Inexact Rounded
ddintx042 tointegralx     -1     -> -1
ddintx043 tointegralx     -1.0   -> -1  Rounded
ddintx044 tointegralx     -1.1   -> -1  Inexact Rounded
ddintx045 tointegralx     -1.2   -> -1  Inexact Rounded
ddintx046 tointegralx     -1.3   -> -1  Inexact Rounded
ddintx047 tointegralx     -1.4   -> -1  Inexact Rounded
ddintx048 tointegralx     -1.5   -> -2  Inexact Rounded
ddintx049 tointegralx     -1.6   -> -2  Inexact Rounded
ddintx050 tointegralx     -1.7   -> -2  Inexact Rounded
ddintx051 tointegralx     -1.8   -> -2  Inexact Rounded
ddintx052 tointegralx     -1.9   -> -2  Inexact Rounded
-- next two would be NaN using quantize(x, 0)
ddintx053 tointegralx    10E+60  -> 1.0E+61
ddintx054 tointegralx   -10E+60  -> -1.0E+61

-- numbers around precision
ddintx060 tointegralx '56267E-17'   -> '0'      Inexact Rounded
ddintx061 tointegralx '56267E-5'    -> '1'      Inexact Rounded
ddintx062 tointegralx '56267E-2'    -> '563'    Inexact Rounded
ddintx063 tointegralx '56267E-1'    -> '5627'   Inexact Rounded
ddintx065 tointegralx '56267E-0'    -> '56267'
ddintx066 tointegralx '56267E+0'    -> '56267'
ddintx067 tointegralx '56267E+1'    -> '5.6267E+5'
ddintx068 tointegralx '56267E+9'    -> '5.6267E+13'
ddintx069 tointegralx '56267E+10'   -> '5.6267E+14'
ddintx070 tointegralx '56267E+11'   -> '5.6267E+15'
ddintx071 tointegralx '56267E+12'   -> '5.6267E+16'
ddintx072 tointegralx '56267E+13'   -> '5.6267E+17'
ddintx073 tointegralx '1.23E+96'    -> '1.23E+96'
ddintx074 tointegralx '1.23E+384'   -> #47fd300000000000  Clamped

ddintx080 tointegralx '-56267E-10'  -> '-0'      Inexact Rounded
ddintx081 tointegralx '-56267E-5'   -> '-1'      Inexact Rounded
ddintx082 tointegralx '-56267E-2'   -> '-563'    Inexact Rounded
ddintx083 tointegralx '-56267E-1'   -> '-5627'   Inexact Rounded
ddintx085 tointegralx '-56267E-0'   -> '-56267'
ddintx086 tointegralx '-56267E+0'   -> '-56267'
ddintx087 tointegralx '-56267E+1'   -> '-5.6267E+5'
ddintx088 tointegralx '-56267E+9'   -> '-5.6267E+13'
ddintx089 tointegralx '-56267E+10'  -> '-5.6267E+14'
ddintx090 tointegralx '-56267E+11'  -> '-5.6267E+15'
ddintx091 tointegralx '-56267E+12'  -> '-5.6267E+16'
ddintx092 tointegralx '-56267E+13'  -> '-5.6267E+17'
ddintx093 tointegralx '-1.23E+96'   -> '-1.23E+96'
ddintx094 tointegralx '-1.23E+384'  -> #c7fd300000000000  Clamped

-- subnormal inputs
ddintx100 tointegralx        1E-299 -> 0  Inexact Rounded
ddintx101 tointegralx      0.1E-299 -> 0  Inexact Rounded
ddintx102 tointegralx     0.01E-299 -> 0  Inexact Rounded
ddintx103 tointegralx        0E-299 -> 0

-- specials and zeros
ddintx120 tointegralx 'Inf'       ->  Infinity
ddintx121 tointegralx '-Inf'      -> -Infinity
ddintx122 tointegralx   NaN       ->  NaN
ddintx123 tointegralx  sNaN       ->  NaN  Invalid_operation
ddintx124 tointegralx     0       ->  0
ddintx125 tointegralx    -0       -> -0
ddintx126 tointegralx     0.000   ->  0
ddintx127 tointegralx     0.00    ->  0
ddintx128 tointegralx     0.0     ->  0
ddintx129 tointegralx     0       ->  0
ddintx130 tointegralx     0E-3    ->  0
ddintx131 tointegralx     0E-2    ->  0
ddintx132 tointegralx     0E-1    ->  0
ddintx133 tointegralx     0E-0    ->  0
ddintx134 tointegralx     0E+1    ->  0E+1
ddintx135 tointegralx     0E+2    ->  0E+2
ddintx136 tointegralx     0E+3    ->  0E+3
ddintx137 tointegralx     0E+4    ->  0E+4
ddintx138 tointegralx     0E+5    ->  0E+5
ddintx139 tointegralx    -0.000   -> -0
ddintx140 tointegralx    -0.00    -> -0
ddintx141 tointegralx    -0.0     -> -0
ddintx142 tointegralx    -0       -> -0
ddintx143 tointegralx    -0E-3    -> -0
ddintx144 tointegralx    -0E-2    -> -0
ddintx145 tointegralx    -0E-1    -> -0
ddintx146 tointegralx    -0E-0    -> -0
ddintx147 tointegralx    -0E+1    -> -0E+1
ddintx148 tointegralx    -0E+2    -> -0E+2
ddintx149 tointegralx    -0E+3    -> -0E+3
ddintx150 tointegralx    -0E+4    -> -0E+4
ddintx151 tointegralx    -0E+5    -> -0E+5
-- propagating NaNs
ddintx152 tointegralx   NaN808    ->  NaN808
ddintx153 tointegralx  sNaN080    ->  NaN80  Invalid_operation
ddintx154 tointegralx  -NaN808    -> -NaN808
ddintx155 tointegralx -sNaN080    -> -NaN80  Invalid_operation
ddintx156 tointegralx  -NaN       -> -NaN
ddintx157 tointegralx -sNaN       -> -NaN    Invalid_operation

-- examples
rounding:    half_up
ddintx200 tointegralx     2.1    -> 2            Inexact Rounded
ddintx201 tointegralx   100      -> 100
ddintx202 tointegralx   100.0    -> 100          Rounded
ddintx203 tointegralx   101.5    -> 102          Inexact Rounded
ddintx204 tointegralx  -101.5    -> -102         Inexact Rounded
ddintx205 tointegralx   10E+5    -> 1.0E+6
ddintx206 tointegralx  7.89E+77  -> 7.89E+77
ddintx207 tointegralx   -Inf     -> -Infinity


-- all rounding modes
rounding:    half_even
ddintx210 tointegralx     55.5   ->  56  Inexact Rounded
ddintx211 tointegralx     56.5   ->  56  Inexact Rounded
ddintx212 tointegralx     57.5   ->  58  Inexact Rounded
ddintx213 tointegralx    -55.5   -> -56  Inexact Rounded
ddintx214 tointegralx    -56.5   -> -56  Inexact Rounded
ddintx215 tointegralx    -57.5   -> -58  Inexact Rounded

rounding:    half_up

ddintx220 tointegralx     55.5   ->  56  Inexact Rounded
ddintx221 tointegralx     56.5   ->  57  Inexact Rounded
ddintx222 tointegralx     57.5   ->  58  Inexact Rounded
ddintx223 tointegralx    -55.5   -> -56  Inexact Rounded
ddintx224 tointegralx    -56.5   -> -57  Inexact Rounded
ddintx225 tointegralx    -57.5   -> -58  Inexact Rounded

rounding:    half_down

ddintx230 tointegralx     55.5   ->  55  Inexact Rounded
ddintx231 tointegralx     56.5   ->  56  Inexact Rounded
ddintx232 tointegralx     57.5   ->  57  Inexact Rounded
ddintx233 tointegralx    -55.5   -> -55  Inexact Rounded
ddintx234 tointegralx    -56.5   -> -56  Inexact Rounded
ddintx235 tointegralx    -57.5   -> -57  Inexact Rounded

rounding:    up

ddintx240 tointegralx     55.3   ->  56  Inexact Rounded
ddintx241 tointegralx     56.3   ->  57  Inexact Rounded
ddintx242 tointegralx     57.3   ->  58  Inexact Rounded
ddintx243 tointegralx    -55.3   -> -56  Inexact Rounded
ddintx244 tointegralx    -56.3   -> -57  Inexact Rounded
ddintx245 tointegralx    -57.3   -> -58  Inexact Rounded

rounding:    down

ddintx250 tointegralx     55.7   ->  55  Inexact Rounded
ddintx251 tointegralx     56.7   ->  56  Inexact Rounded
ddintx252 tointegralx     57.7   ->  57  Inexact Rounded
ddintx253 tointegralx    -55.7   -> -55  Inexact Rounded
ddintx254 tointegralx    -56.7   -> -56  Inexact Rounded
ddintx255 tointegralx    -57.7   -> -57  Inexact Rounded

rounding:    ceiling

ddintx260 tointegralx     55.3   ->  56  Inexact Rounded
ddintx261 tointegralx     56.3   ->  57  Inexact Rounded
ddintx262 tointegralx     57.3   ->  58  Inexact Rounded
ddintx263 tointegralx    -55.3   -> -55  Inexact Rounded
ddintx264 tointegralx    -56.3   -> -56  Inexact Rounded
ddintx265 tointegralx    -57.3   -> -57  Inexact Rounded

rounding:    floor

ddintx270 tointegralx     55.7   ->  55  Inexact Rounded
ddintx271 tointegralx     56.7   ->  56  Inexact Rounded
ddintx272 tointegralx     57.7   ->  57  Inexact Rounded
ddintx273 tointegralx    -55.7   -> -56  Inexact Rounded
ddintx274 tointegralx    -56.7   -> -57  Inexact Rounded
ddintx275 tointegralx    -57.7   -> -58  Inexact Rounded

-- Int and uInt32 edge values for testing conversions
ddintx300 tointegralx -2147483646  -> -2147483646
ddintx301 tointegralx -2147483647  -> -2147483647
ddintx302 tointegralx -2147483648  -> -2147483648
ddintx303 tointegralx -2147483649  -> -2147483649
ddintx304 tointegralx  2147483646  ->  2147483646
ddintx305 tointegralx  2147483647  ->  2147483647
ddintx306 tointegralx  2147483648  ->  2147483648
ddintx307 tointegralx  2147483649  ->  2147483649
ddintx308 tointegralx  4294967294  ->  4294967294
ddintx309 tointegralx  4294967295  ->  4294967295
ddintx310 tointegralx  4294967296  ->  4294967296
ddintx311 tointegralx  4294967297  ->  4294967297

Added test/dectest/ddXor.decTest.



































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
------------------------------------------------------------------------
-- ddXor.decTest -- digitwise logical XOR for decDoubles              --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

precision:   16
maxExponent: 384
minExponent: -383
extended:    1
clamp:       1
rounding:    half_even

-- Sanity check (truth table)
ddxor001 xor             0    0 ->    0
ddxor002 xor             0    1 ->    1
ddxor003 xor             1    0 ->    1
ddxor004 xor             1    1 ->    0
ddxor005 xor          1100 1010 ->  110
-- and at msd and msd-1
ddxor006 xor 0000000000000000 0000000000000000 ->           0
ddxor007 xor 0000000000000000 1000000000000000 ->   1000000000000000
ddxor008 xor 1000000000000000 0000000000000000 ->   1000000000000000
ddxor009 xor 1000000000000000 1000000000000000 ->           0
ddxor010 xor 0000000000000000 0000000000000000 ->           0
ddxor011 xor 0000000000000000 0100000000000000 ->    100000000000000
ddxor012 xor 0100000000000000 0000000000000000 ->    100000000000000
ddxor013 xor 0100000000000000 0100000000000000 ->           0

-- Various lengths
--          1234567890123456     1234567890123456 1234567890123456
ddxor021 xor 1111111110000000     1111111110000000  ->  0
ddxor022 xor  111111110000000      111111110000000  ->  0
ddxor023 xor   11111110000000       11111110000000  ->  0
ddxor024 xor    1111110000000        1111110000000  ->  0
ddxor025 xor     111110000000         111110000000  ->  0
ddxor026 xor      11110000000          11110000000  ->  0
ddxor027 xor       1110000000           1110000000  ->  0
ddxor028 xor        110000000            110000000  ->  0
ddxor029 xor         10000000             10000000  ->  0
ddxor030 xor          1000000              1000000  ->  0
ddxor031 xor           100000               100000  ->  0
ddxor032 xor            10000                10000  ->  0
ddxor033 xor             1000                 1000  ->  0
ddxor034 xor              100                  100  ->  0
ddxor035 xor               10                   10  ->  0
ddxor036 xor                1                    1  ->  0

ddxor040 xor 111111111  111111111111  ->  111000000000
ddxor041 xor  11111111  111111111111  ->  111100000000
ddxor042 xor  11111111     111111111  ->  100000000
ddxor043 xor   1111111     100000010  ->  101111101
ddxor044 xor    111111     100000100  ->  100111011
ddxor045 xor     11111     100001000  ->  100010111
ddxor046 xor      1111     100010000  ->  100011111
ddxor047 xor       111     100100000  ->  100100111
ddxor048 xor        11     101000000  ->  101000011
ddxor049 xor         1     110000000  ->  110000001

ddxor050 xor 1111111111  1  ->  1111111110
ddxor051 xor  111111111  1  ->  111111110
ddxor052 xor   11111111  1  ->  11111110
ddxor053 xor    1111111  1  ->  1111110
ddxor054 xor     111111  1  ->  111110
ddxor055 xor      11111  1  ->  11110
ddxor056 xor       1111  1  ->  1110
ddxor057 xor        111  1  ->  110
ddxor058 xor         11  1  ->  10
ddxor059 xor          1  1  ->  0

ddxor060 xor 1111111111  0  ->  1111111111
ddxor061 xor  111111111  0  ->  111111111
ddxor062 xor   11111111  0  ->  11111111
ddxor063 xor    1111111  0  ->  1111111
ddxor064 xor     111111  0  ->  111111
ddxor065 xor      11111  0  ->  11111
ddxor066 xor       1111  0  ->  1111
ddxor067 xor        111  0  ->  111
ddxor068 xor         11  0  ->  11
ddxor069 xor          1  0  ->  1

ddxor070 xor 1  1111111111  ->  1111111110
ddxor071 xor 1   111111111  ->  111111110
ddxor072 xor 1    11111111  ->  11111110
ddxor073 xor 1     1111111  ->  1111110
ddxor074 xor 1      111111  ->  111110
ddxor075 xor 1       11111  ->  11110
ddxor076 xor 1        1111  ->  1110
ddxor077 xor 1         111  ->  110
ddxor078 xor 1          11  ->  10
ddxor079 xor 1           1  ->  0

ddxor080 xor 0  1111111111  ->  1111111111
ddxor081 xor 0   111111111  ->  111111111
ddxor082 xor 0    11111111  ->  11111111
ddxor083 xor 0     1111111  ->  1111111
ddxor084 xor 0      111111  ->  111111
ddxor085 xor 0       11111  ->  11111
ddxor086 xor 0        1111  ->  1111
ddxor087 xor 0         111  ->  111
ddxor088 xor 0          11  ->  11
ddxor089 xor 0           1  ->  1

ddxor090 xor 011111111  111101111  ->  100010000
ddxor091 xor 101111111  111101111  ->   10010000
ddxor092 xor 110111111  111101111  ->    1010000
ddxor093 xor 111011111  111101111  ->     110000
ddxor094 xor 111101111  111101111  ->          0
ddxor095 xor 111110111  111101111  ->      11000
ddxor096 xor 111111011  111101111  ->      10100
ddxor097 xor 111111101  111101111  ->      10010
ddxor098 xor 111111110  111101111  ->      10001

ddxor100 xor 111101111  011111111  ->  100010000
ddxor101 xor 111101111  101111111  ->   10010000
ddxor102 xor 111101111  110111111  ->    1010000
ddxor103 xor 111101111  111011111  ->     110000
ddxor104 xor 111101111  111101111  ->          0
ddxor105 xor 111101111  111110111  ->      11000
ddxor106 xor 111101111  111111011  ->      10100
ddxor107 xor 111101111  111111101  ->      10010
ddxor108 xor 111101111  111111110  ->      10001

-- non-0/1 should not be accepted, nor should signs
ddxor220 xor 111111112  111111111  ->  NaN Invalid_operation
ddxor221 xor 333333333  333333333  ->  NaN Invalid_operation
ddxor222 xor 555555555  555555555  ->  NaN Invalid_operation
ddxor223 xor 777777777  777777777  ->  NaN Invalid_operation
ddxor224 xor 999999999  999999999  ->  NaN Invalid_operation
ddxor225 xor 222222222  999999999  ->  NaN Invalid_operation
ddxor226 xor 444444444  999999999  ->  NaN Invalid_operation
ddxor227 xor 666666666  999999999  ->  NaN Invalid_operation
ddxor228 xor 888888888  999999999  ->  NaN Invalid_operation
ddxor229 xor 999999999  222222222  ->  NaN Invalid_operation
ddxor230 xor 999999999  444444444  ->  NaN Invalid_operation
ddxor231 xor 999999999  666666666  ->  NaN Invalid_operation
ddxor232 xor 999999999  888888888  ->  NaN Invalid_operation
-- a few randoms
ddxor240 xor  567468689 -934981942 ->  NaN Invalid_operation
ddxor241 xor  567367689  934981942 ->  NaN Invalid_operation
ddxor242 xor -631917772 -706014634 ->  NaN Invalid_operation
ddxor243 xor -756253257  138579234 ->  NaN Invalid_operation
ddxor244 xor  835590149  567435400 ->  NaN Invalid_operation
-- test MSD
ddxor250 xor  2000000000000000 1000000000000000 ->  NaN Invalid_operation
ddxor251 xor  7000000000000000 1000000000000000 ->  NaN Invalid_operation
ddxor252 xor  8000000000000000 1000000000000000 ->  NaN Invalid_operation
ddxor253 xor  9000000000000000 1000000000000000 ->  NaN Invalid_operation
ddxor254 xor  2000000000000000 0000000000000000 ->  NaN Invalid_operation
ddxor255 xor  7000000000000000 0000000000000000 ->  NaN Invalid_operation
ddxor256 xor  8000000000000000 0000000000000000 ->  NaN Invalid_operation
ddxor257 xor  9000000000000000 0000000000000000 ->  NaN Invalid_operation
ddxor258 xor  1000000000000000 2000000000000000 ->  NaN Invalid_operation
ddxor259 xor  1000000000000000 7000000000000000 ->  NaN Invalid_operation
ddxor260 xor  1000000000000000 8000000000000000 ->  NaN Invalid_operation
ddxor261 xor  1000000000000000 9000000000000000 ->  NaN Invalid_operation
ddxor262 xor  0000000000000000 2000000000000000 ->  NaN Invalid_operation
ddxor263 xor  0000000000000000 7000000000000000 ->  NaN Invalid_operation
ddxor264 xor  0000000000000000 8000000000000000 ->  NaN Invalid_operation
ddxor265 xor  0000000000000000 9000000000000000 ->  NaN Invalid_operation
-- test MSD-1
ddxor270 xor  0200001000000000 1000100000000010 ->  NaN Invalid_operation
ddxor271 xor  0700000100000000 1000010000000100 ->  NaN Invalid_operation
ddxor272 xor  0800000010000000 1000001000001000 ->  NaN Invalid_operation
ddxor273 xor  0900000001000000 1000000100010000 ->  NaN Invalid_operation
ddxor274 xor  1000000000100000 0200000010100000 ->  NaN Invalid_operation
ddxor275 xor  1000000000010000 0700000001000000 ->  NaN Invalid_operation
ddxor276 xor  1000000000001000 0800000010100000 ->  NaN Invalid_operation
ddxor277 xor  1000000000000100 0900000000010000 ->  NaN Invalid_operation
-- test LSD
ddxor280 xor  0010000000000002 1000000100000001 ->  NaN Invalid_operation
ddxor281 xor  0001000000000007 1000001000000011 ->  NaN Invalid_operation
ddxor282 xor  0000100000000008 1000010000000001 ->  NaN Invalid_operation
ddxor283 xor  0000010000000009 1000100000000001 ->  NaN Invalid_operation
ddxor284 xor  1000001000000000 0001000000000002 ->  NaN Invalid_operation
ddxor285 xor  1000000100000000 0010000000000007 ->  NaN Invalid_operation
ddxor286 xor  1000000010000000 0100000000000008 ->  NaN Invalid_operation
ddxor287 xor  1000000001000000 1000000000000009 ->  NaN Invalid_operation
-- test Middie
ddxor288 xor  0010000020000000 1000001000000000 ->  NaN Invalid_operation
ddxor289 xor  0001000070000001 1000000100000000 ->  NaN Invalid_operation
ddxor290 xor  0000100080000010 1000000010000000 ->  NaN Invalid_operation
ddxor291 xor  0000010090000100 1000000001000000 ->  NaN Invalid_operation
ddxor292 xor  1000001000001000 0000000020100000 ->  NaN Invalid_operation
ddxor293 xor  1000000100010000 0000000070010000 ->  NaN Invalid_operation
ddxor294 xor  1000000010100000 0000000080001000 ->  NaN Invalid_operation
ddxor295 xor  1000000001000000 0000000090000100 ->  NaN Invalid_operation
-- signs
ddxor296 xor -1000000001000000 -0000010000000100 ->  NaN Invalid_operation
ddxor297 xor -1000000001000000  0000000010000100 ->  NaN Invalid_operation
ddxor298 xor  1000000001000000 -0000001000000100 ->  NaN Invalid_operation
ddxor299 xor  1000000001000000  0000000011000100 ->  1000000010000100

-- Nmax, Nmin, Ntiny-like
ddxor331 xor  2   9.99999999E+299     -> NaN Invalid_operation
ddxor332 xor  3   1E-299              -> NaN Invalid_operation
ddxor333 xor  4   1.00000000E-299     -> NaN Invalid_operation
ddxor334 xor  5   1E-200              -> NaN Invalid_operation
ddxor335 xor  6   -1E-200             -> NaN Invalid_operation
ddxor336 xor  7   -1.00000000E-299    -> NaN Invalid_operation
ddxor337 xor  8   -1E-299             -> NaN Invalid_operation
ddxor338 xor  9   -9.99999999E+299    -> NaN Invalid_operation
ddxor341 xor  9.99999999E+299     -18 -> NaN Invalid_operation
ddxor342 xor  1E-299               01 -> NaN Invalid_operation
ddxor343 xor  1.00000000E-299     -18 -> NaN Invalid_operation
ddxor344 xor  1E-208               18 -> NaN Invalid_operation
ddxor345 xor  -1E-207             -10 -> NaN Invalid_operation
ddxor346 xor  -1.00000000E-299     18 -> NaN Invalid_operation
ddxor347 xor  -1E-299              10 -> NaN Invalid_operation
ddxor348 xor  -9.99999999E+299    -18 -> NaN Invalid_operation

-- A few other non-integers
ddxor361 xor  1.0                  1  -> NaN Invalid_operation
ddxor362 xor  1E+1                 1  -> NaN Invalid_operation
ddxor363 xor  0.0                  1  -> NaN Invalid_operation
ddxor364 xor  0E+1                 1  -> NaN Invalid_operation
ddxor365 xor  9.9                  1  -> NaN Invalid_operation
ddxor366 xor  9E+1                 1  -> NaN Invalid_operation
ddxor371 xor  0 1.0                   -> NaN Invalid_operation
ddxor372 xor  0 1E+1                  -> NaN Invalid_operation
ddxor373 xor  0 0.0                   -> NaN Invalid_operation
ddxor374 xor  0 0E+1                  -> NaN Invalid_operation
ddxor375 xor  0 9.9                   -> NaN Invalid_operation
ddxor376 xor  0 9E+1                  -> NaN Invalid_operation

-- All Specials are in error
ddxor780 xor -Inf  -Inf   -> NaN Invalid_operation
ddxor781 xor -Inf  -1000  -> NaN Invalid_operation
ddxor782 xor -Inf  -1     -> NaN Invalid_operation
ddxor783 xor -Inf  -0     -> NaN Invalid_operation
ddxor784 xor -Inf   0     -> NaN Invalid_operation
ddxor785 xor -Inf   1     -> NaN Invalid_operation
ddxor786 xor -Inf   1000  -> NaN Invalid_operation
ddxor787 xor -1000 -Inf   -> NaN Invalid_operation
ddxor788 xor -Inf  -Inf   -> NaN Invalid_operation
ddxor789 xor -1    -Inf   -> NaN Invalid_operation
ddxor790 xor -0    -Inf   -> NaN Invalid_operation
ddxor791 xor  0    -Inf   -> NaN Invalid_operation
ddxor792 xor  1    -Inf   -> NaN Invalid_operation
ddxor793 xor  1000 -Inf   -> NaN Invalid_operation
ddxor794 xor  Inf  -Inf   -> NaN Invalid_operation

ddxor800 xor  Inf  -Inf   -> NaN Invalid_operation
ddxor801 xor  Inf  -1000  -> NaN Invalid_operation
ddxor802 xor  Inf  -1     -> NaN Invalid_operation
ddxor803 xor  Inf  -0     -> NaN Invalid_operation
ddxor804 xor  Inf   0     -> NaN Invalid_operation
ddxor805 xor  Inf   1     -> NaN Invalid_operation
ddxor806 xor  Inf   1000  -> NaN Invalid_operation
ddxor807 xor  Inf   Inf   -> NaN Invalid_operation
ddxor808 xor -1000  Inf   -> NaN Invalid_operation
ddxor809 xor -Inf   Inf   -> NaN Invalid_operation
ddxor810 xor -1     Inf   -> NaN Invalid_operation
ddxor811 xor -0     Inf   -> NaN Invalid_operation
ddxor812 xor  0     Inf   -> NaN Invalid_operation
ddxor813 xor  1     Inf   -> NaN Invalid_operation
ddxor814 xor  1000  Inf   -> NaN Invalid_operation
ddxor815 xor  Inf   Inf   -> NaN Invalid_operation

ddxor821 xor  NaN -Inf    -> NaN Invalid_operation
ddxor822 xor  NaN -1000   -> NaN Invalid_operation
ddxor823 xor  NaN -1      -> NaN Invalid_operation
ddxor824 xor  NaN -0      -> NaN Invalid_operation
ddxor825 xor  NaN  0      -> NaN Invalid_operation
ddxor826 xor  NaN  1      -> NaN Invalid_operation
ddxor827 xor  NaN  1000   -> NaN Invalid_operation
ddxor828 xor  NaN  Inf    -> NaN Invalid_operation
ddxor829 xor  NaN  NaN    -> NaN Invalid_operation
ddxor830 xor -Inf  NaN    -> NaN Invalid_operation
ddxor831 xor -1000 NaN    -> NaN Invalid_operation
ddxor832 xor -1    NaN    -> NaN Invalid_operation
ddxor833 xor -0    NaN    -> NaN Invalid_operation
ddxor834 xor  0    NaN    -> NaN Invalid_operation
ddxor835 xor  1    NaN    -> NaN Invalid_operation
ddxor836 xor  1000 NaN    -> NaN Invalid_operation
ddxor837 xor  Inf  NaN    -> NaN Invalid_operation

ddxor841 xor  sNaN -Inf   ->  NaN  Invalid_operation
ddxor842 xor  sNaN -1000  ->  NaN  Invalid_operation
ddxor843 xor  sNaN -1     ->  NaN  Invalid_operation
ddxor844 xor  sNaN -0     ->  NaN  Invalid_operation
ddxor845 xor  sNaN  0     ->  NaN  Invalid_operation
ddxor846 xor  sNaN  1     ->  NaN  Invalid_operation
ddxor847 xor  sNaN  1000  ->  NaN  Invalid_operation
ddxor848 xor  sNaN  NaN   ->  NaN  Invalid_operation
ddxor849 xor  sNaN sNaN   ->  NaN  Invalid_operation
ddxor850 xor  NaN  sNaN   ->  NaN  Invalid_operation
ddxor851 xor -Inf  sNaN   ->  NaN  Invalid_operation
ddxor852 xor -1000 sNaN   ->  NaN  Invalid_operation
ddxor853 xor -1    sNaN   ->  NaN  Invalid_operation
ddxor854 xor -0    sNaN   ->  NaN  Invalid_operation
ddxor855 xor  0    sNaN   ->  NaN  Invalid_operation
ddxor856 xor  1    sNaN   ->  NaN  Invalid_operation
ddxor857 xor  1000 sNaN   ->  NaN  Invalid_operation
ddxor858 xor  Inf  sNaN   ->  NaN  Invalid_operation
ddxor859 xor  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
ddxor861 xor  NaN1   -Inf    -> NaN Invalid_operation
ddxor862 xor +NaN2   -1000   -> NaN Invalid_operation
ddxor863 xor  NaN3    1000   -> NaN Invalid_operation
ddxor864 xor  NaN4    Inf    -> NaN Invalid_operation
ddxor865 xor  NaN5   +NaN6   -> NaN Invalid_operation
ddxor866 xor -Inf     NaN7   -> NaN Invalid_operation
ddxor867 xor -1000    NaN8   -> NaN Invalid_operation
ddxor868 xor  1000    NaN9   -> NaN Invalid_operation
ddxor869 xor  Inf    +NaN10  -> NaN Invalid_operation
ddxor871 xor  sNaN11  -Inf   -> NaN Invalid_operation
ddxor872 xor  sNaN12  -1000  -> NaN Invalid_operation
ddxor873 xor  sNaN13   1000  -> NaN Invalid_operation
ddxor874 xor  sNaN14   NaN17 -> NaN Invalid_operation
ddxor875 xor  sNaN15  sNaN18 -> NaN Invalid_operation
ddxor876 xor  NaN16   sNaN19 -> NaN Invalid_operation
ddxor877 xor -Inf    +sNaN20 -> NaN Invalid_operation
ddxor878 xor -1000    sNaN21 -> NaN Invalid_operation
ddxor879 xor  1000    sNaN22 -> NaN Invalid_operation
ddxor880 xor  Inf     sNaN23 -> NaN Invalid_operation
ddxor881 xor +NaN25  +sNaN24 -> NaN Invalid_operation
ddxor882 xor -NaN26    NaN28 -> NaN Invalid_operation
ddxor883 xor -sNaN27  sNaN29 -> NaN Invalid_operation
ddxor884 xor  1000    -NaN30 -> NaN Invalid_operation
ddxor885 xor  1000   -sNaN31 -> NaN Invalid_operation

Added test/dectest/decDouble.decTest.



































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
------------------------------------------------------------------------
-- decDouble.decTest -- run all decDouble decimal arithmetic tests    --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- decDouble tests
dectest: ddAbs
dectest: ddAdd
dectest: ddAnd
dectest: ddBase
dectest: ddCanonical
dectest: ddClass
dectest: ddCompare
dectest: ddCompareSig
dectest: ddCompareTotal
dectest: ddCompareTotalMag
dectest: ddCopy
dectest: ddCopyAbs
dectest: ddCopyNegate
dectest: ddCopySign
dectest: ddDivide
dectest: ddDivideInt
dectest: ddEncode
dectest: ddFMA
dectest: ddInvert
dectest: ddLogB
dectest: ddMax
dectest: ddMaxMag
dectest: ddMin
dectest: ddMinMag
dectest: ddMinus
dectest: ddMultiply
dectest: ddNextMinus
dectest: ddNextPlus
dectest: ddNextToward
dectest: ddOr
dectest: ddPlus
dectest: ddQuantize
dectest: ddReduce
dectest: ddRemainder
dectest: ddRemainderNear
dectest: ddRotate
dectest: ddSameQuantum
dectest: ddScaleB
dectest: ddShift
dectest: ddSubtract
dectest: ddToIntegral
dectest: ddXor

Added test/dectest/decQuad.decTest.



































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
------------------------------------------------------------------------
-- decQuad.decTest -- run all decQuad decimal arithmetic tests        --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- decQuad tests
dectest: dqAbs
dectest: dqAdd
dectest: dqAnd
dectest: dqBase
dectest: dqCanonical
dectest: dqClass
dectest: dqCompare
dectest: dqCompareSig
dectest: dqCompareTotal
dectest: dqCompareTotalMag
dectest: dqCopy
dectest: dqCopyAbs
dectest: dqCopyNegate
dectest: dqCopySign
dectest: dqDivide
dectest: dqDivideInt
dectest: dqEncode
dectest: dqFMA
dectest: dqInvert
dectest: dqLogB
dectest: dqMax
dectest: dqMaxMag
dectest: dqMin
dectest: dqMinMag
dectest: dqMinus
dectest: dqMultiply
dectest: dqNextMinus
dectest: dqNextPlus
dectest: dqNextToward
dectest: dqOr
dectest: dqPlus
dectest: dqQuantize
dectest: dqReduce
dectest: dqRemainder
dectest: dqRemainderNear
dectest: dqRotate
dectest: dqSameQuantum
dectest: dqScaleB
dectest: dqShift
dectest: dqSubtract
dectest: dqToIntegral
dectest: dqXor

Added test/dectest/decSingle.decTest.



















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
------------------------------------------------------------------------
-- decSingle.decTest -- run all decSingle decimal arithmetic tests    --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- decSingle tests
dectest: dsBase
dectest: dsEncode

Deleted test/dectest/decimal128.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
------------------------------------------------------------------------
-- decimal128.decTest -- decimal sixteen-byte format testcases        --
-- Copyright (c) IBM Corporation, 2000, 2003.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- This set of tests is for the sixteen-byte concrete representation.
-- Its characteristics are:
--
--   1 bit  sign
--   5 bits combination field
--  12 bits exponent continuation
-- 110 bits coefficient continuation
--
-- Total exponent length 14 bits
-- Total coefficient length 114 bits (34 digits)
--
-- Elimit = 12287 (maximum encoded exponent)
-- Emax   =  6144 (largest exponent value)
-- Emin   = -6143 (smallest exponent value)
-- bias   =  6176 (subtracted from encoded exponent) = -Etiny

extended:    1
precision:   34
rounding:    half_up
maxExponent: 6144
minExponent: -6143

-- General testcases
-- (mostly derived from the Strawman 4 document and examples)
decg001 apply   #A20780000000000000000000000003D0 -> -7.50
decg002 apply   -7.50  -> #A20780000000000000000000000003D0

-- Normality
decf010 apply   1234567890123456789012345678901234   -> #2608134b9c1e28e56f3c127177823534
decf011 apply   1234567890123456789012345678901234.0 -> #2608134b9c1e28e56f3c127177823534 Rounded
decf012 apply   1234567890123456789012345678901234.1 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf013 apply   1234567890123456789012345678901234.9 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf014 apply  -1234567890123456789012345678901234   -> #a608134b9c1e28e56f3c127177823534
decf015 apply  -1234567890123456789012345678901234.0 -> #a608134b9c1e28e56f3c127177823534 Rounded
decf016 apply  -1234567890123456789012345678901234.1 -> #a608134b9c1e28e56f3c127177823534 Rounded Inexact
decf017 apply  -1234567890123456789012345678901234.9 -> #a608134b9c1e28e56f3c127177823535 Rounded Inexact


-- Nmax and similar
decf022 apply   9.999999999999999999999999999999999E+6144  -> #77ffcff3fcff3fcff3fcff3fcff3fcff
decf023 apply   #77ffcff3fcff3fcff3fcff3fcff3fcff -> 9.999999999999999999999999999999999E+6144
decf024 apply   1.234567890123456789012345678901234E+6144 -> #47ffd34b9c1e28e56f3c127177823534
decf025 apply   #47ffd34b9c1e28e56f3c127177823534 -> 1.234567890123456789012345678901234E+6144
-- fold-downs (more below)
decf030 apply   1.23E+6144    -> #47ffd300000000000000000000000000 Clamped
decf031 apply   #47ffd300000000000000000000000000       -> 1.230000000000000000000000000000000E+6144
decf032 apply   1E+6144       -> #47ffc000000000000000000000000000 Clamped
decf033 apply   #47ffc000000000000000000000000000       -> 1.000000000000000000000000000000000E+6144

-- overflows
maxExponent: 9999  -- set high so conversion causes the overflow
minExponent: -9999
decf040 apply   10E+6144                 -> #78000000000000000000000000000000 Overflow Rounded Inexact
decf041 apply   1.000000000000000E+6145  -> #78000000000000000000000000000000 Overflow Rounded Inexact
maxExponent: 6144
minExponent: -6143

decf051 apply   12345                   -> #220800000000000000000000000049c5
decf052 apply   #220800000000000000000000000049c5       -> 12345
decf053 apply   1234                    -> #22080000000000000000000000000534
decf054 apply   #22080000000000000000000000000534       -> 1234
decf055 apply   123                     -> #220800000000000000000000000000a3
decf056 apply   #220800000000000000000000000000a3       -> 123
decf057 apply   12                      -> #22080000000000000000000000000012
decf058 apply   #22080000000000000000000000000012       -> 12
decf059 apply   1                       -> #22080000000000000000000000000001
decf060 apply   #22080000000000000000000000000001       -> 1
decf061 apply   1.23                    -> #220780000000000000000000000000a3
decf062 apply   #220780000000000000000000000000a3       -> 1.23
decf063 apply   123.45                  -> #220780000000000000000000000049c5
decf064 apply   #220780000000000000000000000049c5       -> 123.45

-- Nmin and below
decf071 apply   1E-6143                                    -> #00084000000000000000000000000001
decf072 apply   #00084000000000000000000000000001          -> 1E-6143
decf073 apply   1.000000000000000000000000000000000E-6143  -> #04000000000000000000000000000000
decf074 apply   #04000000000000000000000000000000          -> 1.000000000000000000000000000000000E-6143
decf075 apply   1.000000000000000000000000000000001E-6143  -> #04000000000000000000000000000001
decf076 apply   #04000000000000000000000000000001          -> 1.000000000000000000000000000000001E-6143

decf077 apply   0.100000000000000000000000000000000E-6143  -> #00000800000000000000000000000000      Subnormal
decf078 apply   #00000800000000000000000000000000          -> 1.00000000000000000000000000000000E-6144  Subnormal
decf079 apply   0.000000000000000000000000000000010E-6143  -> #00000000000000000000000000000010      Subnormal
decf080 apply   #00000000000000000000000000000010          -> 1.0E-6175              Subnormal
decf081 apply   0.00000000000000000000000000000001E-6143   -> #00004000000000000000000000000001      Subnormal
decf082 apply   #00004000000000000000000000000001          -> 1E-6175                Subnormal
decf083 apply   0.000000000000000000000000000000001E-6143  -> #00000000000000000000000000000001      Subnormal
decf084 apply   #00000000000000000000000000000001          -> 1E-6176                 Subnormal

-- underflows
decf090 apply   1e-6176                  -> #00000000000000000000000000000001  Subnormal
decf091 apply   1.9e-6176                -> #00000000000000000000000000000002  Subnormal Underflow Inexact Rounded
decf092 apply   1.1e-6176                -> #00000000000000000000000000000001  Subnormal Underflow Inexact Rounded
decf093 apply   1.00000000001e-6176      -> #00000000000000000000000000000001  Subnormal Underflow Inexact Rounded
decf094 apply   1.00000000000001e-6176   -> #00000000000000000000000000000001  Subnormal Underflow Inexact Rounded
decf095 apply   1.000000000000001e-6176  -> #00000000000000000000000000000001  Subnormal Underflow Inexact Rounded
decf096 apply   0.1e-6176                -> #00000000000000000000000000000000  Subnormal Underflow Inexact Rounded Clamped
decf097 apply   0.00000000001e-6176      -> #00000000000000000000000000000000  Subnormal Underflow Inexact Rounded Clamped
decf098 apply   0.00000000000001e-6176   -> #00000000000000000000000000000000  Subnormal Underflow Inexact Rounded Clamped
decf099 apply   0.000000000000001e-6176  -> #00000000000000000000000000000000  Subnormal Underflow Inexact Rounded Clamped
decf100 apply   999999999999999999999999999999999e-6176 -> #00000ff3fcff3fcff3fcff3fcff3fcff  Subnormal

-- same again, negatives
-- Nmax and similar
decf122 apply  -9.999999999999999999999999999999999E+6144  -> #f7ffcff3fcff3fcff3fcff3fcff3fcff
decf123 apply   #f7ffcff3fcff3fcff3fcff3fcff3fcff -> -9.999999999999999999999999999999999E+6144
decf124 apply  -1.234567890123456789012345678901234E+6144 -> #c7ffd34b9c1e28e56f3c127177823534
decf125 apply   #c7ffd34b9c1e28e56f3c127177823534 -> -1.234567890123456789012345678901234E+6144
-- fold-downs (more below)
decf130 apply  -1.23E+6144    -> #c7ffd300000000000000000000000000 Clamped
decf131 apply   #c7ffd300000000000000000000000000       -> -1.230000000000000000000000000000000E+6144
decf132 apply  -1E+6144       -> #c7ffc000000000000000000000000000 Clamped
decf133 apply   #c7ffc000000000000000000000000000       -> -1.000000000000000000000000000000000E+6144

-- overflows
maxExponent: 9999  -- set high so conversion causes the overflow
minExponent: -9999
decf140 apply  -10E+6144                 -> #f8000000000000000000000000000000 Overflow Rounded Inexact
decf141 apply  -1.000000000000000E+6145  -> #f8000000000000000000000000000000 Overflow Rounded Inexact
maxExponent: 6144
minExponent: -6143

decf151 apply  -12345                   -> #a20800000000000000000000000049c5
decf152 apply   #a20800000000000000000000000049c5       -> -12345
decf153 apply  -1234                    -> #a2080000000000000000000000000534
decf154 apply   #a2080000000000000000000000000534       -> -1234
decf155 apply  -123                     -> #a20800000000000000000000000000a3
decf156 apply   #a20800000000000000000000000000a3       -> -123
decf157 apply  -12                      -> #a2080000000000000000000000000012
decf158 apply   #a2080000000000000000000000000012       -> -12
decf159 apply  -1                       -> #a2080000000000000000000000000001
decf160 apply   #a2080000000000000000000000000001       -> -1
decf161 apply  -1.23                    -> #a20780000000000000000000000000a3
decf162 apply   #a20780000000000000000000000000a3       -> -1.23
decf163 apply  -123.45                  -> #a20780000000000000000000000049c5
decf164 apply   #a20780000000000000000000000049c5       -> -123.45

-- Nmin and below
decf171 apply  -1E-6143                                    -> #80084000000000000000000000000001
decf172 apply   #80084000000000000000000000000001          -> -1E-6143
decf173 apply  -1.000000000000000000000000000000000E-6143  -> #84000000000000000000000000000000
decf174 apply   #84000000000000000000000000000000          -> -1.000000000000000000000000000000000E-6143
decf175 apply  -1.000000000000000000000000000000001E-6143  -> #84000000000000000000000000000001
decf176 apply   #84000000000000000000000000000001          -> -1.000000000000000000000000000000001E-6143

decf177 apply  -0.100000000000000000000000000000000E-6143  -> #80000800000000000000000000000000      Subnormal
decf178 apply   #80000800000000000000000000000000          -> -1.00000000000000000000000000000000E-6144  Subnormal
decf179 apply  -0.000000000000000000000000000000010E-6143  -> #80000000000000000000000000000010      Subnormal
decf180 apply   #80000000000000000000000000000010          -> -1.0E-6175              Subnormal
decf181 apply  -0.00000000000000000000000000000001E-6143   -> #80004000000000000000000000000001      Subnormal
decf182 apply   #80004000000000000000000000000001          -> -1E-6175                Subnormal
decf183 apply  -0.000000000000000000000000000000001E-6143  -> #80000000000000000000000000000001      Subnormal
decf184 apply   #80000000000000000000000000000001          -> -1E-6176                 Subnormal

-- underflows
decf190 apply   -1e-6176                  -> #80000000000000000000000000000001  Subnormal
decf191 apply   -1.9e-6176                -> #80000000000000000000000000000002  Subnormal Underflow Inexact Rounded
decf192 apply   -1.1e-6176                -> #80000000000000000000000000000001  Subnormal Underflow Inexact Rounded
decf193 apply   -1.00000000001e-6176      -> #80000000000000000000000000000001  Subnormal Underflow Inexact Rounded
decf194 apply   -1.00000000000001e-6176   -> #80000000000000000000000000000001  Subnormal Underflow Inexact Rounded
decf195 apply   -1.000000000000001e-6176  -> #80000000000000000000000000000001  Subnormal Underflow Inexact Rounded
decf196 apply   -0.1e-6176                -> #80000000000000000000000000000000  Subnormal Underflow Inexact Rounded Clamped
decf197 apply   -0.00000000001e-6176      -> #80000000000000000000000000000000  Subnormal Underflow Inexact Rounded Clamped
decf198 apply   -0.00000000000001e-6176   -> #80000000000000000000000000000000  Subnormal Underflow Inexact Rounded Clamped
decf199 apply   -0.000000000000001e-6176  -> #80000000000000000000000000000000  Subnormal Underflow Inexact Rounded Clamped
decf200 apply   -999999999999999999999999999999999e-6176 -> #80000ff3fcff3fcff3fcff3fcff3fcff  Subnormal

-- zeros
decf400 apply   0E-8000                 -> #00000000000000000000000000000000  Clamped
decf401 apply   0E-6177                 -> #00000000000000000000000000000000  Clamped
decf402 apply   0E-6176                 -> #00000000000000000000000000000000
decf403 apply   #00000000000000000000000000000000       -> 0E-6176
decf404 apply   0.000000000000000000000000000000000E-6143  -> #00000000000000000000000000000000
decf405 apply   #00000000000000000000000000000000       -> 0E-6176
decf406 apply   0E-2                    -> #22078000000000000000000000000000
decf407 apply   #22078000000000000000000000000000       -> 0.00
decf408 apply   0                       -> #22080000000000000000000000000000
decf409 apply   #22080000000000000000000000000000       -> 0
decf410 apply   0E+3                    -> #2208c000000000000000000000000000
decf411 apply   #2208c000000000000000000000000000       -> 0E+3
decf412 apply   0E+6111                 -> #43ffc000000000000000000000000000
decf413 apply   #43ffc000000000000000000000000000       -> 0E+6111
-- clamped zeros...
decf414 apply   0E+6112                 -> #43ffc000000000000000000000000000  Clamped
decf415 apply   #43ffc000000000000000000000000000       -> 0E+6111
decf416 apply   0E+6144                 -> #43ffc000000000000000000000000000  Clamped
decf417 apply   #43ffc000000000000000000000000000       -> 0E+6111
decf418 apply   0E+8000                 -> #43ffc000000000000000000000000000  Clamped
decf419 apply   #43ffc000000000000000000000000000       -> 0E+6111

-- negative zeros
decf420 apply  -0E-8000                 -> #80000000000000000000000000000000  Clamped
decf421 apply  -0E-6177                 -> #80000000000000000000000000000000  Clamped
decf422 apply  -0E-6176                 -> #80000000000000000000000000000000
decf423 apply   #80000000000000000000000000000000       -> -0E-6176
decf424 apply  -0.000000000000000000000000000000000E-6143  -> #80000000000000000000000000000000
decf425 apply   #80000000000000000000000000000000       -> -0E-6176
decf426 apply  -0E-2                    -> #a2078000000000000000000000000000
decf427 apply   #a2078000000000000000000000000000       -> -0.00
decf428 apply  -0                       -> #a2080000000000000000000000000000
decf429 apply   #a2080000000000000000000000000000       -> -0
decf430 apply  -0E+3                    -> #a208c000000000000000000000000000
decf431 apply   #a208c000000000000000000000000000       -> -0E+3
decf432 apply  -0E+6111                 -> #c3ffc000000000000000000000000000
decf433 apply   #c3ffc000000000000000000000000000       -> -0E+6111
-- clamped zeros...
decf434 apply  -0E+6112                 -> #c3ffc000000000000000000000000000  Clamped
decf435 apply   #c3ffc000000000000000000000000000       -> -0E+6111
decf436 apply  -0E+6144                 -> #c3ffc000000000000000000000000000  Clamped
decf437 apply   #c3ffc000000000000000000000000000       -> -0E+6111
decf438 apply  -0E+8000                 -> #c3ffc000000000000000000000000000  Clamped
decf439 apply   #c3ffc000000000000000000000000000       -> -0E+6111

-- Specials
decf500 apply   Infinity                          -> #78000000000000000000000000000000
decf501 apply   #78787878787878787878787878787878 -> #78000000000000000000000000000000
decf502 apply   #78000000000000000000000000000000 -> Infinity
decf503 apply   #79797979797979797979797979797979 -> #78000000000000000000000000000000
decf504 apply   #79000000000000000000000000000000 -> Infinity
decf505 apply   #7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #78000000000000000000000000000000
decf506 apply   #7a000000000000000000000000000000 -> Infinity
decf507 apply   #7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #78000000000000000000000000000000
decf508 apply   #7b000000000000000000000000000000 -> Infinity

decf509 apply   NaN                               -> #7c000000000000000000000000000000
decf510 apply   #7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #7c003c7c7c7c7c7c7c7c7c7c7c7c7c7c
decf511 apply   #7c000000000000000000000000000000 -> NaN
decf512 apply   #7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #7c003d7d7d7d7d7d7d7d7d7d7d7d7d7d
decf513 apply   #7d000000000000000000000000000000 -> NaN
decf514 apply   #7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #7e003e7e7c7e7e7e7e7c7e7e7e7e7c7e
decf515 apply   #7e000000000000000000000000000000 -> sNaN
decf516 apply   #7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #7e003f7f7c7f7f7f7f7c7f7f7f7f7c7f
decf517 apply   #7f000000000000000000000000000000 -> sNaN
decf518 apply   #7fffffffffffffffffffffffffffffff -> sNaN999999999999999999999999999999999
decf519 apply   #7fffffffffffffffffffffffffffffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff

decf520 apply   -Infinity                         -> #f8000000000000000000000000000000
decf521 apply   #f8787878787878787878787878787878 -> #f8000000000000000000000000000000
decf522 apply   #f8000000000000000000000000000000 -> -Infinity
decf523 apply   #f9797979797979797979797979797979 -> #f8000000000000000000000000000000
decf524 apply   #f9000000000000000000000000000000 -> -Infinity
decf525 apply   #fa7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #f8000000000000000000000000000000
decf526 apply   #fa000000000000000000000000000000 -> -Infinity
decf527 apply   #fb7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #f8000000000000000000000000000000
decf528 apply   #fb000000000000000000000000000000 -> -Infinity

decf529 apply   -NaN                              -> #fc000000000000000000000000000000
decf530 apply   #fc7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #fc003c7c7c7c7c7c7c7c7c7c7c7c7c7c
decf531 apply   #fc000000000000000000000000000000 -> -NaN
decf532 apply   #fd7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #fc003d7d7d7d7d7d7d7d7d7d7d7d7d7d
decf533 apply   #fd000000000000000000000000000000 -> -NaN
decf534 apply   #fe7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #fe003e7e7c7e7e7e7e7c7e7e7e7e7c7e
decf535 apply   #fe000000000000000000000000000000 -> -sNaN
decf536 apply   #ff7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #fe003f7f7c7f7f7f7f7c7f7f7f7f7c7f
decf537 apply   #ff000000000000000000000000000000 -> -sNaN
decf538 apply   #ffffffffffffffffffffffffffffffff -> -sNaN999999999999999999999999999999999
decf539 apply   #ffffffffffffffffffffffffffffffff -> #fe000ff3fcff3fcff3fcff3fcff3fcff

decf540 apply   NaN               -> #7c000000000000000000000000000000
decf541 apply   NaN0              -> #7c000000000000000000000000000000
decf542 apply   NaN1              -> #7c000000000000000000000000000001
decf543 apply   NaN12             -> #7c000000000000000000000000000012
decf544 apply   NaN79             -> #7c000000000000000000000000000079
decf545 apply   NaN12345          -> #7c0000000000000000000000000049c5
decf546 apply   NaN123456         -> #7c000000000000000000000000028e56
decf547 apply   NaN799799         -> #7c0000000000000000000000000f7fdf
decf548 apply   NaN799799799799799799799799799799799  -> #7c003dff7fdff7fdff7fdff7fdff7fdf
decf549 apply   NaN999999999999999999999999999999999  -> #7c000ff3fcff3fcff3fcff3fcff3fcff
decf550 apply   NaN1234567890123456789012345678901234 -> #7c000000000000000000000000000000  -- too many digits

-- fold-down full sequence
decf600 apply   1E+6145                 -> #78000000000000000000000000000000 Overflow Inexact Rounded
decf601 apply   1E+6144                 -> #47ffc000000000000000000000000000 Clamped
decf602 apply   #47ffc000000000000000000000000000       -> 1.000000000000000000000000000000000E+6144
decf603 apply   1E+6143                 -> #43ffc800000000000000000000000000 Clamped
decf604 apply   #43ffc800000000000000000000000000       -> 1.00000000000000000000000000000000E+6143
decf605 apply   1E+6142                 -> #43ffc100000000000000000000000000 Clamped
decf606 apply   #43ffc100000000000000000000000000       -> 1.0000000000000000000000000000000E+6142
decf607 apply   1E+6141                 -> #43ffc010000000000000000000000000 Clamped
decf608 apply   #43ffc010000000000000000000000000       -> 1.000000000000000000000000000000E+6141
decf609 apply   1E+6140                 -> #43ffc002000000000000000000000000 Clamped
decf610 apply   #43ffc002000000000000000000000000       -> 1.00000000000000000000000000000E+6140
decf611 apply   1E+6139                 -> #43ffc000400000000000000000000000 Clamped
decf612 apply   #43ffc000400000000000000000000000       -> 1.0000000000000000000000000000E+6139
decf613 apply   1E+6138                 -> #43ffc000040000000000000000000000 Clamped
decf614 apply   #43ffc000040000000000000000000000       -> 1.000000000000000000000000000E+6138
decf615 apply   1E+6137                 -> #43ffc000008000000000000000000000 Clamped
decf616 apply   #43ffc000008000000000000000000000       -> 1.00000000000000000000000000E+6137
decf617 apply   1E+6136                 -> #43ffc000001000000000000000000000 Clamped
decf618 apply   #43ffc000001000000000000000000000       -> 1.0000000000000000000000000E+6136
decf619 apply   1E+6135                 -> #43ffc000000100000000000000000000 Clamped
decf620 apply   #43ffc000000100000000000000000000       -> 1.000000000000000000000000E+6135
decf621 apply   1E+6134                 -> #43ffc000000020000000000000000000 Clamped
decf622 apply   #43ffc000000020000000000000000000       -> 1.00000000000000000000000E+6134
decf623 apply   1E+6133                 -> #43ffc000000004000000000000000000 Clamped
decf624 apply   #43ffc000000004000000000000000000       -> 1.0000000000000000000000E+6133
decf625 apply   1E+6132                 -> #43ffc000000000400000000000000000 Clamped
decf626 apply   #43ffc000000000400000000000000000       -> 1.000000000000000000000E+6132
decf627 apply   1E+6131                 -> #43ffc000000000080000000000000000 Clamped
decf628 apply   #43ffc000000000080000000000000000       -> 1.00000000000000000000E+6131
decf629 apply   1E+6130                 -> #43ffc000000000010000000000000000 Clamped
decf630 apply   #43ffc000000000010000000000000000       -> 1.0000000000000000000E+6130
decf631 apply   1E+6129                 -> #43ffc000000000001000000000000000 Clamped
decf632 apply   #43ffc000000000001000000000000000       -> 1.000000000000000000E+6129
decf633 apply   1E+6128                 -> #43ffc000000000000200000000000000 Clamped
decf634 apply   #43ffc000000000000200000000000000       -> 1.00000000000000000E+6128
decf635 apply   1E+6127                 -> #43ffc000000000000040000000000000 Clamped
decf636 apply   #43ffc000000000000040000000000000       -> 1.0000000000000000E+6127
decf637 apply   1E+6126                 -> #43ffc000000000000004000000000000 Clamped
decf638 apply   #43ffc000000000000004000000000000       -> 1.000000000000000E+6126
decf639 apply   1E+6125                 -> #43ffc000000000000000800000000000 Clamped
decf640 apply   #43ffc000000000000000800000000000       -> 1.00000000000000E+6125
decf641 apply   1E+6124                 -> #43ffc000000000000000100000000000 Clamped
decf642 apply   #43ffc000000000000000100000000000       -> 1.0000000000000E+6124
decf643 apply   1E+6123                 -> #43ffc000000000000000010000000000 Clamped
decf644 apply   #43ffc000000000000000010000000000       -> 1.000000000000E+6123
decf645 apply   1E+6122                 -> #43ffc000000000000000002000000000 Clamped
decf646 apply   #43ffc000000000000000002000000000       -> 1.00000000000E+6122
decf647 apply   1E+6121                 -> #43ffc000000000000000000400000000 Clamped
decf648 apply   #43ffc000000000000000000400000000       -> 1.0000000000E+6121
decf649 apply   1E+6120                 -> #43ffc000000000000000000040000000 Clamped
decf650 apply   #43ffc000000000000000000040000000       -> 1.000000000E+6120
decf651 apply   1E+6119                 -> #43ffc000000000000000000008000000 Clamped
decf652 apply   #43ffc000000000000000000008000000       -> 1.00000000E+6119
decf653 apply   1E+6118                 -> #43ffc000000000000000000001000000 Clamped
decf654 apply   #43ffc000000000000000000001000000       -> 1.0000000E+6118
decf655 apply   1E+6117                 -> #43ffc000000000000000000000100000 Clamped
decf656 apply   #43ffc000000000000000000000100000       -> 1.000000E+6117
decf657 apply   1E+6116                 -> #43ffc000000000000000000000020000 Clamped
decf658 apply   #43ffc000000000000000000000020000       -> 1.00000E+6116
decf659 apply   1E+6115                 -> #43ffc000000000000000000000004000 Clamped
decf660 apply   #43ffc000000000000000000000004000       -> 1.0000E+6115
decf661 apply   1E+6114                 -> #43ffc000000000000000000000000400 Clamped
decf662 apply   #43ffc000000000000000000000000400       -> 1.000E+6114
decf663 apply   1E+6113                 -> #43ffc000000000000000000000000080 Clamped
decf664 apply   #43ffc000000000000000000000000080       -> 1.00E+6113
decf665 apply   1E+6112                 -> #43ffc000000000000000000000000010 Clamped
decf666 apply   #43ffc000000000000000000000000010       -> 1.0E+6112
decf667 apply   1E+6111                 -> #43ffc000000000000000000000000001
decf668 apply   #43ffc000000000000000000000000001       -> 1E+6111
decf669 apply   1E+6110                 -> #43ff8000000000000000000000000001
decf670 apply   #43ff8000000000000000000000000001       -> 1E+6110

-- Selected DPD codes
decf700 apply   #22080000000000000000000000000000       -> 0
decf701 apply   #22080000000000000000000000000009       -> 9
decf702 apply   #22080000000000000000000000000010       -> 10
decf703 apply   #22080000000000000000000000000019       -> 19
decf704 apply   #22080000000000000000000000000020       -> 20
decf705 apply   #22080000000000000000000000000029       -> 29
decf706 apply   #22080000000000000000000000000030       -> 30
decf707 apply   #22080000000000000000000000000039       -> 39
decf708 apply   #22080000000000000000000000000040       -> 40
decf709 apply   #22080000000000000000000000000049       -> 49
decf710 apply   #22080000000000000000000000000050       -> 50
decf711 apply   #22080000000000000000000000000059       -> 59
decf712 apply   #22080000000000000000000000000060       -> 60
decf713 apply   #22080000000000000000000000000069       -> 69
decf714 apply   #22080000000000000000000000000070       -> 70
decf715 apply   #22080000000000000000000000000071       -> 71
decf716 apply   #22080000000000000000000000000072       -> 72
decf717 apply   #22080000000000000000000000000073       -> 73
decf718 apply   #22080000000000000000000000000074       -> 74
decf719 apply   #22080000000000000000000000000075       -> 75
decf720 apply   #22080000000000000000000000000076       -> 76
decf721 apply   #22080000000000000000000000000077       -> 77
decf722 apply   #22080000000000000000000000000078       -> 78
decf723 apply   #22080000000000000000000000000079       -> 79

decf730 apply   #2208000000000000000000000000029e       -> 994
decf731 apply   #2208000000000000000000000000029f       -> 995
decf732 apply   #220800000000000000000000000002a0       -> 520
decf733 apply   #220800000000000000000000000002a1       -> 521

-- DPD: one of each of the huffman groups
decf740 apply   #220800000000000000000000000003f7       -> 777
decf741 apply   #220800000000000000000000000003f8       -> 778
decf742 apply   #220800000000000000000000000003eb       -> 787
decf743 apply   #2208000000000000000000000000037d       -> 877
decf744 apply   #2208000000000000000000000000039f       -> 997
decf745 apply   #220800000000000000000000000003bf       -> 979
decf746 apply   #220800000000000000000000000003df       -> 799
decf747 apply   #2208000000000000000000000000006e       -> 888


-- DPD all-highs cases (includes the 24 redundant codes)
decf750 apply   #2208000000000000000000000000006e       -> 888
decf751 apply   #2208000000000000000000000000016e       -> 888
decf752 apply   #2208000000000000000000000000026e       -> 888
decf753 apply   #2208000000000000000000000000036e       -> 888
decf754 apply   #2208000000000000000000000000006f       -> 889
decf755 apply   #2208000000000000000000000000016f       -> 889
decf756 apply   #2208000000000000000000000000026f       -> 889
decf757 apply   #2208000000000000000000000000036f       -> 889

decf760 apply   #2208000000000000000000000000007e       -> 898
decf761 apply   #2208000000000000000000000000017e       -> 898
decf762 apply   #2208000000000000000000000000027e       -> 898
decf763 apply   #2208000000000000000000000000037e       -> 898
decf764 apply   #2208000000000000000000000000007f       -> 899
decf765 apply   #2208000000000000000000000000017f       -> 899
decf766 apply   #2208000000000000000000000000027f       -> 899
decf767 apply   #2208000000000000000000000000037f       -> 899

decf770 apply   #220800000000000000000000000000ee       -> 988
decf771 apply   #220800000000000000000000000001ee       -> 988
decf772 apply   #220800000000000000000000000002ee       -> 988
decf773 apply   #220800000000000000000000000003ee       -> 988
decf774 apply   #220800000000000000000000000000ef       -> 989
decf775 apply   #220800000000000000000000000001ef       -> 989
decf776 apply   #220800000000000000000000000002ef       -> 989
decf777 apply   #220800000000000000000000000003ef       -> 989

decf780 apply   #220800000000000000000000000000fe       -> 998
decf781 apply   #220800000000000000000000000001fe       -> 998
decf782 apply   #220800000000000000000000000002fe       -> 998
decf783 apply   #220800000000000000000000000003fe       -> 998
decf784 apply   #220800000000000000000000000000ff       -> 999
decf785 apply   #220800000000000000000000000001ff       -> 999
decf786 apply   #220800000000000000000000000002ff       -> 999
decf787 apply   #220800000000000000000000000003ff       -> 999

-- Miscellaneous (testers' queries, etc.)

decf790 apply   #2208000000000000000000000000c000       -> 30000
decf791 apply   #22080000000000000000000000007800       -> 890000
decf792 apply   30000 -> #2208000000000000000000000000c000
decf793 apply   890000 -> #22080000000000000000000000007800

-- Rounding modes (negatives in decimal64)

rounding: floor
decf800 apply   1234567890123456789012345678901234.00 -> #2608134b9c1e28e56f3c127177823534 Rounded
decf801 apply   1234567890123456789012345678901234.01 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf802 apply   1234567890123456789012345678901234.3  -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf803 apply   1234567890123456789012345678901234.49 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf804 apply   1234567890123456789012345678901233.50 -> #2608134b9c1e28e56f3c127177823533 Rounded Inexact
decf805 apply   1234567890123456789012345678901234.50 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf806 apply   1234567890123456789012345678901234.51 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf807 apply   1234567890123456789012345678901234.66 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf808 apply   1234567890123456789012345678901234.90 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf809 apply   1234567890123456789012345678901234.99 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact

rounding: ceiling
decf810 apply   1234567890123456789012345678901234.00 -> #2608134b9c1e28e56f3c127177823534 Rounded
decf811 apply   1234567890123456789012345678901234.01 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf812 apply   1234567890123456789012345678901234.3  -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf813 apply   1234567890123456789012345678901234.49 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf814 apply   1234567890123456789012345678901233.50 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf815 apply   1234567890123456789012345678901234.50 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf816 apply   1234567890123456789012345678901234.51 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf817 apply   1234567890123456789012345678901234.66 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf818 apply   1234567890123456789012345678901234.90 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf819 apply   1234567890123456789012345678901234.99 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact

rounding: up
decf820 apply   1234567890123456789012345678901234.00 -> #2608134b9c1e28e56f3c127177823534 Rounded
decf821 apply   1234567890123456789012345678901234.01 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf822 apply   1234567890123456789012345678901234.3  -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf823 apply   1234567890123456789012345678901234.49 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf824 apply   1234567890123456789012345678901233.50 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf825 apply   1234567890123456789012345678901234.50 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf826 apply   1234567890123456789012345678901234.51 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf827 apply   1234567890123456789012345678901234.66 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf828 apply   1234567890123456789012345678901234.90 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf829 apply   1234567890123456789012345678901234.99 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact

rounding: down
decf830 apply   1234567890123456789012345678901234.00 -> #2608134b9c1e28e56f3c127177823534 Rounded
decf831 apply   1234567890123456789012345678901234.01 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf832 apply   1234567890123456789012345678901234.3  -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf833 apply   1234567890123456789012345678901234.49 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf834 apply   1234567890123456789012345678901233.50 -> #2608134b9c1e28e56f3c127177823533 Rounded Inexact
decf835 apply   1234567890123456789012345678901234.50 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf836 apply   1234567890123456789012345678901234.51 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf837 apply   1234567890123456789012345678901234.66 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf838 apply   1234567890123456789012345678901234.90 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf839 apply   1234567890123456789012345678901234.99 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact

rounding: half_up
decf840 apply   1234567890123456789012345678901234.00 -> #2608134b9c1e28e56f3c127177823534 Rounded
decf841 apply   1234567890123456789012345678901234.01 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf842 apply   1234567890123456789012345678901234.3  -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf843 apply   1234567890123456789012345678901234.49 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf844 apply   1234567890123456789012345678901233.50 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf845 apply   1234567890123456789012345678901234.50 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf846 apply   1234567890123456789012345678901234.51 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf847 apply   1234567890123456789012345678901234.66 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf848 apply   1234567890123456789012345678901234.90 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf849 apply   1234567890123456789012345678901234.99 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact

rounding: half_even
decf850 apply   1234567890123456789012345678901234.00 -> #2608134b9c1e28e56f3c127177823534 Rounded
decf851 apply   1234567890123456789012345678901234.01 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf852 apply   1234567890123456789012345678901234.3  -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf853 apply   1234567890123456789012345678901234.49 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf854 apply   1234567890123456789012345678901233.50 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf855 apply   1234567890123456789012345678901234.50 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf856 apply   1234567890123456789012345678901234.51 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf857 apply   1234567890123456789012345678901234.66 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf858 apply   1234567890123456789012345678901234.90 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf859 apply   1234567890123456789012345678901234.99 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact

rounding: half_down
decf860 apply   1234567890123456789012345678901234.00 -> #2608134b9c1e28e56f3c127177823534 Rounded
decf861 apply   1234567890123456789012345678901234.01 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf862 apply   1234567890123456789012345678901234.3  -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf863 apply   1234567890123456789012345678901234.49 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf864 apply   1234567890123456789012345678901233.50 -> #2608134b9c1e28e56f3c127177823533 Rounded Inexact
decf865 apply   1234567890123456789012345678901234.50 -> #2608134b9c1e28e56f3c127177823534 Rounded Inexact
decf866 apply   1234567890123456789012345678901234.51 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf867 apply   1234567890123456789012345678901234.66 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf868 apply   1234567890123456789012345678901234.90 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact
decf869 apply   1234567890123456789012345678901234.99 -> #2608134b9c1e28e56f3c127177823535 Rounded Inexact

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted test/dectest/decimal32.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
------------------------------------------------------------------------
-- decimal32.decTest -- decimal four-byte format testcases            --
-- Copyright (c) IBM Corporation, 2000, 2003.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- This set of tests is for the four-byte concrete representation.
-- Its characteristics are:
--
--  1 bit  sign
--  5 bits combination field
--  6 bits exponent continuation
-- 20 bits coefficient continuation
--
-- Total exponent length 8 bits
-- Total coefficient length 24 bits (7 digits)
--
-- Elimit =  191 (maximum encoded exponent)
-- Emax   =   96 (largest exponent value)
-- Emin   =  -95 (smallest exponent value)
-- bias   =  101 (subtracted from encoded exponent) = -Etiny

extended:    1
precision:   7
rounding:    half_up
maxExponent: 96
minExponent: -95

-- General testcases
-- (mostly derived from the Strawman 4 document and examples)
decd001 apply   #A23003D0          -> -7.50
decd002 apply   -7.50              -> #A23003D0

-- Normality
decd010 apply   1234567            -> #2654d2e7
decd011 apply   1234567.0          -> #2654d2e7 Rounded
decd013 apply   1234567.1          -> #2654d2e7 Rounded Inexact
decd014 apply   1234567.9          -> #2654d2e8 Rounded Inexact
decd015 apply  -1234567            -> #a654d2e7
decd016 apply  -1234567.0          -> #a654d2e7 Rounded
decd017 apply  -1234567.1          -> #a654d2e7 Rounded Inexact
decd018 apply  -1234567.9          -> #a654d2e8 Rounded Inexact


-- Nmax and similar
decd022 apply   9.999999E+96            -> #77f3fcff
decd023 apply   #77f3fcff               -> 9.999999E+96
decd024 apply   1.234567E+96            -> #47f4d2e7
decd025 apply   #47f4d2e7               -> 1.234567E+96
-- fold-downs (more below)
decd030 apply   1.23E+96                -> #47f4c000 Clamped
decd031 apply   #47f4c000               -> 1.230000E+96
decd032 apply   1E+96                   -> #47f00000 Clamped
decd033 apply   #47f00000               -> 1.000000E+96

-- overflows
maxExponent: 999   -- set high so conversion causes the overflow
minExponent: -999
decd040 apply   10E+96                  -> #78000000 Overflow Rounded Inexact
decd041 apply   1.000000E+97            -> #78000000 Overflow Rounded Inexact
maxExponent: 96
minExponent: -95

decd051 apply   12345                   -> #225049c5
decd052 apply   #225049c5               -> 12345
decd053 apply   1234                    -> #22500534
decd054 apply   #22500534               -> 1234
decd055 apply   123                     -> #225000a3
decd056 apply   #225000a3               -> 123
decd057 apply   12                      -> #22500012
decd058 apply   #22500012               -> 12
decd059 apply   1                       -> #22500001
decd060 apply   #22500001               -> 1
decd061 apply   1.23                    -> #223000a3
decd062 apply   #223000a3               -> 1.23
decd063 apply   123.45                  -> #223049c5
decd064 apply   #223049c5               -> 123.45

-- Nmin and below
decd071 apply   1E-95                   -> #00600001
decd072 apply   #00600001               -> 1E-95
decd073 apply   1.000000E-95            -> #04000000
decd074 apply   #04000000               -> 1.000000E-95
decd075 apply   1.000001E-95            -> #04000001
decd076 apply   #04000001               -> 1.000001E-95

decd077 apply   0.100000E-95            -> #00020000     Subnormal
decd07x apply   1.00000E-96             -> 1.00000E-96   Subnormal
decd078 apply   #00020000               -> 1.00000E-96   Subnormal
decd079 apply   0.000010E-95            -> #00000010     Subnormal
decd080 apply   #00000010               -> 1.0E-100      Subnormal
decd081 apply   0.000001E-95            -> #00000001     Subnormal
decd082 apply   #00000001               -> 1E-101        Subnormal
decd083 apply   1e-101                  -> #00000001     Subnormal
decd084 apply   #00000001               -> 1E-101        Subnormal
decd08x apply   1e-101                  -> 1E-101        Subnormal

-- underflows
decd090 apply   1e-101                  -> #00000001  Subnormal
decd091 apply   1.9e-101                -> #00000002  Subnormal Underflow Inexact Rounded
decd092 apply   1.1e-101                -> #00000001  Subnormal Underflow Inexact Rounded
decd093 apply   1.001e-101              -> #00000001  Subnormal Underflow Inexact Rounded
decd094 apply   1.000001e-101           -> #00000001  Subnormal Underflow Inexact Rounded
decd095 apply   1.0000001e-101          -> #00000001  Subnormal Underflow Inexact Rounded
decd096 apply   0.1e-101                -> #00000000  Subnormal Underflow Inexact Rounded Clamped
decd097 apply   0.001e-101              -> #00000000  Subnormal Underflow Inexact Rounded Clamped
decd098 apply   0.000001e-101           -> #00000000  Subnormal Underflow Inexact Rounded Clamped
decd099 apply   0.0000001e-101          -> #00000000  Subnormal Underflow Inexact Rounded Clamped

-- same again, negatives --

-- Nmax and similar
decd122 apply  -9.999999E+96            -> #f7f3fcff
decd123 apply   #f7f3fcff               -> -9.999999E+96
decd124 apply  -1.234567E+96            -> #c7f4d2e7
decd125 apply   #c7f4d2e7               -> -1.234567E+96
-- fold-downs (more below)
decd130 apply  -1.23E+96                -> #c7f4c000 Clamped
decd131 apply   #c7f4c000               -> -1.230000E+96
decd132 apply  -1E+96                   -> #c7f00000 Clamped
decd133 apply   #c7f00000               -> -1.000000E+96

-- overflows
maxExponent: 999   -- set high so conversion causes the overflow
minExponent: -999
decd140 apply  -10E+96                  -> #f8000000 Overflow Rounded Inexact
decd141 apply  -1.000000E+97            -> #f8000000 Overflow Rounded Inexact
maxExponent: 96
minExponent: -95

decd151 apply  -12345                   -> #a25049c5
decd152 apply   #a25049c5               -> -12345
decd153 apply  -1234                    -> #a2500534
decd154 apply   #a2500534               -> -1234
decd155 apply  -123                     -> #a25000a3
decd156 apply   #a25000a3               -> -123
decd157 apply  -12                      -> #a2500012
decd158 apply   #a2500012               -> -12
decd159 apply  -1                       -> #a2500001
decd160 apply   #a2500001               -> -1
decd161 apply  -1.23                    -> #a23000a3
decd162 apply   #a23000a3               -> -1.23
decd163 apply  -123.45                  -> #a23049c5
decd164 apply   #a23049c5               -> -123.45

-- Nmin and below
decd171 apply  -1E-95                   -> #80600001
decd172 apply   #80600001               -> -1E-95
decd173 apply  -1.000000E-95            -> #84000000
decd174 apply   #84000000               -> -1.000000E-95
decd175 apply  -1.000001E-95            -> #84000001
decd176 apply   #84000001               -> -1.000001E-95

decd177 apply  -0.100000E-95            -> #80020000     Subnormal
decd178 apply   #80020000               -> -1.00000E-96  Subnormal
decd179 apply  -0.000010E-95            -> #80000010     Subnormal
decd180 apply   #80000010               -> -1.0E-100     Subnormal
decd181 apply  -0.000001E-95            -> #80000001     Subnormal
decd182 apply   #80000001               -> -1E-101       Subnormal
decd183 apply  -1e-101                  -> #80000001     Subnormal
decd184 apply   #80000001               -> -1E-101       Subnormal

-- underflows
decd190 apply  -1e-101                  -> #80000001  Subnormal
decd191 apply  -1.9e-101                -> #80000002  Subnormal Underflow Inexact Rounded
decd192 apply  -1.1e-101                -> #80000001  Subnormal Underflow Inexact Rounded
decd193 apply  -1.001e-101              -> #80000001  Subnormal Underflow Inexact Rounded
decd194 apply  -1.000001e-101           -> #80000001  Subnormal Underflow Inexact Rounded
decd195 apply  -1.0000001e-101          -> #80000001  Subnormal Underflow Inexact Rounded
decd196 apply  -0.1e-101                -> #80000000  Subnormal Underflow Inexact Rounded Clamped
decd197 apply  -0.001e-101              -> #80000000  Subnormal Underflow Inexact Rounded Clamped
decd198 apply  -0.000001e-101           -> #80000000  Subnormal Underflow Inexact Rounded Clamped
decd199 apply  -0.0000001e-101          -> #80000000  Subnormal Underflow Inexact Rounded Clamped

-- zeros
decd400 apply   0E-400                  -> #00000000  Clamped
decd401 apply   0E-101                  -> #00000000
decd402 apply   #00000000               -> 0E-101
decd403 apply   0.000000E-95            -> #00000000
decd404 apply   #00000000               -> 0E-101
decd405 apply   0E-2                    -> #22300000
decd406 apply   #22300000               -> 0.00
decd407 apply   0                       -> #22500000
decd408 apply   #22500000               -> 0
decd409 apply   0E+3                    -> #22800000
decd410 apply   #22800000               -> 0E+3
decd411 apply   0E+90                   -> #43f00000
decd412 apply   #43f00000               -> 0E+90
-- clamped zeros...
decd413 apply   0E+91                   -> #43f00000  Clamped
decd414 apply   #43f00000               -> 0E+90
decd415 apply   0E+96                   -> #43f00000  Clamped
decd416 apply   #43f00000               -> 0E+90
decd417 apply   0E+400                  -> #43f00000  Clamped
decd418 apply   #43f00000               -> 0E+90

-- negative zeros
decd420 apply   -0E-400                 -> #80000000  Clamped
decd421 apply   -0E-101                 -> #80000000
decd422 apply   #80000000               -> -0E-101
decd423 apply   -0.000000E-95           -> #80000000
decd424 apply   #80000000               -> -0E-101
decd425 apply   -0E-2                   -> #a2300000
decd426 apply   #a2300000               -> -0.00
decd427 apply   -0                      -> #a2500000
decd428 apply   #a2500000               -> -0
decd429 apply   -0E+3                   -> #a2800000
decd430 apply   #a2800000               -> -0E+3
decd431 apply   -0E+90                  -> #c3f00000
decd432 apply   #c3f00000               -> -0E+90
-- clamped zeros...
decd433 apply   -0E+91                  -> #c3f00000  Clamped
decd434 apply   #c3f00000               -> -0E+90
decd435 apply   -0E+96                  -> #c3f00000  Clamped
decd436 apply   #c3f00000               -> -0E+90
decd437 apply   -0E+400                 -> #c3f00000  Clamped
decd438 apply   #c3f00000               -> -0E+90

-- Specials
decd500 apply   Infinity  -> #78000000
decd501 apply   #78787878 -> #78000000
decd502 apply   #78000000 -> Infinity
decd503 apply   #79797979 -> #78000000
decd504 apply   #79000000 -> Infinity
decd505 apply   #7a7a7a7a -> #78000000
decd506 apply   #7a000000 -> Infinity
decd507 apply   #7b7b7b7b -> #78000000
decd508 apply   #7b000000 -> Infinity
decd509 apply   #7c7c7c7c -> #7c0c7c7c

decd510 apply   NaN       -> #7c000000
decd511 apply   #7c000000 -> NaN
decd512 apply   #7d7d7d7d -> #7c0d7d7d
decd513 apply   #7d000000 -> NaN
decd514 apply   #7e7e7e7e -> #7e0e7c7e
decd515 apply   #7e000000 -> sNaN
decd516 apply   #7f7f7f7f -> #7e0f7c7f
decd517 apply   #7f000000 -> sNaN
decd518 apply   #7fffffff -> sNaN999999
decd519 apply   #7fffffff -> #7e03fcff

decd520 apply   -Infinity -> #f8000000
decd521 apply   #f8787878 -> #f8000000
decd522 apply   #f8000000 -> -Infinity
decd523 apply   #f9797979 -> #f8000000
decd524 apply   #f9000000 -> -Infinity
decd525 apply   #fa7a7a7a -> #f8000000
decd526 apply   #fa000000 -> -Infinity
decd527 apply   #fb7b7b7b -> #f8000000
decd528 apply   #fb000000 -> -Infinity

decd529 apply   -NaN      -> #fc000000
decd530 apply   #fc7c7c7c -> #fc0c7c7c
decd531 apply   #fc000000 -> -NaN
decd532 apply   #fd7d7d7d -> #fc0d7d7d
decd533 apply   #fd000000 -> -NaN
decd534 apply   #fe7e7e7e -> #fe0e7c7e
decd535 apply   #fe000000 -> -sNaN
decd536 apply   #ff7f7f7f -> #fe0f7c7f
decd537 apply   #ff000000 -> -sNaN
decd538 apply   #ffffffff -> -sNaN999999
decd539 apply   #ffffffff -> #fe03fcff

-- diagnostic NaNs
decd540 apply   NaN       -> #7c000000
decd541 apply   NaN0      -> #7c000000
decd542 apply   NaN1      -> #7c000001
decd543 apply   NaN12     -> #7c000012
decd544 apply   NaN79     -> #7c000079
decd545 apply   NaN12345   -> #7c0049c5
decd546 apply   NaN123456  -> #7c028e56
decd547 apply   NaN799799  -> #7c0f7fdf
decd548 apply   NaN999999  -> #7c03fcff
decd549 apply   NaN1234567 -> #7c000000  -- too many digits


-- fold-down full sequence
decd601 apply   1E+96                   -> #47f00000 Clamped
decd602 apply   #47f00000               -> 1.000000E+96
decd603 apply   1E+95                   -> #43f20000 Clamped
decd604 apply   #43f20000               -> 1.00000E+95
decd605 apply   1E+94                   -> #43f04000 Clamped
decd606 apply   #43f04000               -> 1.0000E+94
decd607 apply   1E+93                   -> #43f00400 Clamped
decd608 apply   #43f00400               -> 1.000E+93
decd609 apply   1E+92                   -> #43f00080 Clamped
decd610 apply   #43f00080               -> 1.00E+92
decd611 apply   1E+91                   -> #43f00010 Clamped
decd612 apply   #43f00010               -> 1.0E+91
decd613 apply   1E+90                   -> #43f00001
decd614 apply   #43f00001               -> 1E+90


-- Selected DPD codes
decd700 apply   #22500000       -> 0
decd701 apply   #22500009       -> 9
decd702 apply   #22500010       -> 10
decd703 apply   #22500019       -> 19
decd704 apply   #22500020       -> 20
decd705 apply   #22500029       -> 29
decd706 apply   #22500030       -> 30
decd707 apply   #22500039       -> 39
decd708 apply   #22500040       -> 40
decd709 apply   #22500049       -> 49
decd710 apply   #22500050       -> 50
decd711 apply   #22500059       -> 59
decd712 apply   #22500060       -> 60
decd713 apply   #22500069       -> 69
decd714 apply   #22500070       -> 70
decd715 apply   #22500071       -> 71
decd716 apply   #22500072       -> 72
decd717 apply   #22500073       -> 73
decd718 apply   #22500074       -> 74
decd719 apply   #22500075       -> 75
decd720 apply   #22500076       -> 76
decd721 apply   #22500077       -> 77
decd722 apply   #22500078       -> 78
decd723 apply   #22500079       -> 79

decd730 apply   #2250029e       -> 994
decd731 apply   #2250029f       -> 995
decd732 apply   #225002a0       -> 520
decd733 apply   #225002a1       -> 521

-- DPD: one of each of the huffman groups
decd740 apply   #225003f7       -> 777
decd741 apply   #225003f8       -> 778
decd742 apply   #225003eb       -> 787
decd743 apply   #2250037d       -> 877
decd744 apply   #2250039f       -> 997
decd745 apply   #225003bf       -> 979
decd746 apply   #225003df       -> 799
decd747 apply   #2250006e       -> 888


-- DPD all-highs cases (includes the 24 redundant codes)
decd750 apply   #2250006e       -> 888
decd751 apply   #2250016e       -> 888
decd752 apply   #2250026e       -> 888
decd753 apply   #2250036e       -> 888
decd754 apply   #2250006f       -> 889
decd755 apply   #2250016f       -> 889
decd756 apply   #2250026f       -> 889
decd757 apply   #2250036f       -> 889

decd760 apply   #2250007e       -> 898
decd761 apply   #2250017e       -> 898
decd762 apply   #2250027e       -> 898
decd763 apply   #2250037e       -> 898
decd764 apply   #2250007f       -> 899
decd765 apply   #2250017f       -> 899
decd766 apply   #2250027f       -> 899
decd767 apply   #2250037f       -> 899

decd770 apply   #225000ee       -> 988
decd771 apply   #225001ee       -> 988
decd772 apply   #225002ee       -> 988
decd773 apply   #225003ee       -> 988
decd774 apply   #225000ef       -> 989
decd775 apply   #225001ef       -> 989
decd776 apply   #225002ef       -> 989
decd777 apply   #225003ef       -> 989

decd780 apply   #225000fe       -> 998
decd781 apply   #225001fe       -> 998
decd782 apply   #225002fe       -> 998
decd783 apply   #225003fe       -> 998
decd784 apply   #225000ff       -> 999
decd785 apply   #225001ff       -> 999
decd786 apply   #225002ff       -> 999
decd787 apply   #225003ff       -> 999

-- Rounding modes (negatives in decimal64)

rounding: floor
decd800 apply   1234567.0          -> #2654d2e7 Rounded
decd801 apply   1234567.01         -> #2654d2e7 Rounded Inexact
decd802 apply   1234567.30         -> #2654d2e7 Rounded Inexact
decd803 apply   1234567.49         -> #2654d2e7 Rounded Inexact
decd804 apply   1234566.50         -> #2654d2e6 Rounded Inexact
decd805 apply   1234567.50         -> #2654d2e7 Rounded Inexact
decd806 apply   1234567.51         -> #2654d2e7 Rounded Inexact
decd807 apply   1234567.75         -> #2654d2e7 Rounded Inexact
decd808 apply   1234567.89         -> #2654d2e7 Rounded Inexact
decd809 apply   1234567.99         -> #2654d2e7 Rounded Inexact

rounding: ceiling
decd810 apply   1234567.0          -> #2654d2e7 Rounded
decd811 apply   1234567.01         -> #2654d2e8 Rounded Inexact
decd812 apply   1234567.30         -> #2654d2e8 Rounded Inexact
decd813 apply   1234567.49         -> #2654d2e8 Rounded Inexact
decd814 apply   1234566.50         -> #2654d2e7 Rounded Inexact
decd815 apply   1234567.50         -> #2654d2e8 Rounded Inexact
decd816 apply   1234567.51         -> #2654d2e8 Rounded Inexact
decd817 apply   1234567.75         -> #2654d2e8 Rounded Inexact
decd818 apply   1234567.89         -> #2654d2e8 Rounded Inexact
decd819 apply   1234567.99         -> #2654d2e8 Rounded Inexact

rounding: up
decd820 apply   1234567.0          -> #2654d2e7 Rounded
decd821 apply   1234567.01         -> #2654d2e8 Rounded Inexact
decd822 apply   1234567.30         -> #2654d2e8 Rounded Inexact
decd823 apply   1234567.49         -> #2654d2e8 Rounded Inexact
decd824 apply   1234566.50         -> #2654d2e7 Rounded Inexact
decd825 apply   1234567.50         -> #2654d2e8 Rounded Inexact
decd826 apply   1234567.51         -> #2654d2e8 Rounded Inexact
decd827 apply   1234567.75         -> #2654d2e8 Rounded Inexact
decd828 apply   1234567.89         -> #2654d2e8 Rounded Inexact
decd829 apply   1234567.99         -> #2654d2e8 Rounded Inexact

rounding: down
decd830 apply   1234567.0          -> #2654d2e7 Rounded
decd831 apply   1234567.01         -> #2654d2e7 Rounded Inexact
decd832 apply   1234567.30         -> #2654d2e7 Rounded Inexact
decd833 apply   1234567.49         -> #2654d2e7 Rounded Inexact
decd834 apply   1234566.50         -> #2654d2e6 Rounded Inexact
decd835 apply   1234567.50         -> #2654d2e7 Rounded Inexact
decd836 apply   1234567.51         -> #2654d2e7 Rounded Inexact
decd837 apply   1234567.75         -> #2654d2e7 Rounded Inexact
decd838 apply   1234567.89         -> #2654d2e7 Rounded Inexact
decd839 apply   1234567.99         -> #2654d2e7 Rounded Inexact

rounding: half_up
decd840 apply   1234567.0          -> #2654d2e7 Rounded
decd841 apply   1234567.01         -> #2654d2e7 Rounded Inexact
decd842 apply   1234567.30         -> #2654d2e7 Rounded Inexact
decd843 apply   1234567.49         -> #2654d2e7 Rounded Inexact
decd844 apply   1234566.50         -> #2654d2e7 Rounded Inexact
decd845 apply   1234567.50         -> #2654d2e8 Rounded Inexact
decd846 apply   1234567.51         -> #2654d2e8 Rounded Inexact
decd847 apply   1234567.75         -> #2654d2e8 Rounded Inexact
decd848 apply   1234567.89         -> #2654d2e8 Rounded Inexact
decd849 apply   1234567.99         -> #2654d2e8 Rounded Inexact

rounding: half_even
decd850 apply   1234567.0          -> #2654d2e7 Rounded
decd851 apply   1234567.01         -> #2654d2e7 Rounded Inexact
decd852 apply   1234567.30         -> #2654d2e7 Rounded Inexact
decd853 apply   1234567.49         -> #2654d2e7 Rounded Inexact
decd854 apply   1234566.50         -> #2654d2e6 Rounded Inexact
decd855 apply   1234567.50         -> #2654d2e8 Rounded Inexact
decd856 apply   1234567.51         -> #2654d2e8 Rounded Inexact
decd857 apply   1234567.75         -> #2654d2e8 Rounded Inexact
decd858 apply   1234567.89         -> #2654d2e8 Rounded Inexact
decd859 apply   1234567.99         -> #2654d2e8 Rounded Inexact

rounding: half_down
decd860 apply   1234567.0          -> #2654d2e7 Rounded
decd861 apply   1234567.01         -> #2654d2e7 Rounded Inexact
decd862 apply   1234567.30         -> #2654d2e7 Rounded Inexact
decd863 apply   1234567.49         -> #2654d2e7 Rounded Inexact
decd864 apply   1234566.50         -> #2654d2e6 Rounded Inexact
decd865 apply   1234567.50         -> #2654d2e7 Rounded Inexact
decd866 apply   1234567.51         -> #2654d2e8 Rounded Inexact
decd867 apply   1234567.75         -> #2654d2e8 Rounded Inexact
decd868 apply   1234567.89         -> #2654d2e8 Rounded Inexact
decd869 apply   1234567.99         -> #2654d2e8 Rounded Inexact
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted test/dectest/decimal64.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
------------------------------------------------------------------------
-- decimal64.decTest -- decimal eight-byte format testcases           --
-- Copyright (c) IBM Corporation, 2000, 2003.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- This set of tests is for the eight-byte concrete representation.
-- Its characteristics are:
--
--  1 bit  sign
--  5 bits combination field
--  8 bits exponent continuation
-- 50 bits coefficient continuation
--
-- Total exponent length 10 bits
-- Total coefficient length 54 bits (16 digits)
--
-- Elimit =  767 (maximum encoded exponent)
-- Emax   =  384 (largest exponent value)
-- Emin   = -383 (smallest exponent value)
-- bias   =  398 (subtracted from encoded exponent) = -Etiny

extended:    1
precision:   16
rounding:    half_up
maxExponent: 384
minExponent: -383

-- General testcases
-- (mostly derived from the Strawman 4 document and examples)
dece001 apply   #A2300000000003D0 -> -7.50
dece002 apply   -7.50             -> #A2300000000003D0

-- Normality
dece010 apply   1234567890123456   -> #263934b9c1e28e56
dece011 apply   1234567890123456.0 -> #263934b9c1e28e56 Rounded
dece012 apply   1234567890123456.1 -> #263934b9c1e28e56 Rounded Inexact
dece013 apply   1234567890123456.9 -> #263934b9c1e28e57 Rounded Inexact
dece014 apply  -1234567890123456   -> #a63934b9c1e28e56
dece015 apply  -1234567890123456.0 -> #a63934b9c1e28e56 Rounded
dece016 apply  -1234567890123456.1 -> #a63934b9c1e28e56 Rounded Inexact
dece017 apply  -1234567890123456.9 -> #a63934b9c1e28e57 Rounded Inexact

-- Nmax and similar
dece021 apply   9999999999999999E+369   -> #77fcff3fcff3fcff
dece022 apply   9.999999999999999E+384  -> #77fcff3fcff3fcff
dece023 apply   #77fcff3fcff3fcff       -> 9.999999999999999E+384
dece024 apply   1.234567890123456E+384  -> #47fd34b9c1e28e56
dece025 apply   #47fd34b9c1e28e56       -> 1.234567890123456E+384

-- fold-downs (more below)
dece030 apply   1.23E+384               -> #47fd300000000000 Clamped
dece031 apply   #47fd300000000000       -> 1.230000000000000E+384
dece032 apply   1E+384                  -> #47fc000000000000 Clamped
dece033 apply   #47fc000000000000       -> 1.000000000000000E+384

-- overflows
maxExponent: 999   -- set high so conversion causes the overflow
minExponent: -999
dece040 apply   10E+384                 -> #7800000000000000 Overflow Rounded Inexact
dece041 apply   1.000000000000000E+385  -> #7800000000000000 Overflow Rounded Inexact
dece042 apply   9999999999999999E+370   -> #7800000000000000 Overflow Rounded Inexact
maxExponent: 384
minExponent: -383

dece051 apply   12345                   -> #22380000000049c5
dece052 apply   #22380000000049c5       -> 12345
dece053 apply   1234                    -> #2238000000000534
dece054 apply   #2238000000000534       -> 1234
dece055 apply   123                     -> #22380000000000a3
dece056 apply   #22380000000000a3       -> 123
dece057 apply   12                      -> #2238000000000012
dece058 apply   #2238000000000012       -> 12
dece059 apply   1                       -> #2238000000000001
dece060 apply   #2238000000000001       -> 1
dece061 apply   1.23                    -> #22300000000000a3
dece062 apply   #22300000000000a3       -> 1.23
dece063 apply   123.45                  -> #22300000000049c5
dece064 apply   #22300000000049c5       -> 123.45

-- Nmin and below
dece071 apply   1E-383                  -> #003c000000000001
dece072 apply   #003c000000000001       -> 1E-383
dece073 apply   1.000000000000000E-383  -> #0400000000000000
dece074 apply   #0400000000000000       -> 1.000000000000000E-383
dece075 apply   1.000000000000001E-383  -> #0400000000000001
dece076 apply   #0400000000000001       -> 1.000000000000001E-383

dece077 apply   0.100000000000000E-383  -> #0000800000000000      Subnormal
dece078 apply   #0000800000000000       -> 1.00000000000000E-384  Subnormal
dece079 apply   0.000000000000010E-383  -> #0000000000000010      Subnormal
dece080 apply   #0000000000000010       -> 1.0E-397               Subnormal
dece081 apply   0.00000000000001E-383   -> #0004000000000001      Subnormal
dece082 apply   #0004000000000001       -> 1E-397                 Subnormal
dece083 apply   0.000000000000001E-383  -> #0000000000000001      Subnormal
dece084 apply   #0000000000000001       -> 1E-398                 Subnormal
-- next is smallest all-nines
dece085 apply   9999999999999999E-398   -> #6400ff3fcff3fcff
dece086 apply   #6400ff3fcff3fcff       -> 9.999999999999999E-383

-- underflows
dece090 apply   1e-398                  -> #0000000000000001  Subnormal
dece091 apply   1.9e-398                -> #0000000000000002  Subnormal Underflow Inexact Rounded
dece092 apply   1.1e-398                -> #0000000000000001  Subnormal Underflow Inexact Rounded
dece093 apply   1.00000000001e-398      -> #0000000000000001  Subnormal Underflow Inexact Rounded
dece094 apply   1.00000000000001e-398   -> #0000000000000001  Subnormal Underflow Inexact Rounded
dece095 apply   1.000000000000001e-398  -> #0000000000000001  Subnormal Underflow Inexact Rounded
dece096 apply   0.1e-398                -> #0000000000000000  Subnormal Underflow Inexact Rounded Clamped
dece097 apply   0.00000000001e-398      -> #0000000000000000  Subnormal Underflow Inexact Rounded Clamped
dece098 apply   0.00000000000001e-398   -> #0000000000000000  Subnormal Underflow Inexact Rounded Clamped
dece099 apply   0.000000000000001e-398  -> #0000000000000000  Subnormal Underflow Inexact Rounded Clamped

-- Same again, negatives
-- Nmax and similar
dece122 apply  -9.999999999999999E+384  -> #f7fcff3fcff3fcff
dece123 apply   #f7fcff3fcff3fcff       -> -9.999999999999999E+384
dece124 apply  -1.234567890123456E+384  -> #c7fd34b9c1e28e56
dece125 apply   #c7fd34b9c1e28e56       -> -1.234567890123456E+384
-- fold-downs (more below)
dece130 apply  -1.23E+384               -> #c7fd300000000000 Clamped
dece131 apply   #c7fd300000000000       -> -1.230000000000000E+384
dece132 apply  -1E+384                  -> #c7fc000000000000 Clamped
dece133 apply   #c7fc000000000000       -> -1.000000000000000E+384

-- overflows
maxExponent: 999   -- set high so conversion causes the overflow
minExponent: -999
dece140 apply  -10E+384                 -> #f800000000000000 Overflow Rounded Inexact
dece141 apply  -1.000000000000000E+385  -> #f800000000000000 Overflow Rounded Inexact
maxExponent: 384
minExponent: -383

dece151 apply  -12345                   -> #a2380000000049c5
dece152 apply   #a2380000000049c5       -> -12345
dece153 apply  -1234                    -> #a238000000000534
dece154 apply   #a238000000000534       -> -1234
dece155 apply  -123                     -> #a2380000000000a3
dece156 apply   #a2380000000000a3       -> -123
dece157 apply  -12                      -> #a238000000000012
dece158 apply   #a238000000000012       -> -12
dece159 apply  -1                       -> #a238000000000001
dece160 apply   #a238000000000001       -> -1
dece161 apply  -1.23                    -> #a2300000000000a3
dece162 apply   #a2300000000000a3       -> -1.23
dece163 apply  -123.45                  -> #a2300000000049c5
dece164 apply   #a2300000000049c5       -> -123.45

-- Nmin and below
dece171 apply  -1E-383                  -> #803c000000000001
dece172 apply   #803c000000000001       -> -1E-383
dece173 apply  -1.000000000000000E-383  -> #8400000000000000
dece174 apply   #8400000000000000       -> -1.000000000000000E-383
dece175 apply  -1.000000000000001E-383  -> #8400000000000001
dece176 apply   #8400000000000001       -> -1.000000000000001E-383

dece177 apply  -0.100000000000000E-383  -> #8000800000000000       Subnormal
dece178 apply   #8000800000000000       -> -1.00000000000000E-384  Subnormal
dece179 apply  -0.000000000000010E-383  -> #8000000000000010       Subnormal
dece180 apply   #8000000000000010       -> -1.0E-397               Subnormal
dece181 apply  -0.00000000000001E-383   -> #8004000000000001       Subnormal
dece182 apply   #8004000000000001       -> -1E-397                 Subnormal
dece183 apply  -0.000000000000001E-383  -> #8000000000000001       Subnormal
dece184 apply   #8000000000000001       -> -1E-398                 Subnormal
-- next is smallest all-nines
dece185 apply   -9999999999999999E-398   -> #e400ff3fcff3fcff
dece186 apply   #e400ff3fcff3fcff       -> -9.999999999999999E-383

-- underflows
dece189 apply   -1e-398                 -> #8000000000000001  Subnormal
dece190 apply   -1.0e-398               -> #8000000000000001  Subnormal Rounded
dece191 apply   -1.9e-398               -> #8000000000000002  Subnormal Underflow Inexact Rounded
dece192 apply   -1.1e-398               -> #8000000000000001  Subnormal Underflow Inexact Rounded
dece193 apply   -1.00000000001e-398     -> #8000000000000001  Subnormal Underflow Inexact Rounded
dece194 apply   -1.00000000000001e-398  -> #8000000000000001  Subnormal Underflow Inexact Rounded
dece195 apply   -1.000000000000001e-398 -> #8000000000000001  Subnormal Underflow Inexact Rounded
dece196 apply   -0.1e-398               -> #8000000000000000  Subnormal Underflow Inexact Rounded Clamped
dece197 apply   -0.00000000001e-398     -> #8000000000000000  Subnormal Underflow Inexact Rounded Clamped
dece198 apply   -0.00000000000001e-398  -> #8000000000000000  Subnormal Underflow Inexact Rounded Clamped
dece199 apply   -0.000000000000001e-398 -> #8000000000000000  Subnormal Underflow Inexact Rounded Clamped

-- zeros
dece401 apply   0E-500                  -> #0000000000000000  Clamped
dece402 apply   0E-400                  -> #0000000000000000  Clamped
dece403 apply   0E-398                  -> #0000000000000000
dece404 apply   #0000000000000000       -> 0E-398
dece405 apply   0.000000000000000E-383  -> #0000000000000000
dece406 apply   #0000000000000000       -> 0E-398
dece407 apply   0E-2                    -> #2230000000000000
dece408 apply   #2230000000000000       -> 0.00
dece409 apply   0                       -> #2238000000000000
dece410 apply   #2238000000000000       -> 0
dece411 apply   0E+3                    -> #2244000000000000
dece412 apply   #2244000000000000       -> 0E+3
dece413 apply   0E+369                  -> #43fc000000000000
dece414 apply   #43fc000000000000       -> 0E+369
-- clamped zeros...
dece415 apply   0E+370                  -> #43fc000000000000  Clamped
dece416 apply   #43fc000000000000       -> 0E+369
dece417 apply   0E+384                  -> #43fc000000000000  Clamped
dece418 apply   #43fc000000000000       -> 0E+369
dece419 apply   0E+400                  -> #43fc000000000000  Clamped
dece420 apply   #43fc000000000000       -> 0E+369
dece421 apply   0E+500                  -> #43fc000000000000  Clamped
dece422 apply   #43fc000000000000       -> 0E+369

-- negative zeros
dece431 apply   -0E-400                 -> #8000000000000000  Clamped
dece432 apply   -0E-400                 -> #8000000000000000  Clamped
dece433 apply   -0E-398                 -> #8000000000000000
dece434 apply   #8000000000000000       -> -0E-398
dece435 apply   -0.000000000000000E-383 -> #8000000000000000
dece436 apply   #8000000000000000       -> -0E-398
dece437 apply   -0E-2                   -> #a230000000000000
dece438 apply   #a230000000000000       -> -0.00
dece439 apply   -0                      -> #a238000000000000
dece440 apply   #a238000000000000       -> -0
dece441 apply   -0E+3                   -> #a244000000000000
dece442 apply   #a244000000000000       -> -0E+3
dece443 apply   -0E+369                 -> #c3fc000000000000
dece444 apply   #c3fc000000000000       -> -0E+369
-- clamped zeros...
dece445 apply   -0E+370                 -> #c3fc000000000000  Clamped
dece446 apply   #c3fc000000000000       -> -0E+369
dece447 apply   -0E+384                 -> #c3fc000000000000  Clamped
dece448 apply   #c3fc000000000000       -> -0E+369
dece449 apply   -0E+400                 -> #c3fc000000000000  Clamped
dece450 apply   #c3fc000000000000       -> -0E+369
dece451 apply   -0E+500                 -> #c3fc000000000000  Clamped
dece452 apply   #c3fc000000000000       -> -0E+369

-- Specials
dece500 apply   Infinity          -> #7800000000000000
dece501 apply   #7878787878787878 -> #7800000000000000
dece502 apply   #7800000000000000 -> Infinity
dece503 apply   #7979797979797979 -> #7800000000000000
dece504 apply   #7900000000000000 -> Infinity
dece505 apply   #7a7a7a7a7a7a7a7a -> #7800000000000000
dece506 apply   #7a00000000000000 -> Infinity
dece507 apply   #7b7b7b7b7b7b7b7b -> #7800000000000000
dece508 apply   #7b00000000000000 -> Infinity

dece509 apply   NaN               -> #7c00000000000000
dece510 apply   #7c7c7c7c7c7c7c7c -> #7c007c7c7c7c7c7c
dece511 apply   #7c00000000000000 -> NaN
dece512 apply   #7d7d7d7d7d7d7d7d -> #7c017d7d7d7d7d7d
dece513 apply   #7d00000000000000 -> NaN
dece514 apply   #7e7e7e7e7e7e7e7e -> #7e007e7e7e7e7c7e
dece515 apply   #7e00000000000000 -> sNaN
dece516 apply   #7f7f7f7f7f7f7f7f -> #7e007f7f7f7f7c7f
dece517 apply   #7f00000000000000 -> sNaN
dece518 apply   #7fffffffffffffff -> sNaN999999999999999
dece519 apply   #7fffffffffffffff -> #7e00ff3fcff3fcff

dece520 apply   -Infinity         -> #f800000000000000
dece521 apply   #f878787878787878 -> #f800000000000000
dece522 apply   #f800000000000000 -> -Infinity
dece523 apply   #f979797979797979 -> #f800000000000000
dece524 apply   #f900000000000000 -> -Infinity
dece525 apply   #fa7a7a7a7a7a7a7a -> #f800000000000000
dece526 apply   #fa00000000000000 -> -Infinity
dece527 apply   #fb7b7b7b7b7b7b7b -> #f800000000000000
dece528 apply   #fb00000000000000 -> -Infinity

dece529 apply   -NaN              -> #fc00000000000000
dece530 apply   #fc7c7c7c7c7c7c7c -> #fc007c7c7c7c7c7c
dece531 apply   #fc00000000000000 -> -NaN
dece532 apply   #fd7d7d7d7d7d7d7d -> #fc017d7d7d7d7d7d
dece533 apply   #fd00000000000000 -> -NaN
dece534 apply   #fe7e7e7e7e7e7e7e -> #fe007e7e7e7e7c7e
dece535 apply   #fe00000000000000 -> -sNaN
dece536 apply   #ff7f7f7f7f7f7f7f -> #fe007f7f7f7f7c7f
dece537 apply   #ff00000000000000 -> -sNaN
dece538 apply   #ffffffffffffffff -> -sNaN999999999999999
dece539 apply   #ffffffffffffffff -> #fe00ff3fcff3fcff

-- diagnostic NaNs
dece540 apply   NaN                 -> #7c00000000000000
dece541 apply   NaN0                -> #7c00000000000000
dece542 apply   NaN1                -> #7c00000000000001
dece543 apply   NaN12               -> #7c00000000000012
dece544 apply   NaN79               -> #7c00000000000079
dece545 apply   NaN12345            -> #7c000000000049c5
dece546 apply   NaN123456           -> #7c00000000028e56
dece547 apply   NaN799799           -> #7c000000000f7fdf
dece548 apply   NaN799799799799799  -> #7c03dff7fdff7fdf
dece549 apply   NaN999999999999999  -> #7c00ff3fcff3fcff
dece550 apply   NaN1234567890123456 -> #7c00000000000000  -- too many digits

-- fold-down full sequence
dece601 apply   1E+384                  -> #47fc000000000000 Clamped
dece602 apply   #47fc000000000000       -> 1.000000000000000E+384
dece603 apply   1E+383                  -> #43fc800000000000 Clamped
dece604 apply   #43fc800000000000       -> 1.00000000000000E+383
dece605 apply   1E+382                  -> #43fc100000000000 Clamped
dece606 apply   #43fc100000000000       -> 1.0000000000000E+382
dece607 apply   1E+381                  -> #43fc010000000000 Clamped
dece608 apply   #43fc010000000000       -> 1.000000000000E+381
dece609 apply   1E+380                  -> #43fc002000000000 Clamped
dece610 apply   #43fc002000000000       -> 1.00000000000E+380
dece611 apply   1E+379                  -> #43fc000400000000 Clamped
dece612 apply   #43fc000400000000       -> 1.0000000000E+379
dece613 apply   1E+378                  -> #43fc000040000000 Clamped
dece614 apply   #43fc000040000000       -> 1.000000000E+378
dece615 apply   1E+377                  -> #43fc000008000000 Clamped
dece616 apply   #43fc000008000000       -> 1.00000000E+377
dece617 apply   1E+376                  -> #43fc000001000000 Clamped
dece618 apply   #43fc000001000000       -> 1.0000000E+376
dece619 apply   1E+375                  -> #43fc000000100000 Clamped
dece620 apply   #43fc000000100000       -> 1.000000E+375
dece621 apply   1E+374                  -> #43fc000000020000 Clamped
dece622 apply   #43fc000000020000       -> 1.00000E+374
dece623 apply   1E+373                  -> #43fc000000004000 Clamped
dece624 apply   #43fc000000004000       -> 1.0000E+373
dece625 apply   1E+372                  -> #43fc000000000400 Clamped
dece626 apply   #43fc000000000400       -> 1.000E+372
dece627 apply   1E+371                  -> #43fc000000000080 Clamped
dece628 apply   #43fc000000000080       -> 1.00E+371
dece629 apply   1E+370                  -> #43fc000000000010 Clamped
dece630 apply   #43fc000000000010       -> 1.0E+370
dece631 apply   1E+369                  -> #43fc000000000001
dece632 apply   #43fc000000000001       -> 1E+369
dece633 apply   1E+368                  -> #43f8000000000001
dece634 apply   #43f8000000000001       -> 1E+368
-- same with 9s
dece641 apply   9E+384                  -> #77fc000000000000 Clamped
dece642 apply   #77fc000000000000       -> 9.000000000000000E+384
dece643 apply   9E+383                  -> #43fc8c0000000000 Clamped
dece644 apply   #43fc8c0000000000       -> 9.00000000000000E+383
dece645 apply   9E+382                  -> #43fc1a0000000000 Clamped
dece646 apply   #43fc1a0000000000       -> 9.0000000000000E+382
dece647 apply   9E+381                  -> #43fc090000000000 Clamped
dece648 apply   #43fc090000000000       -> 9.000000000000E+381
dece649 apply   9E+380                  -> #43fc002300000000 Clamped
dece650 apply   #43fc002300000000       -> 9.00000000000E+380
dece651 apply   9E+379                  -> #43fc000680000000 Clamped
dece652 apply   #43fc000680000000       -> 9.0000000000E+379
dece653 apply   9E+378                  -> #43fc000240000000 Clamped
dece654 apply   #43fc000240000000       -> 9.000000000E+378
dece655 apply   9E+377                  -> #43fc000008c00000 Clamped
dece656 apply   #43fc000008c00000       -> 9.00000000E+377
dece657 apply   9E+376                  -> #43fc000001a00000 Clamped
dece658 apply   #43fc000001a00000       -> 9.0000000E+376
dece659 apply   9E+375                  -> #43fc000000900000 Clamped
dece660 apply   #43fc000000900000       -> 9.000000E+375
dece661 apply   9E+374                  -> #43fc000000023000 Clamped
dece662 apply   #43fc000000023000       -> 9.00000E+374
dece663 apply   9E+373                  -> #43fc000000006800 Clamped
dece664 apply   #43fc000000006800       -> 9.0000E+373
dece665 apply   9E+372                  -> #43fc000000002400 Clamped
dece666 apply   #43fc000000002400       -> 9.000E+372
dece667 apply   9E+371                  -> #43fc00000000008c Clamped
dece668 apply   #43fc00000000008c       -> 9.00E+371
dece669 apply   9E+370                  -> #43fc00000000001a Clamped
dece670 apply   #43fc00000000001a       -> 9.0E+370
dece671 apply   9E+369                  -> #43fc000000000009
dece672 apply   #43fc000000000009       -> 9E+369
dece673 apply   9E+368                  -> #43f8000000000009
dece674 apply   #43f8000000000009       -> 9E+368


-- Selected DPD codes
dece700 apply   #2238000000000000       -> 0
dece701 apply   #2238000000000009       -> 9
dece702 apply   #2238000000000010       -> 10
dece703 apply   #2238000000000019       -> 19
dece704 apply   #2238000000000020       -> 20
dece705 apply   #2238000000000029       -> 29
dece706 apply   #2238000000000030       -> 30
dece707 apply   #2238000000000039       -> 39
dece708 apply   #2238000000000040       -> 40
dece709 apply   #2238000000000049       -> 49
dece710 apply   #2238000000000050       -> 50
dece711 apply   #2238000000000059       -> 59
dece712 apply   #2238000000000060       -> 60
dece713 apply   #2238000000000069       -> 69
dece714 apply   #2238000000000070       -> 70
dece715 apply   #2238000000000071       -> 71
dece716 apply   #2238000000000072       -> 72
dece717 apply   #2238000000000073       -> 73
dece718 apply   #2238000000000074       -> 74
dece719 apply   #2238000000000075       -> 75
dece720 apply   #2238000000000076       -> 76
dece721 apply   #2238000000000077       -> 77
dece722 apply   #2238000000000078       -> 78
dece723 apply   #2238000000000079       -> 79

dece725 apply   #223800000000029e       -> 994
dece726 apply   #223800000000029f       -> 995
dece727 apply   #22380000000002a0       -> 520
dece728 apply   #22380000000002a1       -> 521
-- from telco test data
dece730 apply   #2238000000000188       -> 308
dece731 apply   #22380000000001a3       -> 323
dece732 apply   #223800000000002a       ->  82
dece733 apply   #22380000000001a9       -> 329
dece734 apply   #2238000000000081       -> 101
dece735 apply   #22380000000002a2       -> 522

-- DPD: one of each of the huffman groups
dece740 apply   #22380000000003f7       -> 777
dece741 apply   #22380000000003f8       -> 778
dece742 apply   #22380000000003eb       -> 787
dece743 apply   #223800000000037d       -> 877
dece744 apply   #223800000000039f       -> 997
dece745 apply   #22380000000003bf       -> 979
dece746 apply   #22380000000003df       -> 799
dece747 apply   #223800000000006e       -> 888


-- DPD all-highs cases (includes the 24 redundant codes)
dece750 apply   #223800000000006e       -> 888
dece751 apply   #223800000000016e       -> 888
dece752 apply   #223800000000026e       -> 888
dece753 apply   #223800000000036e       -> 888
dece754 apply   #223800000000006f       -> 889
dece755 apply   #223800000000016f       -> 889
dece756 apply   #223800000000026f       -> 889
dece757 apply   #223800000000036f       -> 889

dece760 apply   #223800000000007e       -> 898
dece761 apply   #223800000000017e       -> 898
dece762 apply   #223800000000027e       -> 898
dece763 apply   #223800000000037e       -> 898
dece764 apply   #223800000000007f       -> 899
dece765 apply   #223800000000017f       -> 899
dece766 apply   #223800000000027f       -> 899
dece767 apply   #223800000000037f       -> 899

dece770 apply   #22380000000000ee       -> 988
dece771 apply   #22380000000001ee       -> 988
dece772 apply   #22380000000002ee       -> 988
dece773 apply   #22380000000003ee       -> 988
dece774 apply   #22380000000000ef       -> 989
dece775 apply   #22380000000001ef       -> 989
dece776 apply   #22380000000002ef       -> 989
dece777 apply   #22380000000003ef       -> 989

dece780 apply   #22380000000000fe       -> 998
dece781 apply   #22380000000001fe       -> 998
dece782 apply   #22380000000002fe       -> 998
dece783 apply   #22380000000003fe       -> 998
dece784 apply   #22380000000000ff       -> 999
dece785 apply   #22380000000001ff       -> 999
dece786 apply   #22380000000002ff       -> 999
dece787 apply   #22380000000003ff       -> 999

-- Rounding modes
rounding: floor
dece800 apply   1234567890123456.0   -> #263934b9c1e28e56 Rounded
dece801 apply   1234567890123456.01  -> #263934b9c1e28e56 Rounded Inexact
dece802 apply   1234567890123456.1   -> #263934b9c1e28e56 Rounded Inexact
dece803 apply   1234567890123456.30  -> #263934b9c1e28e56 Rounded Inexact
dece804 apply   1234567890123456.49  -> #263934b9c1e28e56 Rounded Inexact
dece805 apply   1234567890123456.50  -> #263934b9c1e28e56 Rounded Inexact
dece806 apply   1234567890123455.50  -> #263934b9c1e28e55 Rounded Inexact
dece807 apply   1234567890123456.51  -> #263934b9c1e28e56 Rounded Inexact
dece808 apply   1234567890123456.70  -> #263934b9c1e28e56 Rounded Inexact
dece809 apply   1234567890123456.9   -> #263934b9c1e28e56 Rounded Inexact
dece810 apply   1234567890123456.99  -> #263934b9c1e28e56 Rounded Inexact
dece811 apply  -1234567890123456.01  -> #a63934b9c1e28e57 Rounded Inexact
dece812 apply  -1234567890123456.1   -> #a63934b9c1e28e57 Rounded Inexact
dece813 apply  -1234567890123456.30  -> #a63934b9c1e28e57 Rounded Inexact
dece814 apply  -1234567890123456.49  -> #a63934b9c1e28e57 Rounded Inexact
dece815 apply  -1234567890123456.50  -> #a63934b9c1e28e57 Rounded Inexact
dece816 apply  -1234567890123455.50  -> #a63934b9c1e28e56 Rounded Inexact
dece817 apply  -1234567890123456.51  -> #a63934b9c1e28e57 Rounded Inexact
dece818 apply  -1234567890123456.70  -> #a63934b9c1e28e57 Rounded Inexact
dece819 apply  -1234567890123456.9   -> #a63934b9c1e28e57 Rounded Inexact

rounding: ceiling
dece820 apply   1234567890123456.0   -> #263934b9c1e28e56 Rounded
dece821 apply   1234567890123456.01  -> #263934b9c1e28e57 Rounded Inexact
dece822 apply   1234567890123456.1   -> #263934b9c1e28e57 Rounded Inexact
dece823 apply   1234567890123456.30  -> #263934b9c1e28e57 Rounded Inexact
dece824 apply   1234567890123456.49  -> #263934b9c1e28e57 Rounded Inexact
dece825 apply   1234567890123456.50  -> #263934b9c1e28e57 Rounded Inexact
dece826 apply   1234567890123455.50  -> #263934b9c1e28e56 Rounded Inexact
dece827 apply   1234567890123456.51  -> #263934b9c1e28e57 Rounded Inexact
dece828 apply   1234567890123456.70  -> #263934b9c1e28e57 Rounded Inexact
dece829 apply   1234567890123456.9   -> #263934b9c1e28e57 Rounded Inexact
dece830 apply   1234567890123456.99  -> #263934b9c1e28e57 Rounded Inexact
dece831 apply  -1234567890123456.01  -> #a63934b9c1e28e56 Rounded Inexact
dece832 apply  -1234567890123456.1   -> #a63934b9c1e28e56 Rounded Inexact
dece833 apply  -1234567890123456.30  -> #a63934b9c1e28e56 Rounded Inexact
dece834 apply  -1234567890123456.49  -> #a63934b9c1e28e56 Rounded Inexact
dece835 apply  -1234567890123456.50  -> #a63934b9c1e28e56 Rounded Inexact
dece836 apply  -1234567890123455.50  -> #a63934b9c1e28e55 Rounded Inexact
dece837 apply  -1234567890123456.51  -> #a63934b9c1e28e56 Rounded Inexact
dece838 apply  -1234567890123456.70  -> #a63934b9c1e28e56 Rounded Inexact
dece839 apply  -1234567890123456.9   -> #a63934b9c1e28e56 Rounded Inexact

rounding: up
dece840 apply   1234567890123456.0   -> #263934b9c1e28e56 Rounded
dece841 apply   1234567890123456.01  -> #263934b9c1e28e57 Rounded Inexact
dece842 apply   1234567890123456.1   -> #263934b9c1e28e57 Rounded Inexact
dece843 apply   1234567890123456.30  -> #263934b9c1e28e57 Rounded Inexact
dece844 apply   1234567890123456.49  -> #263934b9c1e28e57 Rounded Inexact
dece845 apply   1234567890123456.50  -> #263934b9c1e28e57 Rounded Inexact
dece846 apply   1234567890123455.50  -> #263934b9c1e28e56 Rounded Inexact
dece847 apply   1234567890123456.51  -> #263934b9c1e28e57 Rounded Inexact
dece848 apply   1234567890123456.70  -> #263934b9c1e28e57 Rounded Inexact
dece849 apply   1234567890123456.99  -> #263934b9c1e28e57 Rounded Inexact
dece850 apply  -1234567890123456.00  -> #a63934b9c1e28e56 Rounded
dece851 apply  -1234567890123456.01  -> #a63934b9c1e28e57 Rounded Inexact
dece852 apply  -1234567890123456.1   -> #a63934b9c1e28e57 Rounded Inexact
dece853 apply  -1234567890123456.30  -> #a63934b9c1e28e57 Rounded Inexact
dece854 apply  -1234567890123456.49  -> #a63934b9c1e28e57 Rounded Inexact
dece855 apply  -1234567890123456.50  -> #a63934b9c1e28e57 Rounded Inexact
dece856 apply  -1234567890123455.50  -> #a63934b9c1e28e56 Rounded Inexact
dece857 apply  -1234567890123456.51  -> #a63934b9c1e28e57 Rounded Inexact
dece858 apply  -1234567890123456.70  -> #a63934b9c1e28e57 Rounded Inexact
dece859 apply  -1234567890123456.9   -> #a63934b9c1e28e57 Rounded Inexact

rounding: down
dece860 apply   1234567890123456.0   -> #263934b9c1e28e56 Rounded
dece861 apply   1234567890123456.01  -> #263934b9c1e28e56 Rounded Inexact
dece862 apply   1234567890123456.1   -> #263934b9c1e28e56 Rounded Inexact
dece863 apply   1234567890123456.30  -> #263934b9c1e28e56 Rounded Inexact
dece864 apply   1234567890123456.49  -> #263934b9c1e28e56 Rounded Inexact
dece865 apply   1234567890123456.50  -> #263934b9c1e28e56 Rounded Inexact
dece866 apply   1234567890123455.50  -> #263934b9c1e28e55 Rounded Inexact
dece867 apply   1234567890123456.51  -> #263934b9c1e28e56 Rounded Inexact
dece868 apply   1234567890123456.70  -> #263934b9c1e28e56 Rounded Inexact
dece869 apply   1234567890123456.9   -> #263934b9c1e28e56 Rounded Inexact
dece870 apply   1234567890123456.99  -> #263934b9c1e28e56 Rounded Inexact
dece871 apply  -1234567890123456.01  -> #a63934b9c1e28e56 Rounded Inexact
dece872 apply  -1234567890123456.1   -> #a63934b9c1e28e56 Rounded Inexact
dece873 apply  -1234567890123456.30  -> #a63934b9c1e28e56 Rounded Inexact
dece874 apply  -1234567890123456.49  -> #a63934b9c1e28e56 Rounded Inexact
dece875 apply  -1234567890123456.50  -> #a63934b9c1e28e56 Rounded Inexact
dece876 apply  -1234567890123455.50  -> #a63934b9c1e28e55 Rounded Inexact
dece877 apply  -1234567890123456.51  -> #a63934b9c1e28e56 Rounded Inexact
dece878 apply  -1234567890123456.70  -> #a63934b9c1e28e56 Rounded Inexact
dece879 apply  -1234567890123456.9   -> #a63934b9c1e28e56 Rounded Inexact

rounding: half_up
dece880 apply   1234567890123456.0   -> #263934b9c1e28e56 Rounded
dece881 apply   1234567890123456.01  -> #263934b9c1e28e56 Rounded Inexact
dece882 apply   1234567890123456.1   -> #263934b9c1e28e56 Rounded Inexact
dece883 apply   1234567890123456.30  -> #263934b9c1e28e56 Rounded Inexact
dece884 apply   1234567890123456.49  -> #263934b9c1e28e56 Rounded Inexact
dece885 apply   1234567890123456.50  -> #263934b9c1e28e57 Rounded Inexact
dece886 apply   1234567890123455.50  -> #263934b9c1e28e56 Rounded Inexact
dece887 apply   1234567890123456.51  -> #263934b9c1e28e57 Rounded Inexact
dece888 apply   1234567890123456.70  -> #263934b9c1e28e57 Rounded Inexact
dece889 apply   1234567890123456.9   -> #263934b9c1e28e57 Rounded Inexact
dece890 apply  -1234567890123456.00  -> #a63934b9c1e28e56 Rounded
dece891 apply  -1234567890123456.01  -> #a63934b9c1e28e56 Rounded Inexact
dece892 apply  -1234567890123456.1   -> #a63934b9c1e28e56 Rounded Inexact
dece893 apply  -1234567890123456.30  -> #a63934b9c1e28e56 Rounded Inexact
dece894 apply  -1234567890123456.49  -> #a63934b9c1e28e56 Rounded Inexact
dece895 apply  -1234567890123456.50  -> #a63934b9c1e28e57 Rounded Inexact
dece896 apply  -1234567890123455.50  -> #a63934b9c1e28e56 Rounded Inexact
dece897 apply  -1234567890123456.51  -> #a63934b9c1e28e57 Rounded Inexact
dece898 apply  -1234567890123456.70  -> #a63934b9c1e28e57 Rounded Inexact
dece899 apply  -1234567890123456.9   -> #a63934b9c1e28e57 Rounded Inexact

rounding: half_even
dece900 apply   1234567890123456.0   -> #263934b9c1e28e56 Rounded
dece901 apply   1234567890123456.01  -> #263934b9c1e28e56 Rounded Inexact
dece902 apply   1234567890123456.1   -> #263934b9c1e28e56 Rounded Inexact
dece903 apply   1234567890123456.30  -> #263934b9c1e28e56 Rounded Inexact
dece904 apply   1234567890123456.49  -> #263934b9c1e28e56 Rounded Inexact
dece905 apply   1234567890123456.50  -> #263934b9c1e28e56 Rounded Inexact
dece906 apply   1234567890123455.50  -> #263934b9c1e28e56 Rounded Inexact
dece907 apply   1234567890123456.51  -> #263934b9c1e28e57 Rounded Inexact
dece908 apply   1234567890123456.70  -> #263934b9c1e28e57 Rounded Inexact
dece909 apply   1234567890123456.9   -> #263934b9c1e28e57 Rounded Inexact
dece910 apply   1234567890123456.99  -> #263934b9c1e28e57 Rounded Inexact
dece911 apply  -1234567890123456.01  -> #a63934b9c1e28e56 Rounded Inexact
dece912 apply  -1234567890123456.1   -> #a63934b9c1e28e56 Rounded Inexact
dece913 apply  -1234567890123456.30  -> #a63934b9c1e28e56 Rounded Inexact
dece914 apply  -1234567890123456.49  -> #a63934b9c1e28e56 Rounded Inexact
dece915 apply  -1234567890123456.50  -> #a63934b9c1e28e56 Rounded Inexact
dece916 apply  -1234567890123455.50  -> #a63934b9c1e28e56 Rounded Inexact
dece917 apply  -1234567890123456.51  -> #a63934b9c1e28e57 Rounded Inexact
dece918 apply  -1234567890123456.70  -> #a63934b9c1e28e57 Rounded Inexact
dece919 apply  -1234567890123456.9   -> #a63934b9c1e28e57 Rounded Inexact

rounding: half_down
dece920 apply   1234567890123456.0   -> #263934b9c1e28e56 Rounded
dece921 apply   1234567890123456.01  -> #263934b9c1e28e56 Rounded Inexact
dece922 apply   1234567890123456.1   -> #263934b9c1e28e56 Rounded Inexact
dece923 apply   1234567890123456.30  -> #263934b9c1e28e56 Rounded Inexact
dece924 apply   1234567890123456.49  -> #263934b9c1e28e56 Rounded Inexact
dece925 apply   1234567890123456.50  -> #263934b9c1e28e56 Rounded Inexact
dece926 apply   1234567890123455.50  -> #263934b9c1e28e55 Rounded Inexact
dece927 apply   1234567890123456.51  -> #263934b9c1e28e57 Rounded Inexact
dece928 apply   1234567890123456.70  -> #263934b9c1e28e57 Rounded Inexact
dece929 apply   1234567890123456.98  -> #263934b9c1e28e57 Rounded Inexact
dece930 apply   1234567890123456.999 -> #263934b9c1e28e57 Rounded Inexact
dece931 apply  -1234567890123456.001 -> #a63934b9c1e28e56 Rounded Inexact
dece932 apply  -1234567890123456.1   -> #a63934b9c1e28e56 Rounded Inexact
dece933 apply  -1234567890123456.30  -> #a63934b9c1e28e56 Rounded Inexact
dece934 apply  -1234567890123456.49  -> #a63934b9c1e28e56 Rounded Inexact
dece935 apply  -1234567890123456.50  -> #a63934b9c1e28e56 Rounded Inexact
dece936 apply  -1234567890123455.50  -> #a63934b9c1e28e55 Rounded Inexact
dece937 apply  -1234567890123456.51  -> #a63934b9c1e28e57 Rounded Inexact
dece938 apply  -1234567890123456.70  -> #a63934b9c1e28e57 Rounded Inexact
dece939 apply  -1234567890123456.9   -> #a63934b9c1e28e57 Rounded Inexact

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Changes to test/dectest/divide.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- divide.decTest -- decimal division                                 --
-- Copyright (c) IBM Corporation, 1981, 2004.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- divide.decTest -- decimal division                                 --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

833
834
835
836
837
838
839






840



841
842
843
844
845
divx1028  divide 5E0        20E-1 -> 2.5
divx1029  divide 5E0      2000E-3 -> 2.5
divx1030  divide 5E0         2E-1 -> 25
divx1031  divide 5E0        20E-2 -> 25
divx1032  divide 480E-2       3E0 -> 1.60
divx1033  divide 47E-1        2E0 -> 2.35












-- Null tests
divx9998 divide 10  # -> NaN Invalid_operation
divx9999 divide  # 10 -> NaN Invalid_operation








>
>
>
>
>
>

>
>
>





833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
divx1028  divide 5E0        20E-1 -> 2.5
divx1029  divide 5E0      2000E-3 -> 2.5
divx1030  divide 5E0         2E-1 -> 25
divx1031  divide 5E0        20E-2 -> 25
divx1032  divide 480E-2       3E0 -> 1.60
divx1033  divide 47E-1        2E0 -> 2.35

-- ECMAScript bad examples
rounding:    half_down
precision: 7
divx1050  divide 5 9  -> 0.5555556 Inexact Rounded
rounding:    half_even
divx1051  divide 5 11 -> 0.4545455 Inexact Rounded

-- payload decapitate
precision: 5
divx1055  divide   sNaN987654321 1 ->  NaN54321  Invalid_operation

-- Null tests
divx9998 divide 10  # -> NaN Invalid_operation
divx9999 divide  # 10 -> NaN Invalid_operation

Changes to test/dectest/divideint.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- divideint.decTest -- decimal integer division                      --
-- Copyright (c) IBM Corporation, 1981, 2004.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- divideint.decTest -- decimal integer division                      --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

Added test/dectest/dqAbs.decTest.





























































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
------------------------------------------------------------------------
-- dqAbs.decTest -- decQuad absolute value, heeding sNaN              --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

dqabs001 abs '1'      -> '1'
dqabs002 abs '-1'     -> '1'
dqabs003 abs '1.00'   -> '1.00'
dqabs004 abs '-1.00'  -> '1.00'
dqabs005 abs '0'      -> '0'
dqabs006 abs '0.00'   -> '0.00'
dqabs007 abs '00.0'   -> '0.0'
dqabs008 abs '00.00'  -> '0.00'
dqabs009 abs '00'     -> '0'

dqabs010 abs '-2'     -> '2'
dqabs011 abs '2'      -> '2'
dqabs012 abs '-2.00'  -> '2.00'
dqabs013 abs '2.00'   -> '2.00'
dqabs014 abs '-0'     -> '0'
dqabs015 abs '-0.00'  -> '0.00'
dqabs016 abs '-00.0'  -> '0.0'
dqabs017 abs '-00.00' -> '0.00'
dqabs018 abs '-00'    -> '0'

dqabs020 abs '-2000000' -> '2000000'
dqabs021 abs '2000000'  -> '2000000'

dqabs030 abs '+0.1'            -> '0.1'
dqabs031 abs '-0.1'            -> '0.1'
dqabs032 abs '+0.01'           -> '0.01'
dqabs033 abs '-0.01'           -> '0.01'
dqabs034 abs '+0.001'          -> '0.001'
dqabs035 abs '-0.001'          -> '0.001'
dqabs036 abs '+0.000001'       -> '0.000001'
dqabs037 abs '-0.000001'       -> '0.000001'
dqabs038 abs '+0.000000000001' -> '1E-12'
dqabs039 abs '-0.000000000001' -> '1E-12'

-- examples from decArith
dqabs040 abs '2.1'     ->  '2.1'
dqabs041 abs '-100'    ->  '100'
dqabs042 abs '101.5'   ->  '101.5'
dqabs043 abs '-101.5'  ->  '101.5'

-- more fixed, potential LHS swaps/overlays if done by subtract 0
dqabs060 abs '-56267E-10'  -> '0.0000056267'
dqabs061 abs '-56267E-5'   -> '0.56267'
dqabs062 abs '-56267E-2'   -> '562.67'
dqabs063 abs '-56267E-1'   -> '5626.7'
dqabs065 abs '-56267E-0'   -> '56267'

-- subnormals and underflow

-- long operand tests
dqabs321 abs 1234567890123456  -> 1234567890123456
dqabs322 abs 12345678000  -> 12345678000
dqabs323 abs 1234567800   -> 1234567800
dqabs324 abs 1234567890   -> 1234567890
dqabs325 abs 1234567891   -> 1234567891
dqabs326 abs 12345678901  -> 12345678901
dqabs327 abs 1234567896   -> 1234567896

-- zeros
dqabs111 abs          0   -> 0
dqabs112 abs         -0   -> 0
dqabs113 abs       0E+6   -> 0E+6
dqabs114 abs      -0E+6   -> 0E+6
dqabs115 abs     0.0000   -> 0.0000
dqabs116 abs    -0.0000   -> 0.0000
dqabs117 abs      0E-141  -> 0E-141
dqabs118 abs     -0E-141  -> 0E-141

-- full coefficients, alternating bits
dqabs121 abs   2682682682682682682682682682682682    ->  2682682682682682682682682682682682
dqabs122 abs  -2682682682682682682682682682682682    ->  2682682682682682682682682682682682
dqabs123 abs   1341341341341341341341341341341341    ->  1341341341341341341341341341341341
dqabs124 abs  -1341341341341341341341341341341341    ->  1341341341341341341341341341341341

-- Nmax, Nmin, Ntiny
dqabs131 abs  9.999999999999999999999999999999999E+6144   ->  9.999999999999999999999999999999999E+6144
dqabs132 abs  1E-6143                                     ->  1E-6143
dqabs133 abs  1.000000000000000000000000000000000E-6143   ->  1.000000000000000000000000000000000E-6143
dqabs134 abs  1E-6176                                     ->  1E-6176 Subnormal

dqabs135 abs  -1E-6176                                    ->  1E-6176 Subnormal
dqabs136 abs  -1.000000000000000000000000000000000E-6143  ->  1.000000000000000000000000000000000E-6143
dqabs137 abs  -1E-6143                                    ->  1E-6143
dqabs138 abs  -9.999999999999999999999999999999999E+6144  ->  9.999999999999999999999999999999999E+6144

-- specials
dqabs520 abs 'Inf'    -> 'Infinity'
dqabs521 abs '-Inf'   -> 'Infinity'
dqabs522 abs   NaN    ->  NaN
dqabs523 abs  sNaN    ->  NaN   Invalid_operation
dqabs524 abs   NaN22  ->  NaN22
dqabs525 abs  sNaN33  ->  NaN33 Invalid_operation
dqabs526 abs  -NaN22  -> -NaN22
dqabs527 abs -sNaN33  -> -NaN33 Invalid_operation

-- Null tests
dqabs900 abs  # -> NaN Invalid_operation

Added test/dectest/dqAdd.decTest.











































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
------------------------------------------------------------------------
-- dqAdd.decTest -- decQuad addition                                  --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests are for decQuads only; all arguments are
-- representable in a decQuad
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- [first group are 'quick confidence check']
dqadd001 add 1       1       ->  2
dqadd002 add 2       3       ->  5
dqadd003 add '5.75'  '3.3'   ->  9.05
dqadd004 add '5'     '-3'    ->  2
dqadd005 add '-5'    '-3'    ->  -8
dqadd006 add '-7'    '2.5'   ->  -4.5
dqadd007 add '0.7'   '0.3'   ->  1.0
dqadd008 add '1.25'  '1.25'  ->  2.50
dqadd009 add '1.23456789'  '1.00000000' -> '2.23456789'
dqadd010 add '1.23456789'  '1.00000011' -> '2.23456800'

--             1234567890123456      1234567890123456
dqadd011 add '0.4444444444444444444444444444444446'  '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Inexact Rounded
dqadd012 add '0.4444444444444444444444444444444445'  '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Rounded
dqadd013 add '0.4444444444444444444444444444444444'  '0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
dqadd014 add   '4444444444444444444444444444444444' '0.49'   -> '4444444444444444444444444444444444' Inexact Rounded
dqadd015 add   '4444444444444444444444444444444444' '0.499'  -> '4444444444444444444444444444444444' Inexact Rounded
dqadd016 add   '4444444444444444444444444444444444' '0.4999' -> '4444444444444444444444444444444444' Inexact Rounded
dqadd017 add   '4444444444444444444444444444444444' '0.5000' -> '4444444444444444444444444444444444' Inexact Rounded
dqadd018 add   '4444444444444444444444444444444444' '0.5001' -> '4444444444444444444444444444444445' Inexact Rounded
dqadd019 add   '4444444444444444444444444444444444' '0.501'  -> '4444444444444444444444444444444445' Inexact Rounded
dqadd020 add   '4444444444444444444444444444444444' '0.51'   -> '4444444444444444444444444444444445' Inexact Rounded

dqadd021 add 0 1 -> 1
dqadd022 add 1 1 -> 2
dqadd023 add 2 1 -> 3
dqadd024 add 3 1 -> 4
dqadd025 add 4 1 -> 5
dqadd026 add 5 1 -> 6
dqadd027 add 6 1 -> 7
dqadd028 add 7 1 -> 8
dqadd029 add 8 1 -> 9
dqadd030 add 9 1 -> 10

-- some carrying effects
dqadd031 add '0.9998'  '0.0000' -> '0.9998'
dqadd032 add '0.9998'  '0.0001' -> '0.9999'
dqadd033 add '0.9998'  '0.0002' -> '1.0000'
dqadd034 add '0.9998'  '0.0003' -> '1.0001'

dqadd035 add '70'  '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqadd036 add '700'  '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqadd037 add '7000'  '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqadd038 add '70000'  '10000e+34' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
dqadd039 add '700000'  '10000e+34' -> '1.000000000000000000000000000000007E+38' Rounded

-- symmetry:
dqadd040 add '10000e+34'  '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqadd041 add '10000e+34'  '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqadd042 add '10000e+34'  '7000' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqadd044 add '10000e+34'  '70000' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
dqadd045 add '10000e+34'  '700000' -> '1.000000000000000000000000000000007E+38' Rounded

-- same, without rounding
dqadd046 add '10000e+9'  '7' -> '10000000000007'
dqadd047 add '10000e+9'  '70' -> '10000000000070'
dqadd048 add '10000e+9'  '700' -> '10000000000700'
dqadd049 add '10000e+9'  '7000' -> '10000000007000'
dqadd050 add '10000e+9'  '70000' -> '10000000070000'
dqadd051 add '10000e+9'  '700000' -> '10000000700000'
dqadd052 add '10000e+9'  '7000000' -> '10000007000000'

-- examples from decarith
dqadd053 add '12' '7.00' -> '19.00'
dqadd054 add '1.3' '-1.07' -> '0.23'
dqadd055 add '1.3' '-1.30' -> '0.00'
dqadd056 add '1.3' '-2.07' -> '-0.77'
dqadd057 add '1E+2' '1E+4' -> '1.01E+4'

-- leading zero preservation
dqadd061 add 1 '0.0001' -> '1.0001'
dqadd062 add 1 '0.00001' -> '1.00001'
dqadd063 add 1 '0.000001' -> '1.000001'
dqadd064 add 1 '0.0000001' -> '1.0000001'
dqadd065 add 1 '0.00000001' -> '1.00000001'

-- some funny zeros [in case of bad signum]
dqadd070 add 1  0    -> 1
dqadd071 add 1 0.    -> 1
dqadd072 add 1  .0   -> 1.0
dqadd073 add 1 0.0   -> 1.0
dqadd074 add 1 0.00  -> 1.00
dqadd075 add  0  1   -> 1
dqadd076 add 0.  1   -> 1
dqadd077 add  .0 1   -> 1.0
dqadd078 add 0.0 1   -> 1.0
dqadd079 add 0.00 1  -> 1.00

-- some carries
dqadd080 add 999999998 1  -> 999999999
dqadd081 add 999999999 1  -> 1000000000
dqadd082 add  99999999 1  -> 100000000
dqadd083 add   9999999 1  -> 10000000
dqadd084 add    999999 1  -> 1000000
dqadd085 add     99999 1  -> 100000
dqadd086 add      9999 1  -> 10000
dqadd087 add       999 1  -> 1000
dqadd088 add        99 1  -> 100
dqadd089 add         9 1  -> 10


-- more LHS swaps
dqadd090 add '-56267E-10'   0 ->  '-0.0000056267'
dqadd091 add '-56267E-6'    0 ->  '-0.056267'
dqadd092 add '-56267E-5'    0 ->  '-0.56267'
dqadd093 add '-56267E-4'    0 ->  '-5.6267'
dqadd094 add '-56267E-3'    0 ->  '-56.267'
dqadd095 add '-56267E-2'    0 ->  '-562.67'
dqadd096 add '-56267E-1'    0 ->  '-5626.7'
dqadd097 add '-56267E-0'    0 ->  '-56267'
dqadd098 add '-5E-10'       0 ->  '-5E-10'
dqadd099 add '-5E-7'        0 ->  '-5E-7'
dqadd100 add '-5E-6'        0 ->  '-0.000005'
dqadd101 add '-5E-5'        0 ->  '-0.00005'
dqadd102 add '-5E-4'        0 ->  '-0.0005'
dqadd103 add '-5E-1'        0 ->  '-0.5'
dqadd104 add '-5E0'         0 ->  '-5'
dqadd105 add '-5E1'         0 ->  '-50'
dqadd106 add '-5E5'         0 ->  '-500000'
dqadd107 add '-5E33'        0 ->  '-5000000000000000000000000000000000'
dqadd108 add '-5E34'        0 ->  '-5.000000000000000000000000000000000E+34'  Rounded
dqadd109 add '-5E35'        0 ->  '-5.000000000000000000000000000000000E+35'  Rounded
dqadd110 add '-5E36'        0 ->  '-5.000000000000000000000000000000000E+36'  Rounded
dqadd111 add '-5E100'       0 ->  '-5.000000000000000000000000000000000E+100' Rounded

-- more RHS swaps
dqadd113 add 0  '-56267E-10' ->  '-0.0000056267'
dqadd114 add 0  '-56267E-6'  ->  '-0.056267'
dqadd116 add 0  '-56267E-5'  ->  '-0.56267'
dqadd117 add 0  '-56267E-4'  ->  '-5.6267'
dqadd119 add 0  '-56267E-3'  ->  '-56.267'
dqadd120 add 0  '-56267E-2'  ->  '-562.67'
dqadd121 add 0  '-56267E-1'  ->  '-5626.7'
dqadd122 add 0  '-56267E-0'  ->  '-56267'
dqadd123 add 0  '-5E-10'     ->  '-5E-10'
dqadd124 add 0  '-5E-7'      ->  '-5E-7'
dqadd125 add 0  '-5E-6'      ->  '-0.000005'
dqadd126 add 0  '-5E-5'      ->  '-0.00005'
dqadd127 add 0  '-5E-4'      ->  '-0.0005'
dqadd128 add 0  '-5E-1'      ->  '-0.5'
dqadd129 add 0  '-5E0'       ->  '-5'
dqadd130 add 0  '-5E1'       ->  '-50'
dqadd131 add 0  '-5E5'       ->  '-500000'
dqadd132 add 0  '-5E33'      ->  '-5000000000000000000000000000000000'
dqadd133 add 0  '-5E34'      ->  '-5.000000000000000000000000000000000E+34'   Rounded
dqadd134 add 0  '-5E35'      ->  '-5.000000000000000000000000000000000E+35'   Rounded
dqadd135 add 0  '-5E36'      ->  '-5.000000000000000000000000000000000E+36'   Rounded
dqadd136 add 0  '-5E100'     ->  '-5.000000000000000000000000000000000E+100'  Rounded

-- related
dqadd137 add  1  '0E-39'      ->  '1.000000000000000000000000000000000'  Rounded
dqadd138 add -1  '0E-39'      ->  '-1.000000000000000000000000000000000' Rounded
dqadd139 add '0E-39' 1        ->  '1.000000000000000000000000000000000'  Rounded
dqadd140 add '0E-39' -1       ->  '-1.000000000000000000000000000000000' Rounded
dqadd141 add 1E+29   0.0000   ->  '100000000000000000000000000000.0000'
dqadd142 add 1E+29   0.00000  ->  '100000000000000000000000000000.0000'  Rounded
dqadd143 add 0.000   1E+30    ->  '1000000000000000000000000000000.000'
dqadd144 add 0.0000  1E+30    ->  '1000000000000000000000000000000.000'  Rounded

-- [some of the next group are really constructor tests]
dqadd146 add '00.0'  0       ->  '0.0'
dqadd147 add '0.00'  0       ->  '0.00'
dqadd148 add  0      '0.00'  ->  '0.00'
dqadd149 add  0      '00.0'  ->  '0.0'
dqadd150 add '00.0'  '0.00'  ->  '0.00'
dqadd151 add '0.00'  '00.0'  ->  '0.00'
dqadd152 add '3'     '.3'    ->  '3.3'
dqadd153 add '3.'    '.3'    ->  '3.3'
dqadd154 add '3.0'   '.3'    ->  '3.3'
dqadd155 add '3.00'  '.3'    ->  '3.30'
dqadd156 add '3'     '3'     ->  '6'
dqadd157 add '3'     '+3'    ->  '6'
dqadd158 add '3'     '-3'    ->  '0'
dqadd159 add '0.3'   '-0.3'  ->  '0.0'
dqadd160 add '0.03'  '-0.03' ->  '0.00'

-- try borderline precision, with carries, etc.
dqadd161 add '1E+12' '-1'    -> '999999999999'
dqadd162 add '1E+12'  '1.11' -> '1000000000001.11'
dqadd163 add '1.11'  '1E+12' -> '1000000000001.11'
dqadd164 add '-1'    '1E+12' -> '999999999999'
dqadd165 add '7E+12' '-1'    -> '6999999999999'
dqadd166 add '7E+12'  '1.11' -> '7000000000001.11'
dqadd167 add '1.11'  '7E+12' -> '7000000000001.11'
dqadd168 add '-1'    '7E+12' -> '6999999999999'

rounding: half_up
dqadd170 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555567' -> '5.000000000000000000000000000000001' Inexact Rounded
dqadd171 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555566' -> '5.000000000000000000000000000000001' Inexact Rounded
dqadd172 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555565' -> '5.000000000000000000000000000000001' Inexact Rounded
dqadd173 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555564' -> '5.000000000000000000000000000000000' Inexact Rounded
dqadd174 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555553' -> '4.999999999999999999999999999999999' Inexact Rounded
dqadd175 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555552' -> '4.999999999999999999999999999999999' Inexact Rounded
dqadd176 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555551' -> '4.999999999999999999999999999999999' Inexact Rounded
dqadd177 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555550' -> '4.999999999999999999999999999999999' Rounded
dqadd178 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555545' -> '4.999999999999999999999999999999999' Inexact Rounded
dqadd179 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555544' -> '4.999999999999999999999999999999998' Inexact Rounded
dqadd180 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555543' -> '4.999999999999999999999999999999998' Inexact Rounded
dqadd181 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555542' -> '4.999999999999999999999999999999998' Inexact Rounded
dqadd182 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555541' -> '4.999999999999999999999999999999998' Inexact Rounded
dqadd183 add '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555540' -> '4.999999999999999999999999999999998' Rounded

-- and some more, including residue effects and different roundings
rounding: half_up
dqadd200 add '1231234567890123456784560123456789' 0             -> '1231234567890123456784560123456789'
dqadd201 add '1231234567890123456784560123456789' 0.000000001   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd202 add '1231234567890123456784560123456789' 0.000001      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd203 add '1231234567890123456784560123456789' 0.1           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd204 add '1231234567890123456784560123456789' 0.4           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd205 add '1231234567890123456784560123456789' 0.49          -> '1231234567890123456784560123456789' Inexact Rounded
dqadd206 add '1231234567890123456784560123456789' 0.499999      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd207 add '1231234567890123456784560123456789' 0.499999999   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd208 add '1231234567890123456784560123456789' 0.5           -> '1231234567890123456784560123456790' Inexact Rounded
dqadd209 add '1231234567890123456784560123456789' 0.500000001   -> '1231234567890123456784560123456790' Inexact Rounded
dqadd210 add '1231234567890123456784560123456789' 0.500001      -> '1231234567890123456784560123456790' Inexact Rounded
dqadd211 add '1231234567890123456784560123456789' 0.51          -> '1231234567890123456784560123456790' Inexact Rounded
dqadd212 add '1231234567890123456784560123456789' 0.6           -> '1231234567890123456784560123456790' Inexact Rounded
dqadd213 add '1231234567890123456784560123456789' 0.9           -> '1231234567890123456784560123456790' Inexact Rounded
dqadd214 add '1231234567890123456784560123456789' 0.99999       -> '1231234567890123456784560123456790' Inexact Rounded
dqadd215 add '1231234567890123456784560123456789' 0.999999999   -> '1231234567890123456784560123456790' Inexact Rounded
dqadd216 add '1231234567890123456784560123456789' 1             -> '1231234567890123456784560123456790'
dqadd217 add '1231234567890123456784560123456789' 1.000000001   -> '1231234567890123456784560123456790' Inexact Rounded
dqadd218 add '1231234567890123456784560123456789' 1.00001       -> '1231234567890123456784560123456790' Inexact Rounded
dqadd219 add '1231234567890123456784560123456789' 1.1           -> '1231234567890123456784560123456790' Inexact Rounded

rounding: half_even
dqadd220 add '1231234567890123456784560123456789' 0             -> '1231234567890123456784560123456789'
dqadd221 add '1231234567890123456784560123456789' 0.000000001   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd222 add '1231234567890123456784560123456789' 0.000001      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd223 add '1231234567890123456784560123456789' 0.1           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd224 add '1231234567890123456784560123456789' 0.4           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd225 add '1231234567890123456784560123456789' 0.49          -> '1231234567890123456784560123456789' Inexact Rounded
dqadd226 add '1231234567890123456784560123456789' 0.499999      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd227 add '1231234567890123456784560123456789' 0.499999999   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd228 add '1231234567890123456784560123456789' 0.5           -> '1231234567890123456784560123456790' Inexact Rounded
dqadd229 add '1231234567890123456784560123456789' 0.500000001   -> '1231234567890123456784560123456790' Inexact Rounded
dqadd230 add '1231234567890123456784560123456789' 0.500001      -> '1231234567890123456784560123456790' Inexact Rounded
dqadd231 add '1231234567890123456784560123456789' 0.51          -> '1231234567890123456784560123456790' Inexact Rounded
dqadd232 add '1231234567890123456784560123456789' 0.6           -> '1231234567890123456784560123456790' Inexact Rounded
dqadd233 add '1231234567890123456784560123456789' 0.9           -> '1231234567890123456784560123456790' Inexact Rounded
dqadd234 add '1231234567890123456784560123456789' 0.99999       -> '1231234567890123456784560123456790' Inexact Rounded
dqadd235 add '1231234567890123456784560123456789' 0.999999999   -> '1231234567890123456784560123456790' Inexact Rounded
dqadd236 add '1231234567890123456784560123456789' 1             -> '1231234567890123456784560123456790'
dqadd237 add '1231234567890123456784560123456789' 1.00000001    -> '1231234567890123456784560123456790' Inexact Rounded
dqadd238 add '1231234567890123456784560123456789' 1.00001       -> '1231234567890123456784560123456790' Inexact Rounded
dqadd239 add '1231234567890123456784560123456789' 1.1           -> '1231234567890123456784560123456790' Inexact Rounded
-- critical few with even bottom digit...
dqadd240 add '1231234567890123456784560123456788' 0.499999999   -> '1231234567890123456784560123456788' Inexact Rounded
dqadd241 add '1231234567890123456784560123456788' 0.5           -> '1231234567890123456784560123456788' Inexact Rounded
dqadd242 add '1231234567890123456784560123456788' 0.500000001   -> '1231234567890123456784560123456789' Inexact Rounded

rounding: down
dqadd250 add '1231234567890123456784560123456789' 0             -> '1231234567890123456784560123456789'
dqadd251 add '1231234567890123456784560123456789' 0.000000001   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd252 add '1231234567890123456784560123456789' 0.000001      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd253 add '1231234567890123456784560123456789' 0.1           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd254 add '1231234567890123456784560123456789' 0.4           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd255 add '1231234567890123456784560123456789' 0.49          -> '1231234567890123456784560123456789' Inexact Rounded
dqadd256 add '1231234567890123456784560123456789' 0.499999      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd257 add '1231234567890123456784560123456789' 0.499999999   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd258 add '1231234567890123456784560123456789' 0.5           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd259 add '1231234567890123456784560123456789' 0.500000001   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd260 add '1231234567890123456784560123456789' 0.500001      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd261 add '1231234567890123456784560123456789' 0.51          -> '1231234567890123456784560123456789' Inexact Rounded
dqadd262 add '1231234567890123456784560123456789' 0.6           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd263 add '1231234567890123456784560123456789' 0.9           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd264 add '1231234567890123456784560123456789' 0.99999       -> '1231234567890123456784560123456789' Inexact Rounded
dqadd265 add '1231234567890123456784560123456789' 0.999999999   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd266 add '1231234567890123456784560123456789' 1             -> '1231234567890123456784560123456790'
dqadd267 add '1231234567890123456784560123456789' 1.00000001    -> '1231234567890123456784560123456790' Inexact Rounded
dqadd268 add '1231234567890123456784560123456789' 1.00001       -> '1231234567890123456784560123456790' Inexact Rounded
dqadd269 add '1231234567890123456784560123456789' 1.1           -> '1231234567890123456784560123456790' Inexact Rounded

-- 1 in last place tests
rounding: half_up
dqadd301 add  -1   1      ->   0
dqadd302 add   0   1      ->   1
dqadd303 add   1   1      ->   2
dqadd304 add  12   1      ->  13
dqadd305 add  98   1      ->  99
dqadd306 add  99   1      -> 100
dqadd307 add 100   1      -> 101
dqadd308 add 101   1      -> 102
dqadd309 add  -1  -1      ->  -2
dqadd310 add   0  -1      ->  -1
dqadd311 add   1  -1      ->   0
dqadd312 add  12  -1      ->  11
dqadd313 add  98  -1      ->  97
dqadd314 add  99  -1      ->  98
dqadd315 add 100  -1      ->  99
dqadd316 add 101  -1      -> 100

dqadd321 add -0.01  0.01    ->  0.00
dqadd322 add  0.00  0.01    ->  0.01
dqadd323 add  0.01  0.01    ->  0.02
dqadd324 add  0.12  0.01    ->  0.13
dqadd325 add  0.98  0.01    ->  0.99
dqadd326 add  0.99  0.01    ->  1.00
dqadd327 add  1.00  0.01    ->  1.01
dqadd328 add  1.01  0.01    ->  1.02
dqadd329 add -0.01 -0.01    -> -0.02
dqadd330 add  0.00 -0.01    -> -0.01
dqadd331 add  0.01 -0.01    ->  0.00
dqadd332 add  0.12 -0.01    ->  0.11
dqadd333 add  0.98 -0.01    ->  0.97
dqadd334 add  0.99 -0.01    ->  0.98
dqadd335 add  1.00 -0.01    ->  0.99
dqadd336 add  1.01 -0.01    ->  1.00

-- some more cases where adding 0 affects the coefficient
dqadd340 add 1E+3    0    ->         1000
dqadd341 add 1E+33   0    ->    1000000000000000000000000000000000
dqadd342 add 1E+34   0    ->   1.000000000000000000000000000000000E+34  Rounded
dqadd343 add 1E+35   0    ->   1.000000000000000000000000000000000E+35  Rounded
-- which simply follow from these cases ...
dqadd344 add 1E+3    1    ->         1001
dqadd345 add 1E+33   1    ->    1000000000000000000000000000000001
dqadd346 add 1E+34   1    ->   1.000000000000000000000000000000000E+34  Inexact Rounded
dqadd347 add 1E+35   1    ->   1.000000000000000000000000000000000E+35  Inexact Rounded
dqadd348 add 1E+3    7    ->         1007
dqadd349 add 1E+33   7    ->    1000000000000000000000000000000007
dqadd350 add 1E+34   7    ->   1.000000000000000000000000000000001E+34  Inexact Rounded
dqadd351 add 1E+35   7    ->   1.000000000000000000000000000000000E+35  Inexact Rounded

-- tryzeros cases
rounding:    half_up
dqadd360  add 0E+50 10000E+1  -> 1.0000E+5
dqadd361  add 0E-50 10000E+1  -> 100000.0000000000000000000000000000 Rounded
dqadd362  add 10000E+1 0E-50  -> 100000.0000000000000000000000000000 Rounded
dqadd363  add 10000E+1 10000E-50  -> 100000.0000000000000000000000000000 Rounded Inexact
dqadd364  add 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0E+6111
--            1 234567890123456789012345678901234

-- a curiosity from JSR 13 testing
rounding:    half_down
dqadd370 add  999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
dqadd371 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
rounding:    half_up
dqadd372 add  999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
dqadd373 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
rounding:    half_even
dqadd374 add  999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
dqadd375 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact

-- ulp replacement tests
dqadd400 add   1   77e-32      ->  1.00000000000000000000000000000077
dqadd401 add   1   77e-33      ->  1.000000000000000000000000000000077
dqadd402 add   1   77e-34      ->  1.000000000000000000000000000000008 Inexact Rounded
dqadd403 add   1   77e-35      ->  1.000000000000000000000000000000001 Inexact Rounded
dqadd404 add   1   77e-36      ->  1.000000000000000000000000000000000 Inexact Rounded
dqadd405 add   1   77e-37      ->  1.000000000000000000000000000000000 Inexact Rounded
dqadd406 add   1   77e-299     ->  1.000000000000000000000000000000000 Inexact Rounded

dqadd410 add  10   77e-32      ->  10.00000000000000000000000000000077
dqadd411 add  10   77e-33      ->  10.00000000000000000000000000000008 Inexact Rounded
dqadd412 add  10   77e-34      ->  10.00000000000000000000000000000001 Inexact Rounded
dqadd413 add  10   77e-35      ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd414 add  10   77e-36      ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd415 add  10   77e-37      ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd416 add  10   77e-299     ->  10.00000000000000000000000000000000 Inexact Rounded

dqadd420 add  77e-32       1   ->  1.00000000000000000000000000000077
dqadd421 add  77e-33       1   ->  1.000000000000000000000000000000077
dqadd422 add  77e-34       1   ->  1.000000000000000000000000000000008 Inexact Rounded
dqadd423 add  77e-35       1   ->  1.000000000000000000000000000000001 Inexact Rounded
dqadd424 add  77e-36       1   ->  1.000000000000000000000000000000000 Inexact Rounded
dqadd425 add  77e-37       1   ->  1.000000000000000000000000000000000 Inexact Rounded
dqadd426 add  77e-299      1   ->  1.000000000000000000000000000000000 Inexact Rounded

dqadd430 add  77e-32      10   ->  10.00000000000000000000000000000077
dqadd431 add  77e-33      10   ->  10.00000000000000000000000000000008 Inexact Rounded
dqadd432 add  77e-34      10   ->  10.00000000000000000000000000000001 Inexact Rounded
dqadd433 add  77e-35      10   ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd434 add  77e-36      10   ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd435 add  77e-37      10   ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd436 add  77e-299     10   ->  10.00000000000000000000000000000000 Inexact Rounded

-- negative ulps
dqadd6440 add   1   -77e-32      ->  0.99999999999999999999999999999923
dqadd6441 add   1   -77e-33      ->  0.999999999999999999999999999999923
dqadd6442 add   1   -77e-34      ->  0.9999999999999999999999999999999923
dqadd6443 add   1   -77e-35      ->  0.9999999999999999999999999999999992 Inexact Rounded
dqadd6444 add   1   -77e-36      ->  0.9999999999999999999999999999999999 Inexact Rounded
dqadd6445 add   1   -77e-37      ->  1.000000000000000000000000000000000 Inexact Rounded
dqadd6446 add   1   -77e-99      ->  1.000000000000000000000000000000000 Inexact Rounded

dqadd6450 add  10   -77e-32      ->   9.99999999999999999999999999999923
dqadd6451 add  10   -77e-33      ->   9.999999999999999999999999999999923
dqadd6452 add  10   -77e-34      ->   9.999999999999999999999999999999992 Inexact Rounded
dqadd6453 add  10   -77e-35      ->   9.999999999999999999999999999999999 Inexact Rounded
dqadd6454 add  10   -77e-36      ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd6455 add  10   -77e-37      ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd6456 add  10   -77e-99      ->  10.00000000000000000000000000000000 Inexact Rounded

dqadd6460 add  -77e-32       1   ->  0.99999999999999999999999999999923
dqadd6461 add  -77e-33       1   ->  0.999999999999999999999999999999923
dqadd6462 add  -77e-34       1   ->  0.9999999999999999999999999999999923
dqadd6463 add  -77e-35       1   ->  0.9999999999999999999999999999999992 Inexact Rounded
dqadd6464 add  -77e-36       1   ->  0.9999999999999999999999999999999999 Inexact Rounded
dqadd6465 add  -77e-37       1   ->  1.000000000000000000000000000000000 Inexact Rounded
dqadd6466 add  -77e-99       1   ->  1.000000000000000000000000000000000 Inexact Rounded

dqadd6470 add  -77e-32      10   ->   9.99999999999999999999999999999923
dqadd6471 add  -77e-33      10   ->   9.999999999999999999999999999999923
dqadd6472 add  -77e-34      10   ->   9.999999999999999999999999999999992 Inexact Rounded
dqadd6473 add  -77e-35      10   ->   9.999999999999999999999999999999999 Inexact Rounded
dqadd6474 add  -77e-36      10   ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd6475 add  -77e-37      10   ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd6476 add  -77e-99      10   ->  10.00000000000000000000000000000000 Inexact Rounded

-- negative ulps
dqadd6480 add  -1    77e-32      ->  -0.99999999999999999999999999999923
dqadd6481 add  -1    77e-33      ->  -0.999999999999999999999999999999923
dqadd6482 add  -1    77e-34      ->  -0.9999999999999999999999999999999923
dqadd6483 add  -1    77e-35      ->  -0.9999999999999999999999999999999992 Inexact Rounded
dqadd6484 add  -1    77e-36      ->  -0.9999999999999999999999999999999999 Inexact Rounded
dqadd6485 add  -1    77e-37      ->  -1.000000000000000000000000000000000 Inexact Rounded
dqadd6486 add  -1    77e-99      ->  -1.000000000000000000000000000000000 Inexact Rounded

dqadd6490 add -10    77e-32      ->   -9.99999999999999999999999999999923
dqadd6491 add -10    77e-33      ->   -9.999999999999999999999999999999923
dqadd6492 add -10    77e-34      ->   -9.999999999999999999999999999999992 Inexact Rounded
dqadd6493 add -10    77e-35      ->   -9.999999999999999999999999999999999 Inexact Rounded
dqadd6494 add -10    77e-36      ->  -10.00000000000000000000000000000000 Inexact Rounded
dqadd6495 add -10    77e-37      ->  -10.00000000000000000000000000000000 Inexact Rounded
dqadd6496 add -10    77e-99      ->  -10.00000000000000000000000000000000 Inexact Rounded

dqadd6500 add   77e-32      -1   ->  -0.99999999999999999999999999999923
dqadd6501 add   77e-33      -1   ->  -0.999999999999999999999999999999923
dqadd6502 add   77e-34      -1   ->  -0.9999999999999999999999999999999923
dqadd6503 add   77e-35      -1   ->  -0.9999999999999999999999999999999992 Inexact Rounded
dqadd6504 add   77e-36      -1   ->  -0.9999999999999999999999999999999999 Inexact Rounded
dqadd6505 add   77e-37      -1   ->  -1.000000000000000000000000000000000 Inexact Rounded
dqadd6506 add   77e-99      -1   ->  -1.000000000000000000000000000000000 Inexact Rounded

dqadd6510 add   77e-32      -10  ->   -9.99999999999999999999999999999923
dqadd6511 add   77e-33      -10  ->   -9.999999999999999999999999999999923
dqadd6512 add   77e-34      -10  ->   -9.999999999999999999999999999999992 Inexact Rounded
dqadd6513 add   77e-35      -10  ->   -9.999999999999999999999999999999999 Inexact Rounded
dqadd6514 add   77e-36      -10  ->  -10.00000000000000000000000000000000 Inexact Rounded
dqadd6515 add   77e-37      -10  ->  -10.00000000000000000000000000000000 Inexact Rounded
dqadd6516 add   77e-99      -10  ->  -10.00000000000000000000000000000000 Inexact Rounded

-- and some more residue effects and different roundings
rounding: half_up
dqadd6540 add '9876543219876543216543210123456789' 0             -> '9876543219876543216543210123456789'
dqadd6541 add '9876543219876543216543210123456789' 0.000000001   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6542 add '9876543219876543216543210123456789' 0.000001      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6543 add '9876543219876543216543210123456789' 0.1           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6544 add '9876543219876543216543210123456789' 0.4           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6545 add '9876543219876543216543210123456789' 0.49          -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6546 add '9876543219876543216543210123456789' 0.499999      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6547 add '9876543219876543216543210123456789' 0.499999999   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6548 add '9876543219876543216543210123456789' 0.5           -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6549 add '9876543219876543216543210123456789' 0.500000001   -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6550 add '9876543219876543216543210123456789' 0.500001      -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6551 add '9876543219876543216543210123456789' 0.51          -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6552 add '9876543219876543216543210123456789' 0.6           -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6553 add '9876543219876543216543210123456789' 0.9           -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6554 add '9876543219876543216543210123456789' 0.99999       -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6555 add '9876543219876543216543210123456789' 0.999999999   -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6556 add '9876543219876543216543210123456789' 1             -> '9876543219876543216543210123456790'
dqadd6557 add '9876543219876543216543210123456789' 1.000000001   -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6558 add '9876543219876543216543210123456789' 1.00001       -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6559 add '9876543219876543216543210123456789' 1.1           -> '9876543219876543216543210123456790' Inexact Rounded

rounding: half_even
dqadd6560 add '9876543219876543216543210123456789' 0             -> '9876543219876543216543210123456789'
dqadd6561 add '9876543219876543216543210123456789' 0.000000001   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6562 add '9876543219876543216543210123456789' 0.000001      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6563 add '9876543219876543216543210123456789' 0.1           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6564 add '9876543219876543216543210123456789' 0.4           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6565 add '9876543219876543216543210123456789' 0.49          -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6566 add '9876543219876543216543210123456789' 0.499999      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6567 add '9876543219876543216543210123456789' 0.499999999   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd6568 add '9876543219876543216543210123456789' 0.5           -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6569 add '9876543219876543216543210123456789' 0.500000001   -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6570 add '9876543219876543216543210123456789' 0.500001      -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6571 add '9876543219876543216543210123456789' 0.51          -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6572 add '9876543219876543216543210123456789' 0.6           -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6573 add '9876543219876543216543210123456789' 0.9           -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6574 add '9876543219876543216543210123456789' 0.99999       -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6575 add '9876543219876543216543210123456789' 0.999999999   -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6576 add '9876543219876543216543210123456789' 1             -> '9876543219876543216543210123456790'
dqadd6577 add '9876543219876543216543210123456789' 1.00000001    -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6578 add '9876543219876543216543210123456789' 1.00001       -> '9876543219876543216543210123456790' Inexact Rounded
dqadd6579 add '9876543219876543216543210123456789' 1.1           -> '9876543219876543216543210123456790' Inexact Rounded

-- critical few with even bottom digit...
dqadd7540 add '9876543219876543216543210123456788' 0.499999999   -> '9876543219876543216543210123456788' Inexact Rounded
dqadd7541 add '9876543219876543216543210123456788' 0.5           -> '9876543219876543216543210123456788' Inexact Rounded
dqadd7542 add '9876543219876543216543210123456788' 0.500000001   -> '9876543219876543216543210123456789' Inexact Rounded

rounding: down
dqadd7550 add '9876543219876543216543210123456789' 0             -> '9876543219876543216543210123456789'
dqadd7551 add '9876543219876543216543210123456789' 0.000000001   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7552 add '9876543219876543216543210123456789' 0.000001      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7553 add '9876543219876543216543210123456789' 0.1           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7554 add '9876543219876543216543210123456789' 0.4           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7555 add '9876543219876543216543210123456789' 0.49          -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7556 add '9876543219876543216543210123456789' 0.499999      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7557 add '9876543219876543216543210123456789' 0.499999999   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7558 add '9876543219876543216543210123456789' 0.5           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7559 add '9876543219876543216543210123456789' 0.500000001   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7560 add '9876543219876543216543210123456789' 0.500001      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7561 add '9876543219876543216543210123456789' 0.51          -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7562 add '9876543219876543216543210123456789' 0.6           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7563 add '9876543219876543216543210123456789' 0.9           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7564 add '9876543219876543216543210123456789' 0.99999       -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7565 add '9876543219876543216543210123456789' 0.999999999   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd7566 add '9876543219876543216543210123456789' 1             -> '9876543219876543216543210123456790'
dqadd7567 add '9876543219876543216543210123456789' 1.00000001    -> '9876543219876543216543210123456790' Inexact Rounded
dqadd7568 add '9876543219876543216543210123456789' 1.00001       -> '9876543219876543216543210123456790' Inexact Rounded
dqadd7569 add '9876543219876543216543210123456789' 1.1           -> '9876543219876543216543210123456790' Inexact Rounded

-- more zeros, etc.
rounding: half_even

dqadd7701 add 5.00 1.00E-3 -> 5.00100
dqadd7702 add 00.00 0.000  -> 0.000
dqadd7703 add 00.00 0E-3   -> 0.000
dqadd7704 add 0E-3  00.00  -> 0.000

dqadd7710 add 0E+3  00.00  -> 0.00
dqadd7711 add 0E+3  00.0   -> 0.0
dqadd7712 add 0E+3  00.    -> 0
dqadd7713 add 0E+3  00.E+1 -> 0E+1
dqadd7714 add 0E+3  00.E+2 -> 0E+2
dqadd7715 add 0E+3  00.E+3 -> 0E+3
dqadd7716 add 0E+3  00.E+4 -> 0E+3
dqadd7717 add 0E+3  00.E+5 -> 0E+3
dqadd7718 add 0E+3  -00.0   -> 0.0
dqadd7719 add 0E+3  -00.    -> 0
dqadd7731 add 0E+3  -00.E+1 -> 0E+1

dqadd7720 add 00.00  0E+3  -> 0.00
dqadd7721 add 00.0   0E+3  -> 0.0
dqadd7722 add 00.    0E+3  -> 0
dqadd7723 add 00.E+1 0E+3  -> 0E+1
dqadd7724 add 00.E+2 0E+3  -> 0E+2
dqadd7725 add 00.E+3 0E+3  -> 0E+3
dqadd7726 add 00.E+4 0E+3  -> 0E+3
dqadd7727 add 00.E+5 0E+3  -> 0E+3
dqadd7728 add -00.00 0E+3  -> 0.00
dqadd7729 add -00.0  0E+3  -> 0.0
dqadd7730 add -00.   0E+3  -> 0

dqadd7732 add  0     0     ->  0
dqadd7733 add  0    -0     ->  0
dqadd7734 add -0     0     ->  0
dqadd7735 add -0    -0     -> -0     -- IEEE 854 special case

dqadd7736 add  1    -1     ->  0
dqadd7737 add -1    -1     -> -2
dqadd7738 add  1     1     ->  2
dqadd7739 add -1     1     ->  0

dqadd7741 add  0    -1     -> -1
dqadd7742 add -0    -1     -> -1
dqadd7743 add  0     1     ->  1
dqadd7744 add -0     1     ->  1
dqadd7745 add -1     0     -> -1
dqadd7746 add -1    -0     -> -1
dqadd7747 add  1     0     ->  1
dqadd7748 add  1    -0     ->  1

dqadd7751 add  0.0  -1     -> -1.0
dqadd7752 add -0.0  -1     -> -1.0
dqadd7753 add  0.0   1     ->  1.0
dqadd7754 add -0.0   1     ->  1.0
dqadd7755 add -1.0   0     -> -1.0
dqadd7756 add -1.0  -0     -> -1.0
dqadd7757 add  1.0   0     ->  1.0
dqadd7758 add  1.0  -0     ->  1.0

dqadd7761 add  0    -1.0   -> -1.0
dqadd7762 add -0    -1.0   -> -1.0
dqadd7763 add  0     1.0   ->  1.0
dqadd7764 add -0     1.0   ->  1.0
dqadd7765 add -1     0.0   -> -1.0
dqadd7766 add -1    -0.0   -> -1.0
dqadd7767 add  1     0.0   ->  1.0
dqadd7768 add  1    -0.0   ->  1.0

dqadd7771 add  0.0  -1.0   -> -1.0
dqadd7772 add -0.0  -1.0   -> -1.0
dqadd7773 add  0.0   1.0   ->  1.0
dqadd7774 add -0.0   1.0   ->  1.0
dqadd7775 add -1.0   0.0   -> -1.0
dqadd7776 add -1.0  -0.0   -> -1.0
dqadd7777 add  1.0   0.0   ->  1.0
dqadd7778 add  1.0  -0.0   ->  1.0

-- Specials
dqadd7780 add -Inf  -Inf   -> -Infinity
dqadd7781 add -Inf  -1000  -> -Infinity
dqadd7782 add -Inf  -1     -> -Infinity
dqadd7783 add -Inf  -0     -> -Infinity
dqadd7784 add -Inf   0     -> -Infinity
dqadd7785 add -Inf   1     -> -Infinity
dqadd7786 add -Inf   1000  -> -Infinity
dqadd7787 add -1000 -Inf   -> -Infinity
dqadd7788 add -Inf  -Inf   -> -Infinity
dqadd7789 add -1    -Inf   -> -Infinity
dqadd7790 add -0    -Inf   -> -Infinity
dqadd7791 add  0    -Inf   -> -Infinity
dqadd7792 add  1    -Inf   -> -Infinity
dqadd7793 add  1000 -Inf   -> -Infinity
dqadd7794 add  Inf  -Inf   ->  NaN  Invalid_operation

dqadd7800 add  Inf  -Inf   ->  NaN  Invalid_operation
dqadd7801 add  Inf  -1000  ->  Infinity
dqadd7802 add  Inf  -1     ->  Infinity
dqadd7803 add  Inf  -0     ->  Infinity
dqadd7804 add  Inf   0     ->  Infinity
dqadd7805 add  Inf   1     ->  Infinity
dqadd7806 add  Inf   1000  ->  Infinity
dqadd7807 add  Inf   Inf   ->  Infinity
dqadd7808 add -1000  Inf   ->  Infinity
dqadd7809 add -Inf   Inf   ->  NaN  Invalid_operation
dqadd7810 add -1     Inf   ->  Infinity
dqadd7811 add -0     Inf   ->  Infinity
dqadd7812 add  0     Inf   ->  Infinity
dqadd7813 add  1     Inf   ->  Infinity
dqadd7814 add  1000  Inf   ->  Infinity
dqadd7815 add  Inf   Inf   ->  Infinity

dqadd7821 add  NaN -Inf    ->  NaN
dqadd7822 add  NaN -1000   ->  NaN
dqadd7823 add  NaN -1      ->  NaN
dqadd7824 add  NaN -0      ->  NaN
dqadd7825 add  NaN  0      ->  NaN
dqadd7826 add  NaN  1      ->  NaN
dqadd7827 add  NaN  1000   ->  NaN
dqadd7828 add  NaN  Inf    ->  NaN
dqadd7829 add  NaN  NaN    ->  NaN
dqadd7830 add -Inf  NaN    ->  NaN
dqadd7831 add -1000 NaN    ->  NaN
dqadd7832 add -1    NaN    ->  NaN
dqadd7833 add -0    NaN    ->  NaN
dqadd7834 add  0    NaN    ->  NaN
dqadd7835 add  1    NaN    ->  NaN
dqadd7836 add  1000 NaN    ->  NaN
dqadd7837 add  Inf  NaN    ->  NaN

dqadd7841 add  sNaN -Inf   ->  NaN  Invalid_operation
dqadd7842 add  sNaN -1000  ->  NaN  Invalid_operation
dqadd7843 add  sNaN -1     ->  NaN  Invalid_operation
dqadd7844 add  sNaN -0     ->  NaN  Invalid_operation
dqadd7845 add  sNaN  0     ->  NaN  Invalid_operation
dqadd7846 add  sNaN  1     ->  NaN  Invalid_operation
dqadd7847 add  sNaN  1000  ->  NaN  Invalid_operation
dqadd7848 add  sNaN  NaN   ->  NaN  Invalid_operation
dqadd7849 add  sNaN sNaN   ->  NaN  Invalid_operation
dqadd7850 add  NaN  sNaN   ->  NaN  Invalid_operation
dqadd7851 add -Inf  sNaN   ->  NaN  Invalid_operation
dqadd7852 add -1000 sNaN   ->  NaN  Invalid_operation
dqadd7853 add -1    sNaN   ->  NaN  Invalid_operation
dqadd7854 add -0    sNaN   ->  NaN  Invalid_operation
dqadd7855 add  0    sNaN   ->  NaN  Invalid_operation
dqadd7856 add  1    sNaN   ->  NaN  Invalid_operation
dqadd7857 add  1000 sNaN   ->  NaN  Invalid_operation
dqadd7858 add  Inf  sNaN   ->  NaN  Invalid_operation
dqadd7859 add  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqadd7861 add  NaN1   -Inf    ->  NaN1
dqadd7862 add +NaN2   -1000   ->  NaN2
dqadd7863 add  NaN3    1000   ->  NaN3
dqadd7864 add  NaN4    Inf    ->  NaN4
dqadd7865 add  NaN5   +NaN6   ->  NaN5
dqadd7866 add -Inf     NaN7   ->  NaN7
dqadd7867 add -1000    NaN8   ->  NaN8
dqadd7868 add  1000    NaN9   ->  NaN9
dqadd7869 add  Inf    +NaN10  ->  NaN10
dqadd7871 add  sNaN11  -Inf   ->  NaN11  Invalid_operation
dqadd7872 add  sNaN12  -1000  ->  NaN12  Invalid_operation
dqadd7873 add  sNaN13   1000  ->  NaN13  Invalid_operation
dqadd7874 add  sNaN14   NaN17 ->  NaN14  Invalid_operation
dqadd7875 add  sNaN15  sNaN18 ->  NaN15  Invalid_operation
dqadd7876 add  NaN16   sNaN19 ->  NaN19  Invalid_operation
dqadd7877 add -Inf    +sNaN20 ->  NaN20  Invalid_operation
dqadd7878 add -1000    sNaN21 ->  NaN21  Invalid_operation
dqadd7879 add  1000    sNaN22 ->  NaN22  Invalid_operation
dqadd7880 add  Inf     sNaN23 ->  NaN23  Invalid_operation
dqadd7881 add +NaN25  +sNaN24 ->  NaN24  Invalid_operation
dqadd7882 add -NaN26    NaN28 -> -NaN26
dqadd7883 add -sNaN27  sNaN29 -> -NaN27  Invalid_operation
dqadd7884 add  1000    -NaN30 -> -NaN30
dqadd7885 add  1000   -sNaN31 -> -NaN31  Invalid_operation

-- Here we explore near the boundary of rounding a subnormal to Nmin
dqadd7575 add  1E-6143 -1E-6176 ->  9.99999999999999999999999999999999E-6144 Subnormal
dqadd7576 add -1E-6143 +1E-6176 -> -9.99999999999999999999999999999999E-6144 Subnormal

-- check overflow edge case
--               1234567890123456
dqadd7972 apply   9.999999999999999999999999999999999E+6144         -> 9.999999999999999999999999999999999E+6144
dqadd7973 add     9.999999999999999999999999999999999E+6144  1      -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd7974 add      9999999999999999999999999999999999E+6111  1      -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd7975 add      9999999999999999999999999999999999E+6111  1E+6111  -> Infinity Overflow Inexact Rounded
dqadd7976 add      9999999999999999999999999999999999E+6111  9E+6110  -> Infinity Overflow Inexact Rounded
dqadd7977 add      9999999999999999999999999999999999E+6111  8E+6110  -> Infinity Overflow Inexact Rounded
dqadd7978 add      9999999999999999999999999999999999E+6111  7E+6110  -> Infinity Overflow Inexact Rounded
dqadd7979 add      9999999999999999999999999999999999E+6111  6E+6110  -> Infinity Overflow Inexact Rounded
dqadd7980 add      9999999999999999999999999999999999E+6111  5E+6110  -> Infinity Overflow Inexact Rounded
dqadd7981 add      9999999999999999999999999999999999E+6111  4E+6110  -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd7982 add      9999999999999999999999999999999999E+6111  3E+6110  -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd7983 add      9999999999999999999999999999999999E+6111  2E+6110  -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd7984 add      9999999999999999999999999999999999E+6111  1E+6110  -> 9.999999999999999999999999999999999E+6144 Inexact Rounded

dqadd7985 apply  -9.999999999999999999999999999999999E+6144         -> -9.999999999999999999999999999999999E+6144
dqadd7986 add    -9.999999999999999999999999999999999E+6144 -1      -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd7987 add     -9999999999999999999999999999999999E+6111 -1      -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd7988 add     -9999999999999999999999999999999999E+6111 -1E+6111  -> -Infinity Overflow Inexact Rounded
dqadd7989 add     -9999999999999999999999999999999999E+6111 -9E+6110  -> -Infinity Overflow Inexact Rounded
dqadd7990 add     -9999999999999999999999999999999999E+6111 -8E+6110  -> -Infinity Overflow Inexact Rounded
dqadd7991 add     -9999999999999999999999999999999999E+6111 -7E+6110  -> -Infinity Overflow Inexact Rounded
dqadd7992 add     -9999999999999999999999999999999999E+6111 -6E+6110  -> -Infinity Overflow Inexact Rounded
dqadd7993 add     -9999999999999999999999999999999999E+6111 -5E+6110  -> -Infinity Overflow Inexact Rounded
dqadd7994 add     -9999999999999999999999999999999999E+6111 -4E+6110  -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd7995 add     -9999999999999999999999999999999999E+6111 -3E+6110  -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd7996 add     -9999999999999999999999999999999999E+6111 -2E+6110  -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd7997 add     -9999999999999999999999999999999999E+6111 -1E+6110  -> -9.999999999999999999999999999999999E+6144 Inexact Rounded

-- And for round down full and subnormal results
rounding:     down
dqadd71100 add 1e+2 -1e-6143    -> 99.99999999999999999999999999999999 Rounded Inexact
dqadd71101 add 1e+1 -1e-6143    -> 9.999999999999999999999999999999999  Rounded Inexact
dqadd71103 add   +1 -1e-6143    -> 0.9999999999999999999999999999999999  Rounded Inexact
dqadd71104 add 1e-1 -1e-6143    -> 0.09999999999999999999999999999999999  Rounded Inexact
dqadd71105 add 1e-2 -1e-6143    -> 0.009999999999999999999999999999999999  Rounded Inexact
dqadd71106 add 1e-3 -1e-6143    -> 0.0009999999999999999999999999999999999  Rounded Inexact
dqadd71107 add 1e-4 -1e-6143    -> 0.00009999999999999999999999999999999999  Rounded Inexact
dqadd71108 add 1e-5 -1e-6143    -> 0.000009999999999999999999999999999999999  Rounded Inexact
dqadd71109 add 1e-6 -1e-6143    -> 9.999999999999999999999999999999999E-7  Rounded Inexact

rounding:     ceiling
dqadd71110 add -1e+2 +1e-6143   -> -99.99999999999999999999999999999999 Rounded Inexact
dqadd71111 add -1e+1 +1e-6143   -> -9.999999999999999999999999999999999  Rounded Inexact
dqadd71113 add    -1 +1e-6143   -> -0.9999999999999999999999999999999999  Rounded Inexact
dqadd71114 add -1e-1 +1e-6143   -> -0.09999999999999999999999999999999999  Rounded Inexact
dqadd71115 add -1e-2 +1e-6143   -> -0.009999999999999999999999999999999999  Rounded Inexact
dqadd71116 add -1e-3 +1e-6143   -> -0.0009999999999999999999999999999999999  Rounded Inexact
dqadd71117 add -1e-4 +1e-6143   -> -0.00009999999999999999999999999999999999  Rounded Inexact
dqadd71118 add -1e-5 +1e-6143   -> -0.000009999999999999999999999999999999999  Rounded Inexact
dqadd71119 add -1e-6 +1e-6143   -> -9.999999999999999999999999999999999E-7  Rounded Inexact

-- tests based on Gunnar Degnbol's edge case
rounding:     half_even

dqadd71300 add 1E34  -0.5                 ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71310 add 1E34  -0.51                ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71311 add 1E34  -0.501               ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71312 add 1E34  -0.5001              ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71313 add 1E34  -0.50001             ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71314 add 1E34  -0.500001            ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71315 add 1E34  -0.5000001           ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71316 add 1E34  -0.50000001          ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71317 add 1E34  -0.500000001         ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71318 add 1E34  -0.5000000001        ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71319 add 1E34  -0.50000000001       ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71320 add 1E34  -0.500000000001      ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71321 add 1E34  -0.5000000000001     ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71322 add 1E34  -0.50000000000001    ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71323 add 1E34  -0.500000000000001   ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71324 add 1E34  -0.5000000000000001  ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71325 add 1E34  -0.5000000000000000  ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71326 add 1E34  -0.500000000000000   ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71327 add 1E34  -0.50000000000000    ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71328 add 1E34  -0.5000000000000     ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71329 add 1E34  -0.500000000000      ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71330 add 1E34  -0.50000000000       ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71331 add 1E34  -0.5000000000        ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71332 add 1E34  -0.500000000         ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71333 add 1E34  -0.50000000          ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71334 add 1E34  -0.5000000           ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71335 add 1E34  -0.500000            ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71336 add 1E34  -0.50000             ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71337 add 1E34  -0.5000              ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71338 add 1E34  -0.500               ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71339 add 1E34  -0.50                ->  1.000000000000000000000000000000000E+34 Inexact Rounded

dqadd71340 add 1E34  -5000000.000010001   ->  9999999999999999999999999995000000      Inexact Rounded
dqadd71341 add 1E34  -5000000.000000001   ->  9999999999999999999999999995000000      Inexact Rounded

dqadd71349 add 9999999999999999999999999999999999 0.4                 ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71350 add 9999999999999999999999999999999999 0.49                ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71351 add 9999999999999999999999999999999999 0.499               ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71352 add 9999999999999999999999999999999999 0.4999              ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71353 add 9999999999999999999999999999999999 0.49999             ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71354 add 9999999999999999999999999999999999 0.499999            ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71355 add 9999999999999999999999999999999999 0.4999999           ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71356 add 9999999999999999999999999999999999 0.49999999          ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71357 add 9999999999999999999999999999999999 0.499999999         ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71358 add 9999999999999999999999999999999999 0.4999999999        ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71359 add 9999999999999999999999999999999999 0.49999999999       ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71360 add 9999999999999999999999999999999999 0.499999999999      ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71361 add 9999999999999999999999999999999999 0.4999999999999     ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71362 add 9999999999999999999999999999999999 0.49999999999999    ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71363 add 9999999999999999999999999999999999 0.499999999999999   ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71364 add 9999999999999999999999999999999999 0.4999999999999999  ->  9999999999999999999999999999999999      Inexact Rounded
dqadd71365 add 9999999999999999999999999999999999 0.5000000000000000  ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71367 add 9999999999999999999999999999999999 0.500000000000000   ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71368 add 9999999999999999999999999999999999 0.50000000000000    ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71369 add 9999999999999999999999999999999999 0.5000000000000     ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71370 add 9999999999999999999999999999999999 0.500000000000      ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71371 add 9999999999999999999999999999999999 0.50000000000       ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71372 add 9999999999999999999999999999999999 0.5000000000        ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71373 add 9999999999999999999999999999999999 0.500000000         ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71374 add 9999999999999999999999999999999999 0.50000000          ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71375 add 9999999999999999999999999999999999 0.5000000           ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71376 add 9999999999999999999999999999999999 0.500000            ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71377 add 9999999999999999999999999999999999 0.50000             ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71378 add 9999999999999999999999999999999999 0.5000              ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71379 add 9999999999999999999999999999999999 0.500               ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71380 add 9999999999999999999999999999999999 0.50                ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71381 add 9999999999999999999999999999999999 0.5                 ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71382 add 9999999999999999999999999999999999 0.5000000000000001  ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71383 add 9999999999999999999999999999999999 0.500000000000001   ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71384 add 9999999999999999999999999999999999 0.50000000000001    ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71385 add 9999999999999999999999999999999999 0.5000000000001     ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71386 add 9999999999999999999999999999999999 0.500000000001      ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71387 add 9999999999999999999999999999999999 0.50000000001       ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71388 add 9999999999999999999999999999999999 0.5000000001        ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71389 add 9999999999999999999999999999999999 0.500000001         ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71390 add 9999999999999999999999999999999999 0.50000001          ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71391 add 9999999999999999999999999999999999 0.5000001           ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71392 add 9999999999999999999999999999999999 0.500001            ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71393 add 9999999999999999999999999999999999 0.50001             ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71394 add 9999999999999999999999999999999999 0.5001              ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71395 add 9999999999999999999999999999999999 0.501               ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd71396 add 9999999999999999999999999999999999 0.51                ->  1.000000000000000000000000000000000E+34 Inexact Rounded

-- More GD edge cases, where difference between the unadjusted
-- exponents is larger than the maximum precision and one side is 0
dqadd71420 add  0 1.123456789987654321123456789012345     -> 1.123456789987654321123456789012345
dqadd71421 add  0 1.123456789987654321123456789012345E-1  -> 0.1123456789987654321123456789012345
dqadd71422 add  0 1.123456789987654321123456789012345E-2  -> 0.01123456789987654321123456789012345
dqadd71423 add  0 1.123456789987654321123456789012345E-3  -> 0.001123456789987654321123456789012345
dqadd71424 add  0 1.123456789987654321123456789012345E-4  -> 0.0001123456789987654321123456789012345
dqadd71425 add  0 1.123456789987654321123456789012345E-5  -> 0.00001123456789987654321123456789012345
dqadd71426 add  0 1.123456789987654321123456789012345E-6  -> 0.000001123456789987654321123456789012345
dqadd71427 add  0 1.123456789987654321123456789012345E-7  -> 1.123456789987654321123456789012345E-7
dqadd71428 add  0 1.123456789987654321123456789012345E-8  -> 1.123456789987654321123456789012345E-8
dqadd71429 add  0 1.123456789987654321123456789012345E-9  -> 1.123456789987654321123456789012345E-9
dqadd71430 add  0 1.123456789987654321123456789012345E-10 -> 1.123456789987654321123456789012345E-10
dqadd71431 add  0 1.123456789987654321123456789012345E-11 -> 1.123456789987654321123456789012345E-11
dqadd71432 add  0 1.123456789987654321123456789012345E-12 -> 1.123456789987654321123456789012345E-12
dqadd71433 add  0 1.123456789987654321123456789012345E-13 -> 1.123456789987654321123456789012345E-13
dqadd71434 add  0 1.123456789987654321123456789012345E-14 -> 1.123456789987654321123456789012345E-14
dqadd71435 add  0 1.123456789987654321123456789012345E-15 -> 1.123456789987654321123456789012345E-15
dqadd71436 add  0 1.123456789987654321123456789012345E-16 -> 1.123456789987654321123456789012345E-16
dqadd71437 add  0 1.123456789987654321123456789012345E-17 -> 1.123456789987654321123456789012345E-17
dqadd71438 add  0 1.123456789987654321123456789012345E-18 -> 1.123456789987654321123456789012345E-18
dqadd71439 add  0 1.123456789987654321123456789012345E-19 -> 1.123456789987654321123456789012345E-19
dqadd71440 add  0 1.123456789987654321123456789012345E-20 -> 1.123456789987654321123456789012345E-20
dqadd71441 add  0 1.123456789987654321123456789012345E-21 -> 1.123456789987654321123456789012345E-21
dqadd71442 add  0 1.123456789987654321123456789012345E-22 -> 1.123456789987654321123456789012345E-22
dqadd71443 add  0 1.123456789987654321123456789012345E-23 -> 1.123456789987654321123456789012345E-23
dqadd71444 add  0 1.123456789987654321123456789012345E-24 -> 1.123456789987654321123456789012345E-24
dqadd71445 add  0 1.123456789987654321123456789012345E-25 -> 1.123456789987654321123456789012345E-25
dqadd71446 add  0 1.123456789987654321123456789012345E-26 -> 1.123456789987654321123456789012345E-26
dqadd71447 add  0 1.123456789987654321123456789012345E-27 -> 1.123456789987654321123456789012345E-27
dqadd71448 add  0 1.123456789987654321123456789012345E-28 -> 1.123456789987654321123456789012345E-28
dqadd71449 add  0 1.123456789987654321123456789012345E-29 -> 1.123456789987654321123456789012345E-29
dqadd71450 add  0 1.123456789987654321123456789012345E-30 -> 1.123456789987654321123456789012345E-30
dqadd71451 add  0 1.123456789987654321123456789012345E-31 -> 1.123456789987654321123456789012345E-31
dqadd71452 add  0 1.123456789987654321123456789012345E-32 -> 1.123456789987654321123456789012345E-32
dqadd71453 add  0 1.123456789987654321123456789012345E-33 -> 1.123456789987654321123456789012345E-33
dqadd71454 add  0 1.123456789987654321123456789012345E-34 -> 1.123456789987654321123456789012345E-34
dqadd71455 add  0 1.123456789987654321123456789012345E-35 -> 1.123456789987654321123456789012345E-35
dqadd71456 add  0 1.123456789987654321123456789012345E-36 -> 1.123456789987654321123456789012345E-36

-- same, reversed 0
dqadd71460 add 1.123456789987654321123456789012345     0 -> 1.123456789987654321123456789012345
dqadd71461 add 1.123456789987654321123456789012345E-1  0 -> 0.1123456789987654321123456789012345
dqadd71462 add 1.123456789987654321123456789012345E-2  0 -> 0.01123456789987654321123456789012345
dqadd71463 add 1.123456789987654321123456789012345E-3  0 -> 0.001123456789987654321123456789012345
dqadd71464 add 1.123456789987654321123456789012345E-4  0 -> 0.0001123456789987654321123456789012345
dqadd71465 add 1.123456789987654321123456789012345E-5  0 -> 0.00001123456789987654321123456789012345
dqadd71466 add 1.123456789987654321123456789012345E-6  0 -> 0.000001123456789987654321123456789012345
dqadd71467 add 1.123456789987654321123456789012345E-7  0 -> 1.123456789987654321123456789012345E-7
dqadd71468 add 1.123456789987654321123456789012345E-8  0 -> 1.123456789987654321123456789012345E-8
dqadd71469 add 1.123456789987654321123456789012345E-9  0 -> 1.123456789987654321123456789012345E-9
dqadd71470 add 1.123456789987654321123456789012345E-10 0 -> 1.123456789987654321123456789012345E-10
dqadd71471 add 1.123456789987654321123456789012345E-11 0 -> 1.123456789987654321123456789012345E-11
dqadd71472 add 1.123456789987654321123456789012345E-12 0 -> 1.123456789987654321123456789012345E-12
dqadd71473 add 1.123456789987654321123456789012345E-13 0 -> 1.123456789987654321123456789012345E-13
dqadd71474 add 1.123456789987654321123456789012345E-14 0 -> 1.123456789987654321123456789012345E-14
dqadd71475 add 1.123456789987654321123456789012345E-15 0 -> 1.123456789987654321123456789012345E-15
dqadd71476 add 1.123456789987654321123456789012345E-16 0 -> 1.123456789987654321123456789012345E-16
dqadd71477 add 1.123456789987654321123456789012345E-17 0 -> 1.123456789987654321123456789012345E-17
dqadd71478 add 1.123456789987654321123456789012345E-18 0 -> 1.123456789987654321123456789012345E-18
dqadd71479 add 1.123456789987654321123456789012345E-19 0 -> 1.123456789987654321123456789012345E-19
dqadd71480 add 1.123456789987654321123456789012345E-20 0 -> 1.123456789987654321123456789012345E-20
dqadd71481 add 1.123456789987654321123456789012345E-21 0 -> 1.123456789987654321123456789012345E-21
dqadd71482 add 1.123456789987654321123456789012345E-22 0 -> 1.123456789987654321123456789012345E-22
dqadd71483 add 1.123456789987654321123456789012345E-23 0 -> 1.123456789987654321123456789012345E-23
dqadd71484 add 1.123456789987654321123456789012345E-24 0 -> 1.123456789987654321123456789012345E-24
dqadd71485 add 1.123456789987654321123456789012345E-25 0 -> 1.123456789987654321123456789012345E-25
dqadd71486 add 1.123456789987654321123456789012345E-26 0 -> 1.123456789987654321123456789012345E-26
dqadd71487 add 1.123456789987654321123456789012345E-27 0 -> 1.123456789987654321123456789012345E-27
dqadd71488 add 1.123456789987654321123456789012345E-28 0 -> 1.123456789987654321123456789012345E-28
dqadd71489 add 1.123456789987654321123456789012345E-29 0 -> 1.123456789987654321123456789012345E-29
dqadd71490 add 1.123456789987654321123456789012345E-30 0 -> 1.123456789987654321123456789012345E-30
dqadd71491 add 1.123456789987654321123456789012345E-31 0 -> 1.123456789987654321123456789012345E-31
dqadd71492 add 1.123456789987654321123456789012345E-32 0 -> 1.123456789987654321123456789012345E-32
dqadd71493 add 1.123456789987654321123456789012345E-33 0 -> 1.123456789987654321123456789012345E-33
dqadd71494 add 1.123456789987654321123456789012345E-34 0 -> 1.123456789987654321123456789012345E-34
dqadd71495 add 1.123456789987654321123456789012345E-35 0 -> 1.123456789987654321123456789012345E-35
dqadd71496 add 1.123456789987654321123456789012345E-36 0 -> 1.123456789987654321123456789012345E-36

-- same, Es on the 0
dqadd71500 add 1.123456789987654321123456789012345  0E-0   -> 1.123456789987654321123456789012345
dqadd71501 add 1.123456789987654321123456789012345  0E-1   -> 1.123456789987654321123456789012345
dqadd71502 add 1.123456789987654321123456789012345  0E-2   -> 1.123456789987654321123456789012345
dqadd71503 add 1.123456789987654321123456789012345  0E-3   -> 1.123456789987654321123456789012345
dqadd71504 add 1.123456789987654321123456789012345  0E-4   -> 1.123456789987654321123456789012345
dqadd71505 add 1.123456789987654321123456789012345  0E-5   -> 1.123456789987654321123456789012345
dqadd71506 add 1.123456789987654321123456789012345  0E-6   -> 1.123456789987654321123456789012345
dqadd71507 add 1.123456789987654321123456789012345  0E-7   -> 1.123456789987654321123456789012345
dqadd71508 add 1.123456789987654321123456789012345  0E-8   -> 1.123456789987654321123456789012345
dqadd71509 add 1.123456789987654321123456789012345  0E-9   -> 1.123456789987654321123456789012345
dqadd71510 add 1.123456789987654321123456789012345  0E-10  -> 1.123456789987654321123456789012345
dqadd71511 add 1.123456789987654321123456789012345  0E-11  -> 1.123456789987654321123456789012345
dqadd71512 add 1.123456789987654321123456789012345  0E-12  -> 1.123456789987654321123456789012345
dqadd71513 add 1.123456789987654321123456789012345  0E-13  -> 1.123456789987654321123456789012345
dqadd71514 add 1.123456789987654321123456789012345  0E-14  -> 1.123456789987654321123456789012345
dqadd71515 add 1.123456789987654321123456789012345  0E-15  -> 1.123456789987654321123456789012345
dqadd71516 add 1.123456789987654321123456789012345  0E-16  -> 1.123456789987654321123456789012345
dqadd71517 add 1.123456789987654321123456789012345  0E-17  -> 1.123456789987654321123456789012345
dqadd71518 add 1.123456789987654321123456789012345  0E-18  -> 1.123456789987654321123456789012345
dqadd71519 add 1.123456789987654321123456789012345  0E-19  -> 1.123456789987654321123456789012345
dqadd71520 add 1.123456789987654321123456789012345  0E-20  -> 1.123456789987654321123456789012345
dqadd71521 add 1.123456789987654321123456789012345  0E-21  -> 1.123456789987654321123456789012345
dqadd71522 add 1.123456789987654321123456789012345  0E-22  -> 1.123456789987654321123456789012345
dqadd71523 add 1.123456789987654321123456789012345  0E-23  -> 1.123456789987654321123456789012345
dqadd71524 add 1.123456789987654321123456789012345  0E-24  -> 1.123456789987654321123456789012345
dqadd71525 add 1.123456789987654321123456789012345  0E-25  -> 1.123456789987654321123456789012345
dqadd71526 add 1.123456789987654321123456789012345  0E-26  -> 1.123456789987654321123456789012345
dqadd71527 add 1.123456789987654321123456789012345  0E-27  -> 1.123456789987654321123456789012345
dqadd71528 add 1.123456789987654321123456789012345  0E-28  -> 1.123456789987654321123456789012345
dqadd71529 add 1.123456789987654321123456789012345  0E-29  -> 1.123456789987654321123456789012345
dqadd71530 add 1.123456789987654321123456789012345  0E-30  -> 1.123456789987654321123456789012345
dqadd71531 add 1.123456789987654321123456789012345  0E-31  -> 1.123456789987654321123456789012345
dqadd71532 add 1.123456789987654321123456789012345  0E-32  -> 1.123456789987654321123456789012345
dqadd71533 add 1.123456789987654321123456789012345  0E-33  -> 1.123456789987654321123456789012345
-- next four flag Rounded because the 0 extends the result
dqadd71534 add 1.123456789987654321123456789012345  0E-34  -> 1.123456789987654321123456789012345 Rounded
dqadd71535 add 1.123456789987654321123456789012345  0E-35  -> 1.123456789987654321123456789012345 Rounded
dqadd71536 add 1.123456789987654321123456789012345  0E-36  -> 1.123456789987654321123456789012345 Rounded
dqadd71537 add 1.123456789987654321123456789012345  0E-37  -> 1.123456789987654321123456789012345 Rounded

-- sum of two opposite-sign operands is exactly 0 and floor => -0
rounding:    half_up
-- exact zeros from zeros
dqadd71600 add  0        0E-19  ->  0E-19
dqadd71601 add -0        0E-19  ->  0E-19
dqadd71602 add  0       -0E-19  ->  0E-19
dqadd71603 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd71611 add -11      11    ->  0
dqadd71612 add  11     -11    ->  0

rounding:    half_down
-- exact zeros from zeros
dqadd71620 add  0        0E-19  ->  0E-19
dqadd71621 add -0        0E-19  ->  0E-19
dqadd71622 add  0       -0E-19  ->  0E-19
dqadd71623 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd71631 add -11      11    ->  0
dqadd71632 add  11     -11    ->  0

rounding:    half_even
-- exact zeros from zeros
dqadd71640 add  0        0E-19  ->  0E-19
dqadd71641 add -0        0E-19  ->  0E-19
dqadd71642 add  0       -0E-19  ->  0E-19
dqadd71643 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd71651 add -11      11    ->  0
dqadd71652 add  11     -11    ->  0

rounding:    up
-- exact zeros from zeros
dqadd71660 add  0        0E-19  ->  0E-19
dqadd71661 add -0        0E-19  ->  0E-19
dqadd71662 add  0       -0E-19  ->  0E-19
dqadd71663 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd71671 add -11      11    ->  0
dqadd71672 add  11     -11    ->  0

rounding:    down
-- exact zeros from zeros
dqadd71680 add  0        0E-19  ->  0E-19
dqadd71681 add -0        0E-19  ->  0E-19
dqadd71682 add  0       -0E-19  ->  0E-19
dqadd71683 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd71691 add -11      11    ->  0
dqadd71692 add  11     -11    ->  0

rounding:    ceiling
-- exact zeros from zeros
dqadd71700 add  0        0E-19  ->  0E-19
dqadd71701 add -0        0E-19  ->  0E-19
dqadd71702 add  0       -0E-19  ->  0E-19
dqadd71703 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd71711 add -11      11    ->  0
dqadd71712 add  11     -11    ->  0

-- and the extra-special ugly case; unusual minuses marked by -- *
rounding:    floor
-- exact zeros from zeros
dqadd71720 add  0        0E-19  ->  0E-19
dqadd71721 add -0        0E-19  -> -0E-19           -- *
dqadd71722 add  0       -0E-19  -> -0E-19           -- *
dqadd71723 add -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd71731 add -11      11    ->  -0                -- *
dqadd71732 add  11     -11    ->  -0                -- *

-- Examples from SQL proposal (Krishna Kulkarni)
dqadd71741 add 130E-2    120E-2    -> 2.50
dqadd71742 add 130E-2    12E-1     -> 2.50
dqadd71743 add 130E-2    1E0       -> 2.30
dqadd71744 add 1E2       1E4       -> 1.01E+4
dqadd71745 add 130E-2   -120E-2 -> 0.10
dqadd71746 add 130E-2   -12E-1  -> 0.10
dqadd71747 add 130E-2   -1E0    -> 0.30
dqadd71748 add 1E2      -1E4    -> -9.9E+3

-- Gappy coefficients; check residue handling even with full coefficient gap
rounding: half_even

dqadd75001 add 1239876543211234567894567890123456 1      -> 1239876543211234567894567890123457
dqadd75002 add 1239876543211234567894567890123456 0.6    -> 1239876543211234567894567890123457  Inexact Rounded
dqadd75003 add 1239876543211234567894567890123456 0.06   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75004 add 1239876543211234567894567890123456 6E-3   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75005 add 1239876543211234567894567890123456 6E-4   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75006 add 1239876543211234567894567890123456 6E-5   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75007 add 1239876543211234567894567890123456 6E-6   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75008 add 1239876543211234567894567890123456 6E-7   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75009 add 1239876543211234567894567890123456 6E-8   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75010 add 1239876543211234567894567890123456 6E-9   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75011 add 1239876543211234567894567890123456 6E-10  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75012 add 1239876543211234567894567890123456 6E-11  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75013 add 1239876543211234567894567890123456 6E-12  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75014 add 1239876543211234567894567890123456 6E-13  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75015 add 1239876543211234567894567890123456 6E-14  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75016 add 1239876543211234567894567890123456 6E-15  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75017 add 1239876543211234567894567890123456 6E-16  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75018 add 1239876543211234567894567890123456 6E-17  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75019 add 1239876543211234567894567890123456 6E-18  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75020 add 1239876543211234567894567890123456 6E-19  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd75021 add 1239876543211234567894567890123456 6E-20  -> 1239876543211234567894567890123456  Inexact Rounded

-- widening second argument at gap
dqadd75030 add 12398765432112345678945678 1                       -> 12398765432112345678945679
dqadd75031 add 12398765432112345678945678 0.1                     -> 12398765432112345678945678.1
dqadd75032 add 12398765432112345678945678 0.12                    -> 12398765432112345678945678.12
dqadd75033 add 12398765432112345678945678 0.123                   -> 12398765432112345678945678.123
dqadd75034 add 12398765432112345678945678 0.1234                  -> 12398765432112345678945678.1234
dqadd75035 add 12398765432112345678945678 0.12345                 -> 12398765432112345678945678.12345
dqadd75036 add 12398765432112345678945678 0.123456                -> 12398765432112345678945678.123456
dqadd75037 add 12398765432112345678945678 0.1234567               -> 12398765432112345678945678.1234567
dqadd75038 add 12398765432112345678945678 0.12345678              -> 12398765432112345678945678.12345678
dqadd75039 add 12398765432112345678945678 0.123456789             -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd75040 add 12398765432112345678945678 0.123456785             -> 12398765432112345678945678.12345678 Inexact Rounded
dqadd75041 add 12398765432112345678945678 0.1234567850            -> 12398765432112345678945678.12345678 Inexact Rounded
dqadd75042 add 12398765432112345678945678 0.1234567851            -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd75043 add 12398765432112345678945678 0.12345678501           -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd75044 add 12398765432112345678945678 0.123456785001          -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd75045 add 12398765432112345678945678 0.1234567850001         -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd75046 add 12398765432112345678945678 0.12345678500001        -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd75047 add 12398765432112345678945678 0.123456785000001       -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd75048 add 12398765432112345678945678 0.1234567850000001      -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd75049 add 12398765432112345678945678 0.1234567850000000      -> 12398765432112345678945678.12345678 Inexact Rounded
--                               90123456
rounding: half_even
dqadd75050 add 12398765432112345678945678 0.0234567750000000      -> 12398765432112345678945678.02345678 Inexact Rounded
dqadd75051 add 12398765432112345678945678 0.0034567750000000      -> 12398765432112345678945678.00345678 Inexact Rounded
dqadd75052 add 12398765432112345678945678 0.0004567750000000      -> 12398765432112345678945678.00045678 Inexact Rounded
dqadd75053 add 12398765432112345678945678 0.0000567750000000      -> 12398765432112345678945678.00005678 Inexact Rounded
dqadd75054 add 12398765432112345678945678 0.0000067750000000      -> 12398765432112345678945678.00000678 Inexact Rounded
dqadd75055 add 12398765432112345678945678 0.0000007750000000      -> 12398765432112345678945678.00000078 Inexact Rounded
dqadd75056 add 12398765432112345678945678 0.0000000750000000      -> 12398765432112345678945678.00000008 Inexact Rounded
dqadd75057 add 12398765432112345678945678 0.0000000050000000      -> 12398765432112345678945678.00000000 Inexact Rounded
dqadd75060 add 12398765432112345678945678 0.0234567750000001      -> 12398765432112345678945678.02345678 Inexact Rounded
dqadd75061 add 12398765432112345678945678 0.0034567750000001      -> 12398765432112345678945678.00345678 Inexact Rounded
dqadd75062 add 12398765432112345678945678 0.0004567750000001      -> 12398765432112345678945678.00045678 Inexact Rounded
dqadd75063 add 12398765432112345678945678 0.0000567750000001      -> 12398765432112345678945678.00005678 Inexact Rounded
dqadd75064 add 12398765432112345678945678 0.0000067750000001      -> 12398765432112345678945678.00000678 Inexact Rounded
dqadd75065 add 12398765432112345678945678 0.0000007750000001      -> 12398765432112345678945678.00000078 Inexact Rounded
dqadd75066 add 12398765432112345678945678 0.0000000750000001      -> 12398765432112345678945678.00000008 Inexact Rounded
dqadd75067 add 12398765432112345678945678 0.0000000050000001      -> 12398765432112345678945678.00000001 Inexact Rounded
-- far-out residues (full coefficient gap is 16+15 digits)
rounding: up
dqadd75070 add 12398765432112345678945678 1E-8                    -> 12398765432112345678945678.00000001
dqadd75071 add 12398765432112345678945678 1E-9                    -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75072 add 12398765432112345678945678 1E-10                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75073 add 12398765432112345678945678 1E-11                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75074 add 12398765432112345678945678 1E-12                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75075 add 12398765432112345678945678 1E-13                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75076 add 12398765432112345678945678 1E-14                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75077 add 12398765432112345678945678 1E-15                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75078 add 12398765432112345678945678 1E-16                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75079 add 12398765432112345678945678 1E-17                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75080 add 12398765432112345678945678 1E-18                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75081 add 12398765432112345678945678 1E-19                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75082 add 12398765432112345678945678 1E-20                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75083 add 12398765432112345678945678 1E-25                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75084 add 12398765432112345678945678 1E-30                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75085 add 12398765432112345678945678 1E-31                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75086 add 12398765432112345678945678 1E-32                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75087 add 12398765432112345678945678 1E-33                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75088 add 12398765432112345678945678 1E-34                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd75089 add 12398765432112345678945678 1E-35                   -> 12398765432112345678945678.00000001 Inexact Rounded

-- Null tests
dqadd9990 add 10  # -> NaN Invalid_operation
dqadd9991 add  # 10 -> NaN Invalid_operation

Added test/dectest/dqAnd.decTest.









































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
------------------------------------------------------------------------
-- dqAnd.decTest -- digitwise logical AND for decQuads                --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Sanity check (truth table)
dqand001 and             0    0 ->    0
dqand002 and             0    1 ->    0
dqand003 and             1    0 ->    0
dqand004 and             1    1 ->    1
dqand005 and          1100 1010 -> 1000
-- and at msd and msd-1
--           1234567890123456789012345678901234
dqand006 and 0000000000000000000000000000000000 0000000000000000000000000000000000 ->                  0
dqand007 and 0000000000000000000000000000000000 1000000000000000000000000000000000 ->                  0
dqand008 and 1000000000000000000000000000000000 0000000000000000000000000000000000 ->                  0
dqand009 and 1000000000000000000000000000000000 1000000000000000000000000000000000 ->   1000000000000000000000000000000000
dqand010 and 0000000000000000000000000000000000 0000000000000000000000000000000000 ->                  0
dqand011 and 0000000000000000000000000000000000 0100000000000000000000000000000000 ->                  0
dqand012 and 0100000000000000000000000000000000 0000000000000000000000000000000000 ->                  0
dqand013 and 0100000000000000000000000000000000 0100000000000000000000000000000000 ->    100000000000000000000000000000000

-- Various lengths
--           1234567890123456789012345678901234

dqand601 and 0111111111111111111111111111111111 1111111111111111111111111111111111  ->  111111111111111111111111111111111
dqand602 and 1011111111111111111111111111111111 1111111111111111111111111111111111  -> 1011111111111111111111111111111111
dqand603 and 1101111111111111111111111111111111 1111111111111111111111111111111111  -> 1101111111111111111111111111111111
dqand604 and 1110111111111111111111111111111111 1111111111111111111111111111111111  -> 1110111111111111111111111111111111
dqand605 and 1111011111111111111111111111111111 1111111111111111111111111111111111  -> 1111011111111111111111111111111111
dqand606 and 1111101111111111111111111111111111 1111111111111111111111111111111111  -> 1111101111111111111111111111111111
dqand607 and 1111110111111111111111111111111111 1111111111111111111111111111111111  -> 1111110111111111111111111111111111
dqand608 and 1111111011111111111111111111111111 1111111111111111111111111111111111  -> 1111111011111111111111111111111111
dqand609 and 1111111101111111111111111111111111 1111111111111111111111111111111111  -> 1111111101111111111111111111111111
dqand610 and 1111111110111111111111111111111111 1111111111111111111111111111111111  -> 1111111110111111111111111111111111
dqand611 and 1111111111011111111111111111111111 1111111111111111111111111111111111  -> 1111111111011111111111111111111111
dqand612 and 1111111111101111111111111111111111 1111111111111111111111111111111111  -> 1111111111101111111111111111111111
dqand613 and 1111111111110111111111111111111111 1111111111111111111111111111111111  -> 1111111111110111111111111111111111
dqand614 and 1111111111111011111111111111111111 1111111111111111111111111111111111  -> 1111111111111011111111111111111111
dqand615 and 1111111111111101111111111111111111 1111111111111111111111111111111111  -> 1111111111111101111111111111111111
dqand616 and 1111111111111110111111111111111111 1111111111111111111111111111111111  -> 1111111111111110111111111111111111
dqand617 and 1111111111111111011111111111111111 1111111111111111111111111111111111  -> 1111111111111111011111111111111111
dqand618 and 1111111111111111101111111111111111 1111111111111111111111111111111111  -> 1111111111111111101111111111111111
dqand619 and 1111111111111111110111111111111111 1111111111111111111111111111111111  -> 1111111111111111110111111111111111
dqand620 and 1111111111111111111011111111111111 1111111111111111111111111111111111  -> 1111111111111111111011111111111111
dqand621 and 1111111111111111111101111111111111 1111111111111111111111111111111111  -> 1111111111111111111101111111111111
dqand622 and 1111111111111111111110111111111111 1111111111111111111111111111111111  -> 1111111111111111111110111111111111
dqand623 and 1111111111111111111111011111111111 1111111111111111111111111111111111  -> 1111111111111111111111011111111111
dqand624 and 1111111111111111111111101111111111 1111111111111111111111111111111111  -> 1111111111111111111111101111111111
dqand625 and 1111111111111111111111110111111111 1111111111111111111111111111111111  -> 1111111111111111111111110111111111
dqand626 and 1111111111111111111111111011111111 1111111111111111111111111111111111  -> 1111111111111111111111111011111111
dqand627 and 1111111111111111111111111101111111 1111111111111111111111111111111111  -> 1111111111111111111111111101111111
dqand628 and 1111111111111111111111111110111111 1111111111111111111111111111111111  -> 1111111111111111111111111110111111
dqand629 and 1111111111111111111111111111011111 1111111111111111111111111111111111  -> 1111111111111111111111111111011111
dqand630 and 1111111111111111111111111111101111 1111111111111111111111111111111111  -> 1111111111111111111111111111101111
dqand631 and 1111111111111111111111111111110111 1111111111111111111111111111111111  -> 1111111111111111111111111111110111
dqand632 and 1111111111111111111111111111111011 1111111111111111111111111111111111  -> 1111111111111111111111111111111011
dqand633 and 1111111111111111111111111111111101 1111111111111111111111111111111111  -> 1111111111111111111111111111111101
dqand634 and 1111111111111111111111111111111110 1111111111111111111111111111111111  -> 1111111111111111111111111111111110

dqand641 and 1111111111111111111111111111111111 0111111111111111111111111111111111  ->  111111111111111111111111111111111
dqand642 and 1111111111111111111111111111111111 1011111111111111111111111111111111  -> 1011111111111111111111111111111111
dqand643 and 1111111111111111111111111111111111 1101111111111111111111111111111111  -> 1101111111111111111111111111111111
dqand644 and 1111111111111111111111111111111111 1110111111111111111111111111111111  -> 1110111111111111111111111111111111
dqand645 and 1111111111111111111111111111111111 1111011111111111111111111111111111  -> 1111011111111111111111111111111111
dqand646 and 1111111111111111111111111111111111 1111101111111111111111111111111111  -> 1111101111111111111111111111111111
dqand647 and 1111111111111111111111111111111111 1111110111111111111111111111111111  -> 1111110111111111111111111111111111
dqand648 and 1111111111111111111111111111111111 1111111011111111111111111111111111  -> 1111111011111111111111111111111111
dqand649 and 1111111111111111111111111111111111 1111111101111111111111111111111111  -> 1111111101111111111111111111111111
dqand650 and 1111111111111111111111111111111111 1111111110111111111111111111111111  -> 1111111110111111111111111111111111
dqand651 and 1111111111111111111111111111111111 1111111111011111111111111111111111  -> 1111111111011111111111111111111111
dqand652 and 1111111111111111111111111111111111 1111111111101111111111111111111111  -> 1111111111101111111111111111111111
dqand653 and 1111111111111111111111111111111111 1111111111110111111111111111111111  -> 1111111111110111111111111111111111
dqand654 and 1111111111111111111111111111111111 1111111111111011111111111111111111  -> 1111111111111011111111111111111111
dqand655 and 1111111111111111111111111111111111 1111111111111101111111111111111111  -> 1111111111111101111111111111111111
dqand656 and 1111111111111111111111111111111111 1111111111111110111111111111111111  -> 1111111111111110111111111111111111
dqand657 and 1111111111111111111111111111111111 1111111111111111011111111111111111  -> 1111111111111111011111111111111111
dqand658 and 1111111111111111111111111111111111 1111111111111111101111111111111111  -> 1111111111111111101111111111111111
dqand659 and 1111111111111111111111111111111111 1111111111111111110111111111111111  -> 1111111111111111110111111111111111
dqand660 and 1111111111111111111111111111111111 1111111111111111111011111111111111  -> 1111111111111111111011111111111111
dqand661 and 1111111111111111111111111111111111 1111111111111111111101111111111111  -> 1111111111111111111101111111111111
dqand662 and 1111111111111111111111111111111111 1111111111111111111110111111111111  -> 1111111111111111111110111111111111
dqand663 and 1111111111111111111111111111111111 1111111111111111111111011111111111  -> 1111111111111111111111011111111111
dqand664 and 1111111111111111111111111111111111 1111111111111111111111101111111111  -> 1111111111111111111111101111111111
dqand665 and 1111111111111111111111111111111111 1111111111111111111111110111111111  -> 1111111111111111111111110111111111
dqand666 and 1111111111111111111111111111111111 1111111111111111111111111011111111  -> 1111111111111111111111111011111111
dqand667 and 1111111111111111111111111111111111 1111111111111111111111111101111111  -> 1111111111111111111111111101111111
dqand668 and 1111111111111111111111111111111111 1111111111111111111111111110111111  -> 1111111111111111111111111110111111
dqand669 and 1111111111111111111111111111111111 1111111111111111111111111111011111  -> 1111111111111111111111111111011111
dqand670 and 1111111111111111111111111111111111 1111111111111111111111111111101111  -> 1111111111111111111111111111101111
dqand671 and 1111111111111111111111111111111111 1111111111111111111111111111110111  -> 1111111111111111111111111111110111
dqand672 and 1111111111111111111111111111111111 1111111111111111111111111111111011  -> 1111111111111111111111111111111011
dqand673 and 1111111111111111111111111111111111 1111111111111111111111111111111101  -> 1111111111111111111111111111111101
dqand674 and 1111111111111111111111111111111111 1111111111111111111111111111111110  -> 1111111111111111111111111111111110
dqand675 and 0111111111111111111111111111111111 1111111111111111111111111111111110  ->  111111111111111111111111111111110
dqand676 and 1111111111111111111111111111111111 1111111111111111111111111111111110  -> 1111111111111111111111111111111110

dqand021 and 1111111111111111 1111111111111111  ->  1111111111111111
dqand024 and 1111111111111111  111111111111111  ->   111111111111111
dqand025 and 1111111111111111   11111111111111  ->    11111111111111
dqand026 and 1111111111111111    1111111111111  ->     1111111111111
dqand027 and 1111111111111111     111111111111  ->      111111111111
dqand028 and 1111111111111111      11111111111  ->       11111111111
dqand029 and 1111111111111111       1111111111  ->        1111111111
dqand030 and 1111111111111111        111111111  ->         111111111
dqand031 and 1111111111111111         11111111  ->          11111111
dqand032 and 1111111111111111          1111111  ->           1111111
dqand033 and 1111111111111111           111111  ->            111111
dqand034 and 1111111111111111            11111  ->             11111
dqand035 and 1111111111111111             1111  ->              1111
dqand036 and 1111111111111111              111  ->               111
dqand037 and 1111111111111111               11  ->                11
dqand038 and 1111111111111111                1  ->                 1
dqand039 and 1111111111111111                0  ->                 0

dqand040 and 1111111111111111    1111111111111111 ->  1111111111111111
dqand041 and  111111111111111    1111111111111111 ->   111111111111111
dqand042 and  111111111111111    1111111111111111 ->   111111111111111
dqand043 and   11111111111111    1111111111111111 ->    11111111111111
dqand044 and    1111111111111    1111111111111111 ->     1111111111111
dqand045 and     111111111111    1111111111111111 ->      111111111111
dqand046 and      11111111111    1111111111111111 ->       11111111111
dqand047 and       1111111111    1111111111111111 ->        1111111111
dqand048 and        111111111    1111111111111111 ->         111111111
dqand049 and         11111111    1111111111111111 ->          11111111
dqand050 and          1111111    1111111111111111 ->           1111111
dqand051 and           111111    1111111111111111 ->            111111
dqand052 and            11111    1111111111111111 ->             11111
dqand053 and             1111    1111111111111111 ->              1111
dqand054 and              111    1111111111111111 ->               111
dqand055 and               11    1111111111111111 ->                11
dqand056 and                1    1111111111111111 ->                 1
dqand057 and                0    1111111111111111 ->                 0

dqand150 and 1111111111  1  ->  1
dqand151 and  111111111  1  ->  1
dqand152 and   11111111  1  ->  1
dqand153 and    1111111  1  ->  1
dqand154 and     111111  1  ->  1
dqand155 and      11111  1  ->  1
dqand156 and       1111  1  ->  1
dqand157 and        111  1  ->  1
dqand158 and         11  1  ->  1
dqand159 and          1  1  ->  1

dqand160 and 1111111111  0  ->  0
dqand161 and  111111111  0  ->  0
dqand162 and   11111111  0  ->  0
dqand163 and    1111111  0  ->  0
dqand164 and     111111  0  ->  0
dqand165 and      11111  0  ->  0
dqand166 and       1111  0  ->  0
dqand167 and        111  0  ->  0
dqand168 and         11  0  ->  0
dqand169 and          1  0  ->  0

dqand170 and 1  1111111111  ->  1
dqand171 and 1   111111111  ->  1
dqand172 and 1    11111111  ->  1
dqand173 and 1     1111111  ->  1
dqand174 and 1      111111  ->  1
dqand175 and 1       11111  ->  1
dqand176 and 1        1111  ->  1
dqand177 and 1         111  ->  1
dqand178 and 1          11  ->  1
dqand179 and 1           1  ->  1

dqand180 and 0  1111111111  ->  0
dqand181 and 0   111111111  ->  0
dqand182 and 0    11111111  ->  0
dqand183 and 0     1111111  ->  0
dqand184 and 0      111111  ->  0
dqand185 and 0       11111  ->  0
dqand186 and 0        1111  ->  0
dqand187 and 0         111  ->  0
dqand188 and 0          11  ->  0
dqand189 and 0           1  ->  0

dqand090 and 011111111  111111111  ->   11111111
dqand091 and 101111111  111111111  ->  101111111
dqand092 and 110111111  111111111  ->  110111111
dqand093 and 111011111  111111111  ->  111011111
dqand094 and 111101111  111111111  ->  111101111
dqand095 and 111110111  111111111  ->  111110111
dqand096 and 111111011  111111111  ->  111111011
dqand097 and 111111101  111111111  ->  111111101
dqand098 and 111111110  111111111  ->  111111110

dqand100 and 111111111  011111111  ->   11111111
dqand101 and 111111111  101111111  ->  101111111
dqand102 and 111111111  110111111  ->  110111111
dqand103 and 111111111  111011111  ->  111011111
dqand104 and 111111111  111101111  ->  111101111
dqand105 and 111111111  111110111  ->  111110111
dqand106 and 111111111  111111011  ->  111111011
dqand107 and 111111111  111111101  ->  111111101
dqand108 and 111111111  111111110  ->  111111110

-- non-0/1 should not be accepted, nor should signs
dqand220 and 111111112  111111111  ->  NaN Invalid_operation
dqand221 and 333333333  333333333  ->  NaN Invalid_operation
dqand222 and 555555555  555555555  ->  NaN Invalid_operation
dqand223 and 777777777  777777777  ->  NaN Invalid_operation
dqand224 and 999999999  999999999  ->  NaN Invalid_operation
dqand225 and 222222222  999999999  ->  NaN Invalid_operation
dqand226 and 444444444  999999999  ->  NaN Invalid_operation
dqand227 and 666666666  999999999  ->  NaN Invalid_operation
dqand228 and 888888888  999999999  ->  NaN Invalid_operation
dqand229 and 999999999  222222222  ->  NaN Invalid_operation
dqand230 and 999999999  444444444  ->  NaN Invalid_operation
dqand231 and 999999999  666666666  ->  NaN Invalid_operation
dqand232 and 999999999  888888888  ->  NaN Invalid_operation
-- a few randoms
dqand240 and  567468689 -934981942 ->  NaN Invalid_operation
dqand241 and  567367689  934981942 ->  NaN Invalid_operation
dqand242 and -631917772 -706014634 ->  NaN Invalid_operation
dqand243 and -756253257  138579234 ->  NaN Invalid_operation
dqand244 and  835590149  567435400 ->  NaN Invalid_operation
-- test MSD
dqand250 and  2000000111000111000111000000000000 1000000111000111000111000000000000 ->  NaN Invalid_operation
dqand251 and  7000000111000111000111000000000000 1000000111000111000111000000000000 ->  NaN Invalid_operation
dqand252 and  8000000111000111000111000000000000 1000000111000111000111000000000000 ->  NaN Invalid_operation
dqand253 and  9000000111000111000111000000000000 1000000111000111000111000000000000 ->  NaN Invalid_operation
dqand254 and  2000000111000111000111000000000000 0000000111000111000111000000000000 ->  NaN Invalid_operation
dqand255 and  7000000111000111000111000000000000 0000000111000111000111000000000000 ->  NaN Invalid_operation
dqand256 and  8000000111000111000111000000000000 0000000111000111000111000000000000 ->  NaN Invalid_operation
dqand257 and  9000000111000111000111000000000000 0000000111000111000111000000000000 ->  NaN Invalid_operation
dqand258 and  1000000111000111000111000000000000 2000000111000111000111000000000000 ->  NaN Invalid_operation
dqand259 and  1000000111000111000111000000000000 7000000111000111000111000000000000 ->  NaN Invalid_operation
dqand260 and  1000000111000111000111000000000000 8000000111000111000111000000000000 ->  NaN Invalid_operation
dqand261 and  1000000111000111000111000000000000 9000000111000111000111000000000000 ->  NaN Invalid_operation
dqand262 and  0000000111000111000111000000000000 2000000111000111000111000000000000 ->  NaN Invalid_operation
dqand263 and  0000000111000111000111000000000000 7000000111000111000111000000000000 ->  NaN Invalid_operation
dqand264 and  0000000111000111000111000000000000 8000000111000111000111000000000000 ->  NaN Invalid_operation
dqand265 and  0000000111000111000111000000000000 9000000111000111000111000000000000 ->  NaN Invalid_operation
-- test MSD-1
dqand270 and  0200000111000111000111001000000000 1000000111000111000111100000000010 ->  NaN Invalid_operation
dqand271 and  0700000111000111000111000100000000 1000000111000111000111010000000100 ->  NaN Invalid_operation
dqand272 and  0800000111000111000111000010000000 1000000111000111000111001000001000 ->  NaN Invalid_operation
dqand273 and  0900000111000111000111000001000000 1000000111000111000111000100010000 ->  NaN Invalid_operation
dqand274 and  1000000111000111000111000000100000 0200000111000111000111000010100000 ->  NaN Invalid_operation
dqand275 and  1000000111000111000111000000010000 0700000111000111000111000001000000 ->  NaN Invalid_operation
dqand276 and  1000000111000111000111000000001000 0800000111000111000111000010100000 ->  NaN Invalid_operation
dqand277 and  1000000111000111000111000000000100 0900000111000111000111000000010000 ->  NaN Invalid_operation
-- test LSD
dqand280 and  0010000111000111000111000000000002 1000000111000111000111000100000001 ->  NaN Invalid_operation
dqand281 and  0001000111000111000111000000000007 1000000111000111000111001000000011 ->  NaN Invalid_operation
dqand282 and  0000000111000111000111100000000008 1000000111000111000111010000000001 ->  NaN Invalid_operation
dqand283 and  0000000111000111000111010000000009 1000000111000111000111100000000001 ->  NaN Invalid_operation
dqand284 and  1000000111000111000111001000000000 0001000111000111000111000000000002 ->  NaN Invalid_operation
dqand285 and  1000000111000111000111000100000000 0010000111000111000111000000000007 ->  NaN Invalid_operation
dqand286 and  1000000111000111000111000010000000 0100000111000111000111000000000008 ->  NaN Invalid_operation
dqand287 and  1000000111000111000111000001000000 1000000111000111000111000000000009 ->  NaN Invalid_operation
-- test Middie
dqand288 and  0010000111000111000111000020000000 1000000111000111000111001000000000 ->  NaN Invalid_operation
dqand289 and  0001000111000111000111000070000001 1000000111000111000111000100000000 ->  NaN Invalid_operation
dqand290 and  0000000111000111000111100080000010 1000000111000111000111000010000000 ->  NaN Invalid_operation
dqand291 and  0000000111000111000111010090000100 1000000111000111000111000001000000 ->  NaN Invalid_operation
dqand292 and  1000000111000111000111001000001000 0000000111000111000111000020100000 ->  NaN Invalid_operation
dqand293 and  1000000111000111000111000100010000 0000000111000111000111000070010000 ->  NaN Invalid_operation
dqand294 and  1000000111000111000111000010100000 0000000111000111000111000080001000 ->  NaN Invalid_operation
dqand295 and  1000000111000111000111000001000000 0000000111000111000111000090000100 ->  NaN Invalid_operation
-- signs
dqand296 and -1000000111000111000111000001000000 -0000001110001110001110010000000100 ->  NaN Invalid_operation
dqand297 and -1000000111000111000111000001000000  0000001110001110001110000010000100 ->  NaN Invalid_operation
dqand298 and  1000000111000111000111000001000000 -0000001110001110001110001000000100 ->  NaN Invalid_operation
dqand299 and  1000000111000111000111000001000000  0000001110001110001110000011000100 ->  110000110000110000001000000

-- Nmax, Nmin, Ntiny-like
dqand331 and  2   9.99999999E+999     -> NaN Invalid_operation
dqand332 and  3   1E-999              -> NaN Invalid_operation
dqand333 and  4   1.00000000E-999     -> NaN Invalid_operation
dqand334 and  5   1E-900              -> NaN Invalid_operation
dqand335 and  6   -1E-900             -> NaN Invalid_operation
dqand336 and  7   -1.00000000E-999    -> NaN Invalid_operation
dqand337 and  8   -1E-999             -> NaN Invalid_operation
dqand338 and  9   -9.99999999E+999    -> NaN Invalid_operation
dqand341 and  9.99999999E+999     -18 -> NaN Invalid_operation
dqand342 and  1E-999               01 -> NaN Invalid_operation
dqand343 and  1.00000000E-999     -18 -> NaN Invalid_operation
dqand344 and  1E-900               18 -> NaN Invalid_operation
dqand345 and  -1E-900             -10 -> NaN Invalid_operation
dqand346 and  -1.00000000E-999     18 -> NaN Invalid_operation
dqand347 and  -1E-999              10 -> NaN Invalid_operation
dqand348 and  -9.99999999E+999    -18 -> NaN Invalid_operation

-- A few other non-integers
dqand361 and  1.0                  1  -> NaN Invalid_operation
dqand362 and  1E+1                 1  -> NaN Invalid_operation
dqand363 and  0.0                  1  -> NaN Invalid_operation
dqand364 and  0E+1                 1  -> NaN Invalid_operation
dqand365 and  9.9                  1  -> NaN Invalid_operation
dqand366 and  9E+1                 1  -> NaN Invalid_operation
dqand371 and  0 1.0                   -> NaN Invalid_operation
dqand372 and  0 1E+1                  -> NaN Invalid_operation
dqand373 and  0 0.0                   -> NaN Invalid_operation
dqand374 and  0 0E+1                  -> NaN Invalid_operation
dqand375 and  0 9.9                   -> NaN Invalid_operation
dqand376 and  0 9E+1                  -> NaN Invalid_operation

-- All Specials are in error
dqand780 and -Inf  -Inf   -> NaN Invalid_operation
dqand781 and -Inf  -1000  -> NaN Invalid_operation
dqand782 and -Inf  -1     -> NaN Invalid_operation
dqand783 and -Inf  -0     -> NaN Invalid_operation
dqand784 and -Inf   0     -> NaN Invalid_operation
dqand785 and -Inf   1     -> NaN Invalid_operation
dqand786 and -Inf   1000  -> NaN Invalid_operation
dqand787 and -1000 -Inf   -> NaN Invalid_operation
dqand788 and -Inf  -Inf   -> NaN Invalid_operation
dqand789 and -1    -Inf   -> NaN Invalid_operation
dqand790 and -0    -Inf   -> NaN Invalid_operation
dqand791 and  0    -Inf   -> NaN Invalid_operation
dqand792 and  1    -Inf   -> NaN Invalid_operation
dqand793 and  1000 -Inf   -> NaN Invalid_operation
dqand794 and  Inf  -Inf   -> NaN Invalid_operation

dqand800 and  Inf  -Inf   -> NaN Invalid_operation
dqand801 and  Inf  -1000  -> NaN Invalid_operation
dqand802 and  Inf  -1     -> NaN Invalid_operation
dqand803 and  Inf  -0     -> NaN Invalid_operation
dqand804 and  Inf   0     -> NaN Invalid_operation
dqand805 and  Inf   1     -> NaN Invalid_operation
dqand806 and  Inf   1000  -> NaN Invalid_operation
dqand807 and  Inf   Inf   -> NaN Invalid_operation
dqand808 and -1000  Inf   -> NaN Invalid_operation
dqand809 and -Inf   Inf   -> NaN Invalid_operation
dqand810 and -1     Inf   -> NaN Invalid_operation
dqand811 and -0     Inf   -> NaN Invalid_operation
dqand812 and  0     Inf   -> NaN Invalid_operation
dqand813 and  1     Inf   -> NaN Invalid_operation
dqand814 and  1000  Inf   -> NaN Invalid_operation
dqand815 and  Inf   Inf   -> NaN Invalid_operation

dqand821 and  NaN -Inf    -> NaN Invalid_operation
dqand822 and  NaN -1000   -> NaN Invalid_operation
dqand823 and  NaN -1      -> NaN Invalid_operation
dqand824 and  NaN -0      -> NaN Invalid_operation
dqand825 and  NaN  0      -> NaN Invalid_operation
dqand826 and  NaN  1      -> NaN Invalid_operation
dqand827 and  NaN  1000   -> NaN Invalid_operation
dqand828 and  NaN  Inf    -> NaN Invalid_operation
dqand829 and  NaN  NaN    -> NaN Invalid_operation
dqand830 and -Inf  NaN    -> NaN Invalid_operation
dqand831 and -1000 NaN    -> NaN Invalid_operation
dqand832 and -1    NaN    -> NaN Invalid_operation
dqand833 and -0    NaN    -> NaN Invalid_operation
dqand834 and  0    NaN    -> NaN Invalid_operation
dqand835 and  1    NaN    -> NaN Invalid_operation
dqand836 and  1000 NaN    -> NaN Invalid_operation
dqand837 and  Inf  NaN    -> NaN Invalid_operation

dqand841 and  sNaN -Inf   ->  NaN  Invalid_operation
dqand842 and  sNaN -1000  ->  NaN  Invalid_operation
dqand843 and  sNaN -1     ->  NaN  Invalid_operation
dqand844 and  sNaN -0     ->  NaN  Invalid_operation
dqand845 and  sNaN  0     ->  NaN  Invalid_operation
dqand846 and  sNaN  1     ->  NaN  Invalid_operation
dqand847 and  sNaN  1000  ->  NaN  Invalid_operation
dqand848 and  sNaN  NaN   ->  NaN  Invalid_operation
dqand849 and  sNaN sNaN   ->  NaN  Invalid_operation
dqand850 and  NaN  sNaN   ->  NaN  Invalid_operation
dqand851 and -Inf  sNaN   ->  NaN  Invalid_operation
dqand852 and -1000 sNaN   ->  NaN  Invalid_operation
dqand853 and -1    sNaN   ->  NaN  Invalid_operation
dqand854 and -0    sNaN   ->  NaN  Invalid_operation
dqand855 and  0    sNaN   ->  NaN  Invalid_operation
dqand856 and  1    sNaN   ->  NaN  Invalid_operation
dqand857 and  1000 sNaN   ->  NaN  Invalid_operation
dqand858 and  Inf  sNaN   ->  NaN  Invalid_operation
dqand859 and  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqand861 and  NaN1   -Inf    -> NaN Invalid_operation
dqand862 and +NaN2   -1000   -> NaN Invalid_operation
dqand863 and  NaN3    1000   -> NaN Invalid_operation
dqand864 and  NaN4    Inf    -> NaN Invalid_operation
dqand865 and  NaN5   +NaN6   -> NaN Invalid_operation
dqand866 and -Inf     NaN7   -> NaN Invalid_operation
dqand867 and -1000    NaN8   -> NaN Invalid_operation
dqand868 and  1000    NaN9   -> NaN Invalid_operation
dqand869 and  Inf    +NaN10  -> NaN Invalid_operation
dqand871 and  sNaN11  -Inf   -> NaN Invalid_operation
dqand872 and  sNaN12  -1000  -> NaN Invalid_operation
dqand873 and  sNaN13   1000  -> NaN Invalid_operation
dqand874 and  sNaN14   NaN17 -> NaN Invalid_operation
dqand875 and  sNaN15  sNaN18 -> NaN Invalid_operation
dqand876 and  NaN16   sNaN19 -> NaN Invalid_operation
dqand877 and -Inf    +sNaN20 -> NaN Invalid_operation
dqand878 and -1000    sNaN21 -> NaN Invalid_operation
dqand879 and  1000    sNaN22 -> NaN Invalid_operation
dqand880 and  Inf     sNaN23 -> NaN Invalid_operation
dqand881 and +NaN25  +sNaN24 -> NaN Invalid_operation
dqand882 and -NaN26    NaN28 -> NaN Invalid_operation
dqand883 and -sNaN27  sNaN29 -> NaN Invalid_operation
dqand884 and  1000    -NaN30 -> NaN Invalid_operation
dqand885 and  1000   -sNaN31 -> NaN Invalid_operation

Added test/dectest/dqBase.decTest.



















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
------------------------------------------------------------------------
-- dqBase.decTest -- base decQuad <--> string conversions             --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This file tests base conversions from string to a decimal number
-- and back to a string (in Scientific form)

-- Note that unlike other operations the operand is subject to rounding
-- to conform to emax and precision settings (that is, numbers will
-- conform to rules and exponent will be in permitted range).  The
-- 'left hand side', therefore, may have numbers that cannot be
-- represented in a decQuad.  Some testcases go to the limit of the
-- next-wider format, and hence these testcases may also be used to
-- test narrowing and widening operations.

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

dqbas001 toSci       0 -> 0
dqbas002 toSci       1 -> 1
dqbas003 toSci     1.0 -> 1.0
dqbas004 toSci    1.00 -> 1.00
dqbas005 toSci      10 -> 10
dqbas006 toSci    1000 -> 1000
dqbas007 toSci    10.0 -> 10.0
dqbas008 toSci    10.1 -> 10.1
dqbas009 toSci    10.4 -> 10.4
dqbas010 toSci    10.5 -> 10.5
dqbas011 toSci    10.6 -> 10.6
dqbas012 toSci    10.9 -> 10.9
dqbas013 toSci    11.0 -> 11.0
dqbas014 toSci  1.234 -> 1.234
dqbas015 toSci  0.123 -> 0.123
dqbas016 toSci  0.012 -> 0.012
dqbas017 toSci  -0    -> -0
dqbas018 toSci  -0.0  -> -0.0
dqbas019 toSci -00.00 -> -0.00

dqbas021 toSci     -1 -> -1
dqbas022 toSci   -1.0 -> -1.0
dqbas023 toSci   -0.1 -> -0.1
dqbas024 toSci   -9.1 -> -9.1
dqbas025 toSci   -9.11 -> -9.11
dqbas026 toSci   -9.119 -> -9.119
dqbas027 toSci   -9.999 -> -9.999

dqbas030 toSci  '123456789.123456'   -> '123456789.123456'
dqbas031 toSci  '123456789.000000'   -> '123456789.000000'
dqbas032 toSci   '123456789123456'   -> '123456789123456'
dqbas033 toSci   '0.0000123456789'   -> '0.0000123456789'
dqbas034 toSci  '0.00000123456789'   -> '0.00000123456789'
dqbas035 toSci '0.000000123456789'   -> '1.23456789E-7'
dqbas036 toSci '0.0000000123456789'  -> '1.23456789E-8'

dqbas037 toSci '0.123456789012344'   -> '0.123456789012344'
dqbas038 toSci '0.123456789012345'   -> '0.123456789012345'

-- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
dqbsn001 toSci -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
dqbsn002 toSci -1E-6143 -> -1E-6143
dqbsn003 toSci -1E-6176 -> -1E-6176 Subnormal
dqbsn004 toSci -0 -> -0
dqbsn005 toSci +0 ->  0
dqbsn006 toSci +1E-6176 ->  1E-6176 Subnormal
dqbsn007 toSci +1E-6143 ->  1E-6143
dqbsn008 toSci +9.999999999999999999999999999999999E+6144 ->  9.999999999999999999999999999999999E+6144

-- String [many more examples are implicitly tested elsewhere]
-- strings without E cannot generate E in result
dqbas040 toSci "12"        -> '12'
dqbas041 toSci "-76"       -> '-76'
dqbas042 toSci "12.76"     -> '12.76'
dqbas043 toSci "+12.76"    -> '12.76'
dqbas044 toSci "012.76"    -> '12.76'
dqbas045 toSci "+0.003"    -> '0.003'
dqbas046 toSci "17."       -> '17'
dqbas047 toSci ".5"        -> '0.5'
dqbas048 toSci "044"       -> '44'
dqbas049 toSci "0044"      -> '44'
dqbas050 toSci "0.0005"      -> '0.0005'
dqbas051 toSci "00.00005"    -> '0.00005'
dqbas052 toSci "0.000005"    -> '0.000005'
dqbas053 toSci "0.0000050"   -> '0.0000050'
dqbas054 toSci "0.0000005"   -> '5E-7'
dqbas055 toSci "0.00000005"  -> '5E-8'
dqbas056 toSci "12345678.543210" -> '12345678.543210'
dqbas057 toSci "2345678.543210" -> '2345678.543210'
dqbas058 toSci "345678.543210" -> '345678.543210'
dqbas059 toSci "0345678.54321" -> '345678.54321'
dqbas060 toSci "345678.5432" -> '345678.5432'
dqbas061 toSci "+345678.5432" -> '345678.5432'
dqbas062 toSci "+0345678.5432" -> '345678.5432'
dqbas063 toSci "+00345678.5432" -> '345678.5432'
dqbas064 toSci "-345678.5432"  -> '-345678.5432'
dqbas065 toSci "-0345678.5432"  -> '-345678.5432'
dqbas066 toSci "-00345678.5432"  -> '-345678.5432'
-- examples
dqbas067 toSci "5E-6"        -> '0.000005'
dqbas068 toSci "50E-7"       -> '0.0000050'
dqbas069 toSci "5E-7"        -> '5E-7'

-- [No exotics as no Unicode]

-- rounded with dots in all (including edge) places
dqbas071 toSci  .1234567891234567890123456780123456123  -> 0.1234567891234567890123456780123456 Inexact Rounded
dqbas072 toSci  1.234567891234567890123456780123456123  ->  1.234567891234567890123456780123456 Inexact Rounded
dqbas073 toSci  12.34567891234567890123456780123456123  ->  12.34567891234567890123456780123456 Inexact Rounded
dqbas074 toSci  123.4567891234567890123456780123456123  ->  123.4567891234567890123456780123456 Inexact Rounded
dqbas075 toSci  1234.567891234567890123456780123456123  ->  1234.567891234567890123456780123456 Inexact Rounded
dqbas076 toSci  12345.67891234567890123456780123456123  ->  12345.67891234567890123456780123456 Inexact Rounded
dqbas077 toSci  123456.7891234567890123456780123456123  ->  123456.7891234567890123456780123456 Inexact Rounded
dqbas078 toSci  1234567.891234567890123456780123456123  ->  1234567.891234567890123456780123456 Inexact Rounded
dqbas079 toSci  12345678.91234567890123456780123456123  ->  12345678.91234567890123456780123456 Inexact Rounded
dqbas080 toSci  123456789.1234567890123456780123456123  ->  123456789.1234567890123456780123456 Inexact Rounded
dqbas081 toSci  1234567891.234567890123456780123456123  ->  1234567891.234567890123456780123456 Inexact Rounded
dqbas082 toSci  12345678912.34567890123456780123456123  ->  12345678912.34567890123456780123456 Inexact Rounded
dqbas083 toSci  123456789123.4567890123456780123456123  ->  123456789123.4567890123456780123456 Inexact Rounded
dqbas084 toSci  1234567891234.567890123456780123456123  ->  1234567891234.567890123456780123456 Inexact Rounded
dqbas085 toSci  12345678912345.67890123456780123456123  ->  12345678912345.67890123456780123456 Inexact Rounded
dqbas086 toSci  123456789123456.7890123456780123456123  ->  123456789123456.7890123456780123456 Inexact Rounded
dqbas087 toSci  1234567891234567.890123456780123456123  ->  1234567891234567.890123456780123456 Inexact Rounded
dqbas088 toSci  12345678912345678.90123456780123456123  ->  12345678912345678.90123456780123456 Inexact Rounded
dqbas089 toSci  123456789123456789.0123456780123456123  ->  123456789123456789.0123456780123456 Inexact Rounded
dqbas090 toSci  1234567891234567890.123456780123456123  ->  1234567891234567890.123456780123456 Inexact Rounded
dqbas091 toSci  12345678912345678901.23456780123456123  ->  12345678912345678901.23456780123456 Inexact Rounded
dqbas092 toSci  123456789123456789012.3456780123456123  ->  123456789123456789012.3456780123456 Inexact Rounded
dqbas093 toSci  1234567891234567890123.456780123456123  ->  1234567891234567890123.456780123456 Inexact Rounded
dqbas094 toSci  12345678912345678901234.56780123456123  ->  12345678912345678901234.56780123456 Inexact Rounded
dqbas095 toSci  123456789123456789012345.6780123456123  ->  123456789123456789012345.6780123456 Inexact Rounded
dqbas096 toSci  1234567891234567890123456.780123456123  ->  1234567891234567890123456.780123456 Inexact Rounded
dqbas097 toSci  12345678912345678901234567.80123456123  ->  12345678912345678901234567.80123456 Inexact Rounded
dqbas098 toSci  123456789123456789012345678.0123456123  ->  123456789123456789012345678.0123456 Inexact Rounded
dqbas099 toSci  1234567891234567890123456780.123456123  ->  1234567891234567890123456780.123456 Inexact Rounded
dqbas100 toSci  12345678912345678901234567801.23456123  ->  12345678912345678901234567801.23456 Inexact Rounded
dqbas101 toSci  123456789123456789012345678012.3456123  ->  123456789123456789012345678012.3456 Inexact Rounded
dqbas102 toSci  1234567891234567890123456780123.456123  ->  1234567891234567890123456780123.456 Inexact Rounded
dqbas103 toSci  12345678912345678901234567801234.56123  ->  12345678912345678901234567801234.56 Inexact Rounded
dqbas104 toSci  123456789123456789012345678012345.6123  ->  123456789123456789012345678012345.6 Inexact Rounded
dqbas105 toSci  1234567891234567890123456780123456.123  ->  1234567891234567890123456780123456  Inexact Rounded
dqbas106 toSci  12345678912345678901234567801234561.23  ->  1.234567891234567890123456780123456E+34 Inexact Rounded
dqbas107 toSci  123456789123456789012345678012345612.3  ->  1.234567891234567890123456780123456E+35 Inexact Rounded
dqbas108 toSci  1234567891234567890123456780123456123.  ->  1.234567891234567890123456780123456E+36 Inexact Rounded
-- 123456789012345678

-- Numbers with E
dqbas130 toSci "0.000E-1"  -> '0.0000'
dqbas131 toSci "0.000E-2"  -> '0.00000'
dqbas132 toSci "0.000E-3"  -> '0.000000'
dqbas133 toSci "0.000E-4"  -> '0E-7'
dqbas134 toSci "0.00E-2"   -> '0.0000'
dqbas135 toSci "0.00E-3"   -> '0.00000'
dqbas136 toSci "0.00E-4"   -> '0.000000'
dqbas137 toSci "0.00E-5"   -> '0E-7'
dqbas138 toSci "+0E+9"     -> '0E+9'
dqbas139 toSci "-0E+9"     -> '-0E+9'
dqbas140 toSci "1E+9"      -> '1E+9'
dqbas141 toSci "1e+09"     -> '1E+9'
dqbas142 toSci "1E+90"     -> '1E+90'
dqbas143 toSci "+1E+009"   -> '1E+9'
dqbas144 toSci "0E+9"      -> '0E+9'
dqbas145 toSci "1E+9"      -> '1E+9'
dqbas146 toSci "1E+09"     -> '1E+9'
dqbas147 toSci "1e+90"     -> '1E+90'
dqbas148 toSci "1E+009"    -> '1E+9'
dqbas149 toSci "000E+9"    -> '0E+9'
dqbas150 toSci "1E9"       -> '1E+9'
dqbas151 toSci "1e09"      -> '1E+9'
dqbas152 toSci "1E90"      -> '1E+90'
dqbas153 toSci "1E009"     -> '1E+9'
dqbas154 toSci "0E9"       -> '0E+9'
dqbas155 toSci "0.000e+0"  -> '0.000'
dqbas156 toSci "0.000E-1"  -> '0.0000'
dqbas157 toSci "4E+9"      -> '4E+9'
dqbas158 toSci "44E+9"     -> '4.4E+10'
dqbas159 toSci "0.73e-7"   -> '7.3E-8'
dqbas160 toSci "00E+9"     -> '0E+9'
dqbas161 toSci "00E-9"     -> '0E-9'
dqbas162 toSci "10E+9"     -> '1.0E+10'
dqbas163 toSci "10E+09"    -> '1.0E+10'
dqbas164 toSci "10e+90"    -> '1.0E+91'
dqbas165 toSci "10E+009"   -> '1.0E+10'
dqbas166 toSci "100e+9"    -> '1.00E+11'
dqbas167 toSci "100e+09"   -> '1.00E+11'
dqbas168 toSci "100E+90"   -> '1.00E+92'
dqbas169 toSci "100e+009"  -> '1.00E+11'

dqbas170 toSci "1.265"     -> '1.265'
dqbas171 toSci "1.265E-20" -> '1.265E-20'
dqbas172 toSci "1.265E-8"  -> '1.265E-8'
dqbas173 toSci "1.265E-4"  -> '0.0001265'
dqbas174 toSci "1.265E-3"  -> '0.001265'
dqbas175 toSci "1.265E-2"  -> '0.01265'
dqbas176 toSci "1.265E-1"  -> '0.1265'
dqbas177 toSci "1.265E-0"  -> '1.265'
dqbas178 toSci "1.265E+1"  -> '12.65'
dqbas179 toSci "1.265E+2"  -> '126.5'
dqbas180 toSci "1.265E+3"  -> '1265'
dqbas181 toSci "1.265E+4"  -> '1.265E+4'
dqbas182 toSci "1.265E+8"  -> '1.265E+8'
dqbas183 toSci "1.265E+20" -> '1.265E+20'

dqbas190 toSci "12.65"     -> '12.65'
dqbas191 toSci "12.65E-20" -> '1.265E-19'
dqbas192 toSci "12.65E-8"  -> '1.265E-7'
dqbas193 toSci "12.65E-4"  -> '0.001265'
dqbas194 toSci "12.65E-3"  -> '0.01265'
dqbas195 toSci "12.65E-2"  -> '0.1265'
dqbas196 toSci "12.65E-1"  -> '1.265'
dqbas197 toSci "12.65E-0"  -> '12.65'
dqbas198 toSci "12.65E+1"  -> '126.5'
dqbas199 toSci "12.65E+2"  -> '1265'
dqbas200 toSci "12.65E+3"  -> '1.265E+4'
dqbas201 toSci "12.65E+4"  -> '1.265E+5'
dqbas202 toSci "12.65E+8"  -> '1.265E+9'
dqbas203 toSci "12.65E+20" -> '1.265E+21'

dqbas210 toSci "126.5"     -> '126.5'
dqbas211 toSci "126.5E-20" -> '1.265E-18'
dqbas212 toSci "126.5E-8"  -> '0.000001265'
dqbas213 toSci "126.5E-4"  -> '0.01265'
dqbas214 toSci "126.5E-3"  -> '0.1265'
dqbas215 toSci "126.5E-2"  -> '1.265'
dqbas216 toSci "126.5E-1"  -> '12.65'
dqbas217 toSci "126.5E-0"  -> '126.5'
dqbas218 toSci "126.5E+1"  -> '1265'
dqbas219 toSci "126.5E+2"  -> '1.265E+4'
dqbas220 toSci "126.5E+3"  -> '1.265E+5'
dqbas221 toSci "126.5E+4"  -> '1.265E+6'
dqbas222 toSci "126.5E+8"  -> '1.265E+10'
dqbas223 toSci "126.5E+20" -> '1.265E+22'

dqbas230 toSci "1265"     -> '1265'
dqbas231 toSci "1265E-20" -> '1.265E-17'
dqbas232 toSci "1265E-8"  -> '0.00001265'
dqbas233 toSci "1265E-4"  -> '0.1265'
dqbas234 toSci "1265E-3"  -> '1.265'
dqbas235 toSci "1265E-2"  -> '12.65'
dqbas236 toSci "1265E-1"  -> '126.5'
dqbas237 toSci "1265E-0"  -> '1265'
dqbas238 toSci "1265E+1"  -> '1.265E+4'
dqbas239 toSci "1265E+2"  -> '1.265E+5'
dqbas240 toSci "1265E+3"  -> '1.265E+6'
dqbas241 toSci "1265E+4"  -> '1.265E+7'
dqbas242 toSci "1265E+8"  -> '1.265E+11'
dqbas243 toSci "1265E+20" -> '1.265E+23'

dqbas250 toSci "0.1265"     -> '0.1265'
dqbas251 toSci "0.1265E-20" -> '1.265E-21'
dqbas252 toSci "0.1265E-8"  -> '1.265E-9'
dqbas253 toSci "0.1265E-4"  -> '0.00001265'
dqbas254 toSci "0.1265E-3"  -> '0.0001265'
dqbas255 toSci "0.1265E-2"  -> '0.001265'
dqbas256 toSci "0.1265E-1"  -> '0.01265'
dqbas257 toSci "0.1265E-0"  -> '0.1265'
dqbas258 toSci "0.1265E+1"  -> '1.265'
dqbas259 toSci "0.1265E+2"  -> '12.65'
dqbas260 toSci "0.1265E+3"  -> '126.5'
dqbas261 toSci "0.1265E+4"  -> '1265'
dqbas262 toSci "0.1265E+8"  -> '1.265E+7'
dqbas263 toSci "0.1265E+20" -> '1.265E+19'

-- some more negative zeros [systematic tests below]
dqbas290 toSci "-0.000E-1"  -> '-0.0000'
dqbas291 toSci "-0.000E-2"  -> '-0.00000'
dqbas292 toSci "-0.000E-3"  -> '-0.000000'
dqbas293 toSci "-0.000E-4"  -> '-0E-7'
dqbas294 toSci "-0.00E-2"   -> '-0.0000'
dqbas295 toSci "-0.00E-3"   -> '-0.00000'
dqbas296 toSci "-0.0E-2"    -> '-0.000'
dqbas297 toSci "-0.0E-3"    -> '-0.0000'
dqbas298 toSci "-0E-2"      -> '-0.00'
dqbas299 toSci "-0E-3"      -> '-0.000'

-- Engineering notation tests
dqbas301  toSci 10e12  -> 1.0E+13
dqbas302  toEng 10e12  -> 10E+12
dqbas303  toSci 10e11  -> 1.0E+12
dqbas304  toEng 10e11  -> 1.0E+12
dqbas305  toSci 10e10  -> 1.0E+11
dqbas306  toEng 10e10  -> 100E+9
dqbas307  toSci 10e9   -> 1.0E+10
dqbas308  toEng 10e9   -> 10E+9
dqbas309  toSci 10e8   -> 1.0E+9
dqbas310  toEng 10e8   -> 1.0E+9
dqbas311  toSci 10e7   -> 1.0E+8
dqbas312  toEng 10e7   -> 100E+6
dqbas313  toSci 10e6   -> 1.0E+7
dqbas314  toEng 10e6   -> 10E+6
dqbas315  toSci 10e5   -> 1.0E+6
dqbas316  toEng 10e5   -> 1.0E+6
dqbas317  toSci 10e4   -> 1.0E+5
dqbas318  toEng 10e4   -> 100E+3
dqbas319  toSci 10e3   -> 1.0E+4
dqbas320  toEng 10e3   -> 10E+3
dqbas321  toSci 10e2   -> 1.0E+3
dqbas322  toEng 10e2   -> 1.0E+3
dqbas323  toSci 10e1   -> 1.0E+2
dqbas324  toEng 10e1   -> 100
dqbas325  toSci 10e0   -> 10
dqbas326  toEng 10e0   -> 10
dqbas327  toSci 10e-1  -> 1.0
dqbas328  toEng 10e-1  -> 1.0
dqbas329  toSci 10e-2  -> 0.10
dqbas330  toEng 10e-2  -> 0.10
dqbas331  toSci 10e-3  -> 0.010
dqbas332  toEng 10e-3  -> 0.010
dqbas333  toSci 10e-4  -> 0.0010
dqbas334  toEng 10e-4  -> 0.0010
dqbas335  toSci 10e-5  -> 0.00010
dqbas336  toEng 10e-5  -> 0.00010
dqbas337  toSci 10e-6  -> 0.000010
dqbas338  toEng 10e-6  -> 0.000010
dqbas339  toSci 10e-7  -> 0.0000010
dqbas340  toEng 10e-7  -> 0.0000010
dqbas341  toSci 10e-8  -> 1.0E-7
dqbas342  toEng 10e-8  -> 100E-9
dqbas343  toSci 10e-9  -> 1.0E-8
dqbas344  toEng 10e-9  -> 10E-9
dqbas345  toSci 10e-10 -> 1.0E-9
dqbas346  toEng 10e-10 -> 1.0E-9
dqbas347  toSci 10e-11 -> 1.0E-10
dqbas348  toEng 10e-11 -> 100E-12
dqbas349  toSci 10e-12 -> 1.0E-11
dqbas350  toEng 10e-12 -> 10E-12
dqbas351  toSci 10e-13 -> 1.0E-12
dqbas352  toEng 10e-13 -> 1.0E-12

dqbas361  toSci 7E12  -> 7E+12
dqbas362  toEng 7E12  -> 7E+12
dqbas363  toSci 7E11  -> 7E+11
dqbas364  toEng 7E11  -> 700E+9
dqbas365  toSci 7E10  -> 7E+10
dqbas366  toEng 7E10  -> 70E+9
dqbas367  toSci 7E9   -> 7E+9
dqbas368  toEng 7E9   -> 7E+9
dqbas369  toSci 7E8   -> 7E+8
dqbas370  toEng 7E8   -> 700E+6
dqbas371  toSci 7E7   -> 7E+7
dqbas372  toEng 7E7   -> 70E+6
dqbas373  toSci 7E6   -> 7E+6
dqbas374  toEng 7E6   -> 7E+6
dqbas375  toSci 7E5   -> 7E+5
dqbas376  toEng 7E5   -> 700E+3
dqbas377  toSci 7E4   -> 7E+4
dqbas378  toEng 7E4   -> 70E+3
dqbas379  toSci 7E3   -> 7E+3
dqbas380  toEng 7E3   -> 7E+3
dqbas381  toSci 7E2   -> 7E+2
dqbas382  toEng 7E2   -> 700
dqbas383  toSci 7E1   -> 7E+1
dqbas384  toEng 7E1   -> 70
dqbas385  toSci 7E0   -> 7
dqbas386  toEng 7E0   -> 7
dqbas387  toSci 7E-1  -> 0.7
dqbas388  toEng 7E-1  -> 0.7
dqbas389  toSci 7E-2  -> 0.07
dqbas390  toEng 7E-2  -> 0.07
dqbas391  toSci 7E-3  -> 0.007
dqbas392  toEng 7E-3  -> 0.007
dqbas393  toSci 7E-4  -> 0.0007
dqbas394  toEng 7E-4  -> 0.0007
dqbas395  toSci 7E-5  -> 0.00007
dqbas396  toEng 7E-5  -> 0.00007
dqbas397  toSci 7E-6  -> 0.000007
dqbas398  toEng 7E-6  -> 0.000007
dqbas399  toSci 7E-7  -> 7E-7
dqbas400  toEng 7E-7  -> 700E-9
dqbas401  toSci 7E-8  -> 7E-8
dqbas402  toEng 7E-8  -> 70E-9
dqbas403  toSci 7E-9  -> 7E-9
dqbas404  toEng 7E-9  -> 7E-9
dqbas405  toSci 7E-10 -> 7E-10
dqbas406  toEng 7E-10 -> 700E-12
dqbas407  toSci 7E-11 -> 7E-11
dqbas408  toEng 7E-11 -> 70E-12
dqbas409  toSci 7E-12 -> 7E-12
dqbas410  toEng 7E-12 -> 7E-12
dqbas411  toSci 7E-13 -> 7E-13
dqbas412  toEng 7E-13 -> 700E-15

-- Exacts remain exact up to precision ..
dqbas420  toSci    100 -> 100
dqbas422  toSci   1000 -> 1000
dqbas424  toSci  999.9 ->  999.9
dqbas426  toSci 1000.0 -> 1000.0
dqbas428  toSci 1000.1 -> 1000.1
dqbas430  toSci 10000 -> 10000
dqbas432  toSci 1000000000000000000000000000000        -> 1000000000000000000000000000000
dqbas434  toSci 10000000000000000000000000000000       -> 10000000000000000000000000000000
dqbas436  toSci 100000000000000000000000000000000      -> 100000000000000000000000000000000
dqbas438  toSci 1000000000000000000000000000000000     -> 1000000000000000000000000000000000
dqbas440  toSci 10000000000000000000000000000000000    -> 1.000000000000000000000000000000000E+34   Rounded
dqbas442  toSci 10000000000000000000000000000000000    -> 1.000000000000000000000000000000000E+34   Rounded
dqbas444  toSci 10000000000000000000000000000000003    -> 1.000000000000000000000000000000000E+34   Rounded Inexact
dqbas446  toSci 10000000000000000000000000000000005    -> 1.000000000000000000000000000000000E+34   Rounded Inexact
dqbas448  toSci 100000000000000000000000000000000050   -> 1.000000000000000000000000000000000E+35   Rounded Inexact
dqbas450  toSci 10000000000000000000000000000000009    -> 1.000000000000000000000000000000001E+34   Rounded Inexact
dqbas452  toSci 100000000000000000000000000000000000   -> 1.000000000000000000000000000000000E+35   Rounded
dqbas454  toSci 100000000000000000000000000000000003   -> 1.000000000000000000000000000000000E+35   Rounded Inexact
dqbas456  toSci 100000000000000000000000000000000005   -> 1.000000000000000000000000000000000E+35   Rounded Inexact
dqbas458  toSci 100000000000000000000000000000000009   -> 1.000000000000000000000000000000000E+35   Rounded Inexact
dqbas460  toSci 1000000000000000000000000000000000000  -> 1.000000000000000000000000000000000E+36   Rounded
dqbas462  toSci 1000000000000000000000000000000000300  -> 1.000000000000000000000000000000000E+36   Rounded Inexact
dqbas464  toSci 1000000000000000000000000000000000500  -> 1.000000000000000000000000000000000E+36   Rounded Inexact
dqbas466  toSci 1000000000000000000000000000000000900  -> 1.000000000000000000000000000000001E+36   Rounded Inexact
dqbas468  toSci 10000000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+37   Rounded
dqbas470  toSci 10000000000000000000000000000000003000 -> 1.000000000000000000000000000000000E+37   Rounded Inexact
dqbas472  toSci 10000000000000000000000000000000005000 -> 1.000000000000000000000000000000000E+37   Rounded Inexact
dqbas474  toSci 10000000000000000000000000000000009000 -> 1.000000000000000000000000000000001E+37   Rounded Inexact

-- check rounding modes heeded
rounding:  ceiling
dqbsr401  toSci  1.1111111111111111111111111111123450    ->  1.111111111111111111111111111112345  Rounded
dqbsr402  toSci  1.11111111111111111111111111111234549   ->  1.111111111111111111111111111112346  Rounded Inexact
dqbsr403  toSci  1.11111111111111111111111111111234550   ->  1.111111111111111111111111111112346  Rounded Inexact
dqbsr404  toSci  1.11111111111111111111111111111234551   ->  1.111111111111111111111111111112346  Rounded Inexact
rounding:  up
dqbsr405  toSci  1.1111111111111111111111111111123450    ->  1.111111111111111111111111111112345  Rounded
dqbsr406  toSci  1.11111111111111111111111111111234549   ->  1.111111111111111111111111111112346  Rounded Inexact
dqbsr407  toSci  1.11111111111111111111111111111234550   ->  1.111111111111111111111111111112346  Rounded Inexact
dqbsr408  toSci  1.11111111111111111111111111111234551   ->  1.111111111111111111111111111112346  Rounded Inexact
rounding:  floor
dqbsr410  toSci  1.1111111111111111111111111111123450    ->  1.111111111111111111111111111112345  Rounded
dqbsr411  toSci  1.11111111111111111111111111111234549   ->  1.111111111111111111111111111112345  Rounded Inexact
dqbsr412  toSci  1.11111111111111111111111111111234550   ->  1.111111111111111111111111111112345  Rounded Inexact
dqbsr413  toSci  1.11111111111111111111111111111234551   ->  1.111111111111111111111111111112345  Rounded Inexact
rounding:  half_down
dqbsr415  toSci  1.1111111111111111111111111111123450    ->  1.111111111111111111111111111112345  Rounded
dqbsr416  toSci  1.11111111111111111111111111111234549   ->  1.111111111111111111111111111112345  Rounded Inexact
dqbsr417  toSci  1.11111111111111111111111111111234550   ->  1.111111111111111111111111111112345  Rounded Inexact
dqbsr418  toSci  1.11111111111111111111111111111234650   ->  1.111111111111111111111111111112346  Rounded Inexact
dqbsr419  toSci  1.11111111111111111111111111111234551   ->  1.111111111111111111111111111112346  Rounded Inexact
rounding:  half_even
dqbsr421  toSci  1.1111111111111111111111111111123450    ->  1.111111111111111111111111111112345  Rounded
dqbsr422  toSci  1.11111111111111111111111111111234549   ->  1.111111111111111111111111111112345  Rounded Inexact
dqbsr423  toSci  1.11111111111111111111111111111234550   ->  1.111111111111111111111111111112346  Rounded Inexact
dqbsr424  toSci  1.11111111111111111111111111111234650   ->  1.111111111111111111111111111112346  Rounded Inexact
dqbsr425  toSci  1.11111111111111111111111111111234551   ->  1.111111111111111111111111111112346  Rounded Inexact
rounding:  down
dqbsr426  toSci  1.1111111111111111111111111111123450    ->  1.111111111111111111111111111112345  Rounded
dqbsr427  toSci  1.11111111111111111111111111111234549   ->  1.111111111111111111111111111112345  Rounded Inexact
dqbsr428  toSci  1.11111111111111111111111111111234550   ->  1.111111111111111111111111111112345  Rounded Inexact
dqbsr429  toSci  1.11111111111111111111111111111234551   ->  1.111111111111111111111111111112345  Rounded Inexact
rounding:  half_up
dqbsr431  toSci  1.1111111111111111111111111111123450    ->  1.111111111111111111111111111112345  Rounded
dqbsr432  toSci  1.11111111111111111111111111111234549   ->  1.111111111111111111111111111112345  Rounded Inexact
dqbsr433  toSci  1.11111111111111111111111111111234550   ->  1.111111111111111111111111111112346  Rounded Inexact
dqbsr434  toSci  1.11111111111111111111111111111234650   ->  1.111111111111111111111111111112347  Rounded Inexact
dqbsr435  toSci  1.11111111111111111111111111111234551   ->  1.111111111111111111111111111112346  Rounded Inexact
-- negatives
rounding:  ceiling
dqbsr501  toSci -1.1111111111111111111111111111123450    -> -1.111111111111111111111111111112345  Rounded
dqbsr502  toSci -1.11111111111111111111111111111234549   -> -1.111111111111111111111111111112345  Rounded Inexact
dqbsr503  toSci -1.11111111111111111111111111111234550   -> -1.111111111111111111111111111112345  Rounded Inexact
dqbsr504  toSci -1.11111111111111111111111111111234551   -> -1.111111111111111111111111111112345  Rounded Inexact
rounding:  up
dqbsr505  toSci -1.1111111111111111111111111111123450    -> -1.111111111111111111111111111112345  Rounded
dqbsr506  toSci -1.11111111111111111111111111111234549   -> -1.111111111111111111111111111112346  Rounded Inexact
dqbsr507  toSci -1.11111111111111111111111111111234550   -> -1.111111111111111111111111111112346  Rounded Inexact
dqbsr508  toSci -1.11111111111111111111111111111234551   -> -1.111111111111111111111111111112346  Rounded Inexact
rounding:  floor
dqbsr510  toSci -1.1111111111111111111111111111123450    -> -1.111111111111111111111111111112345  Rounded
dqbsr511  toSci -1.11111111111111111111111111111234549   -> -1.111111111111111111111111111112346  Rounded Inexact
dqbsr512  toSci -1.11111111111111111111111111111234550   -> -1.111111111111111111111111111112346  Rounded Inexact
dqbsr513  toSci -1.11111111111111111111111111111234551   -> -1.111111111111111111111111111112346  Rounded Inexact
rounding:  half_down
dqbsr515  toSci -1.1111111111111111111111111111123450    -> -1.111111111111111111111111111112345  Rounded
dqbsr516  toSci -1.11111111111111111111111111111234549   -> -1.111111111111111111111111111112345  Rounded Inexact
dqbsr517  toSci -1.11111111111111111111111111111234550   -> -1.111111111111111111111111111112345  Rounded Inexact
dqbsr518  toSci -1.11111111111111111111111111111234650   -> -1.111111111111111111111111111112346  Rounded Inexact
dqbsr519  toSci -1.11111111111111111111111111111234551   -> -1.111111111111111111111111111112346  Rounded Inexact
rounding:  half_even
dqbsr521  toSci -1.1111111111111111111111111111123450    -> -1.111111111111111111111111111112345  Rounded
dqbsr522  toSci -1.11111111111111111111111111111234549   -> -1.111111111111111111111111111112345  Rounded Inexact
dqbsr523  toSci -1.11111111111111111111111111111234550   -> -1.111111111111111111111111111112346  Rounded Inexact
dqbsr524  toSci -1.11111111111111111111111111111234650   -> -1.111111111111111111111111111112346  Rounded Inexact
dqbsr525  toSci -1.11111111111111111111111111111234551   -> -1.111111111111111111111111111112346  Rounded Inexact
rounding:  down
dqbsr526  toSci -1.1111111111111111111111111111123450    -> -1.111111111111111111111111111112345  Rounded
dqbsr527  toSci -1.11111111111111111111111111111234549   -> -1.111111111111111111111111111112345  Rounded Inexact
dqbsr528  toSci -1.11111111111111111111111111111234550   -> -1.111111111111111111111111111112345  Rounded Inexact
dqbsr529  toSci -1.11111111111111111111111111111234551   -> -1.111111111111111111111111111112345  Rounded Inexact
rounding:  half_up
dqbsr531  toSci -1.1111111111111111111111111111123450    -> -1.111111111111111111111111111112345  Rounded
dqbsr532  toSci -1.11111111111111111111111111111234549   -> -1.111111111111111111111111111112345  Rounded Inexact
dqbsr533  toSci -1.11111111111111111111111111111234550   -> -1.111111111111111111111111111112346  Rounded Inexact
dqbsr534  toSci -1.11111111111111111111111111111234650   -> -1.111111111111111111111111111112347  Rounded Inexact
dqbsr535  toSci -1.11111111111111111111111111111234551   -> -1.111111111111111111111111111112346  Rounded Inexact

rounding:    half_even

-- The 'baddies' tests from DiagBigDecimal, plus some new ones
dqbas500 toSci '1..2'            -> NaN Conversion_syntax
dqbas501 toSci '.'               -> NaN Conversion_syntax
dqbas502 toSci '..'              -> NaN Conversion_syntax
dqbas503 toSci '++1'             -> NaN Conversion_syntax
dqbas504 toSci '--1'             -> NaN Conversion_syntax
dqbas505 toSci '-+1'             -> NaN Conversion_syntax
dqbas506 toSci '+-1'             -> NaN Conversion_syntax
dqbas507 toSci '12e'             -> NaN Conversion_syntax
dqbas508 toSci '12e++'           -> NaN Conversion_syntax
dqbas509 toSci '12f4'            -> NaN Conversion_syntax
dqbas510 toSci ' +1'             -> NaN Conversion_syntax
dqbas511 toSci '+ 1'             -> NaN Conversion_syntax
dqbas512 toSci '12 '             -> NaN Conversion_syntax
dqbas513 toSci ' + 1'            -> NaN Conversion_syntax
dqbas514 toSci ' - 1 '           -> NaN Conversion_syntax
dqbas515 toSci 'x'               -> NaN Conversion_syntax
dqbas516 toSci '-1-'             -> NaN Conversion_syntax
dqbas517 toSci '12-'             -> NaN Conversion_syntax
dqbas518 toSci '3+'              -> NaN Conversion_syntax
dqbas519 toSci ''                -> NaN Conversion_syntax
dqbas520 toSci '1e-'             -> NaN Conversion_syntax
dqbas521 toSci '7e99999a'        -> NaN Conversion_syntax
dqbas522 toSci '7e123567890x'    -> NaN Conversion_syntax
dqbas523 toSci '7e12356789012x'  -> NaN Conversion_syntax
dqbas524 toSci ''                -> NaN Conversion_syntax
dqbas525 toSci 'e100'            -> NaN Conversion_syntax
dqbas526 toSci '\u0e5a'          -> NaN Conversion_syntax
dqbas527 toSci '\u0b65'          -> NaN Conversion_syntax
dqbas528 toSci '123,65'          -> NaN Conversion_syntax
dqbas529 toSci '1.34.5'          -> NaN Conversion_syntax
dqbas530 toSci '.123.5'          -> NaN Conversion_syntax
dqbas531 toSci '01.35.'          -> NaN Conversion_syntax
dqbas532 toSci '01.35-'          -> NaN Conversion_syntax
dqbas533 toSci '0000..'          -> NaN Conversion_syntax
dqbas534 toSci '.0000.'          -> NaN Conversion_syntax
dqbas535 toSci '00..00'          -> NaN Conversion_syntax
dqbas536 toSci '111e*123'        -> NaN Conversion_syntax
dqbas537 toSci '111e123-'        -> NaN Conversion_syntax
dqbas538 toSci '111e+12+'        -> NaN Conversion_syntax
dqbas539 toSci '111e1-3-'        -> NaN Conversion_syntax
dqbas540 toSci '111e1*23'        -> NaN Conversion_syntax
dqbas541 toSci '111e1e+3'        -> NaN Conversion_syntax
dqbas542 toSci '1e1.0'           -> NaN Conversion_syntax
dqbas543 toSci '1e123e'          -> NaN Conversion_syntax
dqbas544 toSci 'ten'             -> NaN Conversion_syntax
dqbas545 toSci 'ONE'             -> NaN Conversion_syntax
dqbas546 toSci '1e.1'            -> NaN Conversion_syntax
dqbas547 toSci '1e1.'            -> NaN Conversion_syntax
dqbas548 toSci '1ee'             -> NaN Conversion_syntax
dqbas549 toSci 'e+1'             -> NaN Conversion_syntax
dqbas550 toSci '1.23.4'          -> NaN Conversion_syntax
dqbas551 toSci '1.2.1'           -> NaN Conversion_syntax
dqbas552 toSci '1E+1.2'          -> NaN Conversion_syntax
dqbas553 toSci '1E+1.2.3'        -> NaN Conversion_syntax
dqbas554 toSci '1E++1'           -> NaN Conversion_syntax
dqbas555 toSci '1E--1'           -> NaN Conversion_syntax
dqbas556 toSci '1E+-1'           -> NaN Conversion_syntax
dqbas557 toSci '1E-+1'           -> NaN Conversion_syntax
dqbas558 toSci '1E''1'           -> NaN Conversion_syntax
dqbas559 toSci "1E""1"           -> NaN Conversion_syntax
dqbas560 toSci "1E"""""          -> NaN Conversion_syntax
-- Near-specials
dqbas561 toSci "qNaN"            -> NaN Conversion_syntax
dqbas562 toSci "NaNq"            -> NaN Conversion_syntax
dqbas563 toSci "NaNs"            -> NaN Conversion_syntax
dqbas564 toSci "Infi"            -> NaN Conversion_syntax
dqbas565 toSci "Infin"           -> NaN Conversion_syntax
dqbas566 toSci "Infini"          -> NaN Conversion_syntax
dqbas567 toSci "Infinit"         -> NaN Conversion_syntax
dqbas568 toSci "-Infinit"        -> NaN Conversion_syntax
dqbas569 toSci "0Inf"            -> NaN Conversion_syntax
dqbas570 toSci "9Inf"            -> NaN Conversion_syntax
dqbas571 toSci "-0Inf"           -> NaN Conversion_syntax
dqbas572 toSci "-9Inf"           -> NaN Conversion_syntax
dqbas573 toSci "-sNa"            -> NaN Conversion_syntax
dqbas574 toSci "xNaN"            -> NaN Conversion_syntax
dqbas575 toSci "0sNaN"           -> NaN Conversion_syntax

-- some baddies with dots and Es and dots and specials
dqbas576 toSci  'e+1'            ->  NaN Conversion_syntax
dqbas577 toSci  '.e+1'           ->  NaN Conversion_syntax
dqbas578 toSci  '+.e+1'          ->  NaN Conversion_syntax
dqbas579 toSci  '-.e+'           ->  NaN Conversion_syntax
dqbas580 toSci  '-.e'            ->  NaN Conversion_syntax
dqbas581 toSci  'E+1'            ->  NaN Conversion_syntax
dqbas582 toSci  '.E+1'           ->  NaN Conversion_syntax
dqbas583 toSci  '+.E+1'          ->  NaN Conversion_syntax
dqbas584 toSci  '-.E+'           ->  NaN Conversion_syntax
dqbas585 toSci  '-.E'            ->  NaN Conversion_syntax

dqbas586 toSci  '.NaN'           ->  NaN Conversion_syntax
dqbas587 toSci  '-.NaN'          ->  NaN Conversion_syntax
dqbas588 toSci  '+.sNaN'         ->  NaN Conversion_syntax
dqbas589 toSci  '+.Inf'          ->  NaN Conversion_syntax
dqbas590 toSci  '.Infinity'      ->  NaN Conversion_syntax

-- Zeros
dqbas601 toSci 0.000000000       -> 0E-9
dqbas602 toSci 0.00000000        -> 0E-8
dqbas603 toSci 0.0000000         -> 0E-7
dqbas604 toSci 0.000000          -> 0.000000
dqbas605 toSci 0.00000           -> 0.00000
dqbas606 toSci 0.0000            -> 0.0000
dqbas607 toSci 0.000             -> 0.000
dqbas608 toSci 0.00              -> 0.00
dqbas609 toSci 0.0               -> 0.0
dqbas610 toSci  .0               -> 0.0
dqbas611 toSci 0.                -> 0
dqbas612 toSci -.0               -> -0.0
dqbas613 toSci -0.               -> -0
dqbas614 toSci -0.0              -> -0.0
dqbas615 toSci -0.00             -> -0.00
dqbas616 toSci -0.000            -> -0.000
dqbas617 toSci -0.0000           -> -0.0000
dqbas618 toSci -0.00000          -> -0.00000
dqbas619 toSci -0.000000         -> -0.000000
dqbas620 toSci -0.0000000        -> -0E-7
dqbas621 toSci -0.00000000       -> -0E-8
dqbas622 toSci -0.000000000      -> -0E-9

dqbas630 toSci  0.00E+0          -> 0.00
dqbas631 toSci  0.00E+1          -> 0.0
dqbas632 toSci  0.00E+2          -> 0
dqbas633 toSci  0.00E+3          -> 0E+1
dqbas634 toSci  0.00E+4          -> 0E+2
dqbas635 toSci  0.00E+5          -> 0E+3
dqbas636 toSci  0.00E+6          -> 0E+4
dqbas637 toSci  0.00E+7          -> 0E+5
dqbas638 toSci  0.00E+8          -> 0E+6
dqbas639 toSci  0.00E+9          -> 0E+7

dqbas640 toSci  0.0E+0           -> 0.0
dqbas641 toSci  0.0E+1           -> 0
dqbas642 toSci  0.0E+2           -> 0E+1
dqbas643 toSci  0.0E+3           -> 0E+2
dqbas644 toSci  0.0E+4           -> 0E+3
dqbas645 toSci  0.0E+5           -> 0E+4
dqbas646 toSci  0.0E+6           -> 0E+5
dqbas647 toSci  0.0E+7           -> 0E+6
dqbas648 toSci  0.0E+8           -> 0E+7
dqbas649 toSci  0.0E+9           -> 0E+8

dqbas650 toSci  0E+0             -> 0
dqbas651 toSci  0E+1             -> 0E+1
dqbas652 toSci  0E+2             -> 0E+2
dqbas653 toSci  0E+3             -> 0E+3
dqbas654 toSci  0E+4             -> 0E+4
dqbas655 toSci  0E+5             -> 0E+5
dqbas656 toSci  0E+6             -> 0E+6
dqbas657 toSci  0E+7             -> 0E+7
dqbas658 toSci  0E+8             -> 0E+8
dqbas659 toSci  0E+9             -> 0E+9

dqbas660 toSci  0.0E-0           -> 0.0
dqbas661 toSci  0.0E-1           -> 0.00
dqbas662 toSci  0.0E-2           -> 0.000
dqbas663 toSci  0.0E-3           -> 0.0000
dqbas664 toSci  0.0E-4           -> 0.00000
dqbas665 toSci  0.0E-5           -> 0.000000
dqbas666 toSci  0.0E-6           -> 0E-7
dqbas667 toSci  0.0E-7           -> 0E-8
dqbas668 toSci  0.0E-8           -> 0E-9
dqbas669 toSci  0.0E-9           -> 0E-10

dqbas670 toSci  0.00E-0          -> 0.00
dqbas671 toSci  0.00E-1          -> 0.000
dqbas672 toSci  0.00E-2          -> 0.0000
dqbas673 toSci  0.00E-3          -> 0.00000
dqbas674 toSci  0.00E-4          -> 0.000000
dqbas675 toSci  0.00E-5          -> 0E-7
dqbas676 toSci  0.00E-6          -> 0E-8
dqbas677 toSci  0.00E-7          -> 0E-9
dqbas678 toSci  0.00E-8          -> 0E-10
dqbas679 toSci  0.00E-9          -> 0E-11

dqbas680 toSci  000000.          ->  0
dqbas681 toSci   00000.          ->  0
dqbas682 toSci    0000.          ->  0
dqbas683 toSci     000.          ->  0
dqbas684 toSci      00.          ->  0
dqbas685 toSci       0.          ->  0
dqbas686 toSci  +00000.          ->  0
dqbas687 toSci  -00000.          -> -0
dqbas688 toSci  +0.              ->  0
dqbas689 toSci  -0.              -> -0

-- Specials
dqbas700 toSci "NaN"             -> NaN
dqbas701 toSci "nan"             -> NaN
dqbas702 toSci "nAn"             -> NaN
dqbas703 toSci "NAN"             -> NaN
dqbas704 toSci "+NaN"            -> NaN
dqbas705 toSci "+nan"            -> NaN
dqbas706 toSci "+nAn"            -> NaN
dqbas707 toSci "+NAN"            -> NaN
dqbas708 toSci "-NaN"            -> -NaN
dqbas709 toSci "-nan"            -> -NaN
dqbas710 toSci "-nAn"            -> -NaN
dqbas711 toSci "-NAN"            -> -NaN
dqbas712 toSci 'NaN0'            -> NaN
dqbas713 toSci 'NaN1'            -> NaN1
dqbas714 toSci 'NaN12'           -> NaN12
dqbas715 toSci 'NaN123'          -> NaN123
dqbas716 toSci 'NaN1234'         -> NaN1234
dqbas717 toSci 'NaN01'           -> NaN1
dqbas718 toSci 'NaN012'          -> NaN12
dqbas719 toSci 'NaN0123'         -> NaN123
dqbas720 toSci 'NaN01234'        -> NaN1234
dqbas721 toSci 'NaN001'          -> NaN1
dqbas722 toSci 'NaN0012'         -> NaN12
dqbas723 toSci 'NaN00123'        -> NaN123
dqbas724 toSci 'NaN001234'       -> NaN1234
dqbas725 toSci 'NaN1234567890123456781234567890123456' -> NaN Conversion_syntax
dqbas726 toSci 'NaN123e+1'       -> NaN Conversion_syntax
dqbas727 toSci 'NaN12.45'        -> NaN Conversion_syntax
dqbas728 toSci 'NaN-12'          -> NaN Conversion_syntax
dqbas729 toSci 'NaN+12'          -> NaN Conversion_syntax

dqbas730 toSci "sNaN"            -> sNaN
dqbas731 toSci "snan"            -> sNaN
dqbas732 toSci "SnAn"            -> sNaN
dqbas733 toSci "SNAN"            -> sNaN
dqbas734 toSci "+sNaN"           -> sNaN
dqbas735 toSci "+snan"           -> sNaN
dqbas736 toSci "+SnAn"           -> sNaN
dqbas737 toSci "+SNAN"           -> sNaN
dqbas738 toSci "-sNaN"           -> -sNaN
dqbas739 toSci "-snan"           -> -sNaN
dqbas740 toSci "-SnAn"           -> -sNaN
dqbas741 toSci "-SNAN"           -> -sNaN
dqbas742 toSci 'sNaN0000'        -> sNaN
dqbas743 toSci 'sNaN7'           -> sNaN7
dqbas744 toSci 'sNaN007234'      -> sNaN7234
dqbas745 toSci 'sNaN1234567890123456787234561234567890' -> NaN Conversion_syntax
dqbas746 toSci 'sNaN72.45'       -> NaN Conversion_syntax
dqbas747 toSci 'sNaN-72'         -> NaN Conversion_syntax

dqbas748 toSci "Inf"             -> Infinity
dqbas749 toSci "inf"             -> Infinity
dqbas750 toSci "iNf"             -> Infinity
dqbas751 toSci "INF"             -> Infinity
dqbas752 toSci "+Inf"            -> Infinity
dqbas753 toSci "+inf"            -> Infinity
dqbas754 toSci "+iNf"            -> Infinity
dqbas755 toSci "+INF"            -> Infinity
dqbas756 toSci "-Inf"            -> -Infinity
dqbas757 toSci "-inf"            -> -Infinity
dqbas758 toSci "-iNf"            -> -Infinity
dqbas759 toSci "-INF"            -> -Infinity

dqbas760 toSci "Infinity"        -> Infinity
dqbas761 toSci "infinity"        -> Infinity
dqbas762 toSci "iNfInItY"        -> Infinity
dqbas763 toSci "INFINITY"        -> Infinity
dqbas764 toSci "+Infinity"       -> Infinity
dqbas765 toSci "+infinity"       -> Infinity
dqbas766 toSci "+iNfInItY"       -> Infinity
dqbas767 toSci "+INFINITY"       -> Infinity
dqbas768 toSci "-Infinity"       -> -Infinity
dqbas769 toSci "-infinity"       -> -Infinity
dqbas770 toSci "-iNfInItY"       -> -Infinity
dqbas771 toSci "-INFINITY"       -> -Infinity

-- Specials and zeros for toEng
dqbast772 toEng "NaN"              -> NaN
dqbast773 toEng "-Infinity"        -> -Infinity
dqbast774 toEng "-sNaN"            -> -sNaN
dqbast775 toEng "-NaN"             -> -NaN
dqbast776 toEng "+Infinity"        -> Infinity
dqbast778 toEng "+sNaN"            -> sNaN
dqbast779 toEng "+NaN"             -> NaN
dqbast780 toEng "INFINITY"         -> Infinity
dqbast781 toEng "SNAN"             -> sNaN
dqbast782 toEng "NAN"              -> NaN
dqbast783 toEng "infinity"         -> Infinity
dqbast784 toEng "snan"             -> sNaN
dqbast785 toEng "nan"              -> NaN
dqbast786 toEng "InFINITY"         -> Infinity
dqbast787 toEng "SnAN"             -> sNaN
dqbast788 toEng "nAN"              -> NaN
dqbast789 toEng "iNfinity"         -> Infinity
dqbast790 toEng "sNan"             -> sNaN
dqbast791 toEng "Nan"              -> NaN
dqbast792 toEng "Infinity"         -> Infinity
dqbast793 toEng "sNaN"             -> sNaN

-- Zero toEng, etc.
dqbast800 toEng 0e+1              -> "0.00E+3"  -- doc example

dqbast801 toEng 0.000000000       -> 0E-9
dqbast802 toEng 0.00000000        -> 0.00E-6
dqbast803 toEng 0.0000000         -> 0.0E-6
dqbast804 toEng 0.000000          -> 0.000000
dqbast805 toEng 0.00000           -> 0.00000
dqbast806 toEng 0.0000            -> 0.0000
dqbast807 toEng 0.000             -> 0.000
dqbast808 toEng 0.00              -> 0.00
dqbast809 toEng 0.0               -> 0.0
dqbast810 toEng  .0               -> 0.0
dqbast811 toEng 0.                -> 0
dqbast812 toEng -.0               -> -0.0
dqbast813 toEng -0.               -> -0
dqbast814 toEng -0.0              -> -0.0
dqbast815 toEng -0.00             -> -0.00
dqbast816 toEng -0.000            -> -0.000
dqbast817 toEng -0.0000           -> -0.0000
dqbast818 toEng -0.00000          -> -0.00000
dqbast819 toEng -0.000000         -> -0.000000
dqbast820 toEng -0.0000000        -> -0.0E-6
dqbast821 toEng -0.00000000       -> -0.00E-6
dqbast822 toEng -0.000000000      -> -0E-9

dqbast830 toEng  0.00E+0          -> 0.00
dqbast831 toEng  0.00E+1          -> 0.0
dqbast832 toEng  0.00E+2          -> 0
dqbast833 toEng  0.00E+3          -> 0.00E+3
dqbast834 toEng  0.00E+4          -> 0.0E+3
dqbast835 toEng  0.00E+5          -> 0E+3
dqbast836 toEng  0.00E+6          -> 0.00E+6
dqbast837 toEng  0.00E+7          -> 0.0E+6
dqbast838 toEng  0.00E+8          -> 0E+6
dqbast839 toEng  0.00E+9          -> 0.00E+9

dqbast840 toEng  0.0E+0           -> 0.0
dqbast841 toEng  0.0E+1           -> 0
dqbast842 toEng  0.0E+2           -> 0.00E+3
dqbast843 toEng  0.0E+3           -> 0.0E+3
dqbast844 toEng  0.0E+4           -> 0E+3
dqbast845 toEng  0.0E+5           -> 0.00E+6
dqbast846 toEng  0.0E+6           -> 0.0E+6
dqbast847 toEng  0.0E+7           -> 0E+6
dqbast848 toEng  0.0E+8           -> 0.00E+9
dqbast849 toEng  0.0E+9           -> 0.0E+9

dqbast850 toEng  0E+0             -> 0
dqbast851 toEng  0E+1             -> 0.00E+3
dqbast852 toEng  0E+2             -> 0.0E+3
dqbast853 toEng  0E+3             -> 0E+3
dqbast854 toEng  0E+4             -> 0.00E+6
dqbast855 toEng  0E+5             -> 0.0E+6
dqbast856 toEng  0E+6             -> 0E+6
dqbast857 toEng  0E+7             -> 0.00E+9
dqbast858 toEng  0E+8             -> 0.0E+9
dqbast859 toEng  0E+9             -> 0E+9

dqbast860 toEng  0.0E-0           -> 0.0
dqbast861 toEng  0.0E-1           -> 0.00
dqbast862 toEng  0.0E-2           -> 0.000
dqbast863 toEng  0.0E-3           -> 0.0000
dqbast864 toEng  0.0E-4           -> 0.00000
dqbast865 toEng  0.0E-5           -> 0.000000
dqbast866 toEng  0.0E-6           -> 0.0E-6
dqbast867 toEng  0.0E-7           -> 0.00E-6
dqbast868 toEng  0.0E-8           -> 0E-9
dqbast869 toEng  0.0E-9           -> 0.0E-9

dqbast870 toEng  0.00E-0          -> 0.00
dqbast871 toEng  0.00E-1          -> 0.000
dqbast872 toEng  0.00E-2          -> 0.0000
dqbast873 toEng  0.00E-3          -> 0.00000
dqbast874 toEng  0.00E-4          -> 0.000000
dqbast875 toEng  0.00E-5          -> 0.0E-6
dqbast876 toEng  0.00E-6          -> 0.00E-6
dqbast877 toEng  0.00E-7          -> 0E-9
dqbast878 toEng  0.00E-8          -> 0.0E-9
dqbast879 toEng  0.00E-9          -> 0.00E-9

-- long input strings
dqbas801 tosci '01234567890123456' -> 1234567890123456
dqbas802 tosci '001234567890123456' -> 1234567890123456
dqbas803 tosci '0001234567890123456' -> 1234567890123456
dqbas804 tosci '00001234567890123456' -> 1234567890123456
dqbas805 tosci '000001234567890123456' -> 1234567890123456
dqbas806 tosci '0000001234567890123456' -> 1234567890123456
dqbas807 tosci '00000001234567890123456' -> 1234567890123456
dqbas808 tosci '000000001234567890123456' -> 1234567890123456
dqbas809 tosci '0000000001234567890123456' -> 1234567890123456
dqbas810 tosci '00000000001234567890123456' -> 1234567890123456

dqbas811 tosci '0.1234567890123456' -> 0.1234567890123456
dqbas812 tosci '0.01234567890123456' -> 0.01234567890123456
dqbas813 tosci '0.001234567890123456' -> 0.001234567890123456
dqbas814 tosci '0.0001234567890123456' -> 0.0001234567890123456
dqbas815 tosci '0.00001234567890123456' -> 0.00001234567890123456
dqbas816 tosci '0.000001234567890123456' -> 0.000001234567890123456
dqbas817 tosci '0.0000001234567890123456' -> 1.234567890123456E-7
dqbas818 tosci '0.00000001234567890123456' -> 1.234567890123456E-8
dqbas819 tosci '0.000000001234567890123456' -> 1.234567890123456E-9
dqbas820 tosci '0.0000000001234567890123456' -> 1.234567890123456E-10

dqbas821 tosci '12345678912345678901234567801234567890' -> 1.234567891234567890123456780123457E+37 Inexact Rounded
dqbas822 tosci '123456789123456789012345678012345678901' -> 1.234567891234567890123456780123457E+38 Inexact Rounded
dqbas823 tosci '1234567891234567890123456780123456789012' -> 1.234567891234567890123456780123457E+39 Inexact Rounded
dqbas824 tosci '12345678912345678901234567801234567890123' -> 1.234567891234567890123456780123457E+40 Inexact Rounded
dqbas825 tosci '123456789123456789012345678012345678901234' -> 1.234567891234567890123456780123457E+41 Inexact Rounded
dqbas826 tosci '1234567891234567890123456780123456789012345' -> 1.234567891234567890123456780123457E+42 Inexact Rounded
dqbas827 tosci '12345678912345678901234567801234567890123456' -> 1.234567891234567890123456780123457E+43 Inexact Rounded
dqbas828 tosci '123456789123456789012345678012345678901234567' -> 1.234567891234567890123456780123457E+44 Inexact Rounded
dqbas829 tosci '1234567891234567890123456780123456789012345678' -> 1.234567891234567890123456780123457E+45 Inexact Rounded

-- subnormals and overflows
dqbas906 toSci '99e999999999'       -> Infinity Overflow  Inexact Rounded
dqbas907 toSci '999e999999999'      -> Infinity Overflow  Inexact Rounded
dqbas908 toSci '0.9e-999999999'     -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas909 toSci '0.09e-999999999'    -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas910 toSci '0.1e1000000000'     -> Infinity Overflow  Inexact Rounded
dqbas911 toSci '10e-1000000000'     -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas912 toSci '0.9e9999999999'     -> Infinity Overflow  Inexact Rounded
dqbas913 toSci '99e-9999999999'     -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas914 toSci '111e9999999999'     -> Infinity Overflow  Inexact Rounded
dqbas915 toSci '1111e-9999999999'   -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas916 toSci '1111e-99999999999'  -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas917 toSci '7e1000000000'       -> Infinity Overflow  Inexact Rounded
-- negatives the same
dqbas918 toSci '-99e999999999'      -> -Infinity Overflow  Inexact Rounded
dqbas919 toSci '-999e999999999'     -> -Infinity Overflow  Inexact Rounded
dqbas920 toSci '-0.9e-999999999'    -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas921 toSci '-0.09e-999999999'   -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas922 toSci '-0.1e1000000000'    -> -Infinity Overflow  Inexact Rounded
dqbas923 toSci '-10e-1000000000'    -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas924 toSci '-0.9e9999999999'    -> -Infinity Overflow  Inexact Rounded
dqbas925 toSci '-99e-9999999999'    -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas926 toSci '-111e9999999999'    -> -Infinity Overflow  Inexact Rounded
dqbas927 toSci '-1111e-9999999999'  -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas928 toSci '-1111e-99999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas929 toSci '-7e1000000000'      -> -Infinity Overflow  Inexact Rounded

-- overflow results at different rounding modes
rounding:  ceiling
dqbas930 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
dqbas931 toSci '-7e10000'  -> -9.999999999999999999999999999999999E+6144 Overflow  Inexact Rounded
rounding:  up
dqbas932 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
dqbas933 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded
rounding:  down
dqbas934 toSci  '7e10000'  ->  9.999999999999999999999999999999999E+6144 Overflow  Inexact Rounded
dqbas935 toSci '-7e10000'  -> -9.999999999999999999999999999999999E+6144 Overflow  Inexact Rounded
rounding:  floor
dqbas936 toSci  '7e10000'  ->  9.999999999999999999999999999999999E+6144 Overflow  Inexact Rounded
dqbas937 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded

rounding:  half_up
dqbas938 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
dqbas939 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded
rounding:  half_even
dqbas940 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
dqbas941 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded
rounding:  half_down
dqbas942 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
dqbas943 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded

rounding:  half_even

-- Now check 854/754r some subnormals and underflow to 0
dqbem400 toSci  1.0000E-383     -> 1.0000E-383
dqbem401 toSci  0.1E-6172        -> 1E-6173       Subnormal
dqbem402 toSci  0.1000E-6172     -> 1.000E-6173   Subnormal
dqbem403 toSci  0.0100E-6172     -> 1.00E-6174    Subnormal
dqbem404 toSci  0.0010E-6172     -> 1.0E-6175     Subnormal
dqbem405 toSci  0.0001E-6172     -> 1E-6176       Subnormal
dqbem406 toSci  0.00010E-6172    -> 1E-6176     Subnormal Rounded
dqbem407 toSci  0.00013E-6172    -> 1E-6176     Underflow Subnormal Inexact Rounded
dqbem408 toSci  0.00015E-6172    -> 2E-6176     Underflow Subnormal Inexact Rounded
dqbem409 toSci  0.00017E-6172    -> 2E-6176     Underflow Subnormal Inexact Rounded
dqbem410 toSci  0.00023E-6172    -> 2E-6176     Underflow Subnormal Inexact Rounded
dqbem411 toSci  0.00025E-6172    -> 2E-6176     Underflow Subnormal Inexact Rounded
dqbem412 toSci  0.00027E-6172    -> 3E-6176     Underflow Subnormal Inexact Rounded
dqbem413 toSci  0.000149E-6172   -> 1E-6176     Underflow Subnormal Inexact Rounded
dqbem414 toSci  0.000150E-6172   -> 2E-6176     Underflow Subnormal Inexact Rounded
dqbem415 toSci  0.000151E-6172   -> 2E-6176     Underflow Subnormal Inexact Rounded
dqbem416 toSci  0.000249E-6172   -> 2E-6176     Underflow Subnormal Inexact Rounded
dqbem417 toSci  0.000250E-6172   -> 2E-6176     Underflow Subnormal Inexact Rounded
dqbem418 toSci  0.000251E-6172   -> 3E-6176     Underflow Subnormal Inexact Rounded
dqbem419 toSci  0.00009E-6172    -> 1E-6176     Underflow Subnormal Inexact Rounded
dqbem420 toSci  0.00005E-6172    -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped
dqbem421 toSci  0.00003E-6172    -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped
dqbem422 toSci  0.000009E-6172   -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped
dqbem423 toSci  0.000005E-6172   -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped
dqbem424 toSci  0.000003E-6172   -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped

dqbem425 toSci  0.001049E-6172   -> 1.0E-6175   Underflow Subnormal Inexact Rounded
dqbem426 toSci  0.001050E-6172   -> 1.0E-6175   Underflow Subnormal Inexact Rounded
dqbem427 toSci  0.001051E-6172   -> 1.1E-6175   Underflow Subnormal Inexact Rounded
dqbem428 toSci  0.001149E-6172   -> 1.1E-6175   Underflow Subnormal Inexact Rounded
dqbem429 toSci  0.001150E-6172   -> 1.2E-6175   Underflow Subnormal Inexact Rounded
dqbem430 toSci  0.001151E-6172   -> 1.2E-6175   Underflow Subnormal Inexact Rounded

dqbem432 toSci  0.010049E-6172   -> 1.00E-6174  Underflow Subnormal Inexact Rounded
dqbem433 toSci  0.010050E-6172   -> 1.00E-6174  Underflow Subnormal Inexact Rounded
dqbem434 toSci  0.010051E-6172   -> 1.01E-6174  Underflow Subnormal Inexact Rounded
dqbem435 toSci  0.010149E-6172   -> 1.01E-6174  Underflow Subnormal Inexact Rounded
dqbem436 toSci  0.010150E-6172   -> 1.02E-6174  Underflow Subnormal Inexact Rounded
dqbem437 toSci  0.010151E-6172   -> 1.02E-6174  Underflow Subnormal Inexact Rounded

dqbem440 toSci  0.10103E-6172    -> 1.010E-6173 Underflow Subnormal Inexact Rounded
dqbem441 toSci  0.10105E-6172    -> 1.010E-6173 Underflow Subnormal Inexact Rounded
dqbem442 toSci  0.10107E-6172    -> 1.011E-6173 Underflow Subnormal Inexact Rounded
dqbem443 toSci  0.10113E-6172    -> 1.011E-6173 Underflow Subnormal Inexact Rounded
dqbem444 toSci  0.10115E-6172    -> 1.012E-6173 Underflow Subnormal Inexact Rounded
dqbem445 toSci  0.10117E-6172    -> 1.012E-6173 Underflow Subnormal Inexact Rounded

dqbem450 toSci  1.10730E-6173   -> 1.107E-6173 Underflow Subnormal Inexact Rounded
dqbem451 toSci  1.10750E-6173   -> 1.108E-6173 Underflow Subnormal Inexact Rounded
dqbem452 toSci  1.10770E-6173   -> 1.108E-6173 Underflow Subnormal Inexact Rounded
dqbem453 toSci  1.10830E-6173   -> 1.108E-6173 Underflow Subnormal Inexact Rounded
dqbem454 toSci  1.10850E-6173   -> 1.108E-6173 Underflow Subnormal Inexact Rounded
dqbem455 toSci  1.10870E-6173   -> 1.109E-6173 Underflow Subnormal Inexact Rounded

-- make sure sign OK
dqbem456 toSci  -0.10103E-6172   -> -1.010E-6173 Underflow Subnormal Inexact Rounded
dqbem457 toSci  -0.10105E-6172   -> -1.010E-6173 Underflow Subnormal Inexact Rounded
dqbem458 toSci  -0.10107E-6172   -> -1.011E-6173 Underflow Subnormal Inexact Rounded
dqbem459 toSci  -0.10113E-6172   -> -1.011E-6173 Underflow Subnormal Inexact Rounded
dqbem460 toSci  -0.10115E-6172   -> -1.012E-6173 Underflow Subnormal Inexact Rounded
dqbem461 toSci  -0.10117E-6172   -> -1.012E-6173 Underflow Subnormal Inexact Rounded

-- '999s' cases
dqbem464 toSci  999999E-6173         -> 9.99999E-6168 Subnormal
dqbem465 toSci  99999.0E-6172        -> 9.99990E-6168 Subnormal
dqbem466 toSci  99999.E-6172         -> 9.9999E-6168  Subnormal
dqbem467 toSci  9999.9E-6172         -> 9.9999E-6169  Subnormal
dqbem468 toSci  999.99E-6172         -> 9.9999E-6170  Subnormal
dqbem469 toSci  99.999E-6172         -> 9.9999E-6171  Subnormal
dqbem470 toSci  9.9999E-6172         -> 9.9999E-6172  Subnormal
dqbem471 toSci  0.99999E-6172        -> 1.0000E-6172 Underflow Subnormal Inexact Rounded
dqbem472 toSci  0.099999E-6172       -> 1.000E-6173 Underflow Subnormal Inexact Rounded
dqbem473 toSci  0.0099999E-6172      -> 1.00E-6174  Underflow Subnormal Inexact Rounded
dqbem474 toSci  0.00099999E-6172     -> 1.0E-6175   Underflow Subnormal Inexact Rounded
dqbem475 toSci  0.000099999E-6172    -> 1E-6176     Underflow Subnormal Inexact Rounded
dqbem476 toSci  0.0000099999E-6172   -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped
dqbem477 toSci  0.00000099999E-6172  -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped
dqbem478 toSci  0.000000099999E-6172 -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped

-- Exponents with insignificant leading zeros
dqbas1001 toSci  1e999999999 -> Infinity Overflow Inexact Rounded
dqbas1002 toSci  1e0999999999 -> Infinity Overflow Inexact Rounded
dqbas1003 toSci  1e00999999999 -> Infinity Overflow Inexact Rounded
dqbas1004 toSci  1e000999999999 -> Infinity Overflow Inexact Rounded
dqbas1005 toSci  1e000000000000999999999 -> Infinity Overflow Inexact Rounded
dqbas1006 toSci  1e000000000001000000007 -> Infinity Overflow Inexact Rounded
dqbas1007 toSci  1e-999999999 -> 0E-6176             Underflow Subnormal Inexact Rounded Clamped
dqbas1008 toSci  1e-0999999999 -> 0E-6176            Underflow Subnormal Inexact Rounded Clamped
dqbas1009 toSci  1e-00999999999 -> 0E-6176           Underflow Subnormal Inexact Rounded Clamped
dqbas1010 toSci  1e-000999999999 -> 0E-6176          Underflow Subnormal Inexact Rounded Clamped
dqbas1011 toSci  1e-000000000000999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqbas1012 toSci  1e-000000000001000000007 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped

-- check for double-rounded subnormals
dqbas1041 toSci     1.1111111111111111111111111111152444E-6144 ->  1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
dqbas1042 toSci     1.1111111111111111111111111111152445E-6144 ->  1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
dqbas1043 toSci     1.1111111111111111111111111111152446E-6144 ->  1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow

-- clamped zeros [see also clamp.decTest]
dqbas1075 toSci   0e+10000  ->  0E+6111 Clamped
dqbas1076 toSci   0e-10000  ->  0E-6176  Clamped
dqbas1077 toSci  -0e+10000  -> -0E+6111 Clamped
dqbas1078 toSci  -0e-10000  -> -0E-6176  Clamped

-- extreme values from next-wider
dqbas1101 toSci -9.9999999999999999999999999999999999999999999999999999999999999999999E+1572864 -> -Infinity Overflow Inexact Rounded
dqbas1102 toSci -1E-1572863 -> -0E-6176 Inexact Rounded Subnormal Underflow Clamped
dqbas1103 toSci -1E-1572932 -> -0E-6176 Inexact Rounded Subnormal Underflow Clamped
dqbas1104 toSci -0 -> -0
dqbas1105 toSci +0 ->  0
dqbas1106 toSci +1E-1572932 ->  0E-6176 Inexact Rounded Subnormal Underflow Clamped
dqbas1107 toSci +1E-1572863 ->  0E-6176 Inexact Rounded Subnormal Underflow Clamped
dqbas1108 toSci +9.9999999999999999999999999999999999999999999999999999999999999999999E+1572864 ->  Infinity Overflow Inexact Rounded

Added test/dectest/dqCanonical.decTest.









































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
------------------------------------------------------------------------
-- dqCanonical.decTest -- test decQuad canonical results              --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This file tests that copy operations leave uncanonical operands
-- unchanged, and vice versa

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Uncanonical declets are: abc, where:
--   a=1,2,3
--   b=6,7,e,f
--   c=e,f

-- assert some standard (canonical) values; this tests that FromString
-- produces canonical results (many more in decimalNN)
ddcan001 apply 9.999999999999999999999999999999999E+6144  -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan002 apply 0                      -> #22080000000000000000000000000000
ddcan003 apply 1                      -> #22080000000000000000000000000001
ddcan004 apply -1                     -> #a2080000000000000000000000000001
ddcan005 apply Infinity               -> #78000000000000000000000000000000
ddcan006 apply -Infinity              -> #f8000000000000000000000000000000
ddcan007 apply -NaN                   -> #fc000000000000000000000000000000
ddcan008 apply -sNaN                  -> #fe000000000000000000000000000000
ddcan009 apply  NaN999999999999999999999999999999999  -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan010 apply sNaN999999999999999999999999999999999  -> #7e000ff3fcff3fcff3fcff3fcff3fcff
decan011 apply  9999999999999999999999999999999999    -> #6e080ff3fcff3fcff3fcff3fcff3fcff
ddcan012 apply 7.50                                   -> #220780000000000000000000000003d0
ddcan013 apply 9.99                                   -> #220780000000000000000000000000ff

-- Base tests for canonical encodings (individual operator
-- propagation is tested later)

-- Finites: declets in coefficient
ddcan021 canonical  #77ffcff3fcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan022 canonical  #77fffff3fcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan023 canonical  #77ffcffffcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan024 canonical  #77ffcff3ffff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan025 canonical  #77ffcff3fcffffcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan026 canonical  #77ffcff3fcff3ffff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan027 canonical  #77ffcff3fcff3fcffffcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan028 canonical  #77ffcff3fcff3fcff3ffff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan029 canonical  #77ffcff3fcff3fcff3fcffffcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan030 canonical  #77ffcff3fcff3fcff3fcff3ffff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan031 canonical  #77ffcff3fcff3fcff3fcff3fcffffcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan032 canonical  #77ffcff3fcff3fcff3fcff3fcff3ffff -> #77ffcff3fcff3fcff3fcff3fcff3fcff

-- NaN: declets in payload
ddcan061 canonical  #7c000ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan062 canonical  #7c000ffffcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan063 canonical  #7c000ff3ffff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan064 canonical  #7c000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan065 canonical  #7c000ff3fcff3ffff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan066 canonical  #7c000ff3fcff3fcffffcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan067 canonical  #7c000ff3fcff3fcff3ffff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan068 canonical  #7c000ff3fcff3fcff3fcffffcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan069 canonical  #7c000ff3fcff3fcff3fcff3ffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan070 canonical  #7c000ff3fcff3fcff3fcff3fcffffcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan071 canonical  #7c000ff3fcff3fcff3fcff3fcff3ffff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-- NaN: exponent continuation bits [excluding sNaN selector]
ddcan081 canonical  #7d000ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan082 canonical  #7c800ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan083 canonical  #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan084 canonical  #7c200ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan085 canonical  #7c100ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan086 canonical  #7c080ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan087 canonical  #7c040ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan088 canonical  #7c020ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan089 canonical  #7c010ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan090 canonical  #7c008ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan091 canonical  #7c004ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff

-- sNaN: declets in payload
ddcan101 canonical  #7e000ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan102 canonical  #7e000ffffcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan103 canonical  #7e000ff3ffff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan104 canonical  #7e000ff3fcffffcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan105 canonical  #7e000ff3fcff3ffff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan106 canonical  #7e000ff3fcff3fcffffcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan107 canonical  #7e000ff3fcff3fcff3ffff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan108 canonical  #7e000ff3fcff3fcff3fcffffcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan109 canonical  #7e000ff3fcff3fcff3fcff3ffff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan100 canonical  #7e000ff3fcff3fcff3fcff3fcffffcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan111 canonical  #7e000ff3fcff3fcff3fcff3fcff3ffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-- sNaN: exponent continuation bits [excluding sNaN selector]
ddcan121 canonical  #7f000ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan122 canonical  #7e800ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan123 canonical  #7e400ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan124 canonical  #7e200ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan125 canonical  #7e100ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan126 canonical  #7e080ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan127 canonical  #7e040ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan128 canonical  #7e020ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan129 canonical  #7e010ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan130 canonical  #7e008ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
ddcan131 canonical  #7e004ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff

-- Inf: exponent continuation bits
ddcan137 canonical  #78000000000000000000000000000000 -> #78000000000000000000000000000000
ddcan138 canonical  #79000000000000000000000000000000 -> #78000000000000000000000000000000
ddcan139 canonical  #7a000000000000000000000000000000 -> #78000000000000000000000000000000
ddcan140 canonical  #78800000000000000000000000000000 -> #78000000000000000000000000000000
ddcan141 canonical  #78400000000000000000000000000000 -> #78000000000000000000000000000000
ddcan142 canonical  #78200000000000000000000000000000 -> #78000000000000000000000000000000
ddcan143 canonical  #78100000000000000000000000000000 -> #78000000000000000000000000000000
ddcan144 canonical  #78080000000000000000000000000000 -> #78000000000000000000000000000000
ddcan145 canonical  #78040000000000000000000000000000 -> #78000000000000000000000000000000
ddcan146 canonical  #78020000000000000000000000000000 -> #78000000000000000000000000000000
ddcan147 canonical  #78010000000000000000000000000000 -> #78000000000000000000000000000000
ddcan148 canonical  #78008000000000000000000000000000 -> #78000000000000000000000000000000
ddcan149 canonical  #78004000000000000000000000000000 -> #78000000000000000000000000000000

-- Inf: coefficient continuation bits (first, last, and a few others)
ddcan150 canonical  #78000000000000000000000000000000 -> #78000000000000000000000000000000
ddcan151 canonical  #78020000000000000000000000000000 -> #78000000000000000000000000000000
ddcan152 canonical  #78000000000000000000000000000001 -> #78000000000000000000000000000000
ddcan153 canonical  #78010000000000000000000000000000 -> #78000000000000000000000000000000
ddcan154 canonical  #78002000000000000000000000000000 -> #78000000000000000000000000000000
ddcan155 canonical  #78000800000000000000000000000000 -> #78000000000000000000000000000000
ddcan156 canonical  #78000020000000000000000000000000 -> #78000000000000000000000000000000
ddcan157 canonical  #78000004000000000000000000000000 -> #78000000000000000000000000000000
ddcan158 canonical  #78000000400000000000000000000000 -> #78000000000000000000000000000000
ddcan159 canonical  #78000000080000000000000000000000 -> #78000000000000000000000000000000
ddcan160 canonical  #78000000004000000000000000000000 -> #78000000000000000000000000000000
ddcan161 canonical  #78000000000200000000000000000000 -> #78000000000000000000000000000000
ddcan162 canonical  #78000000000080000000000000000000 -> #78000000000000000000000000000000
ddcan163 canonical  #78000000000002000000000000000000 -> #78000000000000000000000000000000
ddcan164 canonical  #78000000000000400000000000000000 -> #78000000000000000000000000000000
ddcan165 canonical  #78000000000000080000000000000000 -> #78000000000000000000000000000000
ddcan166 canonical  #78000000000000001000000000000000 -> #78000000000000000000000000000000
ddcan167 canonical  #78000000000000000200000000000000 -> #78000000000000000000000000000000
ddcan168 canonical  #78000000000000000080000000000000 -> #78000000000000000000000000000000
ddcan169 canonical  #78000000000000000004000000000000 -> #78000000000000000000000000000000
ddcan170 canonical  #78000000000000000000400000000000 -> #78000000000000000000000000000000
ddcan171 canonical  #78000000000000000000010000000000 -> #78000000000000000000000000000000
ddcan172 canonical  #78000000000000000000002000000000 -> #78000000000000000000000000000000
ddcan173 canonical  #78000000000000000000000400000000 -> #78000000000000000000000000000000
ddcan174 canonical  #78000000000000000000000080000000 -> #78000000000000000000000000000000
ddcan175 canonical  #78000000000000000000000002000000 -> #78000000000000000000000000000000
ddcan176 canonical  #78000000000000000000000000400000 -> #78000000000000000000000000000000
ddcan177 canonical  #78000000000000000000000000020000 -> #78000000000000000000000000000000
ddcan178 canonical  #78000000000000000000000000001000 -> #78000000000000000000000000000000
ddcan179 canonical  #78000000000000000000000000000400 -> #78000000000000000000000000000000
ddcan180 canonical  #78000000000000000000000000000020 -> #78000000000000000000000000000000
ddcan181 canonical  #78000000000000000000000000000008 -> #78000000000000000000000000000000


-- Now the operators -- trying to check paths that might fail to
-- canonicalize propagated operands

----- Add:
-- Finites: neutral 0
ddcan202 add  0E+6144 #77ffcff3fcff3fcffffcff3fcff3fcff         -> #77ffcff3fcff3fcff3fcff3fcff3fcff
ddcan203 add          #77ffcff3fcff3fcff3fcff3ffff3fcff 0E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-- tiny zero
ddcan204 add  0E-6176 #77ffcff3ffff3fcff3fcff3fcff3fcff         -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
ddcan205 add          #77ffcff3fcff3fcff3fcff3fcff3ffff 0E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
-- tiny non zero
ddcan206 add -1E-6176 #77ffcff3fcff3fcff3fcff3fcfffffff          -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
ddcan207 add          #77ffcffffffffffffffffffffff3fcff -1E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
-- NaN: declets in payload
ddcan211 add  0  #7c000ff3fcff3fcff3fcfffffff3fcff   -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan212 add     #7c000ff3fcff3fcfffffff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-- NaN: exponent continuation bits [excluding sNaN selector]
ddcan213 add  0  #7c400ff3fcff3fcff3fcff3fcff3fcff   -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan214 add     #7c020ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-- sNaN: declets in payload
ddcan215 add  0  #7e000ff3fcffffcff3fcff3fcff3fcff   -> #7c000ff3fcff3fcff3fcff3fcff3fcff  Invalid_operation
ddcan216 add     #7e003ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff  Invalid_operation
-- sNaN: exponent continuation bits [excluding sNaN selector]
ddcan217 add  0  #7e500ff3fcff3fcff3fcff3fcff3fcff   -> #7c000ff3fcff3fcff3fcff3fcff3fcff  Invalid_operation
ddcan218 add     #7e0e0ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff  Invalid_operation
-- Inf: exponent continuation bits
ddcan220 add  0  #78010000000000000000000000000000   -> #78000000000000000000000000000000
ddcan221 add     #78680000000000000000000000000000 0 -> #78000000000000000000000000000000
-- Inf: coefficient continuation bits
ddcan222 add  0  #78002000000000000000000000000000   -> #78000000000000000000000000000000
ddcan223 add     #78000000000000000000000000000001 0 -> #78000000000000000000000000000000
ddcan224 add  0  #78000002000000000000000000000000   -> #78000000000000000000000000000000
ddcan225 add     #780000000000f0000000000000000000 0 -> #78000000000000000000000000000000
ddcan226 add  0  #78000000000000000005000000000000   -> #78000000000000000000000000000000
ddcan227 add     #780000000000000000000000000a0000 0 -> #78000000000000000000000000000000

----- Class: [does not return encoded]

----- Compare:
ddcan231 compare -Inf   1     ->  #a2080000000000000000000000000001
ddcan232 compare -Inf  -Inf   ->  #22080000000000000000000000000000
ddcan233 compare  1    -Inf   ->  #22080000000000000000000000000001
ddcan234 compare  #7c010ff3fcff3fcff3fcff3ffffffcff     -1000  -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan235 compare  #7e004ff3fcff3fcff3ffffffcff3fcff     -1000  -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation

----- CompareSig:
ddcan241 comparesig -Inf   1     ->  #a2080000000000000000000000000001
ddcan242 comparesig -Inf  -Inf   ->  #22080000000000000000000000000000
ddcan243 comparesig  1    -Inf   ->  #22080000000000000000000000000001
ddcan244 comparesig  #7c400ff3ffff3fcff3fcff3fcff3fcff   -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
ddcan245 comparesig  #7e050ff3fcfffffff3fcff3fcff3fcff   -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation

----- Copy: [does not usually canonicalize]
-- finites
ddcan250 copy  #6e080ff3fcff3fcfffffff3fcfffffff -> #6e080ff3fcff3fcfffffff3fcfffffff
ddcan251 copy  #ee080ff3fcff3ffff3fcff3ffff3fcff -> #ee080ff3fcff3ffff3fcff3ffff3fcff
-- NaNs
ddcan252 copy  #7c000ff3fcffffffffffffffcff3fcff -> #7c000ff3fcffffffffffffffcff3fcff
ddcan253 copy  #7c080ff3fcff3fcff3fcff3fcff3fcff -> #7c080ff3fcff3fcff3fcff3fcff3fcff
-- sNaN
ddcan254 copy  #7e003ff3fcffffffffffffffcff3fcff -> #7e003ff3fcffffffffffffffcff3fcff
ddcan255 copy  #7e100ff3fcff3fcff3fcff3fcff3fcff -> #7e100ff3fcff3fcff3fcff3fcff3fcff
-- Inf
ddcan258 copy  #78002000000000000000000000000000 -> #78002000000000000000000000000000
ddcan259 copy  #78000000000010000000000000100000 -> #78000000000010000000000000100000

----- CopyAbs: [does not usually canonicalize]
-- finites
ddcan260 copyabs  #6e080ff3fcff3fcfffffff3fcfffffff -> #6e080ff3fcff3fcfffffff3fcfffffff
ddcan261 copyabs  #ee080ff3fcff3ffff3fcff3ffff3fcff -> #6e080ff3fcff3ffff3fcff3ffff3fcff
-- NaNs
ddcan262 copyabs  #fc000ff3fcffffffffffffffcff3fcff -> #7c000ff3fcffffffffffffffcff3fcff
ddcan263 copyabs  #fc080ff3fcff3fcff3fcff3fcff3fcff -> #7c080ff3fcff3fcff3fcff3fcff3fcff
-- sNaN
ddcan264 copyabs  #fe003ff3fcffffffffffffffcff3fcff -> #7e003ff3fcffffffffffffffcff3fcff
ddcan265 copyabs  #fe100ff3fcff3fcff3fcff3fcff3fcff -> #7e100ff3fcff3fcff3fcff3fcff3fcff
-- Inf
ddcan268 copyabs  #f8002000000000000000000000000000 -> #78002000000000000000000000000000
ddcan269 copyabs  #f8000000000000700700700000000000 -> #78000000000000700700700000000000

----- CopyNegate: [does not usually canonicalize]
-- finites
ddcan270 copynegate  #6e080ff3fcff3fcfffffff3fcfffffff -> #ee080ff3fcff3fcfffffff3fcfffffff
ddcan271 copynegate  #ee080ff3fcff3ffff3fcff3ffff3fcff -> #6e080ff3fcff3ffff3fcff3ffff3fcff
-- NaNs
ddcan272 copynegate  #7c000ff3fcffffffffffff3fcff3fcff -> #fc000ff3fcffffffffffff3fcff3fcff
ddcan273 copynegate  #7c080ff3fcff3fcff3fcff3fcff3fcff -> #fc080ff3fcff3fcff3fcff3fcff3fcff
-- sNaN
ddcan274 copynegate  #7e003ff3fcffffffffffffffcff3fcff -> #fe003ff3fcffffffffffffffcff3fcff
ddcan275 copynegate  #7e100ff3fcff3fcff3fcff3fcff3fcff -> #fe100ff3fcff3fcff3fcff3fcff3fcff
-- Inf
ddcan278 copynegate  #78002000000000000000000000000000 -> #f8002000000000000000000000000000
ddcan279 copynegate  #78000000000010000000000000100000 -> #f8000000000010000000000000100000

----- CopySign: [does not usually canonicalize]
-- finites
ddcan280 copysign  #6e080ff3fcff3fcfffffff3fcfffffff -1 -> #ee080ff3fcff3fcfffffff3fcfffffff
ddcan281 copysign  #ee080ff3fcff3ffff3fcff3ffff3fcff  1 -> #6e080ff3fcff3ffff3fcff3ffff3fcff
-- NaNs
ddcan282 copysign  #7c000ff3fcffffffffffffffcff3fcff -1 -> #fc000ff3fcffffffffffffffcff3fcff
ddcan283 copysign  #7c080ff3fcff3fcff3fcff3fcff3fcff  1 -> #7c080ff3fcff3fcff3fcff3fcff3fcff
-- sNaN
ddcan284 copysign  #7e003ff3fcffffffffffffffcff3fcff -1 -> #fe003ff3fcffffffffffffffcff3fcff
ddcan285 copysign  #7e100ff3fcff3fcff3fcff3fcff3fcff  1 -> #7e100ff3fcff3fcff3fcff3fcff3fcff
-- Inf
ddcan288 copysign  #78002000000000000000000000000000 -1 -> #f8002000000000000000000000000000
ddcan289 copysign  #78000000000010000000000000100000  1 -> #78000000000010000000000000100000

----- Multiply:
-- Finites: neutral 0
ddcan302 multiply  1  #77ffff3fcff3fcff0000000000000000               -> #77ffff3fcff3fcff0000000000000000
ddcan303 multiply     #77fcffffcff3fcff0000000000000000 1             -> #77fccfffcff3fcff0000000000000000
-- negative
ddcan306 multiply -1  #77ffff3fcff3fcff0000000000000000               -> #f7ffff3fcff3fcff0000000000000000
ddcan307 multiply     #77fcffffcff3fcff0000000000000000 -1            -> #f7fccfffcff3fcff0000000000000000
-- NaN: declets in payload
ddcan311 multiply  1  #7c03ff3fcff3fcff0000000000000000               -> #7c003f3fcff3fcff0000000000000000
ddcan312 multiply     #7c03ff3fcff3fcff0000000000000000 1             -> #7c003f3fcff3fcff0000000000000000
-- NaN: exponent continuation bits [excluding sNaN selector]
ddcan313 multiply  1  #7c40ff3fcff3fcff0000000000000000               -> #7c003f3fcff3fcff0000000000000000
ddcan314 multiply     #7c40ff3fcff3fcff0000000000000000 1             -> #7c003f3fcff3fcff0000000000000000
-- sNaN: declets in payload
ddcan315 multiply  1  #7e00ffffcff3fcff0000000000000000               -> #7c000fffcff3fcff0000000000000000 Invalid_operation
ddcan316 multiply     #7e00ffffcff3fcff0000000000000000 1             -> #7c000fffcff3fcff0000000000000000 Invalid_operation
-- sNaN: exponent continuation bits [excluding sNaN selector]
ddcan317 multiply  1  #7e80ff3fcff3fcff0000000000000000               -> #7c003f3fcff3fcff0000000000000000 Invalid_operation
ddcan318 multiply     #7e80ff3fcff3fcff0000000000000000 1             -> #7c003f3fcff3fcff0000000000000000 Invalid_operation
-- Inf: exponent continuation bits
ddcan320 multiply  1  #78800000000000000000000000000000               -> #78000000000000000000000000000000
ddcan321 multiply     #78800000000000000000000000000000 1             -> #78000000000000000000000000000000
-- Inf: coefficient continuation bits
ddcan322 multiply  1  #78020000000000000000000000000000               -> #78000000000000000000000000000000
ddcan323 multiply     #78020000000000000000000000000000 1             -> #78000000000000000000000000000000
ddcan324 multiply  1  #78000000000000010000000000000000               -> #78000000000000000000000000000000
ddcan325 multiply     #78000000000000010000000000000000 1             -> #78000000000000000000000000000000
ddcan326 multiply  1  #78000020000000000000000000000000               -> #78000000000000000000000000000000
ddcan327 multiply     #78000020000000000000000000000000 1             -> #78000000000000000000000000000000

----- Quantize:
ddcan401 quantize  #ee080ff3fcff3fcff3fffffffff3fcff 0    -> #ee080ff3fcff3fcff3fcff3fcff3fcff
ddcan402 quantize  #ee080ff3fffffffffffcff3fcff3fcff 0    -> #ee080ff3fcff3fcff3fcff3fcff3fcff
ddcan403 quantize  #78800000000000000000000000000000 Inf  -> #78000000000000000000000000000000
ddcan404 quantize  #78020000000000000000000000000000 -Inf -> #78000000000000000000000000000000
ddcan410 quantize  #7c080ff3fcff3fcff3fcff3fcff3fcff  1   -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan411 quantize  #fc000ff3fcfffffff3fcff3fcff3fcff  1   -> #fc000ff3fcff3fcff3fcff3fcff3fcff
ddcan412 quantize  #7e100ff3fcff3fcff3fcff3fcff3fcff  1   -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
ddcan413 quantize  #fe000ff3fcff3fcff3ffffffcff3fcff  1   -> #fc000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation

----- Subtract:
-- Finites: neutral 0
ddcan502 subtract  0E+6144 #77ffcff3fcff3fcffffcff3fcff3fcff         -> #f7ffcff3fcff3fcff3fcff3fcff3fcff
ddcan503 subtract          #77ffcff3fcff3fcff3fcff3ffff3fcff 0E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-- tiny zero
ddcan504 subtract  0E-6176 #77ffcff3ffff3fcff3fcff3fcff3fcff         -> #f7ffcff3fcff3fcff3fcff3fcff3fcff Rounded
ddcan505 subtract          #77ffcff3fcff3fcff3fcff3fcff3ffff 0E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
-- tiny non zero
ddcan506 subtract -1E-6176 #77ffcff3fcff3fcff3fcff3fcfffffff          -> #f7ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
ddcan507 subtract          #77ffcffffffffffffffffffffff3fcff -1E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
-- NaN: declets in payload
ddcan511 subtract  0  #7c000ff3fcff3fcff3fcfffffff3fcff   -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan512 subtract     #7c000ff3fcff3fcfffffff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-- NaN: exponent continuation bits [excluding sNaN selector]
ddcan513 subtract  0  #7c400ff3fcff3fcff3fcff3fcff3fcff   -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan514 subtract     #7c020ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-- sNaN: declets in payload
ddcan515 subtract  0  #7e000ff3fcffffcff3fcff3fcff3fcff   -> #7c000ff3fcff3fcff3fcff3fcff3fcff  Invalid_operation
ddcan516 subtract     #7e003ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff  Invalid_operation
-- sNaN: exponent continuation bits [excluding sNaN selector]
ddcan517 subtract  0  #7e500ff3fcff3fcff3fcff3fcff3fcff   -> #7c000ff3fcff3fcff3fcff3fcff3fcff  Invalid_operation
ddcan518 subtract     #7e0e0ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff  Invalid_operation
-- Inf: exponent continuation bits
ddcan520 subtract  0  #78010000000000000000000000000000   -> #f8000000000000000000000000000000
ddcan521 subtract     #78680000000000000000000000000000 0 -> #78000000000000000000000000000000
-- Inf: coefficient continuation bits
ddcan522 subtract  0  #78002000000000000000000000000000   -> #f8000000000000000000000000000000
ddcan523 subtract     #78000000000000000000000000000001 0 -> #78000000000000000000000000000000
ddcan524 subtract  0  #78000002000000000000000000000000   -> #f8000000000000000000000000000000
ddcan525 subtract     #780000000000f0000000000000000000 0 -> #78000000000000000000000000000000
ddcan526 subtract  0  #78000000000000000005000000000000   -> #f8000000000000000000000000000000
ddcan527 subtract     #780000000000000000000000000a0000 0 -> #78000000000000000000000000000000

----- ToIntegral:
ddcan601 tointegralx  #6e080ff3fdff3fcff3fcff3fcff3fcff  -> #6e080ff3fcff3fcff3fcff3fcff3fcff
ddcan602 tointegralx  #ee080ff3fcff3ffff3fcff3fcff3fcff  -> #ee080ff3fcff3fcff3fcff3fcff3fcff
ddcan603 tointegralx  #78800000000000000000000000000000  -> #78000000000000000000000000000000
ddcan604 tointegralx  #78020000000000000000000000000000  -> #78000000000000000000000000000000
ddcan614 tointegralx  #7c100ff3fcff3fcff3fcff3fcff3fcff  -> #7c000ff3fcff3fcff3fcff3fcff3fcff
ddcan615 tointegralx  #fc000ff3fcff3fcff3fcffffcff3fcff  -> #fc000ff3fcff3fcff3fcff3fcff3fcff
ddcan616 tointegralx  #7e010ff3fcff3fcff3fcff3fcff3fcff  -> #7c000ff3fcff3fcff3fcff3fcff3fcff  Invalid_operation
ddcan617 tointegralx  #fe000ff3fcff3fcff3fdff3fcff3fcff  -> #fc000ff3fcff3fcff3fcff3fcff3fcff  Invalid_operation
-- uncanonical 3999, 39.99, 3.99, 0.399,                  and negatives
ddcan618 tointegralx  #22080000000000000000000000000fff  -> #22080000000000000000000000000cff
ddcan619 tointegralx  #22078000000000000000000000000fff  -> #22080000000000000000000000000040  Inexact Rounded
ddcan620 tointegralx  #22074000000000000000000000000fff  -> #22080000000000000000000000000004  Inexact Rounded
ddcan621 tointegralx  #22070000000000000000000000000fff  -> #22080000000000000000000000000000  Inexact Rounded
ddcan622 tointegralx  #a2080000000000000000000000000fff  -> #a2080000000000000000000000000cff
ddcan623 tointegralx  #a2078000000000000000000000000fff  -> #a2080000000000000000000000000040  Inexact Rounded
ddcan624 tointegralx  #a2074000000000000000000000000fff  -> #a2080000000000000000000000000004  Inexact Rounded
ddcan625 tointegralx  #a2070000000000000000000000000fff  -> #a2080000000000000000000000000000  Inexact Rounded



Added test/dectest/dqClass.decTest.



























































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
------------------------------------------------------------------------
-- dqClass.decTest -- decQuad Class operations                        --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- [New 2006.11.27]

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

dqcla001  class    0                        -> +Zero
dqcla002  class    0.00                     -> +Zero
dqcla003  class    0E+5                     -> +Zero
dqcla004  class    1E-6176                  -> +Subnormal
dqcla005  class  0.1E-6143                  -> +Subnormal
dqcla006  class  0.99999999999999999999999999999999E-6143     -> +Subnormal
dqcla007  class  1.00000000000000000000000000000000E-6143     -> +Normal
dqcla008  class   1E-6143                   -> +Normal
dqcla009  class   1E-100                    -> +Normal
dqcla010  class   1E-10                     -> +Normal
dqcla012  class   1E-1                      -> +Normal
dqcla013  class   1                         -> +Normal
dqcla014  class   2.50                      -> +Normal
dqcla015  class   100.100                   -> +Normal
dqcla016  class   1E+30                     -> +Normal
dqcla017  class   1E+6144                   -> +Normal
dqcla018  class   9.99999999999999999999999999999999E+6144    -> +Normal
dqcla019  class   Inf                       -> +Infinity

dqcla021  class   -0                        -> -Zero
dqcla022  class   -0.00                     -> -Zero
dqcla023  class   -0E+5                     -> -Zero
dqcla024  class   -1E-6176                  -> -Subnormal
dqcla025  class  -0.1E-6143                 -> -Subnormal
dqcla026  class  -0.99999999999999999999999999999999E-6143    -> -Subnormal
dqcla027  class  -1.00000000000000000000000000000000E-6143    -> -Normal
dqcla028  class  -1E-6143                   -> -Normal
dqcla029  class  -1E-100                    -> -Normal
dqcla030  class  -1E-10                     -> -Normal
dqcla032  class  -1E-1                      -> -Normal
dqcla033  class  -1                         -> -Normal
dqcla034  class  -2.50                      -> -Normal
dqcla035  class  -100.100                   -> -Normal
dqcla036  class  -1E+30                     -> -Normal
dqcla037  class  -1E+6144                   -> -Normal
dqcla0614  class  -9.99999999999999999999999999999999E+6144    -> -Normal
dqcla039  class  -Inf                       -> -Infinity

dqcla041  class   NaN                       -> NaN
dqcla042  class  -NaN                       -> NaN
dqcla043  class  +NaN12345                  -> NaN
dqcla044  class   sNaN                      -> sNaN
dqcla045  class  -sNaN                      -> sNaN
dqcla046  class  +sNaN12345                 -> sNaN



Added test/dectest/dqCompare.decTest.



































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
------------------------------------------------------------------------
-- dqCompare.decTest -- decQuad comparison that allows quiet NaNs     --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Note that we cannot assume add/subtract tests cover paths adequately,
-- here, because the code might be quite different (comparison cannot
-- overflow or underflow, so actual subtractions are not necessary).

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks
dqcom001 compare  -2  -2  -> 0
dqcom002 compare  -2  -1  -> -1
dqcom003 compare  -2   0  -> -1
dqcom004 compare  -2   1  -> -1
dqcom005 compare  -2   2  -> -1
dqcom006 compare  -1  -2  -> 1
dqcom007 compare  -1  -1  -> 0
dqcom008 compare  -1   0  -> -1
dqcom009 compare  -1   1  -> -1
dqcom010 compare  -1   2  -> -1
dqcom011 compare   0  -2  -> 1
dqcom012 compare   0  -1  -> 1
dqcom013 compare   0   0  -> 0
dqcom014 compare   0   1  -> -1
dqcom015 compare   0   2  -> -1
dqcom016 compare   1  -2  -> 1
dqcom017 compare   1  -1  -> 1
dqcom018 compare   1   0  -> 1
dqcom019 compare   1   1  -> 0
dqcom020 compare   1   2  -> -1
dqcom021 compare   2  -2  -> 1
dqcom022 compare   2  -1  -> 1
dqcom023 compare   2   0  -> 1
dqcom025 compare   2   1  -> 1
dqcom026 compare   2   2  -> 0

dqcom031 compare  -20  -20  -> 0
dqcom032 compare  -20  -10  -> -1
dqcom033 compare  -20   00  -> -1
dqcom034 compare  -20   10  -> -1
dqcom035 compare  -20   20  -> -1
dqcom036 compare  -10  -20  -> 1
dqcom037 compare  -10  -10  -> 0
dqcom038 compare  -10   00  -> -1
dqcom039 compare  -10   10  -> -1
dqcom040 compare  -10   20  -> -1
dqcom041 compare   00  -20  -> 1
dqcom042 compare   00  -10  -> 1
dqcom043 compare   00   00  -> 0
dqcom044 compare   00   10  -> -1
dqcom045 compare   00   20  -> -1
dqcom046 compare   10  -20  -> 1
dqcom047 compare   10  -10  -> 1
dqcom048 compare   10   00  -> 1
dqcom049 compare   10   10  -> 0
dqcom050 compare   10   20  -> -1
dqcom051 compare   20  -20  -> 1
dqcom052 compare   20  -10  -> 1
dqcom053 compare   20   00  -> 1
dqcom055 compare   20   10  -> 1
dqcom056 compare   20   20  -> 0

dqcom061 compare  -2.0  -2.0  -> 0
dqcom062 compare  -2.0  -1.0  -> -1
dqcom063 compare  -2.0   0.0  -> -1
dqcom064 compare  -2.0   1.0  -> -1
dqcom065 compare  -2.0   2.0  -> -1
dqcom066 compare  -1.0  -2.0  -> 1
dqcom067 compare  -1.0  -1.0  -> 0
dqcom068 compare  -1.0   0.0  -> -1
dqcom069 compare  -1.0   1.0  -> -1
dqcom070 compare  -1.0   2.0  -> -1
dqcom071 compare   0.0  -2.0  -> 1
dqcom072 compare   0.0  -1.0  -> 1
dqcom073 compare   0.0   0.0  -> 0
dqcom074 compare   0.0   1.0  -> -1
dqcom075 compare   0.0   2.0  -> -1
dqcom076 compare   1.0  -2.0  -> 1
dqcom077 compare   1.0  -1.0  -> 1
dqcom078 compare   1.0   0.0  -> 1
dqcom079 compare   1.0   1.0  -> 0
dqcom080 compare   1.0   2.0  -> -1
dqcom081 compare   2.0  -2.0  -> 1
dqcom082 compare   2.0  -1.0  -> 1
dqcom083 compare   2.0   0.0  -> 1
dqcom085 compare   2.0   1.0  -> 1
dqcom086 compare   2.0   2.0  -> 0

-- now some cases which might overflow if subtract were used
dqcom090 compare  9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144  -> 0
dqcom091 compare -9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144  -> -1
dqcom092 compare  9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 1
dqcom093 compare -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0

-- some differing length/exponent cases
dqcom100 compare   7.0    7.0    -> 0
dqcom101 compare   7.0    7      -> 0
dqcom102 compare   7      7.0    -> 0
dqcom103 compare   7E+0   7.0    -> 0
dqcom104 compare   70E-1  7.0    -> 0
dqcom105 compare   0.7E+1 7      -> 0
dqcom106 compare   70E-1  7      -> 0
dqcom107 compare   7.0    7E+0   -> 0
dqcom108 compare   7.0    70E-1  -> 0
dqcom109 compare   7      0.7E+1 -> 0
dqcom110 compare   7      70E-1  -> 0

dqcom120 compare   8.0    7.0    -> 1
dqcom121 compare   8.0    7      -> 1
dqcom122 compare   8      7.0    -> 1
dqcom123 compare   8E+0   7.0    -> 1
dqcom124 compare   80E-1  7.0    -> 1
dqcom125 compare   0.8E+1 7      -> 1
dqcom126 compare   80E-1  7      -> 1
dqcom127 compare   8.0    7E+0   -> 1
dqcom128 compare   8.0    70E-1  -> 1
dqcom129 compare   8      0.7E+1  -> 1
dqcom130 compare   8      70E-1  -> 1

dqcom140 compare   8.0    9.0    -> -1
dqcom141 compare   8.0    9      -> -1
dqcom142 compare   8      9.0    -> -1
dqcom143 compare   8E+0   9.0    -> -1
dqcom144 compare   80E-1  9.0    -> -1
dqcom145 compare   0.8E+1 9      -> -1
dqcom146 compare   80E-1  9      -> -1
dqcom147 compare   8.0    9E+0   -> -1
dqcom148 compare   8.0    90E-1  -> -1
dqcom149 compare   8      0.9E+1 -> -1
dqcom150 compare   8      90E-1  -> -1

-- and again, with sign changes -+ ..
dqcom200 compare  -7.0    7.0    -> -1
dqcom201 compare  -7.0    7      -> -1
dqcom202 compare  -7      7.0    -> -1
dqcom203 compare  -7E+0   7.0    -> -1
dqcom204 compare  -70E-1  7.0    -> -1
dqcom205 compare  -0.7E+1 7      -> -1
dqcom206 compare  -70E-1  7      -> -1
dqcom207 compare  -7.0    7E+0   -> -1
dqcom208 compare  -7.0    70E-1  -> -1
dqcom209 compare  -7      0.7E+1 -> -1
dqcom210 compare  -7      70E-1  -> -1

dqcom220 compare  -8.0    7.0    -> -1
dqcom221 compare  -8.0    7      -> -1
dqcom222 compare  -8      7.0    -> -1
dqcom223 compare  -8E+0   7.0    -> -1
dqcom224 compare  -80E-1  7.0    -> -1
dqcom225 compare  -0.8E+1 7      -> -1
dqcom226 compare  -80E-1  7      -> -1
dqcom227 compare  -8.0    7E+0   -> -1
dqcom228 compare  -8.0    70E-1  -> -1
dqcom229 compare  -8      0.7E+1 -> -1
dqcom230 compare  -8      70E-1  -> -1

dqcom240 compare  -8.0    9.0    -> -1
dqcom241 compare  -8.0    9      -> -1
dqcom242 compare  -8      9.0    -> -1
dqcom243 compare  -8E+0   9.0    -> -1
dqcom244 compare  -80E-1  9.0    -> -1
dqcom245 compare  -0.8E+1 9      -> -1
dqcom246 compare  -80E-1  9      -> -1
dqcom247 compare  -8.0    9E+0   -> -1
dqcom248 compare  -8.0    90E-1  -> -1
dqcom249 compare  -8      0.9E+1 -> -1
dqcom250 compare  -8      90E-1  -> -1

-- and again, with sign changes +- ..
dqcom300 compare   7.0    -7.0    -> 1
dqcom301 compare   7.0    -7      -> 1
dqcom302 compare   7      -7.0    -> 1
dqcom303 compare   7E+0   -7.0    -> 1
dqcom304 compare   70E-1  -7.0    -> 1
dqcom305 compare   .7E+1  -7      -> 1
dqcom306 compare   70E-1  -7      -> 1
dqcom307 compare   7.0    -7E+0   -> 1
dqcom308 compare   7.0    -70E-1  -> 1
dqcom309 compare   7      -.7E+1  -> 1
dqcom310 compare   7      -70E-1  -> 1

dqcom320 compare   8.0    -7.0    -> 1
dqcom321 compare   8.0    -7      -> 1
dqcom322 compare   8      -7.0    -> 1
dqcom323 compare   8E+0   -7.0    -> 1
dqcom324 compare   80E-1  -7.0    -> 1
dqcom325 compare   .8E+1  -7      -> 1
dqcom326 compare   80E-1  -7      -> 1
dqcom327 compare   8.0    -7E+0   -> 1
dqcom328 compare   8.0    -70E-1  -> 1
dqcom329 compare   8      -.7E+1  -> 1
dqcom330 compare   8      -70E-1  -> 1

dqcom340 compare   8.0    -9.0    -> 1
dqcom341 compare   8.0    -9      -> 1
dqcom342 compare   8      -9.0    -> 1
dqcom343 compare   8E+0   -9.0    -> 1
dqcom344 compare   80E-1  -9.0    -> 1
dqcom345 compare   .8E+1  -9      -> 1
dqcom346 compare   80E-1  -9      -> 1
dqcom347 compare   8.0    -9E+0   -> 1
dqcom348 compare   8.0    -90E-1  -> 1
dqcom349 compare   8      -.9E+1  -> 1
dqcom350 compare   8      -90E-1  -> 1

-- and again, with sign changes -- ..
dqcom400 compare   -7.0    -7.0    -> 0
dqcom401 compare   -7.0    -7      -> 0
dqcom402 compare   -7      -7.0    -> 0
dqcom403 compare   -7E+0   -7.0    -> 0
dqcom404 compare   -70E-1  -7.0    -> 0
dqcom405 compare   -.7E+1  -7      -> 0
dqcom406 compare   -70E-1  -7      -> 0
dqcom407 compare   -7.0    -7E+0   -> 0
dqcom408 compare   -7.0    -70E-1  -> 0
dqcom409 compare   -7      -.7E+1  -> 0
dqcom410 compare   -7      -70E-1  -> 0

dqcom420 compare   -8.0    -7.0    -> -1
dqcom421 compare   -8.0    -7      -> -1
dqcom422 compare   -8      -7.0    -> -1
dqcom423 compare   -8E+0   -7.0    -> -1
dqcom424 compare   -80E-1  -7.0    -> -1
dqcom425 compare   -.8E+1  -7      -> -1
dqcom426 compare   -80E-1  -7      -> -1
dqcom427 compare   -8.0    -7E+0   -> -1
dqcom428 compare   -8.0    -70E-1  -> -1
dqcom429 compare   -8      -.7E+1  -> -1
dqcom430 compare   -8      -70E-1  -> -1

dqcom440 compare   -8.0    -9.0    -> 1
dqcom441 compare   -8.0    -9      -> 1
dqcom442 compare   -8      -9.0    -> 1
dqcom443 compare   -8E+0   -9.0    -> 1
dqcom444 compare   -80E-1  -9.0    -> 1
dqcom445 compare   -.8E+1  -9      -> 1
dqcom446 compare   -80E-1  -9      -> 1
dqcom447 compare   -8.0    -9E+0   -> 1
dqcom448 compare   -8.0    -90E-1  -> 1
dqcom449 compare   -8      -.9E+1  -> 1
dqcom450 compare   -8      -90E-1  -> 1

-- misalignment traps for little-endian
dqcom451 compare      1.0       0.1  -> 1
dqcom452 compare      0.1       1.0  -> -1
dqcom453 compare     10.0       0.1  -> 1
dqcom454 compare      0.1      10.0  -> -1
dqcom455 compare      100       1.0  -> 1
dqcom456 compare      1.0       100  -> -1
dqcom457 compare     1000      10.0  -> 1
dqcom458 compare     10.0      1000  -> -1
dqcom459 compare    10000     100.0  -> 1
dqcom460 compare    100.0     10000  -> -1
dqcom461 compare   100000    1000.0  -> 1
dqcom462 compare   1000.0    100000  -> -1
dqcom463 compare  1000000   10000.0  -> 1
dqcom464 compare  10000.0   1000000  -> -1

-- testcases that subtract to lots of zeros at boundaries [pgr]
dqcom473 compare 123.9999999999999999994560000000000E-89 123.999999999999999999456E-89 -> 0
dqcom474 compare 123.999999999999999999456000000000E+89 123.999999999999999999456E+89 -> 0
dqcom475 compare 123.99999999999999999945600000000E-89 123.999999999999999999456E-89 -> 0
dqcom476 compare 123.9999999999999999994560000000E+89 123.999999999999999999456E+89 -> 0
dqcom477 compare 123.999999999999999999456000000E-89 123.999999999999999999456E-89 -> 0
dqcom478 compare 123.99999999999999999945600000E+89 123.999999999999999999456E+89 -> 0
dqcom479 compare 123.9999999999999999994560000E-89 123.999999999999999999456E-89 -> 0
dqcom480 compare 123.999999999999999999456000E+89 123.999999999999999999456E+89 -> 0
dqcom481 compare 123.99999999999999999945600E-89 123.999999999999999999456E-89 -> 0
dqcom482 compare 123.9999999999999999994560E+89 123.999999999999999999456E+89 -> 0
dqcom483 compare 123.999999999999999999456E-89 123.999999999999999999456E-89 -> 0
dqcom487 compare 123.999999999999999999456E+89 123.9999999999999999994560000000000E+89 -> 0
dqcom488 compare 123.999999999999999999456E-89 123.999999999999999999456000000000E-89 -> 0
dqcom489 compare 123.999999999999999999456E+89 123.99999999999999999945600000000E+89 -> 0
dqcom490 compare 123.999999999999999999456E-89 123.9999999999999999994560000000E-89 -> 0
dqcom491 compare 123.999999999999999999456E+89 123.999999999999999999456000000E+89 -> 0
dqcom492 compare 123.999999999999999999456E-89 123.99999999999999999945600000E-89 -> 0
dqcom493 compare 123.999999999999999999456E+89 123.9999999999999999994560000E+89 -> 0
dqcom494 compare 123.999999999999999999456E-89 123.999999999999999999456000E-89 -> 0
dqcom495 compare 123.999999999999999999456E+89 123.99999999999999999945600E+89 -> 0
dqcom496 compare 123.999999999999999999456E-89 123.9999999999999999994560E-89 -> 0
dqcom497 compare 123.999999999999999999456E+89 123.999999999999999999456E+89 -> 0

-- wide-ranging, around precision; signs equal
dqcom500 compare    1     1E-15    -> 1
dqcom501 compare    1     1E-14    -> 1
dqcom502 compare    1     1E-13    -> 1
dqcom503 compare    1     1E-12    -> 1
dqcom504 compare    1     1E-11    -> 1
dqcom505 compare    1     1E-10    -> 1
dqcom506 compare    1     1E-9     -> 1
dqcom507 compare    1     1E-8     -> 1
dqcom508 compare    1     1E-7     -> 1
dqcom509 compare    1     1E-6     -> 1
dqcom510 compare    1     1E-5     -> 1
dqcom511 compare    1     1E-4     -> 1
dqcom512 compare    1     1E-3     -> 1
dqcom513 compare    1     1E-2     -> 1
dqcom514 compare    1     1E-1     -> 1
dqcom515 compare    1     1E-0     -> 0
dqcom516 compare    1     1E+1     -> -1
dqcom517 compare    1     1E+2     -> -1
dqcom518 compare    1     1E+3     -> -1
dqcom519 compare    1     1E+4     -> -1
dqcom521 compare    1     1E+5     -> -1
dqcom522 compare    1     1E+6     -> -1
dqcom523 compare    1     1E+7     -> -1
dqcom524 compare    1     1E+8     -> -1
dqcom525 compare    1     1E+9     -> -1
dqcom526 compare    1     1E+10    -> -1
dqcom527 compare    1     1E+11    -> -1
dqcom528 compare    1     1E+12    -> -1
dqcom529 compare    1     1E+13    -> -1
dqcom530 compare    1     1E+14    -> -1
dqcom531 compare    1     1E+15    -> -1
-- LR swap
dqcom540 compare    1E-15  1       -> -1
dqcom541 compare    1E-14  1       -> -1
dqcom542 compare    1E-13  1       -> -1
dqcom543 compare    1E-12  1       -> -1
dqcom544 compare    1E-11  1       -> -1
dqcom545 compare    1E-10  1       -> -1
dqcom546 compare    1E-9   1       -> -1
dqcom547 compare    1E-8   1       -> -1
dqcom548 compare    1E-7   1       -> -1
dqcom549 compare    1E-6   1       -> -1
dqcom550 compare    1E-5   1       -> -1
dqcom551 compare    1E-4   1       -> -1
dqcom552 compare    1E-3   1       -> -1
dqcom553 compare    1E-2   1       -> -1
dqcom554 compare    1E-1   1       -> -1
dqcom555 compare    1E-0   1       ->  0
dqcom556 compare    1E+1   1       ->  1
dqcom557 compare    1E+2   1       ->  1
dqcom558 compare    1E+3   1       ->  1
dqcom559 compare    1E+4   1       ->  1
dqcom561 compare    1E+5   1       ->  1
dqcom562 compare    1E+6   1       ->  1
dqcom563 compare    1E+7   1       ->  1
dqcom564 compare    1E+8   1       ->  1
dqcom565 compare    1E+9   1       ->  1
dqcom566 compare    1E+10  1       ->  1
dqcom567 compare    1E+11  1       ->  1
dqcom568 compare    1E+12  1       ->  1
dqcom569 compare    1E+13  1       ->  1
dqcom570 compare    1E+14  1       ->  1
dqcom571 compare    1E+15  1       ->  1
-- similar with a useful coefficient, one side only
dqcom580 compare  0.000000987654321     1E-15    -> 1
dqcom581 compare  0.000000987654321     1E-14    -> 1
dqcom582 compare  0.000000987654321     1E-13    -> 1
dqcom583 compare  0.000000987654321     1E-12    -> 1
dqcom584 compare  0.000000987654321     1E-11    -> 1
dqcom585 compare  0.000000987654321     1E-10    -> 1
dqcom586 compare  0.000000987654321     1E-9     -> 1
dqcom587 compare  0.000000987654321     1E-8     -> 1
dqcom588 compare  0.000000987654321     1E-7     -> 1
dqcom589 compare  0.000000987654321     1E-6     -> -1
dqcom590 compare  0.000000987654321     1E-5     -> -1
dqcom591 compare  0.000000987654321     1E-4     -> -1
dqcom592 compare  0.000000987654321     1E-3     -> -1
dqcom593 compare  0.000000987654321     1E-2     -> -1
dqcom594 compare  0.000000987654321     1E-1     -> -1
dqcom595 compare  0.000000987654321     1E-0     -> -1
dqcom596 compare  0.000000987654321     1E+1     -> -1
dqcom597 compare  0.000000987654321     1E+2     -> -1
dqcom598 compare  0.000000987654321     1E+3     -> -1
dqcom599 compare  0.000000987654321     1E+4     -> -1

-- check some unit-y traps
dqcom600 compare   12            12.2345 -> -1
dqcom601 compare   12.0          12.2345 -> -1
dqcom602 compare   12.00         12.2345 -> -1
dqcom603 compare   12.000        12.2345 -> -1
dqcom604 compare   12.0000       12.2345 -> -1
dqcom605 compare   12.00000      12.2345 -> -1
dqcom606 compare   12.000000     12.2345 -> -1
dqcom607 compare   12.0000000    12.2345 -> -1
dqcom608 compare   12.00000000   12.2345 -> -1
dqcom609 compare   12.000000000  12.2345 -> -1
dqcom610 compare   12.1234 12            ->  1
dqcom611 compare   12.1234 12.0          ->  1
dqcom612 compare   12.1234 12.00         ->  1
dqcom613 compare   12.1234 12.000        ->  1
dqcom614 compare   12.1234 12.0000       ->  1
dqcom615 compare   12.1234 12.00000      ->  1
dqcom616 compare   12.1234 12.000000     ->  1
dqcom617 compare   12.1234 12.0000000    ->  1
dqcom618 compare   12.1234 12.00000000   ->  1
dqcom619 compare   12.1234 12.000000000  ->  1
dqcom620 compare  -12           -12.2345 ->  1
dqcom621 compare  -12.0         -12.2345 ->  1
dqcom622 compare  -12.00        -12.2345 ->  1
dqcom623 compare  -12.000       -12.2345 ->  1
dqcom624 compare  -12.0000      -12.2345 ->  1
dqcom625 compare  -12.00000     -12.2345 ->  1
dqcom626 compare  -12.000000    -12.2345 ->  1
dqcom627 compare  -12.0000000   -12.2345 ->  1
dqcom628 compare  -12.00000000  -12.2345 ->  1
dqcom629 compare  -12.000000000 -12.2345 ->  1
dqcom630 compare  -12.1234 -12           -> -1
dqcom631 compare  -12.1234 -12.0         -> -1
dqcom632 compare  -12.1234 -12.00        -> -1
dqcom633 compare  -12.1234 -12.000       -> -1
dqcom634 compare  -12.1234 -12.0000      -> -1
dqcom635 compare  -12.1234 -12.00000     -> -1
dqcom636 compare  -12.1234 -12.000000    -> -1
dqcom637 compare  -12.1234 -12.0000000   -> -1
dqcom638 compare  -12.1234 -12.00000000  -> -1
dqcom639 compare  -12.1234 -12.000000000 -> -1

-- extended zeros
dqcom640 compare   0     0   -> 0
dqcom641 compare   0    -0   -> 0
dqcom642 compare   0    -0.0 -> 0
dqcom643 compare   0     0.0 -> 0
dqcom644 compare  -0     0   -> 0
dqcom645 compare  -0    -0   -> 0
dqcom646 compare  -0    -0.0 -> 0
dqcom647 compare  -0     0.0 -> 0
dqcom648 compare   0.0   0   -> 0
dqcom649 compare   0.0  -0   -> 0
dqcom650 compare   0.0  -0.0 -> 0
dqcom651 compare   0.0   0.0 -> 0
dqcom652 compare  -0.0   0   -> 0
dqcom653 compare  -0.0  -0   -> 0
dqcom654 compare  -0.0  -0.0 -> 0
dqcom655 compare  -0.0   0.0 -> 0

dqcom656 compare  -0E1   0.0 -> 0
dqcom657 compare  -0E2   0.0 -> 0
dqcom658 compare   0E1   0.0 -> 0
dqcom659 compare   0E2   0.0 -> 0
dqcom660 compare  -0E1   0   -> 0
dqcom661 compare  -0E2   0   -> 0
dqcom662 compare   0E1   0   -> 0
dqcom663 compare   0E2   0   -> 0
dqcom664 compare  -0E1  -0E1 -> 0
dqcom665 compare  -0E2  -0E1 -> 0
dqcom666 compare   0E1  -0E1 -> 0
dqcom667 compare   0E2  -0E1 -> 0
dqcom668 compare  -0E1  -0E2 -> 0
dqcom669 compare  -0E2  -0E2 -> 0
dqcom670 compare   0E1  -0E2 -> 0
dqcom671 compare   0E2  -0E2 -> 0
dqcom672 compare  -0E1   0E1 -> 0
dqcom673 compare  -0E2   0E1 -> 0
dqcom674 compare   0E1   0E1 -> 0
dqcom675 compare   0E2   0E1 -> 0
dqcom676 compare  -0E1   0E2 -> 0
dqcom677 compare  -0E2   0E2 -> 0
dqcom678 compare   0E1   0E2 -> 0
dqcom679 compare   0E2   0E2 -> 0

-- trailing zeros; unit-y
dqcom680 compare   12    12           -> 0
dqcom681 compare   12    12.0         -> 0
dqcom682 compare   12    12.00        -> 0
dqcom683 compare   12    12.000       -> 0
dqcom684 compare   12    12.0000      -> 0
dqcom685 compare   12    12.00000     -> 0
dqcom686 compare   12    12.000000    -> 0
dqcom687 compare   12    12.0000000   -> 0
dqcom688 compare   12    12.00000000  -> 0
dqcom689 compare   12    12.000000000 -> 0
dqcom690 compare   12              12 -> 0
dqcom691 compare   12.0            12 -> 0
dqcom692 compare   12.00           12 -> 0
dqcom693 compare   12.000          12 -> 0
dqcom694 compare   12.0000         12 -> 0
dqcom695 compare   12.00000        12 -> 0
dqcom696 compare   12.000000       12 -> 0
dqcom697 compare   12.0000000      12 -> 0
dqcom698 compare   12.00000000     12 -> 0
dqcom699 compare   12.000000000    12 -> 0

-- first, second, & last digit
dqcom700 compare   1234567899999999999999999990123456 1234567899999999999999999990123455 -> 1
dqcom701 compare   1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
dqcom702 compare   1234567899999999999999999990123456 1234567899999999999999999990123457 -> -1
dqcom703 compare   1234567899999999999999999990123456 0234567899999999999999999990123456 -> 1
dqcom704 compare   1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
dqcom705 compare   1234567899999999999999999990123456 2234567899999999999999999990123456 -> -1
dqcom706 compare   1134567899999999999999999990123456 1034567899999999999999999990123456 -> 1
dqcom707 compare   1134567899999999999999999990123456 1134567899999999999999999990123456 -> 0
dqcom708 compare   1134567899999999999999999990123456 1234567899999999999999999990123456 -> -1

-- miscellaneous
dqcom721 compare 12345678000 1 -> 1
dqcom722 compare 1 12345678000 -> -1
dqcom723 compare 1234567800  1 -> 1
dqcom724 compare 1 1234567800  -> -1
dqcom725 compare 1234567890  1 -> 1
dqcom726 compare 1 1234567890  -> -1
dqcom727 compare 1234567891  1 -> 1
dqcom728 compare 1 1234567891  -> -1
dqcom729 compare 12345678901 1 -> 1
dqcom730 compare 1 12345678901 -> -1
dqcom731 compare 1234567896  1 -> 1
dqcom732 compare 1 1234567896  -> -1

-- residue cases at lower precision
dqcom740 compare  1  0.9999999  -> 1
dqcom741 compare  1  0.999999   -> 1
dqcom742 compare  1  0.99999    -> 1
dqcom743 compare  1  1.0000     -> 0
dqcom744 compare  1  1.00001    -> -1
dqcom745 compare  1  1.000001   -> -1
dqcom746 compare  1  1.0000001  -> -1
dqcom750 compare  0.9999999  1  -> -1
dqcom751 compare  0.999999   1  -> -1
dqcom752 compare  0.99999    1  -> -1
dqcom753 compare  1.0000     1  -> 0
dqcom754 compare  1.00001    1  -> 1
dqcom755 compare  1.000001   1  -> 1
dqcom756 compare  1.0000001  1  -> 1

-- Specials
dqcom780 compare  Inf  -Inf   ->  1
dqcom781 compare  Inf  -1000  ->  1
dqcom782 compare  Inf  -1     ->  1
dqcom783 compare  Inf  -0     ->  1
dqcom784 compare  Inf   0     ->  1
dqcom785 compare  Inf   1     ->  1
dqcom786 compare  Inf   1000  ->  1
dqcom787 compare  Inf   Inf   ->  0
dqcom788 compare -1000  Inf   -> -1
dqcom789 compare -Inf   Inf   -> -1
dqcom790 compare -1     Inf   -> -1
dqcom791 compare -0     Inf   -> -1
dqcom792 compare  0     Inf   -> -1
dqcom793 compare  1     Inf   -> -1
dqcom794 compare  1000  Inf   -> -1
dqcom795 compare  Inf   Inf   ->  0

dqcom800 compare -Inf  -Inf   ->  0
dqcom801 compare -Inf  -1000  -> -1
dqcom802 compare -Inf  -1     -> -1
dqcom803 compare -Inf  -0     -> -1
dqcom804 compare -Inf   0     -> -1
dqcom805 compare -Inf   1     -> -1
dqcom806 compare -Inf   1000  -> -1
dqcom807 compare -Inf   Inf   -> -1
dqcom808 compare -Inf  -Inf   ->  0
dqcom809 compare -1000 -Inf   ->  1
dqcom810 compare -1    -Inf   ->  1
dqcom811 compare -0    -Inf   ->  1
dqcom812 compare  0    -Inf   ->  1
dqcom813 compare  1    -Inf   ->  1
dqcom814 compare  1000 -Inf   ->  1
dqcom815 compare  Inf  -Inf   ->  1

dqcom821 compare  NaN -Inf    ->  NaN
dqcom822 compare  NaN -1000   ->  NaN
dqcom823 compare  NaN -1      ->  NaN
dqcom824 compare  NaN -0      ->  NaN
dqcom825 compare  NaN  0      ->  NaN
dqcom826 compare  NaN  1      ->  NaN
dqcom827 compare  NaN  1000   ->  NaN
dqcom828 compare  NaN  Inf    ->  NaN
dqcom829 compare  NaN  NaN    ->  NaN
dqcom830 compare -Inf  NaN    ->  NaN
dqcom831 compare -1000 NaN    ->  NaN
dqcom832 compare -1    NaN    ->  NaN
dqcom833 compare -0    NaN    ->  NaN
dqcom834 compare  0    NaN    ->  NaN
dqcom835 compare  1    NaN    ->  NaN
dqcom836 compare  1000 NaN    ->  NaN
dqcom837 compare  Inf  NaN    ->  NaN
dqcom838 compare -NaN -NaN    -> -NaN
dqcom839 compare +NaN -NaN    ->  NaN
dqcom840 compare -NaN +NaN    -> -NaN

dqcom841 compare  sNaN -Inf   ->  NaN  Invalid_operation
dqcom842 compare  sNaN -1000  ->  NaN  Invalid_operation
dqcom843 compare  sNaN -1     ->  NaN  Invalid_operation
dqcom844 compare  sNaN -0     ->  NaN  Invalid_operation
dqcom845 compare  sNaN  0     ->  NaN  Invalid_operation
dqcom846 compare  sNaN  1     ->  NaN  Invalid_operation
dqcom847 compare  sNaN  1000  ->  NaN  Invalid_operation
dqcom848 compare  sNaN  NaN   ->  NaN  Invalid_operation
dqcom849 compare  sNaN sNaN   ->  NaN  Invalid_operation
dqcom850 compare  NaN  sNaN   ->  NaN  Invalid_operation
dqcom851 compare -Inf  sNaN   ->  NaN  Invalid_operation
dqcom852 compare -1000 sNaN   ->  NaN  Invalid_operation
dqcom853 compare -1    sNaN   ->  NaN  Invalid_operation
dqcom854 compare -0    sNaN   ->  NaN  Invalid_operation
dqcom855 compare  0    sNaN   ->  NaN  Invalid_operation
dqcom856 compare  1    sNaN   ->  NaN  Invalid_operation
dqcom857 compare  1000 sNaN   ->  NaN  Invalid_operation
dqcom858 compare  Inf  sNaN   ->  NaN  Invalid_operation
dqcom859 compare  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqcom860 compare  NaN9 -Inf   ->  NaN9
dqcom861 compare  NaN8  999   ->  NaN8
dqcom862 compare  NaN77 Inf   ->  NaN77
dqcom863 compare -NaN67 NaN5  -> -NaN67
dqcom864 compare -Inf  -NaN4  -> -NaN4
dqcom865 compare -999  -NaN33 -> -NaN33
dqcom866 compare  Inf   NaN2  ->  NaN2
dqcom867 compare -NaN41 -NaN42 -> -NaN41
dqcom868 compare +NaN41 -NaN42 ->  NaN41
dqcom869 compare -NaN41 +NaN42 -> -NaN41
dqcom870 compare +NaN41 +NaN42 ->  NaN41

dqcom871 compare -sNaN99 -Inf    -> -NaN99 Invalid_operation
dqcom872 compare  sNaN98 -11     ->  NaN98 Invalid_operation
dqcom873 compare  sNaN97  NaN    ->  NaN97 Invalid_operation
dqcom874 compare  sNaN16 sNaN94  ->  NaN16 Invalid_operation
dqcom875 compare  NaN85  sNaN83  ->  NaN83 Invalid_operation
dqcom876 compare -Inf    sNaN92  ->  NaN92 Invalid_operation
dqcom877 compare  088    sNaN81  ->  NaN81 Invalid_operation
dqcom878 compare  Inf    sNaN90  ->  NaN90 Invalid_operation
dqcom879 compare  NaN   -sNaN89  -> -NaN89 Invalid_operation

-- wide range
dqcom880 compare +1.23456789012345E-0 9E+6144 -> -1
dqcom881 compare 9E+6144 +1.23456789012345E-0 ->  1
dqcom882 compare +0.100 9E-6143               ->  1
dqcom883 compare 9E-6143 +0.100               -> -1
dqcom885 compare -1.23456789012345E-0 9E+6144 -> -1
dqcom886 compare 9E+6144 -1.23456789012345E-0 ->  1
dqcom887 compare -0.100 9E-6143               -> -1
dqcom888 compare 9E-6143 -0.100               ->  1

-- signs
dqcom901 compare  1e+77  1e+11 ->  1
dqcom902 compare  1e+77 -1e+11 ->  1
dqcom903 compare -1e+77  1e+11 -> -1
dqcom904 compare -1e+77 -1e+11 -> -1
dqcom905 compare  1e-77  1e-11 -> -1
dqcom906 compare  1e-77 -1e-11 ->  1
dqcom907 compare -1e-77  1e-11 -> -1
dqcom908 compare -1e-77 -1e-11 ->  1

-- full alignment range, both ways
dqcomp1001 compare 1 1.000000000000000000000000000000000  -> 0
dqcomp1002 compare 1 1.00000000000000000000000000000000   -> 0
dqcomp1003 compare 1 1.0000000000000000000000000000000    -> 0
dqcomp1004 compare 1 1.000000000000000000000000000000     -> 0
dqcomp1005 compare 1 1.00000000000000000000000000000      -> 0
dqcomp1006 compare 1 1.0000000000000000000000000000       -> 0
dqcomp1007 compare 1 1.000000000000000000000000000        -> 0
dqcomp1008 compare 1 1.00000000000000000000000000         -> 0
dqcomp1009 compare 1 1.0000000000000000000000000          -> 0
dqcomp1010 compare 1 1.000000000000000000000000           -> 0
dqcomp1011 compare 1 1.00000000000000000000000            -> 0
dqcomp1012 compare 1 1.0000000000000000000000             -> 0
dqcomp1013 compare 1 1.000000000000000000000              -> 0
dqcomp1014 compare 1 1.00000000000000000000               -> 0
dqcomp1015 compare 1 1.0000000000000000000                -> 0
dqcomp1016 compare 1 1.000000000000000000                 -> 0
dqcomp1017 compare 1 1.00000000000000000                  -> 0
dqcomp1018 compare 1 1.0000000000000000                   -> 0
dqcomp1019 compare 1 1.000000000000000  -> 0
dqcomp1020 compare 1 1.00000000000000   -> 0
dqcomp1021 compare 1 1.0000000000000    -> 0
dqcomp1022 compare 1 1.000000000000     -> 0
dqcomp1023 compare 1 1.00000000000      -> 0
dqcomp1024 compare 1 1.0000000000       -> 0
dqcomp1025 compare 1 1.000000000        -> 0
dqcomp1026 compare 1 1.00000000         -> 0
dqcomp1027 compare 1 1.0000000          -> 0
dqcomp1028 compare 1 1.000000           -> 0
dqcomp1029 compare 1 1.00000            -> 0
dqcomp1030 compare 1 1.0000             -> 0
dqcomp1031 compare 1 1.000              -> 0
dqcomp1032 compare 1 1.00               -> 0
dqcomp1033 compare 1 1.0                -> 0

dqcomp1041 compare 1.000000000000000000000000000000000  1 -> 0
dqcomp1042 compare 1.00000000000000000000000000000000   1 -> 0
dqcomp1043 compare 1.0000000000000000000000000000000    1 -> 0
dqcomp1044 compare 1.000000000000000000000000000000     1 -> 0
dqcomp1045 compare 1.00000000000000000000000000000      1 -> 0
dqcomp1046 compare 1.0000000000000000000000000000       1 -> 0
dqcomp1047 compare 1.000000000000000000000000000        1 -> 0
dqcomp1048 compare 1.00000000000000000000000000         1 -> 0
dqcomp1049 compare 1.0000000000000000000000000          1 -> 0
dqcomp1050 compare 1.000000000000000000000000           1 -> 0
dqcomp1051 compare 1.00000000000000000000000            1 -> 0
dqcomp1052 compare 1.0000000000000000000000             1 -> 0
dqcomp1053 compare 1.000000000000000000000              1 -> 0
dqcomp1054 compare 1.00000000000000000000               1 -> 0
dqcomp1055 compare 1.0000000000000000000                1 -> 0
dqcomp1056 compare 1.000000000000000000                 1 -> 0
dqcomp1057 compare 1.00000000000000000                  1 -> 0
dqcomp1058 compare 1.0000000000000000                   1 -> 0
dqcomp1059 compare 1.000000000000000  1 -> 0
dqcomp1060 compare 1.00000000000000   1 -> 0
dqcomp1061 compare 1.0000000000000    1 -> 0
dqcomp1062 compare 1.000000000000     1 -> 0
dqcomp1063 compare 1.00000000000      1 -> 0
dqcomp1064 compare 1.0000000000       1 -> 0
dqcomp1065 compare 1.000000000        1 -> 0
dqcomp1066 compare 1.00000000         1 -> 0
dqcomp1067 compare 1.0000000          1 -> 0
dqcomp1068 compare 1.000000           1 -> 0
dqcomp1069 compare 1.00000            1 -> 0
dqcomp1070 compare 1.0000             1 -> 0
dqcomp1071 compare 1.000              1 -> 0
dqcomp1072 compare 1.00               1 -> 0
dqcomp1073 compare 1.0                1 -> 0

-- check MSD always detected non-zero
dqcomp1080 compare 0 0.000000000000000000000000000000000  -> 0
dqcomp1081 compare 0 1.000000000000000000000000000000000  -> -1
dqcomp1082 compare 0 2.000000000000000000000000000000000  -> -1
dqcomp1083 compare 0 3.000000000000000000000000000000000  -> -1
dqcomp1084 compare 0 4.000000000000000000000000000000000  -> -1
dqcomp1085 compare 0 5.000000000000000000000000000000000  -> -1
dqcomp1086 compare 0 6.000000000000000000000000000000000  -> -1
dqcomp1087 compare 0 7.000000000000000000000000000000000  -> -1
dqcomp1088 compare 0 8.000000000000000000000000000000000  -> -1
dqcomp1089 compare 0 9.000000000000000000000000000000000  -> -1
dqcomp1090 compare 0.000000000000000000000000000000000  0 -> 0
dqcomp1091 compare 1.000000000000000000000000000000000  0 -> 1
dqcomp1092 compare 2.000000000000000000000000000000000  0 -> 1
dqcomp1093 compare 3.000000000000000000000000000000000  0 -> 1
dqcomp1094 compare 4.000000000000000000000000000000000  0 -> 1
dqcomp1095 compare 5.000000000000000000000000000000000  0 -> 1
dqcomp1096 compare 6.000000000000000000000000000000000  0 -> 1
dqcomp1097 compare 7.000000000000000000000000000000000  0 -> 1
dqcomp1098 compare 8.000000000000000000000000000000000  0 -> 1
dqcomp1099 compare 9.000000000000000000000000000000000  0 -> 1

-- Null tests
dqcom990 compare 10  # -> NaN Invalid_operation
dqcom991 compare  # 10 -> NaN Invalid_operation

Added test/dectest/dqCompareSig.decTest.















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
------------------------------------------------------------------------
-- dqCompareSig.decTest -- decQuad comparison; all NaNs signal        --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Note that we cannot assume add/subtract tests cover paths adequately,
-- here, because the code might be quite different (comparison cannot
-- overflow or underflow, so actual subtractions are not necessary).

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks
dqcms001 comparesig  -2  -2  -> 0
dqcms002 comparesig  -2  -1  -> -1
dqcms003 comparesig  -2   0  -> -1
dqcms004 comparesig  -2   1  -> -1
dqcms005 comparesig  -2   2  -> -1
dqcms006 comparesig  -1  -2  -> 1
dqcms007 comparesig  -1  -1  -> 0
dqcms008 comparesig  -1   0  -> -1
dqcms009 comparesig  -1   1  -> -1
dqcms010 comparesig  -1   2  -> -1
dqcms011 comparesig   0  -2  -> 1
dqcms012 comparesig   0  -1  -> 1
dqcms013 comparesig   0   0  -> 0
dqcms014 comparesig   0   1  -> -1
dqcms015 comparesig   0   2  -> -1
dqcms016 comparesig   1  -2  -> 1
dqcms017 comparesig   1  -1  -> 1
dqcms018 comparesig   1   0  -> 1
dqcms019 comparesig   1   1  -> 0
dqcms020 comparesig   1   2  -> -1
dqcms021 comparesig   2  -2  -> 1
dqcms022 comparesig   2  -1  -> 1
dqcms023 comparesig   2   0  -> 1
dqcms025 comparesig   2   1  -> 1
dqcms026 comparesig   2   2  -> 0

dqcms031 comparesig  -20  -20  -> 0
dqcms032 comparesig  -20  -10  -> -1
dqcms033 comparesig  -20   00  -> -1
dqcms034 comparesig  -20   10  -> -1
dqcms035 comparesig  -20   20  -> -1
dqcms036 comparesig  -10  -20  -> 1
dqcms037 comparesig  -10  -10  -> 0
dqcms038 comparesig  -10   00  -> -1
dqcms039 comparesig  -10   10  -> -1
dqcms040 comparesig  -10   20  -> -1
dqcms041 comparesig   00  -20  -> 1
dqcms042 comparesig   00  -10  -> 1
dqcms043 comparesig   00   00  -> 0
dqcms044 comparesig   00   10  -> -1
dqcms045 comparesig   00   20  -> -1
dqcms046 comparesig   10  -20  -> 1
dqcms047 comparesig   10  -10  -> 1
dqcms048 comparesig   10   00  -> 1
dqcms049 comparesig   10   10  -> 0
dqcms050 comparesig   10   20  -> -1
dqcms051 comparesig   20  -20  -> 1
dqcms052 comparesig   20  -10  -> 1
dqcms053 comparesig   20   00  -> 1
dqcms055 comparesig   20   10  -> 1
dqcms056 comparesig   20   20  -> 0

dqcms061 comparesig  -2.0  -2.0  -> 0
dqcms062 comparesig  -2.0  -1.0  -> -1
dqcms063 comparesig  -2.0   0.0  -> -1
dqcms064 comparesig  -2.0   1.0  -> -1
dqcms065 comparesig  -2.0   2.0  -> -1
dqcms066 comparesig  -1.0  -2.0  -> 1
dqcms067 comparesig  -1.0  -1.0  -> 0
dqcms068 comparesig  -1.0   0.0  -> -1
dqcms069 comparesig  -1.0   1.0  -> -1
dqcms070 comparesig  -1.0   2.0  -> -1
dqcms071 comparesig   0.0  -2.0  -> 1
dqcms072 comparesig   0.0  -1.0  -> 1
dqcms073 comparesig   0.0   0.0  -> 0
dqcms074 comparesig   0.0   1.0  -> -1
dqcms075 comparesig   0.0   2.0  -> -1
dqcms076 comparesig   1.0  -2.0  -> 1
dqcms077 comparesig   1.0  -1.0  -> 1
dqcms078 comparesig   1.0   0.0  -> 1
dqcms079 comparesig   1.0   1.0  -> 0
dqcms080 comparesig   1.0   2.0  -> -1
dqcms081 comparesig   2.0  -2.0  -> 1
dqcms082 comparesig   2.0  -1.0  -> 1
dqcms083 comparesig   2.0   0.0  -> 1
dqcms085 comparesig   2.0   1.0  -> 1
dqcms086 comparesig   2.0   2.0  -> 0

-- now some cases which might overflow if subtract were used
dqcms090 comparesig  9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144  -> 0
dqcms091 comparesig -9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144  -> -1
dqcms092 comparesig  9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 1
dqcms093 comparesig -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0

-- some differing length/exponent cases
dqcms100 comparesig   7.0    7.0    -> 0
dqcms101 comparesig   7.0    7      -> 0
dqcms102 comparesig   7      7.0    -> 0
dqcms103 comparesig   7E+0   7.0    -> 0
dqcms104 comparesig   70E-1  7.0    -> 0
dqcms105 comparesig   0.7E+1 7      -> 0
dqcms106 comparesig   70E-1  7      -> 0
dqcms107 comparesig   7.0    7E+0   -> 0
dqcms108 comparesig   7.0    70E-1  -> 0
dqcms109 comparesig   7      0.7E+1 -> 0
dqcms110 comparesig   7      70E-1  -> 0

dqcms120 comparesig   8.0    7.0    -> 1
dqcms121 comparesig   8.0    7      -> 1
dqcms122 comparesig   8      7.0    -> 1
dqcms123 comparesig   8E+0   7.0    -> 1
dqcms124 comparesig   80E-1  7.0    -> 1
dqcms125 comparesig   0.8E+1 7      -> 1
dqcms126 comparesig   80E-1  7      -> 1
dqcms127 comparesig   8.0    7E+0   -> 1
dqcms128 comparesig   8.0    70E-1  -> 1
dqcms129 comparesig   8      0.7E+1  -> 1
dqcms130 comparesig   8      70E-1  -> 1

dqcms140 comparesig   8.0    9.0    -> -1
dqcms141 comparesig   8.0    9      -> -1
dqcms142 comparesig   8      9.0    -> -1
dqcms143 comparesig   8E+0   9.0    -> -1
dqcms144 comparesig   80E-1  9.0    -> -1
dqcms145 comparesig   0.8E+1 9      -> -1
dqcms146 comparesig   80E-1  9      -> -1
dqcms147 comparesig   8.0    9E+0   -> -1
dqcms148 comparesig   8.0    90E-1  -> -1
dqcms149 comparesig   8      0.9E+1 -> -1
dqcms150 comparesig   8      90E-1  -> -1

-- and again, with sign changes -+ ..
dqcms200 comparesig  -7.0    7.0    -> -1
dqcms201 comparesig  -7.0    7      -> -1
dqcms202 comparesig  -7      7.0    -> -1
dqcms203 comparesig  -7E+0   7.0    -> -1
dqcms204 comparesig  -70E-1  7.0    -> -1
dqcms205 comparesig  -0.7E+1 7      -> -1
dqcms206 comparesig  -70E-1  7      -> -1
dqcms207 comparesig  -7.0    7E+0   -> -1
dqcms208 comparesig  -7.0    70E-1  -> -1
dqcms209 comparesig  -7      0.7E+1 -> -1
dqcms210 comparesig  -7      70E-1  -> -1

dqcms220 comparesig  -8.0    7.0    -> -1
dqcms221 comparesig  -8.0    7      -> -1
dqcms222 comparesig  -8      7.0    -> -1
dqcms223 comparesig  -8E+0   7.0    -> -1
dqcms224 comparesig  -80E-1  7.0    -> -1
dqcms225 comparesig  -0.8E+1 7      -> -1
dqcms226 comparesig  -80E-1  7      -> -1
dqcms227 comparesig  -8.0    7E+0   -> -1
dqcms228 comparesig  -8.0    70E-1  -> -1
dqcms229 comparesig  -8      0.7E+1 -> -1
dqcms230 comparesig  -8      70E-1  -> -1

dqcms240 comparesig  -8.0    9.0    -> -1
dqcms241 comparesig  -8.0    9      -> -1
dqcms242 comparesig  -8      9.0    -> -1
dqcms243 comparesig  -8E+0   9.0    -> -1
dqcms244 comparesig  -80E-1  9.0    -> -1
dqcms245 comparesig  -0.8E+1 9      -> -1
dqcms246 comparesig  -80E-1  9      -> -1
dqcms247 comparesig  -8.0    9E+0   -> -1
dqcms248 comparesig  -8.0    90E-1  -> -1
dqcms249 comparesig  -8      0.9E+1 -> -1
dqcms250 comparesig  -8      90E-1  -> -1

-- and again, with sign changes +- ..
dqcms300 comparesig   7.0    -7.0    -> 1
dqcms301 comparesig   7.0    -7      -> 1
dqcms302 comparesig   7      -7.0    -> 1
dqcms303 comparesig   7E+0   -7.0    -> 1
dqcms304 comparesig   70E-1  -7.0    -> 1
dqcms305 comparesig   .7E+1  -7      -> 1
dqcms306 comparesig   70E-1  -7      -> 1
dqcms307 comparesig   7.0    -7E+0   -> 1
dqcms308 comparesig   7.0    -70E-1  -> 1
dqcms309 comparesig   7      -.7E+1  -> 1
dqcms310 comparesig   7      -70E-1  -> 1

dqcms320 comparesig   8.0    -7.0    -> 1
dqcms321 comparesig   8.0    -7      -> 1
dqcms322 comparesig   8      -7.0    -> 1
dqcms323 comparesig   8E+0   -7.0    -> 1
dqcms324 comparesig   80E-1  -7.0    -> 1
dqcms325 comparesig   .8E+1  -7      -> 1
dqcms326 comparesig   80E-1  -7      -> 1
dqcms327 comparesig   8.0    -7E+0   -> 1
dqcms328 comparesig   8.0    -70E-1  -> 1
dqcms329 comparesig   8      -.7E+1  -> 1
dqcms330 comparesig   8      -70E-1  -> 1

dqcms340 comparesig   8.0    -9.0    -> 1
dqcms341 comparesig   8.0    -9      -> 1
dqcms342 comparesig   8      -9.0    -> 1
dqcms343 comparesig   8E+0   -9.0    -> 1
dqcms344 comparesig   80E-1  -9.0    -> 1
dqcms345 comparesig   .8E+1  -9      -> 1
dqcms346 comparesig   80E-1  -9      -> 1
dqcms347 comparesig   8.0    -9E+0   -> 1
dqcms348 comparesig   8.0    -90E-1  -> 1
dqcms349 comparesig   8      -.9E+1  -> 1
dqcms350 comparesig   8      -90E-1  -> 1

-- and again, with sign changes -- ..
dqcms400 comparesig   -7.0    -7.0    -> 0
dqcms401 comparesig   -7.0    -7      -> 0
dqcms402 comparesig   -7      -7.0    -> 0
dqcms403 comparesig   -7E+0   -7.0    -> 0
dqcms404 comparesig   -70E-1  -7.0    -> 0
dqcms405 comparesig   -.7E+1  -7      -> 0
dqcms406 comparesig   -70E-1  -7      -> 0
dqcms407 comparesig   -7.0    -7E+0   -> 0
dqcms408 comparesig   -7.0    -70E-1  -> 0
dqcms409 comparesig   -7      -.7E+1  -> 0
dqcms410 comparesig   -7      -70E-1  -> 0

dqcms420 comparesig   -8.0    -7.0    -> -1
dqcms421 comparesig   -8.0    -7      -> -1
dqcms422 comparesig   -8      -7.0    -> -1
dqcms423 comparesig   -8E+0   -7.0    -> -1
dqcms424 comparesig   -80E-1  -7.0    -> -1
dqcms425 comparesig   -.8E+1  -7      -> -1
dqcms426 comparesig   -80E-1  -7      -> -1
dqcms427 comparesig   -8.0    -7E+0   -> -1
dqcms428 comparesig   -8.0    -70E-1  -> -1
dqcms429 comparesig   -8      -.7E+1  -> -1
dqcms430 comparesig   -8      -70E-1  -> -1

dqcms440 comparesig   -8.0    -9.0    -> 1
dqcms441 comparesig   -8.0    -9      -> 1
dqcms442 comparesig   -8      -9.0    -> 1
dqcms443 comparesig   -8E+0   -9.0    -> 1
dqcms444 comparesig   -80E-1  -9.0    -> 1
dqcms445 comparesig   -.8E+1  -9      -> 1
dqcms446 comparesig   -80E-1  -9      -> 1
dqcms447 comparesig   -8.0    -9E+0   -> 1
dqcms448 comparesig   -8.0    -90E-1  -> 1
dqcms449 comparesig   -8      -.9E+1  -> 1
dqcms450 comparesig   -8      -90E-1  -> 1


-- testcases that subtract to lots of zeros at boundaries [pgr]
dqcms473 comparesig 123.9999999999999999994560000000000E-89 123.999999999999999999456E-89 -> 0
dqcms474 comparesig 123.999999999999999999456000000000E+89 123.999999999999999999456E+89 -> 0
dqcms475 comparesig 123.99999999999999999945600000000E-89 123.999999999999999999456E-89 -> 0
dqcms476 comparesig 123.9999999999999999994560000000E+89 123.999999999999999999456E+89 -> 0
dqcms477 comparesig 123.999999999999999999456000000E-89 123.999999999999999999456E-89 -> 0
dqcms478 comparesig 123.99999999999999999945600000E+89 123.999999999999999999456E+89 -> 0
dqcms479 comparesig 123.9999999999999999994560000E-89 123.999999999999999999456E-89 -> 0
dqcms480 comparesig 123.999999999999999999456000E+89 123.999999999999999999456E+89 -> 0
dqcms481 comparesig 123.99999999999999999945600E-89 123.999999999999999999456E-89 -> 0
dqcms482 comparesig 123.9999999999999999994560E+89 123.999999999999999999456E+89 -> 0
dqcms483 comparesig 123.999999999999999999456E-89 123.999999999999999999456E-89 -> 0
dqcms487 comparesig 123.999999999999999999456E+89 123.9999999999999999994560000000000E+89 -> 0
dqcms488 comparesig 123.999999999999999999456E-89 123.999999999999999999456000000000E-89 -> 0
dqcms489 comparesig 123.999999999999999999456E+89 123.99999999999999999945600000000E+89 -> 0
dqcms490 comparesig 123.999999999999999999456E-89 123.9999999999999999994560000000E-89 -> 0
dqcms491 comparesig 123.999999999999999999456E+89 123.999999999999999999456000000E+89 -> 0
dqcms492 comparesig 123.999999999999999999456E-89 123.99999999999999999945600000E-89 -> 0
dqcms493 comparesig 123.999999999999999999456E+89 123.9999999999999999994560000E+89 -> 0
dqcms494 comparesig 123.999999999999999999456E-89 123.999999999999999999456000E-89 -> 0
dqcms495 comparesig 123.999999999999999999456E+89 123.99999999999999999945600E+89 -> 0
dqcms496 comparesig 123.999999999999999999456E-89 123.9999999999999999994560E-89 -> 0
dqcms497 comparesig 123.999999999999999999456E+89 123.999999999999999999456E+89 -> 0

-- wide-ranging, around precision; signs equal
dqcms500 comparesig    1     1E-15    -> 1
dqcms501 comparesig    1     1E-14    -> 1
dqcms502 comparesig    1     1E-13    -> 1
dqcms503 comparesig    1     1E-12    -> 1
dqcms504 comparesig    1     1E-11    -> 1
dqcms505 comparesig    1     1E-10    -> 1
dqcms506 comparesig    1     1E-9     -> 1
dqcms507 comparesig    1     1E-8     -> 1
dqcms508 comparesig    1     1E-7     -> 1
dqcms509 comparesig    1     1E-6     -> 1
dqcms510 comparesig    1     1E-5     -> 1
dqcms511 comparesig    1     1E-4     -> 1
dqcms512 comparesig    1     1E-3     -> 1
dqcms513 comparesig    1     1E-2     -> 1
dqcms514 comparesig    1     1E-1     -> 1
dqcms515 comparesig    1     1E-0     -> 0
dqcms516 comparesig    1     1E+1     -> -1
dqcms517 comparesig    1     1E+2     -> -1
dqcms518 comparesig    1     1E+3     -> -1
dqcms519 comparesig    1     1E+4     -> -1
dqcms521 comparesig    1     1E+5     -> -1
dqcms522 comparesig    1     1E+6     -> -1
dqcms523 comparesig    1     1E+7     -> -1
dqcms524 comparesig    1     1E+8     -> -1
dqcms525 comparesig    1     1E+9     -> -1
dqcms526 comparesig    1     1E+10    -> -1
dqcms527 comparesig    1     1E+11    -> -1
dqcms528 comparesig    1     1E+12    -> -1
dqcms529 comparesig    1     1E+13    -> -1
dqcms530 comparesig    1     1E+14    -> -1
dqcms531 comparesig    1     1E+15    -> -1
-- LR swap
dqcms540 comparesig    1E-15  1       -> -1
dqcms541 comparesig    1E-14  1       -> -1
dqcms542 comparesig    1E-13  1       -> -1
dqcms543 comparesig    1E-12  1       -> -1
dqcms544 comparesig    1E-11  1       -> -1
dqcms545 comparesig    1E-10  1       -> -1
dqcms546 comparesig    1E-9   1       -> -1
dqcms547 comparesig    1E-8   1       -> -1
dqcms548 comparesig    1E-7   1       -> -1
dqcms549 comparesig    1E-6   1       -> -1
dqcms550 comparesig    1E-5   1       -> -1
dqcms551 comparesig    1E-4   1       -> -1
dqcms552 comparesig    1E-3   1       -> -1
dqcms553 comparesig    1E-2   1       -> -1
dqcms554 comparesig    1E-1   1       -> -1
dqcms555 comparesig    1E-0   1       ->  0
dqcms556 comparesig    1E+1   1       ->  1
dqcms557 comparesig    1E+2   1       ->  1
dqcms558 comparesig    1E+3   1       ->  1
dqcms559 comparesig    1E+4   1       ->  1
dqcms561 comparesig    1E+5   1       ->  1
dqcms562 comparesig    1E+6   1       ->  1
dqcms563 comparesig    1E+7   1       ->  1
dqcms564 comparesig    1E+8   1       ->  1
dqcms565 comparesig    1E+9   1       ->  1
dqcms566 comparesig    1E+10  1       ->  1
dqcms567 comparesig    1E+11  1       ->  1
dqcms568 comparesig    1E+12  1       ->  1
dqcms569 comparesig    1E+13  1       ->  1
dqcms570 comparesig    1E+14  1       ->  1
dqcms571 comparesig    1E+15  1       ->  1
-- similar with a useful coefficient, one side only
dqcms580 comparesig  0.000000987654321     1E-15    -> 1
dqcms581 comparesig  0.000000987654321     1E-14    -> 1
dqcms582 comparesig  0.000000987654321     1E-13    -> 1
dqcms583 comparesig  0.000000987654321     1E-12    -> 1
dqcms584 comparesig  0.000000987654321     1E-11    -> 1
dqcms585 comparesig  0.000000987654321     1E-10    -> 1
dqcms586 comparesig  0.000000987654321     1E-9     -> 1
dqcms587 comparesig  0.000000987654321     1E-8     -> 1
dqcms588 comparesig  0.000000987654321     1E-7     -> 1
dqcms589 comparesig  0.000000987654321     1E-6     -> -1
dqcms590 comparesig  0.000000987654321     1E-5     -> -1
dqcms591 comparesig  0.000000987654321     1E-4     -> -1
dqcms592 comparesig  0.000000987654321     1E-3     -> -1
dqcms593 comparesig  0.000000987654321     1E-2     -> -1
dqcms594 comparesig  0.000000987654321     1E-1     -> -1
dqcms595 comparesig  0.000000987654321     1E-0     -> -1
dqcms596 comparesig  0.000000987654321     1E+1     -> -1
dqcms597 comparesig  0.000000987654321     1E+2     -> -1
dqcms598 comparesig  0.000000987654321     1E+3     -> -1
dqcms599 comparesig  0.000000987654321     1E+4     -> -1

-- check some unit-y traps
dqcms600 comparesig   12            12.2345 -> -1
dqcms601 comparesig   12.0          12.2345 -> -1
dqcms602 comparesig   12.00         12.2345 -> -1
dqcms603 comparesig   12.000        12.2345 -> -1
dqcms604 comparesig   12.0000       12.2345 -> -1
dqcms605 comparesig   12.00000      12.2345 -> -1
dqcms606 comparesig   12.000000     12.2345 -> -1
dqcms607 comparesig   12.0000000    12.2345 -> -1
dqcms608 comparesig   12.00000000   12.2345 -> -1
dqcms609 comparesig   12.000000000  12.2345 -> -1
dqcms610 comparesig   12.1234 12            ->  1
dqcms611 comparesig   12.1234 12.0          ->  1
dqcms612 comparesig   12.1234 12.00         ->  1
dqcms613 comparesig   12.1234 12.000        ->  1
dqcms614 comparesig   12.1234 12.0000       ->  1
dqcms615 comparesig   12.1234 12.00000      ->  1
dqcms616 comparesig   12.1234 12.000000     ->  1
dqcms617 comparesig   12.1234 12.0000000    ->  1
dqcms618 comparesig   12.1234 12.00000000   ->  1
dqcms619 comparesig   12.1234 12.000000000  ->  1
dqcms620 comparesig  -12           -12.2345 ->  1
dqcms621 comparesig  -12.0         -12.2345 ->  1
dqcms622 comparesig  -12.00        -12.2345 ->  1
dqcms623 comparesig  -12.000       -12.2345 ->  1
dqcms624 comparesig  -12.0000      -12.2345 ->  1
dqcms625 comparesig  -12.00000     -12.2345 ->  1
dqcms626 comparesig  -12.000000    -12.2345 ->  1
dqcms627 comparesig  -12.0000000   -12.2345 ->  1
dqcms628 comparesig  -12.00000000  -12.2345 ->  1
dqcms629 comparesig  -12.000000000 -12.2345 ->  1
dqcms630 comparesig  -12.1234 -12           -> -1
dqcms631 comparesig  -12.1234 -12.0         -> -1
dqcms632 comparesig  -12.1234 -12.00        -> -1
dqcms633 comparesig  -12.1234 -12.000       -> -1
dqcms634 comparesig  -12.1234 -12.0000      -> -1
dqcms635 comparesig  -12.1234 -12.00000     -> -1
dqcms636 comparesig  -12.1234 -12.000000    -> -1
dqcms637 comparesig  -12.1234 -12.0000000   -> -1
dqcms638 comparesig  -12.1234 -12.00000000  -> -1
dqcms639 comparesig  -12.1234 -12.000000000 -> -1

-- extended zeros
dqcms640 comparesig   0     0   -> 0
dqcms641 comparesig   0    -0   -> 0
dqcms642 comparesig   0    -0.0 -> 0
dqcms643 comparesig   0     0.0 -> 0
dqcms644 comparesig  -0     0   -> 0
dqcms645 comparesig  -0    -0   -> 0
dqcms646 comparesig  -0    -0.0 -> 0
dqcms647 comparesig  -0     0.0 -> 0
dqcms648 comparesig   0.0   0   -> 0
dqcms649 comparesig   0.0  -0   -> 0
dqcms650 comparesig   0.0  -0.0 -> 0
dqcms651 comparesig   0.0   0.0 -> 0
dqcms652 comparesig  -0.0   0   -> 0
dqcms653 comparesig  -0.0  -0   -> 0
dqcms654 comparesig  -0.0  -0.0 -> 0
dqcms655 comparesig  -0.0   0.0 -> 0

dqcms656 comparesig  -0E1   0.0 -> 0
dqcms657 comparesig  -0E2   0.0 -> 0
dqcms658 comparesig   0E1   0.0 -> 0
dqcms659 comparesig   0E2   0.0 -> 0
dqcms660 comparesig  -0E1   0   -> 0
dqcms661 comparesig  -0E2   0   -> 0
dqcms662 comparesig   0E1   0   -> 0
dqcms663 comparesig   0E2   0   -> 0
dqcms664 comparesig  -0E1  -0E1 -> 0
dqcms665 comparesig  -0E2  -0E1 -> 0
dqcms666 comparesig   0E1  -0E1 -> 0
dqcms667 comparesig   0E2  -0E1 -> 0
dqcms668 comparesig  -0E1  -0E2 -> 0
dqcms669 comparesig  -0E2  -0E2 -> 0
dqcms670 comparesig   0E1  -0E2 -> 0
dqcms671 comparesig   0E2  -0E2 -> 0
dqcms672 comparesig  -0E1   0E1 -> 0
dqcms673 comparesig  -0E2   0E1 -> 0
dqcms674 comparesig   0E1   0E1 -> 0
dqcms675 comparesig   0E2   0E1 -> 0
dqcms676 comparesig  -0E1   0E2 -> 0
dqcms677 comparesig  -0E2   0E2 -> 0
dqcms678 comparesig   0E1   0E2 -> 0
dqcms679 comparesig   0E2   0E2 -> 0

-- trailing zeros; unit-y
dqcms680 comparesig   12    12           -> 0
dqcms681 comparesig   12    12.0         -> 0
dqcms682 comparesig   12    12.00        -> 0
dqcms683 comparesig   12    12.000       -> 0
dqcms684 comparesig   12    12.0000      -> 0
dqcms685 comparesig   12    12.00000     -> 0
dqcms686 comparesig   12    12.000000    -> 0
dqcms687 comparesig   12    12.0000000   -> 0
dqcms688 comparesig   12    12.00000000  -> 0
dqcms689 comparesig   12    12.000000000 -> 0
dqcms690 comparesig   12              12 -> 0
dqcms691 comparesig   12.0            12 -> 0
dqcms692 comparesig   12.00           12 -> 0
dqcms693 comparesig   12.000          12 -> 0
dqcms694 comparesig   12.0000         12 -> 0
dqcms695 comparesig   12.00000        12 -> 0
dqcms696 comparesig   12.000000       12 -> 0
dqcms697 comparesig   12.0000000      12 -> 0
dqcms698 comparesig   12.00000000     12 -> 0
dqcms699 comparesig   12.000000000    12 -> 0

-- first, second, & last digit
dqcms700 comparesig   1234567899999999999999999990123456 1234567899999999999999999990123455 -> 1
dqcms701 comparesig   1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
dqcms702 comparesig   1234567899999999999999999990123456 1234567899999999999999999990123457 -> -1
dqcms703 comparesig   1234567899999999999999999990123456 0234567899999999999999999990123456 -> 1
dqcms704 comparesig   1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
dqcms705 comparesig   1234567899999999999999999990123456 2234567899999999999999999990123456 -> -1
dqcms706 comparesig   1134567899999999999999999990123456 1034567899999999999999999990123456 -> 1
dqcms707 comparesig   1134567899999999999999999990123456 1134567899999999999999999990123456 -> 0
dqcms708 comparesig   1134567899999999999999999990123456 1234567899999999999999999990123456 -> -1

-- miscellaneous
dqcms721 comparesig 12345678000 1 -> 1
dqcms722 comparesig 1 12345678000 -> -1
dqcms723 comparesig 1234567800  1 -> 1
dqcms724 comparesig 1 1234567800  -> -1
dqcms725 comparesig 1234567890  1 -> 1
dqcms726 comparesig 1 1234567890  -> -1
dqcms727 comparesig 1234567891  1 -> 1
dqcms728 comparesig 1 1234567891  -> -1
dqcms729 comparesig 12345678901 1 -> 1
dqcms730 comparesig 1 12345678901 -> -1
dqcms731 comparesig 1234567896  1 -> 1
dqcms732 comparesig 1 1234567896  -> -1

-- residue cases at lower precision
dqcms740 comparesig  1  0.9999999  -> 1
dqcms741 comparesig  1  0.999999   -> 1
dqcms742 comparesig  1  0.99999    -> 1
dqcms743 comparesig  1  1.0000     -> 0
dqcms744 comparesig  1  1.00001    -> -1
dqcms745 comparesig  1  1.000001   -> -1
dqcms746 comparesig  1  1.0000001  -> -1
dqcms750 comparesig  0.9999999  1  -> -1
dqcms751 comparesig  0.999999   1  -> -1
dqcms752 comparesig  0.99999    1  -> -1
dqcms753 comparesig  1.0000     1  -> 0
dqcms754 comparesig  1.00001    1  -> 1
dqcms755 comparesig  1.000001   1  -> 1
dqcms756 comparesig  1.0000001  1  -> 1

-- Specials
dqcms780 comparesig  Inf  -Inf   ->  1
dqcms781 comparesig  Inf  -1000  ->  1
dqcms782 comparesig  Inf  -1     ->  1
dqcms783 comparesig  Inf  -0     ->  1
dqcms784 comparesig  Inf   0     ->  1
dqcms785 comparesig  Inf   1     ->  1
dqcms786 comparesig  Inf   1000  ->  1
dqcms787 comparesig  Inf   Inf   ->  0
dqcms788 comparesig -1000  Inf   -> -1
dqcms789 comparesig -Inf   Inf   -> -1
dqcms790 comparesig -1     Inf   -> -1
dqcms791 comparesig -0     Inf   -> -1
dqcms792 comparesig  0     Inf   -> -1
dqcms793 comparesig  1     Inf   -> -1
dqcms794 comparesig  1000  Inf   -> -1
dqcms795 comparesig  Inf   Inf   ->  0

dqcms800 comparesig -Inf  -Inf   ->  0
dqcms801 comparesig -Inf  -1000  -> -1
dqcms802 comparesig -Inf  -1     -> -1
dqcms803 comparesig -Inf  -0     -> -1
dqcms804 comparesig -Inf   0     -> -1
dqcms805 comparesig -Inf   1     -> -1
dqcms806 comparesig -Inf   1000  -> -1
dqcms807 comparesig -Inf   Inf   -> -1
dqcms808 comparesig -Inf  -Inf   ->  0
dqcms809 comparesig -1000 -Inf   ->  1
dqcms810 comparesig -1    -Inf   ->  1
dqcms811 comparesig -0    -Inf   ->  1
dqcms812 comparesig  0    -Inf   ->  1
dqcms813 comparesig  1    -Inf   ->  1
dqcms814 comparesig  1000 -Inf   ->  1
dqcms815 comparesig  Inf  -Inf   ->  1

dqcms821 comparesig  NaN -Inf    ->  NaN  Invalid_operation
dqcms822 comparesig  NaN -1000   ->  NaN  Invalid_operation
dqcms823 comparesig  NaN -1      ->  NaN  Invalid_operation
dqcms824 comparesig  NaN -0      ->  NaN  Invalid_operation
dqcms825 comparesig  NaN  0      ->  NaN  Invalid_operation
dqcms826 comparesig  NaN  1      ->  NaN  Invalid_operation
dqcms827 comparesig  NaN  1000   ->  NaN  Invalid_operation
dqcms828 comparesig  NaN  Inf    ->  NaN  Invalid_operation
dqcms829 comparesig  NaN  NaN    ->  NaN  Invalid_operation
dqcms830 comparesig -Inf  NaN    ->  NaN  Invalid_operation
dqcms831 comparesig -1000 NaN    ->  NaN  Invalid_operation
dqcms832 comparesig -1    NaN    ->  NaN  Invalid_operation
dqcms833 comparesig -0    NaN    ->  NaN  Invalid_operation
dqcms834 comparesig  0    NaN    ->  NaN  Invalid_operation
dqcms835 comparesig  1    NaN    ->  NaN  Invalid_operation
dqcms836 comparesig  1000 NaN    ->  NaN  Invalid_operation
dqcms837 comparesig  Inf  NaN    ->  NaN  Invalid_operation
dqcms838 comparesig -NaN -NaN    -> -NaN  Invalid_operation
dqcms839 comparesig +NaN -NaN    ->  NaN  Invalid_operation
dqcms840 comparesig -NaN +NaN    -> -NaN  Invalid_operation

dqcms841 comparesig  sNaN -Inf   ->  NaN  Invalid_operation
dqcms842 comparesig  sNaN -1000  ->  NaN  Invalid_operation
dqcms843 comparesig  sNaN -1     ->  NaN  Invalid_operation
dqcms844 comparesig  sNaN -0     ->  NaN  Invalid_operation
dqcms845 comparesig  sNaN  0     ->  NaN  Invalid_operation
dqcms846 comparesig  sNaN  1     ->  NaN  Invalid_operation
dqcms847 comparesig  sNaN  1000  ->  NaN  Invalid_operation
dqcms848 comparesig  sNaN  NaN   ->  NaN  Invalid_operation
dqcms849 comparesig  sNaN sNaN   ->  NaN  Invalid_operation
dqcms850 comparesig  NaN  sNaN   ->  NaN  Invalid_operation
dqcms851 comparesig -Inf  sNaN   ->  NaN  Invalid_operation
dqcms852 comparesig -1000 sNaN   ->  NaN  Invalid_operation
dqcms853 comparesig -1    sNaN   ->  NaN  Invalid_operation
dqcms854 comparesig -0    sNaN   ->  NaN  Invalid_operation
dqcms855 comparesig  0    sNaN   ->  NaN  Invalid_operation
dqcms856 comparesig  1    sNaN   ->  NaN  Invalid_operation
dqcms857 comparesig  1000 sNaN   ->  NaN  Invalid_operation
dqcms858 comparesig  Inf  sNaN   ->  NaN  Invalid_operation
dqcms859 comparesig  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqcms860 comparesig  NaN9 -Inf   ->  NaN9    Invalid_operation
dqcms861 comparesig  NaN8  999   ->  NaN8    Invalid_operation
dqcms862 comparesig  NaN77 Inf   ->  NaN77   Invalid_operation
dqcms863 comparesig -NaN67 NaN5  -> -NaN67   Invalid_operation
dqcms864 comparesig -Inf  -NaN4  -> -NaN4    Invalid_operation
dqcms865 comparesig -999  -NaN33 -> -NaN33   Invalid_operation
dqcms866 comparesig  Inf   NaN2  ->  NaN2    Invalid_operation
dqcms867 comparesig -NaN41 -NaN42 -> -NaN41  Invalid_operation
dqcms868 comparesig +NaN41 -NaN42 ->  NaN41  Invalid_operation
dqcms869 comparesig -NaN41 +NaN42 -> -NaN41  Invalid_operation
dqcms870 comparesig +NaN41 +NaN42 ->  NaN41  Invalid_operation

dqcms871 comparesig -sNaN99 -Inf    -> -NaN99 Invalid_operation
dqcms872 comparesig  sNaN98 -11     ->  NaN98 Invalid_operation
dqcms873 comparesig  sNaN97  NaN    ->  NaN97 Invalid_operation
dqcms874 comparesig  sNaN16 sNaN94  ->  NaN16 Invalid_operation
dqcms875 comparesig  NaN85  sNaN83  ->  NaN83 Invalid_operation
dqcms876 comparesig -Inf    sNaN92  ->  NaN92 Invalid_operation
dqcms877 comparesig  088    sNaN81  ->  NaN81 Invalid_operation
dqcms878 comparesig  Inf    sNaN90  ->  NaN90 Invalid_operation
dqcms879 comparesig  NaN   -sNaN89  -> -NaN89 Invalid_operation

-- wide range
dqcms880 comparesig +1.23456789012345E-0 9E+6144 -> -1
dqcms881 comparesig 9E+6144 +1.23456789012345E-0 ->  1
dqcms882 comparesig +0.100 9E-6143               ->  1
dqcms883 comparesig 9E-6143 +0.100               -> -1
dqcms885 comparesig -1.23456789012345E-0 9E+6144 -> -1
dqcms886 comparesig 9E+6144 -1.23456789012345E-0 ->  1
dqcms887 comparesig -0.100 9E-6143               -> -1
dqcms888 comparesig 9E-6143 -0.100               ->  1

-- signs
dqcms901 comparesig  1e+77  1e+11 ->  1
dqcms902 comparesig  1e+77 -1e+11 ->  1
dqcms903 comparesig -1e+77  1e+11 -> -1
dqcms904 comparesig -1e+77 -1e+11 -> -1
dqcms905 comparesig  1e-77  1e-11 -> -1
dqcms906 comparesig  1e-77 -1e-11 ->  1
dqcms907 comparesig -1e-77  1e-11 -> -1
dqcms908 comparesig -1e-77 -1e-11 ->  1

-- Null tests
dqcms990 comparesig 10  # -> NaN Invalid_operation
dqcms991 comparesig  # 10 -> NaN Invalid_operation

Added test/dectest/dqCompareTotal.decTest.





































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
------------------------------------------------------------------------
-- dqCompareTotal.decTest -- decQuad comparison using total ordering  --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Note that we cannot assume add/subtract tests cover paths adequately,
-- here, because the code might be quite different (comparison cannot
-- overflow or underflow, so actual subtractions are not necessary).
-- Similarly, comparetotal will have some radically different paths
-- than compare.

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks
dqcot001 comparetotal  -2  -2  -> 0
dqcot002 comparetotal  -2  -1  -> -1
dqcot003 comparetotal  -2   0  -> -1
dqcot004 comparetotal  -2   1  -> -1
dqcot005 comparetotal  -2   2  -> -1
dqcot006 comparetotal  -1  -2  -> 1
dqcot007 comparetotal  -1  -1  -> 0
dqcot008 comparetotal  -1   0  -> -1
dqcot009 comparetotal  -1   1  -> -1
dqcot010 comparetotal  -1   2  -> -1
dqcot011 comparetotal   0  -2  -> 1
dqcot012 comparetotal   0  -1  -> 1
dqcot013 comparetotal   0   0  -> 0
dqcot014 comparetotal   0   1  -> -1
dqcot015 comparetotal   0   2  -> -1
dqcot016 comparetotal   1  -2  -> 1
dqcot017 comparetotal   1  -1  -> 1
dqcot018 comparetotal   1   0  -> 1
dqcot019 comparetotal   1   1  -> 0
dqcot020 comparetotal   1   2  -> -1
dqcot021 comparetotal   2  -2  -> 1
dqcot022 comparetotal   2  -1  -> 1
dqcot023 comparetotal   2   0  -> 1
dqcot025 comparetotal   2   1  -> 1
dqcot026 comparetotal   2   2  -> 0

dqcot031 comparetotal  -20  -20  -> 0
dqcot032 comparetotal  -20  -10  -> -1
dqcot033 comparetotal  -20   00  -> -1
dqcot034 comparetotal  -20   10  -> -1
dqcot035 comparetotal  -20   20  -> -1
dqcot036 comparetotal  -10  -20  -> 1
dqcot037 comparetotal  -10  -10  -> 0
dqcot038 comparetotal  -10   00  -> -1
dqcot039 comparetotal  -10   10  -> -1
dqcot040 comparetotal  -10   20  -> -1
dqcot041 comparetotal   00  -20  -> 1
dqcot042 comparetotal   00  -10  -> 1
dqcot043 comparetotal   00   00  -> 0
dqcot044 comparetotal   00   10  -> -1
dqcot045 comparetotal   00   20  -> -1
dqcot046 comparetotal   10  -20  -> 1
dqcot047 comparetotal   10  -10  -> 1
dqcot048 comparetotal   10   00  -> 1
dqcot049 comparetotal   10   10  -> 0
dqcot050 comparetotal   10   20  -> -1
dqcot051 comparetotal   20  -20  -> 1
dqcot052 comparetotal   20  -10  -> 1
dqcot053 comparetotal   20   00  -> 1
dqcot055 comparetotal   20   10  -> 1
dqcot056 comparetotal   20   20  -> 0

dqcot061 comparetotal  -2.0  -2.0  -> 0
dqcot062 comparetotal  -2.0  -1.0  -> -1
dqcot063 comparetotal  -2.0   0.0  -> -1
dqcot064 comparetotal  -2.0   1.0  -> -1
dqcot065 comparetotal  -2.0   2.0  -> -1
dqcot066 comparetotal  -1.0  -2.0  -> 1
dqcot067 comparetotal  -1.0  -1.0  -> 0
dqcot068 comparetotal  -1.0   0.0  -> -1
dqcot069 comparetotal  -1.0   1.0  -> -1
dqcot070 comparetotal  -1.0   2.0  -> -1
dqcot071 comparetotal   0.0  -2.0  -> 1
dqcot072 comparetotal   0.0  -1.0  -> 1
dqcot073 comparetotal   0.0   0.0  -> 0
dqcot074 comparetotal   0.0   1.0  -> -1
dqcot075 comparetotal   0.0   2.0  -> -1
dqcot076 comparetotal   1.0  -2.0  -> 1
dqcot077 comparetotal   1.0  -1.0  -> 1
dqcot078 comparetotal   1.0   0.0  -> 1
dqcot079 comparetotal   1.0   1.0  -> 0
dqcot080 comparetotal   1.0   2.0  -> -1
dqcot081 comparetotal   2.0  -2.0  -> 1
dqcot082 comparetotal   2.0  -1.0  -> 1
dqcot083 comparetotal   2.0   0.0  -> 1
dqcot085 comparetotal   2.0   1.0  -> 1
dqcot086 comparetotal   2.0   2.0  -> 0

-- now some cases which might overflow if subtract were used
dqcot090 comparetotal  9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144  -> 0
dqcot091 comparetotal -9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144  -> -1
dqcot092 comparetotal  9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 1
dqcot093 comparetotal -9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0

-- some differing length/exponent cases
-- in this first group, compare would compare all equal
dqcot100 comparetotal   7.0    7.0    -> 0
dqcot101 comparetotal   7.0    7      -> -1
dqcot102 comparetotal   7      7.0    -> 1
dqcot103 comparetotal   7E+0   7.0    -> 1
dqcot104 comparetotal   70E-1  7.0    -> 0
dqcot105 comparetotal   0.7E+1 7      -> 0
dqcot106 comparetotal   70E-1  7      -> -1
dqcot107 comparetotal   7.0    7E+0   -> -1
dqcot108 comparetotal   7.0    70E-1  -> 0
dqcot109 comparetotal   7      0.7E+1 -> 0
dqcot110 comparetotal   7      70E-1  -> 1

dqcot120 comparetotal   8.0    7.0    -> 1
dqcot121 comparetotal   8.0    7      -> 1
dqcot122 comparetotal   8      7.0    -> 1
dqcot123 comparetotal   8E+0   7.0    -> 1
dqcot124 comparetotal   80E-1  7.0    -> 1
dqcot125 comparetotal   0.8E+1 7      -> 1
dqcot126 comparetotal   80E-1  7      -> 1
dqcot127 comparetotal   8.0    7E+0   -> 1
dqcot128 comparetotal   8.0    70E-1  -> 1
dqcot129 comparetotal   8      0.7E+1  -> 1
dqcot130 comparetotal   8      70E-1  -> 1

dqcot140 comparetotal   8.0    9.0    -> -1
dqcot141 comparetotal   8.0    9      -> -1
dqcot142 comparetotal   8      9.0    -> -1
dqcot143 comparetotal   8E+0   9.0    -> -1
dqcot144 comparetotal   80E-1  9.0    -> -1
dqcot145 comparetotal   0.8E+1 9      -> -1
dqcot146 comparetotal   80E-1  9      -> -1
dqcot147 comparetotal   8.0    9E+0   -> -1
dqcot148 comparetotal   8.0    90E-1  -> -1
dqcot149 comparetotal   8      0.9E+1 -> -1
dqcot150 comparetotal   8      90E-1  -> -1

-- and again, with sign changes -+ ..
dqcot200 comparetotal  -7.0    7.0    -> -1
dqcot201 comparetotal  -7.0    7      -> -1
dqcot202 comparetotal  -7      7.0    -> -1
dqcot203 comparetotal  -7E+0   7.0    -> -1
dqcot204 comparetotal  -70E-1  7.0    -> -1
dqcot205 comparetotal  -0.7E+1 7      -> -1
dqcot206 comparetotal  -70E-1  7      -> -1
dqcot207 comparetotal  -7.0    7E+0   -> -1
dqcot208 comparetotal  -7.0    70E-1  -> -1
dqcot209 comparetotal  -7      0.7E+1 -> -1
dqcot210 comparetotal  -7      70E-1  -> -1

dqcot220 comparetotal  -8.0    7.0    -> -1
dqcot221 comparetotal  -8.0    7      -> -1
dqcot222 comparetotal  -8      7.0    -> -1
dqcot223 comparetotal  -8E+0   7.0    -> -1
dqcot224 comparetotal  -80E-1  7.0    -> -1
dqcot225 comparetotal  -0.8E+1 7      -> -1
dqcot226 comparetotal  -80E-1  7      -> -1
dqcot227 comparetotal  -8.0    7E+0   -> -1
dqcot228 comparetotal  -8.0    70E-1  -> -1
dqcot229 comparetotal  -8      0.7E+1 -> -1
dqcot230 comparetotal  -8      70E-1  -> -1

dqcot240 comparetotal  -8.0    9.0    -> -1
dqcot241 comparetotal  -8.0    9      -> -1
dqcot242 comparetotal  -8      9.0    -> -1
dqcot243 comparetotal  -8E+0   9.0    -> -1
dqcot244 comparetotal  -80E-1  9.0    -> -1
dqcot245 comparetotal  -0.8E+1 9      -> -1
dqcot246 comparetotal  -80E-1  9      -> -1
dqcot247 comparetotal  -8.0    9E+0   -> -1
dqcot248 comparetotal  -8.0    90E-1  -> -1
dqcot249 comparetotal  -8      0.9E+1 -> -1
dqcot250 comparetotal  -8      90E-1  -> -1

-- and again, with sign changes +- ..
dqcot300 comparetotal   7.0    -7.0    -> 1
dqcot301 comparetotal   7.0    -7      -> 1
dqcot302 comparetotal   7      -7.0    -> 1
dqcot303 comparetotal   7E+0   -7.0    -> 1
dqcot304 comparetotal   70E-1  -7.0    -> 1
dqcot305 comparetotal   .7E+1  -7      -> 1
dqcot306 comparetotal   70E-1  -7      -> 1
dqcot307 comparetotal   7.0    -7E+0   -> 1
dqcot308 comparetotal   7.0    -70E-1  -> 1
dqcot309 comparetotal   7      -.7E+1  -> 1
dqcot310 comparetotal   7      -70E-1  -> 1

dqcot320 comparetotal   8.0    -7.0    -> 1
dqcot321 comparetotal   8.0    -7      -> 1
dqcot322 comparetotal   8      -7.0    -> 1
dqcot323 comparetotal   8E+0   -7.0    -> 1
dqcot324 comparetotal   80E-1  -7.0    -> 1
dqcot325 comparetotal   .8E+1  -7      -> 1
dqcot326 comparetotal   80E-1  -7      -> 1
dqcot327 comparetotal   8.0    -7E+0   -> 1
dqcot328 comparetotal   8.0    -70E-1  -> 1
dqcot329 comparetotal   8      -.7E+1  -> 1
dqcot330 comparetotal   8      -70E-1  -> 1

dqcot340 comparetotal   8.0    -9.0    -> 1
dqcot341 comparetotal   8.0    -9      -> 1
dqcot342 comparetotal   8      -9.0    -> 1
dqcot343 comparetotal   8E+0   -9.0    -> 1
dqcot344 comparetotal   80E-1  -9.0    -> 1
dqcot345 comparetotal   .8E+1  -9      -> 1
dqcot346 comparetotal   80E-1  -9      -> 1
dqcot347 comparetotal   8.0    -9E+0   -> 1
dqcot348 comparetotal   8.0    -90E-1  -> 1
dqcot349 comparetotal   8      -.9E+1  -> 1
dqcot350 comparetotal   8      -90E-1  -> 1

-- and again, with sign changes -- ..
dqcot400 comparetotal   -7.0    -7.0    -> 0
dqcot401 comparetotal   -7.0    -7      -> 1
dqcot402 comparetotal   -7      -7.0    -> -1
dqcot403 comparetotal   -7E+0   -7.0    -> -1
dqcot404 comparetotal   -70E-1  -7.0    -> 0
dqcot405 comparetotal   -.7E+1  -7      -> 0
dqcot406 comparetotal   -70E-1  -7      -> 1
dqcot407 comparetotal   -7.0    -7E+0   -> 1
dqcot408 comparetotal   -7.0    -70E-1  -> 0
dqcot409 comparetotal   -7      -.7E+1  -> 0
dqcot410 comparetotal   -7      -70E-1  -> -1

dqcot420 comparetotal   -8.0    -7.0    -> -1
dqcot421 comparetotal   -8.0    -7      -> -1
dqcot422 comparetotal   -8      -7.0    -> -1
dqcot423 comparetotal   -8E+0   -7.0    -> -1
dqcot424 comparetotal   -80E-1  -7.0    -> -1
dqcot425 comparetotal   -.8E+1  -7      -> -1
dqcot426 comparetotal   -80E-1  -7      -> -1
dqcot427 comparetotal   -8.0    -7E+0   -> -1
dqcot428 comparetotal   -8.0    -70E-1  -> -1
dqcot429 comparetotal   -8      -.7E+1  -> -1
dqcot430 comparetotal   -8      -70E-1  -> -1

dqcot440 comparetotal   -8.0    -9.0    -> 1
dqcot441 comparetotal   -8.0    -9      -> 1
dqcot442 comparetotal   -8      -9.0    -> 1
dqcot443 comparetotal   -8E+0   -9.0    -> 1
dqcot444 comparetotal   -80E-1  -9.0    -> 1
dqcot445 comparetotal   -.8E+1  -9      -> 1
dqcot446 comparetotal   -80E-1  -9      -> 1
dqcot447 comparetotal   -8.0    -9E+0   -> 1
dqcot448 comparetotal   -8.0    -90E-1  -> 1
dqcot449 comparetotal   -8      -.9E+1  -> 1
dqcot450 comparetotal   -8      -90E-1  -> 1


-- testcases that subtract to lots of zeros at boundaries [pgr]
dqcot473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
dqcot474 comparetotal 123.456000000000E+89 123.456E+89 -> -1
dqcot475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
dqcot476 comparetotal 123.4560000000E+89 123.456E+89 -> -1
dqcot477 comparetotal 123.456000000E-89 123.456E-89 -> -1
dqcot478 comparetotal 123.45600000E+89 123.456E+89 -> -1
dqcot479 comparetotal 123.4560000E-89 123.456E-89 -> -1
dqcot480 comparetotal 123.456000E+89 123.456E+89 -> -1
dqcot481 comparetotal 123.45600E-89 123.456E-89 -> -1
dqcot482 comparetotal 123.4560E+89 123.456E+89 -> -1
dqcot483 comparetotal 123.456E-89 123.456E-89 -> 0
dqcot487 comparetotal 123.456E+89 123.4560000000000E+89 -> 1
dqcot488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
dqcot489 comparetotal 123.456E+89 123.45600000000E+89 -> 1
dqcot490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
dqcot491 comparetotal 123.456E+89 123.456000000E+89 -> 1
dqcot492 comparetotal 123.456E-89 123.45600000E-89 -> 1
dqcot493 comparetotal 123.456E+89 123.4560000E+89 -> 1
dqcot494 comparetotal 123.456E-89 123.456000E-89 -> 1
dqcot495 comparetotal 123.456E+89 123.45600E+89 -> 1
dqcot496 comparetotal 123.456E-89 123.4560E-89 -> 1
dqcot497 comparetotal 123.456E+89 123.456E+89 -> 0

-- wide-ranging, around precision; signs equal
dqcot498 comparetotal    1     1E-17    -> 1
dqcot499 comparetotal    1     1E-16    -> 1
dqcot500 comparetotal    1     1E-15    -> 1
dqcot501 comparetotal    1     1E-14    -> 1
dqcot502 comparetotal    1     1E-13    -> 1
dqcot503 comparetotal    1     1E-12    -> 1
dqcot504 comparetotal    1     1E-11    -> 1
dqcot505 comparetotal    1     1E-10    -> 1
dqcot506 comparetotal    1     1E-9     -> 1
dqcot507 comparetotal    1     1E-8     -> 1
dqcot508 comparetotal    1     1E-7     -> 1
dqcot509 comparetotal    1     1E-6     -> 1
dqcot510 comparetotal    1     1E-5     -> 1
dqcot511 comparetotal    1     1E-4     -> 1
dqcot512 comparetotal    1     1E-3     -> 1
dqcot513 comparetotal    1     1E-2     -> 1
dqcot514 comparetotal    1     1E-1     -> 1
dqcot515 comparetotal    1     1E-0     -> 0
dqcot516 comparetotal    1     1E+1     -> -1
dqcot517 comparetotal    1     1E+2     -> -1
dqcot518 comparetotal    1     1E+3     -> -1
dqcot519 comparetotal    1     1E+4     -> -1
dqcot521 comparetotal    1     1E+5     -> -1
dqcot522 comparetotal    1     1E+6     -> -1
dqcot523 comparetotal    1     1E+7     -> -1
dqcot524 comparetotal    1     1E+8     -> -1
dqcot525 comparetotal    1     1E+9     -> -1
dqcot526 comparetotal    1     1E+10    -> -1
dqcot527 comparetotal    1     1E+11    -> -1
dqcot528 comparetotal    1     1E+12    -> -1
dqcot529 comparetotal    1     1E+13    -> -1
dqcot530 comparetotal    1     1E+14    -> -1
dqcot531 comparetotal    1     1E+15    -> -1
dqcot532 comparetotal    1     1E+16    -> -1
dqcot533 comparetotal    1     1E+17    -> -1
-- LR swap
dqcot538 comparetotal    1E-17  1       -> -1
dqcot539 comparetotal    1E-16  1       -> -1
dqcot540 comparetotal    1E-15  1       -> -1
dqcot541 comparetotal    1E-14  1       -> -1
dqcot542 comparetotal    1E-13  1       -> -1
dqcot543 comparetotal    1E-12  1       -> -1
dqcot544 comparetotal    1E-11  1       -> -1
dqcot545 comparetotal    1E-10  1       -> -1
dqcot546 comparetotal    1E-9   1       -> -1
dqcot547 comparetotal    1E-8   1       -> -1
dqcot548 comparetotal    1E-7   1       -> -1
dqcot549 comparetotal    1E-6   1       -> -1
dqcot550 comparetotal    1E-5   1       -> -1
dqcot551 comparetotal    1E-4   1       -> -1
dqcot552 comparetotal    1E-3   1       -> -1
dqcot553 comparetotal    1E-2   1       -> -1
dqcot554 comparetotal    1E-1   1       -> -1
dqcot555 comparetotal    1E-0   1       ->  0
dqcot556 comparetotal    1E+1   1       ->  1
dqcot557 comparetotal    1E+2   1       ->  1
dqcot558 comparetotal    1E+3   1       ->  1
dqcot559 comparetotal    1E+4   1       ->  1
dqcot561 comparetotal    1E+5   1       ->  1
dqcot562 comparetotal    1E+6   1       ->  1
dqcot563 comparetotal    1E+7   1       ->  1
dqcot564 comparetotal    1E+8   1       ->  1
dqcot565 comparetotal    1E+9   1       ->  1
dqcot566 comparetotal    1E+10  1       ->  1
dqcot567 comparetotal    1E+11  1       ->  1
dqcot568 comparetotal    1E+12  1       ->  1
dqcot569 comparetotal    1E+13  1       ->  1
dqcot570 comparetotal    1E+14  1       ->  1
dqcot571 comparetotal    1E+15  1       ->  1
dqcot572 comparetotal    1E+16  1       ->  1
dqcot573 comparetotal    1E+17  1       ->  1
-- similar with a useful coefficient, one side only
dqcot578 comparetotal  0.000000987654321     1E-17    -> 1
dqcot579 comparetotal  0.000000987654321     1E-16    -> 1
dqcot580 comparetotal  0.000000987654321     1E-15    -> 1
dqcot581 comparetotal  0.000000987654321     1E-14    -> 1
dqcot582 comparetotal  0.000000987654321     1E-13    -> 1
dqcot583 comparetotal  0.000000987654321     1E-12    -> 1
dqcot584 comparetotal  0.000000987654321     1E-11    -> 1
dqcot585 comparetotal  0.000000987654321     1E-10    -> 1
dqcot586 comparetotal  0.000000987654321     1E-9     -> 1
dqcot587 comparetotal  0.000000987654321     1E-8     -> 1
dqcot588 comparetotal  0.000000987654321     1E-7     -> 1
dqcot589 comparetotal  0.000000987654321     1E-6     -> -1
dqcot590 comparetotal  0.000000987654321     1E-5     -> -1
dqcot591 comparetotal  0.000000987654321     1E-4     -> -1
dqcot592 comparetotal  0.000000987654321     1E-3     -> -1
dqcot593 comparetotal  0.000000987654321     1E-2     -> -1
dqcot594 comparetotal  0.000000987654321     1E-1     -> -1
dqcot595 comparetotal  0.000000987654321     1E-0     -> -1
dqcot596 comparetotal  0.000000987654321     1E+1     -> -1
dqcot597 comparetotal  0.000000987654321     1E+2     -> -1
dqcot598 comparetotal  0.000000987654321     1E+3     -> -1
dqcot599 comparetotal  0.000000987654321     1E+4     -> -1

-- check some unit-y traps
dqcot600 comparetotal   12            12.2345 -> -1
dqcot601 comparetotal   12.0          12.2345 -> -1
dqcot602 comparetotal   12.00         12.2345 -> -1
dqcot603 comparetotal   12.000        12.2345 -> -1
dqcot604 comparetotal   12.0000       12.2345 -> -1
dqcot605 comparetotal   12.00000      12.2345 -> -1
dqcot606 comparetotal   12.000000     12.2345 -> -1
dqcot607 comparetotal   12.0000000    12.2345 -> -1
dqcot608 comparetotal   12.00000000   12.2345 -> -1
dqcot609 comparetotal   12.000000000  12.2345 -> -1
dqcot610 comparetotal   12.1234 12            ->  1
dqcot611 comparetotal   12.1234 12.0          ->  1
dqcot612 comparetotal   12.1234 12.00         ->  1
dqcot613 comparetotal   12.1234 12.000        ->  1
dqcot614 comparetotal   12.1234 12.0000       ->  1
dqcot615 comparetotal   12.1234 12.00000      ->  1
dqcot616 comparetotal   12.1234 12.000000     ->  1
dqcot617 comparetotal   12.1234 12.0000000    ->  1
dqcot618 comparetotal   12.1234 12.00000000   ->  1
dqcot619 comparetotal   12.1234 12.000000000  ->  1
dqcot620 comparetotal  -12           -12.2345 ->  1
dqcot621 comparetotal  -12.0         -12.2345 ->  1
dqcot622 comparetotal  -12.00        -12.2345 ->  1
dqcot623 comparetotal  -12.000       -12.2345 ->  1
dqcot624 comparetotal  -12.0000      -12.2345 ->  1
dqcot625 comparetotal  -12.00000     -12.2345 ->  1
dqcot626 comparetotal  -12.000000    -12.2345 ->  1
dqcot627 comparetotal  -12.0000000   -12.2345 ->  1
dqcot628 comparetotal  -12.00000000  -12.2345 ->  1
dqcot629 comparetotal  -12.000000000 -12.2345 ->  1
dqcot630 comparetotal  -12.1234 -12           -> -1
dqcot631 comparetotal  -12.1234 -12.0         -> -1
dqcot632 comparetotal  -12.1234 -12.00        -> -1
dqcot633 comparetotal  -12.1234 -12.000       -> -1
dqcot634 comparetotal  -12.1234 -12.0000      -> -1
dqcot635 comparetotal  -12.1234 -12.00000     -> -1
dqcot636 comparetotal  -12.1234 -12.000000    -> -1
dqcot637 comparetotal  -12.1234 -12.0000000   -> -1
dqcot638 comparetotal  -12.1234 -12.00000000  -> -1
dqcot639 comparetotal  -12.1234 -12.000000000 -> -1

-- extended zeros
dqcot640 comparetotal   0     0   -> 0
dqcot641 comparetotal   0    -0   -> 1
dqcot642 comparetotal   0    -0.0 -> 1
dqcot643 comparetotal   0     0.0 -> 1
dqcot644 comparetotal  -0     0   -> -1
dqcot645 comparetotal  -0    -0   -> 0
dqcot646 comparetotal  -0    -0.0 -> -1
dqcot647 comparetotal  -0     0.0 -> -1
dqcot648 comparetotal   0.0   0   -> -1
dqcot649 comparetotal   0.0  -0   -> 1
dqcot650 comparetotal   0.0  -0.0 -> 1
dqcot651 comparetotal   0.0   0.0 -> 0
dqcot652 comparetotal  -0.0   0   -> -1
dqcot653 comparetotal  -0.0  -0   -> 1
dqcot654 comparetotal  -0.0  -0.0 -> 0
dqcot655 comparetotal  -0.0   0.0 -> -1

dqcot656 comparetotal  -0E1   0.0 -> -1
dqcot657 comparetotal  -0E2   0.0 -> -1
dqcot658 comparetotal   0E1   0.0 -> 1
dqcot659 comparetotal   0E2   0.0 -> 1
dqcot660 comparetotal  -0E1   0   -> -1
dqcot661 comparetotal  -0E2   0   -> -1
dqcot662 comparetotal   0E1   0   -> 1
dqcot663 comparetotal   0E2   0   -> 1
dqcot664 comparetotal  -0E1  -0E1 -> 0
dqcot665 comparetotal  -0E2  -0E1 -> -1
dqcot666 comparetotal   0E1  -0E1 -> 1
dqcot667 comparetotal   0E2  -0E1 -> 1
dqcot668 comparetotal  -0E1  -0E2 -> 1
dqcot669 comparetotal  -0E2  -0E2 -> 0
dqcot670 comparetotal   0E1  -0E2 -> 1
dqcot671 comparetotal   0E2  -0E2 -> 1
dqcot672 comparetotal  -0E1   0E1 -> -1
dqcot673 comparetotal  -0E2   0E1 -> -1
dqcot674 comparetotal   0E1   0E1 -> 0
dqcot675 comparetotal   0E2   0E1 -> 1
dqcot676 comparetotal  -0E1   0E2 -> -1
dqcot677 comparetotal  -0E2   0E2 -> -1
dqcot678 comparetotal   0E1   0E2 -> -1
dqcot679 comparetotal   0E2   0E2 -> 0

-- trailing zeros; unit-y
dqcot680 comparetotal   12    12           -> 0
dqcot681 comparetotal   12    12.0         -> 1
dqcot682 comparetotal   12    12.00        -> 1
dqcot683 comparetotal   12    12.000       -> 1
dqcot684 comparetotal   12    12.0000      -> 1
dqcot685 comparetotal   12    12.00000     -> 1
dqcot686 comparetotal   12    12.000000    -> 1
dqcot687 comparetotal   12    12.0000000   -> 1
dqcot688 comparetotal   12    12.00000000  -> 1
dqcot689 comparetotal   12    12.000000000 -> 1
dqcot690 comparetotal   12              12 -> 0
dqcot691 comparetotal   12.0            12 -> -1
dqcot692 comparetotal   12.00           12 -> -1
dqcot693 comparetotal   12.000          12 -> -1
dqcot694 comparetotal   12.0000         12 -> -1
dqcot695 comparetotal   12.00000        12 -> -1
dqcot696 comparetotal   12.000000       12 -> -1
dqcot697 comparetotal   12.0000000      12 -> -1
dqcot698 comparetotal   12.00000000     12 -> -1
dqcot699 comparetotal   12.000000000    12 -> -1

-- old long operand checks
dqcot701 comparetotal 12345678000  1 ->  1
dqcot702 comparetotal 1 12345678000  -> -1
dqcot703 comparetotal 1234567800   1 ->  1
dqcot704 comparetotal 1 1234567800   -> -1
dqcot705 comparetotal 1234567890   1 ->  1
dqcot706 comparetotal 1 1234567890   -> -1
dqcot707 comparetotal 1234567891   1 ->  1
dqcot708 comparetotal 1 1234567891   -> -1
dqcot709 comparetotal 12345678901  1 ->  1
dqcot710 comparetotal 1 12345678901  -> -1
dqcot711 comparetotal 1234567896   1 ->  1
dqcot712 comparetotal 1 1234567896   -> -1
dqcot713 comparetotal -1234567891  1 -> -1
dqcot714 comparetotal 1 -1234567891  ->  1
dqcot715 comparetotal -12345678901 1 -> -1
dqcot716 comparetotal 1 -12345678901 ->  1
dqcot717 comparetotal -1234567896  1 -> -1
dqcot718 comparetotal 1 -1234567896  ->  1

-- old residue cases
dqcot740 comparetotal  1  0.9999999  -> 1
dqcot741 comparetotal  1  0.999999   -> 1
dqcot742 comparetotal  1  0.99999    -> 1
dqcot743 comparetotal  1  1.0000     -> 1
dqcot744 comparetotal  1  1.00001    -> -1
dqcot745 comparetotal  1  1.000001   -> -1
dqcot746 comparetotal  1  1.0000001  -> -1
dqcot750 comparetotal  0.9999999  1  -> -1
dqcot751 comparetotal  0.999999   1  -> -1
dqcot752 comparetotal  0.99999    1  -> -1
dqcot753 comparetotal  1.0000     1  -> -1
dqcot754 comparetotal  1.00001    1  -> 1
dqcot755 comparetotal  1.000001   1  -> 1
dqcot756 comparetotal  1.0000001  1  -> 1

-- Specials
dqcot780 comparetotal  Inf  -Inf   ->  1
dqcot781 comparetotal  Inf  -1000  ->  1
dqcot782 comparetotal  Inf  -1     ->  1
dqcot783 comparetotal  Inf  -0     ->  1
dqcot784 comparetotal  Inf   0     ->  1
dqcot785 comparetotal  Inf   1     ->  1
dqcot786 comparetotal  Inf   1000  ->  1
dqcot787 comparetotal  Inf   Inf   ->  0
dqcot788 comparetotal -1000  Inf   -> -1
dqcot789 comparetotal -Inf   Inf   -> -1
dqcot790 comparetotal -1     Inf   -> -1
dqcot791 comparetotal -0     Inf   -> -1
dqcot792 comparetotal  0     Inf   -> -1
dqcot793 comparetotal  1     Inf   -> -1
dqcot794 comparetotal  1000  Inf   -> -1
dqcot795 comparetotal  Inf   Inf   ->  0

dqcot800 comparetotal -Inf  -Inf   ->  0
dqcot801 comparetotal -Inf  -1000  -> -1
dqcot802 comparetotal -Inf  -1     -> -1
dqcot803 comparetotal -Inf  -0     -> -1
dqcot804 comparetotal -Inf   0     -> -1
dqcot805 comparetotal -Inf   1     -> -1
dqcot806 comparetotal -Inf   1000  -> -1
dqcot807 comparetotal -Inf   Inf   -> -1
dqcot808 comparetotal -Inf  -Inf   ->  0
dqcot809 comparetotal -1000 -Inf   ->  1
dqcot810 comparetotal -1    -Inf   ->  1
dqcot811 comparetotal -0    -Inf   ->  1
dqcot812 comparetotal  0    -Inf   ->  1
dqcot813 comparetotal  1    -Inf   ->  1
dqcot814 comparetotal  1000 -Inf   ->  1
dqcot815 comparetotal  Inf  -Inf   ->  1

dqcot821 comparetotal  NaN -Inf    ->  1
dqcot822 comparetotal  NaN -1000   ->  1
dqcot823 comparetotal  NaN -1      ->  1
dqcot824 comparetotal  NaN -0      ->  1
dqcot825 comparetotal  NaN  0      ->  1
dqcot826 comparetotal  NaN  1      ->  1
dqcot827 comparetotal  NaN  1000   ->  1
dqcot828 comparetotal  NaN  Inf    ->  1
dqcot829 comparetotal  NaN  NaN    ->  0
dqcot830 comparetotal -Inf  NaN    ->  -1
dqcot831 comparetotal -1000 NaN    ->  -1
dqcot832 comparetotal -1    NaN    ->  -1
dqcot833 comparetotal -0    NaN    ->  -1
dqcot834 comparetotal  0    NaN    ->  -1
dqcot835 comparetotal  1    NaN    ->  -1
dqcot836 comparetotal  1000 NaN    ->  -1
dqcot837 comparetotal  Inf  NaN    ->  -1
dqcot838 comparetotal -NaN -NaN    ->  0
dqcot839 comparetotal +NaN -NaN    ->  1
dqcot840 comparetotal -NaN +NaN    ->  -1

dqcot841 comparetotal  sNaN -sNaN  ->  1
dqcot842 comparetotal  sNaN -NaN   ->  1
dqcot843 comparetotal  sNaN -Inf   ->  1
dqcot844 comparetotal  sNaN -1000  ->  1
dqcot845 comparetotal  sNaN -1     ->  1
dqcot846 comparetotal  sNaN -0     ->  1
dqcot847 comparetotal  sNaN  0     ->  1
dqcot848 comparetotal  sNaN  1     ->  1
dqcot849 comparetotal  sNaN  1000  ->  1
dqcot850 comparetotal  sNaN  NaN   ->  -1
dqcot851 comparetotal  sNaN sNaN   ->  0

dqcot852 comparetotal -sNaN sNaN   ->  -1
dqcot853 comparetotal -NaN  sNaN   ->  -1
dqcot854 comparetotal -Inf  sNaN   ->  -1
dqcot855 comparetotal -1000 sNaN   ->  -1
dqcot856 comparetotal -1    sNaN   ->  -1
dqcot857 comparetotal -0    sNaN   ->  -1
dqcot858 comparetotal  0    sNaN   ->  -1
dqcot859 comparetotal  1    sNaN   ->  -1
dqcot860 comparetotal  1000 sNaN   ->  -1
dqcot861 comparetotal  Inf  sNaN   ->  -1
dqcot862 comparetotal  NaN  sNaN   ->  1
dqcot863 comparetotal  sNaN sNaN   ->  0

dqcot871 comparetotal  -sNaN -sNaN  ->  0
dqcot872 comparetotal  -sNaN -NaN   ->  1
dqcot873 comparetotal  -sNaN -Inf   ->  -1
dqcot874 comparetotal  -sNaN -1000  ->  -1
dqcot875 comparetotal  -sNaN -1     ->  -1
dqcot876 comparetotal  -sNaN -0     ->  -1
dqcot877 comparetotal  -sNaN  0     ->  -1
dqcot878 comparetotal  -sNaN  1     ->  -1
dqcot879 comparetotal  -sNaN  1000  ->  -1
dqcot880 comparetotal  -sNaN  NaN   ->  -1
dqcot881 comparetotal  -sNaN sNaN   ->  -1

dqcot882 comparetotal -sNaN -sNaN   ->  0
dqcot883 comparetotal -NaN  -sNaN   ->  -1
dqcot884 comparetotal -Inf  -sNaN   ->  1
dqcot885 comparetotal -1000 -sNaN   ->  1
dqcot886 comparetotal -1    -sNaN   ->  1
dqcot887 comparetotal -0    -sNaN   ->  1
dqcot888 comparetotal  0    -sNaN   ->  1
dqcot889 comparetotal  1    -sNaN   ->  1
dqcot890 comparetotal  1000 -sNaN   ->  1
dqcot891 comparetotal  Inf  -sNaN   ->  1
dqcot892 comparetotal  NaN  -sNaN   ->  1
dqcot893 comparetotal  sNaN -sNaN   ->  1

-- NaNs with payload
dqcot960 comparetotal  NaN9 -Inf   ->  1
dqcot961 comparetotal  NaN8  999   ->  1
dqcot962 comparetotal  NaN77 Inf   ->  1
dqcot963 comparetotal -NaN67 NaN5  ->  -1
dqcot964 comparetotal -Inf  -NaN4  ->  1
dqcot965 comparetotal -999  -NaN33 ->  1
dqcot966 comparetotal  Inf   NaN2  ->  -1

dqcot970 comparetotal -NaN41 -NaN42 -> 1
dqcot971 comparetotal +NaN41 -NaN42 -> 1
dqcot972 comparetotal -NaN41 +NaN42 -> -1
dqcot973 comparetotal +NaN41 +NaN42 -> -1
dqcot974 comparetotal -NaN42 -NaN01 -> -1
dqcot975 comparetotal +NaN42 -NaN01 ->  1
dqcot976 comparetotal -NaN42 +NaN01 -> -1
dqcot977 comparetotal +NaN42 +NaN01 ->  1

dqcot980 comparetotal -sNaN771 -sNaN772 -> 1
dqcot981 comparetotal +sNaN771 -sNaN772 -> 1
dqcot982 comparetotal -sNaN771 +sNaN772 -> -1
dqcot983 comparetotal +sNaN771 +sNaN772 -> -1
dqcot984 comparetotal -sNaN772 -sNaN771 -> -1
dqcot985 comparetotal +sNaN772 -sNaN771 ->  1
dqcot986 comparetotal -sNaN772 +sNaN771 -> -1
dqcot987 comparetotal +sNaN772 +sNaN771 ->  1

dqcot991 comparetotal -sNaN99 -Inf    -> -1
dqcot992 comparetotal  sNaN98 -11     ->  1
dqcot993 comparetotal  sNaN97  NaN    -> -1
dqcot994 comparetotal  sNaN16 sNaN94  -> -1
dqcot995 comparetotal  NaN85  sNaN83  ->  1
dqcot996 comparetotal -Inf    sNaN92  -> -1
dqcot997 comparetotal  088    sNaN81  -> -1
dqcot998 comparetotal  Inf    sNaN90  -> -1
dqcot999 comparetotal  NaN   -sNaN89  ->  1

-- spread zeros
dqcot1110 comparetotal   0E-6143  0       -> -1
dqcot1111 comparetotal   0E-6143 -0       ->  1
dqcot1112 comparetotal  -0E-6143  0       -> -1
dqcot1113 comparetotal  -0E-6143 -0       ->  1
dqcot1114 comparetotal   0E-6143  0E+6144  -> -1
dqcot1115 comparetotal   0E-6143 -0E+6144  ->  1
dqcot1116 comparetotal  -0E-6143  0E+6144  -> -1
dqcot1117 comparetotal  -0E-6143 -0E+6144  ->  1
dqcot1118 comparetotal   0       0E+6144  -> -1
dqcot1119 comparetotal   0      -0E+6144  ->  1
dqcot1120 comparetotal  -0       0E+6144  -> -1
dqcot1121 comparetotal  -0      -0E+6144  ->  1

dqcot1130 comparetotal   0E+6144  0       ->  1
dqcot1131 comparetotal   0E+6144 -0       ->  1
dqcot1132 comparetotal  -0E+6144  0       -> -1
dqcot1133 comparetotal  -0E+6144 -0       -> -1
dqcot1134 comparetotal   0E+6144  0E-6143  ->  1
dqcot1135 comparetotal   0E+6144 -0E-6143  ->  1
dqcot1136 comparetotal  -0E+6144  0E-6143  -> -1
dqcot1137 comparetotal  -0E+6144 -0E-6143  -> -1
dqcot1138 comparetotal   0       0E-6143  ->  1
dqcot1139 comparetotal   0      -0E-6143  ->  1
dqcot1140 comparetotal  -0       0E-6143  -> -1
dqcot1141 comparetotal  -0      -0E-6143  -> -1

-- Null tests
dqcot9990 comparetotal 10  # -> NaN Invalid_operation
dqcot9991 comparetotal  # 10 -> NaN Invalid_operation

Added test/dectest/dqCompareTotalMag.decTest.





































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
------------------------------------------------------------------------
-- dqCompareTotalMag.decTest -- decQuad comparison; abs. total order  --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Note that we cannot assume add/subtract tests cover paths adequately,
-- here, because the code might be quite different (comparison cannot
-- overflow or underflow, so actual subtractions are not necessary).
-- Similarly, comparetotal will have some radically different paths
-- than compare.

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks
dqctm001 comparetotmag  -2  -2   ->   0
dqctm002 comparetotmag  -2  -1   ->   1
dqctm003 comparetotmag  -2   0   ->   1
dqctm004 comparetotmag  -2   1   ->   1
dqctm005 comparetotmag  -2   2   ->   0
dqctm006 comparetotmag  -1  -2   ->  -1
dqctm007 comparetotmag  -1  -1   ->   0
dqctm008 comparetotmag  -1   0   ->   1
dqctm009 comparetotmag  -1   1   ->   0
dqctm010 comparetotmag  -1   2   ->  -1
dqctm011 comparetotmag   0  -2   ->  -1
dqctm012 comparetotmag   0  -1   ->  -1
dqctm013 comparetotmag   0   0   ->   0
dqctm014 comparetotmag   0   1   ->  -1
dqctm015 comparetotmag   0   2   ->  -1
dqctm016 comparetotmag   1  -2   ->  -1
dqctm017 comparetotmag   1  -1   ->   0
dqctm018 comparetotmag   1   0   ->   1
dqctm019 comparetotmag   1   1   ->   0
dqctm020 comparetotmag   1   2   ->  -1
dqctm021 comparetotmag   2  -2   ->   0
dqctm022 comparetotmag   2  -1   ->   1
dqctm023 comparetotmag   2   0   ->   1
dqctm025 comparetotmag   2   1   ->   1
dqctm026 comparetotmag   2   2   ->   0

dqctm031 comparetotmag  -20  -20   ->   0
dqctm032 comparetotmag  -20  -10   ->   1
dqctm033 comparetotmag  -20   00   ->   1
dqctm034 comparetotmag  -20   10   ->   1
dqctm035 comparetotmag  -20   20   ->   0
dqctm036 comparetotmag  -10  -20   ->  -1
dqctm037 comparetotmag  -10  -10   ->   0
dqctm038 comparetotmag  -10   00   ->   1
dqctm039 comparetotmag  -10   10   ->   0
dqctm040 comparetotmag  -10   20   ->  -1
dqctm041 comparetotmag   00  -20   ->  -1
dqctm042 comparetotmag   00  -10   ->  -1
dqctm043 comparetotmag   00   00   ->   0
dqctm044 comparetotmag   00   10   ->  -1
dqctm045 comparetotmag   00   20   ->  -1
dqctm046 comparetotmag   10  -20   ->  -1
dqctm047 comparetotmag   10  -10   ->   0
dqctm048 comparetotmag   10   00   ->   1
dqctm049 comparetotmag   10   10   ->   0
dqctm050 comparetotmag   10   20   ->  -1
dqctm051 comparetotmag   20  -20   ->   0
dqctm052 comparetotmag   20  -10   ->   1
dqctm053 comparetotmag   20   00   ->   1
dqctm055 comparetotmag   20   10   ->   1
dqctm056 comparetotmag   20   20   ->   0

dqctm061 comparetotmag  -2.0  -2.0   ->   0
dqctm062 comparetotmag  -2.0  -1.0   ->   1
dqctm063 comparetotmag  -2.0   0.0   ->   1
dqctm064 comparetotmag  -2.0   1.0   ->   1
dqctm065 comparetotmag  -2.0   2.0   ->   0
dqctm066 comparetotmag  -1.0  -2.0   ->  -1
dqctm067 comparetotmag  -1.0  -1.0   ->   0
dqctm068 comparetotmag  -1.0   0.0   ->   1
dqctm069 comparetotmag  -1.0   1.0   ->   0
dqctm070 comparetotmag  -1.0   2.0   ->  -1
dqctm071 comparetotmag   0.0  -2.0   ->  -1
dqctm072 comparetotmag   0.0  -1.0   ->  -1
dqctm073 comparetotmag   0.0   0.0   ->   0
dqctm074 comparetotmag   0.0   1.0   ->  -1
dqctm075 comparetotmag   0.0   2.0   ->  -1
dqctm076 comparetotmag   1.0  -2.0   ->  -1
dqctm077 comparetotmag   1.0  -1.0   ->   0
dqctm078 comparetotmag   1.0   0.0   ->   1
dqctm079 comparetotmag   1.0   1.0   ->   0
dqctm080 comparetotmag   1.0   2.0   ->  -1
dqctm081 comparetotmag   2.0  -2.0   ->   0
dqctm082 comparetotmag   2.0  -1.0   ->   1
dqctm083 comparetotmag   2.0   0.0   ->   1
dqctm085 comparetotmag   2.0   1.0   ->   1
dqctm086 comparetotmag   2.0   2.0   ->   0

-- now some cases which might overflow if subtract were used
dqctm090 comparetotmag  9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144   ->   0
dqctm091 comparetotmag -9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144   ->   0
dqctm092 comparetotmag  9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144  ->   0
dqctm093 comparetotmag -9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144  ->   0

-- some differing length/exponent cases
-- in this first group, compare would compare all equal
dqctm100 comparetotmag   7.0    7.0     ->   0
dqctm101 comparetotmag   7.0    7       ->  -1
dqctm102 comparetotmag   7      7.0     ->   1
dqctm103 comparetotmag   7E+0   7.0     ->   1
dqctm104 comparetotmag   70E-1  7.0     ->   0
dqctm105 comparetotmag   0.7E+1 7       ->   0
dqctm106 comparetotmag   70E-1  7       ->  -1
dqctm107 comparetotmag   7.0    7E+0    ->  -1
dqctm108 comparetotmag   7.0    70E-1   ->   0
dqctm109 comparetotmag   7      0.7E+1  ->   0
dqctm110 comparetotmag   7      70E-1   ->   1

dqctm120 comparetotmag   8.0    7.0     ->   1
dqctm121 comparetotmag   8.0    7       ->   1
dqctm122 comparetotmag   8      7.0     ->   1
dqctm123 comparetotmag   8E+0   7.0     ->   1
dqctm124 comparetotmag   80E-1  7.0     ->   1
dqctm125 comparetotmag   0.8E+1 7       ->   1
dqctm126 comparetotmag   80E-1  7       ->   1
dqctm127 comparetotmag   8.0    7E+0    ->   1
dqctm128 comparetotmag   8.0    70E-1   ->   1
dqctm129 comparetotmag   8      0.7E+1   ->   1
dqctm130 comparetotmag   8      70E-1   ->   1

dqctm140 comparetotmag   8.0    9.0     ->  -1
dqctm141 comparetotmag   8.0    9       ->  -1
dqctm142 comparetotmag   8      9.0     ->  -1
dqctm143 comparetotmag   8E+0   9.0     ->  -1
dqctm144 comparetotmag   80E-1  9.0     ->  -1
dqctm145 comparetotmag   0.8E+1 9       ->  -1
dqctm146 comparetotmag   80E-1  9       ->  -1
dqctm147 comparetotmag   8.0    9E+0    ->  -1
dqctm148 comparetotmag   8.0    90E-1   ->  -1
dqctm149 comparetotmag   8      0.9E+1  ->  -1
dqctm150 comparetotmag   8      90E-1   ->  -1

-- and again, with sign changes -+ ..
dqctm200 comparetotmag  -7.0    7.0     ->   0
dqctm201 comparetotmag  -7.0    7       ->  -1
dqctm202 comparetotmag  -7      7.0     ->   1
dqctm203 comparetotmag  -7E+0   7.0     ->   1
dqctm204 comparetotmag  -70E-1  7.0     ->   0
dqctm205 comparetotmag  -0.7E+1 7       ->   0
dqctm206 comparetotmag  -70E-1  7       ->  -1
dqctm207 comparetotmag  -7.0    7E+0    ->  -1
dqctm208 comparetotmag  -7.0    70E-1   ->   0
dqctm209 comparetotmag  -7      0.7E+1  ->   0
dqctm210 comparetotmag  -7      70E-1   ->   1

dqctm220 comparetotmag  -8.0    7.0     ->   1
dqctm221 comparetotmag  -8.0    7       ->   1
dqctm222 comparetotmag  -8      7.0     ->   1
dqctm223 comparetotmag  -8E+0   7.0     ->   1
dqctm224 comparetotmag  -80E-1  7.0     ->   1
dqctm225 comparetotmag  -0.8E+1 7       ->   1
dqctm226 comparetotmag  -80E-1  7       ->   1
dqctm227 comparetotmag  -8.0    7E+0    ->   1
dqctm228 comparetotmag  -8.0    70E-1   ->   1
dqctm229 comparetotmag  -8      0.7E+1  ->   1
dqctm230 comparetotmag  -8      70E-1   ->   1

dqctm240 comparetotmag  -8.0    9.0     ->  -1
dqctm241 comparetotmag  -8.0    9       ->  -1
dqctm242 comparetotmag  -8      9.0     ->  -1
dqctm243 comparetotmag  -8E+0   9.0     ->  -1
dqctm244 comparetotmag  -80E-1  9.0     ->  -1
dqctm245 comparetotmag  -0.8E+1 9       ->  -1
dqctm246 comparetotmag  -80E-1  9       ->  -1
dqctm247 comparetotmag  -8.0    9E+0    ->  -1
dqctm248 comparetotmag  -8.0    90E-1   ->  -1
dqctm249 comparetotmag  -8      0.9E+1  ->  -1
dqctm250 comparetotmag  -8      90E-1   ->  -1

-- and again, with sign changes +- ..
dqctm300 comparetotmag   7.0    -7.0     ->   0
dqctm301 comparetotmag   7.0    -7       ->  -1
dqctm302 comparetotmag   7      -7.0     ->   1
dqctm303 comparetotmag   7E+0   -7.0     ->   1
dqctm304 comparetotmag   70E-1  -7.0     ->   0
dqctm305 comparetotmag   .7E+1  -7       ->   0
dqctm306 comparetotmag   70E-1  -7       ->  -1
dqctm307 comparetotmag   7.0    -7E+0    ->  -1
dqctm308 comparetotmag   7.0    -70E-1   ->   0
dqctm309 comparetotmag   7      -.7E+1   ->   0
dqctm310 comparetotmag   7      -70E-1   ->   1

dqctm320 comparetotmag   8.0    -7.0     ->   1
dqctm321 comparetotmag   8.0    -7       ->   1
dqctm322 comparetotmag   8      -7.0     ->   1
dqctm323 comparetotmag   8E+0   -7.0     ->   1
dqctm324 comparetotmag   80E-1  -7.0     ->   1
dqctm325 comparetotmag   .8E+1  -7       ->   1
dqctm326 comparetotmag   80E-1  -7       ->   1
dqctm327 comparetotmag   8.0    -7E+0    ->   1
dqctm328 comparetotmag   8.0    -70E-1   ->   1
dqctm329 comparetotmag   8      -.7E+1   ->   1
dqctm330 comparetotmag   8      -70E-1   ->   1

dqctm340 comparetotmag   8.0    -9.0     ->  -1
dqctm341 comparetotmag   8.0    -9       ->  -1
dqctm342 comparetotmag   8      -9.0     ->  -1
dqctm343 comparetotmag   8E+0   -9.0     ->  -1
dqctm344 comparetotmag   80E-1  -9.0     ->  -1
dqctm345 comparetotmag   .8E+1  -9       ->  -1
dqctm346 comparetotmag   80E-1  -9       ->  -1
dqctm347 comparetotmag   8.0    -9E+0    ->  -1
dqctm348 comparetotmag   8.0    -90E-1   ->  -1
dqctm349 comparetotmag   8      -.9E+1   ->  -1
dqctm350 comparetotmag   8      -90E-1   ->  -1

-- and again, with sign changes -- ..
dqctm400 comparetotmag   -7.0    -7.0     ->   0
dqctm401 comparetotmag   -7.0    -7       ->  -1
dqctm402 comparetotmag   -7      -7.0     ->   1
dqctm403 comparetotmag   -7E+0   -7.0     ->   1
dqctm404 comparetotmag   -70E-1  -7.0     ->   0
dqctm405 comparetotmag   -.7E+1  -7       ->   0
dqctm406 comparetotmag   -70E-1  -7       ->  -1
dqctm407 comparetotmag   -7.0    -7E+0    ->  -1
dqctm408 comparetotmag   -7.0    -70E-1   ->   0
dqctm409 comparetotmag   -7      -.7E+1   ->   0
dqctm410 comparetotmag   -7      -70E-1   ->   1

dqctm420 comparetotmag   -8.0    -7.0     ->   1
dqctm421 comparetotmag   -8.0    -7       ->   1
dqctm422 comparetotmag   -8      -7.0     ->   1
dqctm423 comparetotmag   -8E+0   -7.0     ->   1
dqctm424 comparetotmag   -80E-1  -7.0     ->   1
dqctm425 comparetotmag   -.8E+1  -7       ->   1
dqctm426 comparetotmag   -80E-1  -7       ->   1
dqctm427 comparetotmag   -8.0    -7E+0    ->   1
dqctm428 comparetotmag   -8.0    -70E-1   ->   1
dqctm429 comparetotmag   -8      -.7E+1   ->   1
dqctm430 comparetotmag   -8      -70E-1   ->   1

dqctm440 comparetotmag   -8.0    -9.0     ->  -1
dqctm441 comparetotmag   -8.0    -9       ->  -1
dqctm442 comparetotmag   -8      -9.0     ->  -1
dqctm443 comparetotmag   -8E+0   -9.0     ->  -1
dqctm444 comparetotmag   -80E-1  -9.0     ->  -1
dqctm445 comparetotmag   -.8E+1  -9       ->  -1
dqctm446 comparetotmag   -80E-1  -9       ->  -1
dqctm447 comparetotmag   -8.0    -9E+0    ->  -1
dqctm448 comparetotmag   -8.0    -90E-1   ->  -1
dqctm449 comparetotmag   -8      -.9E+1   ->  -1
dqctm450 comparetotmag   -8      -90E-1   ->  -1


-- testcases that subtract to lots of zeros at boundaries [pgr]
dqctm473 comparetotmag 123.4560000000000E-89 123.456E-89  ->  -1
dqctm474 comparetotmag 123.456000000000E+89 123.456E+89  ->  -1
dqctm475 comparetotmag 123.45600000000E-89 123.456E-89  ->  -1
dqctm476 comparetotmag 123.4560000000E+89 123.456E+89  ->  -1
dqctm477 comparetotmag 123.456000000E-89 123.456E-89  ->  -1
dqctm478 comparetotmag 123.45600000E+89 123.456E+89  ->  -1
dqctm479 comparetotmag 123.4560000E-89 123.456E-89  ->  -1
dqctm480 comparetotmag 123.456000E+89 123.456E+89  ->  -1
dqctm481 comparetotmag 123.45600E-89 123.456E-89  ->  -1
dqctm482 comparetotmag 123.4560E+89 123.456E+89  ->  -1
dqctm483 comparetotmag 123.456E-89 123.456E-89  ->   0
dqctm487 comparetotmag 123.456E+89 123.4560000000000E+89  ->   1
dqctm488 comparetotmag 123.456E-89 123.456000000000E-89  ->   1
dqctm489 comparetotmag 123.456E+89 123.45600000000E+89  ->   1
dqctm490 comparetotmag 123.456E-89 123.4560000000E-89  ->   1
dqctm491 comparetotmag 123.456E+89 123.456000000E+89  ->   1
dqctm492 comparetotmag 123.456E-89 123.45600000E-89  ->   1
dqctm493 comparetotmag 123.456E+89 123.4560000E+89  ->   1
dqctm494 comparetotmag 123.456E-89 123.456000E-89  ->   1
dqctm495 comparetotmag 123.456E+89 123.45600E+89  ->   1
dqctm496 comparetotmag 123.456E-89 123.4560E-89  ->   1
dqctm497 comparetotmag 123.456E+89 123.456E+89  ->   0

-- wide-ranging, around precision; signs equal
dqctm498 comparetotmag    1     1E-17     ->   1
dqctm499 comparetotmag    1     1E-16     ->   1
dqctm500 comparetotmag    1     1E-15     ->   1
dqctm501 comparetotmag    1     1E-14     ->   1
dqctm502 comparetotmag    1     1E-13     ->   1
dqctm503 comparetotmag    1     1E-12     ->   1
dqctm504 comparetotmag    1     1E-11     ->   1
dqctm505 comparetotmag    1     1E-10     ->   1
dqctm506 comparetotmag    1     1E-9      ->   1
dqctm507 comparetotmag    1     1E-8      ->   1
dqctm508 comparetotmag    1     1E-7      ->   1
dqctm509 comparetotmag    1     1E-6      ->   1
dqctm510 comparetotmag    1     1E-5      ->   1
dqctm511 comparetotmag    1     1E-4      ->   1
dqctm512 comparetotmag    1     1E-3      ->   1
dqctm513 comparetotmag    1     1E-2      ->   1
dqctm514 comparetotmag    1     1E-1      ->   1
dqctm515 comparetotmag    1     1E-0      ->   0
dqctm516 comparetotmag    1     1E+1      ->  -1
dqctm517 comparetotmag    1     1E+2      ->  -1
dqctm518 comparetotmag    1     1E+3      ->  -1
dqctm519 comparetotmag    1     1E+4      ->  -1
dqctm521 comparetotmag    1     1E+5      ->  -1
dqctm522 comparetotmag    1     1E+6      ->  -1
dqctm523 comparetotmag    1     1E+7      ->  -1
dqctm524 comparetotmag    1     1E+8      ->  -1
dqctm525 comparetotmag    1     1E+9      ->  -1
dqctm526 comparetotmag    1     1E+10     ->  -1
dqctm527 comparetotmag    1     1E+11     ->  -1
dqctm528 comparetotmag    1     1E+12     ->  -1
dqctm529 comparetotmag    1     1E+13     ->  -1
dqctm530 comparetotmag    1     1E+14     ->  -1
dqctm531 comparetotmag    1     1E+15     ->  -1
dqctm532 comparetotmag    1     1E+16     ->  -1
dqctm533 comparetotmag    1     1E+17     ->  -1
-- LR swap
dqctm538 comparetotmag    1E-17  1        ->  -1
dqctm539 comparetotmag    1E-16  1        ->  -1
dqctm540 comparetotmag    1E-15  1        ->  -1
dqctm541 comparetotmag    1E-14  1        ->  -1
dqctm542 comparetotmag    1E-13  1        ->  -1
dqctm543 comparetotmag    1E-12  1        ->  -1
dqctm544 comparetotmag    1E-11  1        ->  -1
dqctm545 comparetotmag    1E-10  1        ->  -1
dqctm546 comparetotmag    1E-9   1        ->  -1
dqctm547 comparetotmag    1E-8   1        ->  -1
dqctm548 comparetotmag    1E-7   1        ->  -1
dqctm549 comparetotmag    1E-6   1        ->  -1
dqctm550 comparetotmag    1E-5   1        ->  -1
dqctm551 comparetotmag    1E-4   1        ->  -1
dqctm552 comparetotmag    1E-3   1        ->  -1
dqctm553 comparetotmag    1E-2   1        ->  -1
dqctm554 comparetotmag    1E-1   1        ->  -1
dqctm555 comparetotmag    1E-0   1        ->   0
dqctm556 comparetotmag    1E+1   1        ->   1
dqctm557 comparetotmag    1E+2   1        ->   1
dqctm558 comparetotmag    1E+3   1        ->   1
dqctm559 comparetotmag    1E+4   1        ->   1
dqctm561 comparetotmag    1E+5   1        ->   1
dqctm562 comparetotmag    1E+6   1        ->   1
dqctm563 comparetotmag    1E+7   1        ->   1
dqctm564 comparetotmag    1E+8   1        ->   1
dqctm565 comparetotmag    1E+9   1        ->   1
dqctm566 comparetotmag    1E+10  1        ->   1
dqctm567 comparetotmag    1E+11  1        ->   1
dqctm568 comparetotmag    1E+12  1        ->   1
dqctm569 comparetotmag    1E+13  1        ->   1
dqctm570 comparetotmag    1E+14  1        ->   1
dqctm571 comparetotmag    1E+15  1        ->   1
dqctm572 comparetotmag    1E+16  1        ->   1
dqctm573 comparetotmag    1E+17  1        ->   1
-- similar with a useful coefficient, one side only
dqctm578 comparetotmag  0.000000987654321     1E-17     ->   1
dqctm579 comparetotmag  0.000000987654321     1E-16     ->   1
dqctm580 comparetotmag  0.000000987654321     1E-15     ->   1
dqctm581 comparetotmag  0.000000987654321     1E-14     ->   1
dqctm582 comparetotmag  0.000000987654321     1E-13     ->   1
dqctm583 comparetotmag  0.000000987654321     1E-12     ->   1
dqctm584 comparetotmag  0.000000987654321     1E-11     ->   1
dqctm585 comparetotmag  0.000000987654321     1E-10     ->   1
dqctm586 comparetotmag  0.000000987654321     1E-9      ->   1
dqctm587 comparetotmag  0.000000987654321     1E-8      ->   1
dqctm588 comparetotmag  0.000000987654321     1E-7      ->   1
dqctm589 comparetotmag  0.000000987654321     1E-6      ->  -1
dqctm590 comparetotmag  0.000000987654321     1E-5      ->  -1
dqctm591 comparetotmag  0.000000987654321     1E-4      ->  -1
dqctm592 comparetotmag  0.000000987654321     1E-3      ->  -1
dqctm593 comparetotmag  0.000000987654321     1E-2      ->  -1
dqctm594 comparetotmag  0.000000987654321     1E-1      ->  -1
dqctm595 comparetotmag  0.000000987654321     1E-0      ->  -1
dqctm596 comparetotmag  0.000000987654321     1E+1      ->  -1
dqctm597 comparetotmag  0.000000987654321     1E+2      ->  -1
dqctm598 comparetotmag  0.000000987654321     1E+3      ->  -1
dqctm599 comparetotmag  0.000000987654321     1E+4      ->  -1

-- check some unit-y traps
dqctm600 comparetotmag   12            12.2345  ->  -1
dqctm601 comparetotmag   12.0          12.2345  ->  -1
dqctm602 comparetotmag   12.00         12.2345  ->  -1
dqctm603 comparetotmag   12.000        12.2345  ->  -1
dqctm604 comparetotmag   12.0000       12.2345  ->  -1
dqctm605 comparetotmag   12.00000      12.2345  ->  -1
dqctm606 comparetotmag   12.000000     12.2345  ->  -1
dqctm607 comparetotmag   12.0000000    12.2345  ->  -1
dqctm608 comparetotmag   12.00000000   12.2345  ->  -1
dqctm609 comparetotmag   12.000000000  12.2345  ->  -1
dqctm610 comparetotmag   12.1234 12             ->   1
dqctm611 comparetotmag   12.1234 12.0           ->   1
dqctm612 comparetotmag   12.1234 12.00          ->   1
dqctm613 comparetotmag   12.1234 12.000         ->   1
dqctm614 comparetotmag   12.1234 12.0000        ->   1
dqctm615 comparetotmag   12.1234 12.00000       ->   1
dqctm616 comparetotmag   12.1234 12.000000      ->   1
dqctm617 comparetotmag   12.1234 12.0000000     ->   1
dqctm618 comparetotmag   12.1234 12.00000000    ->   1
dqctm619 comparetotmag   12.1234 12.000000000   ->   1
dqctm620 comparetotmag  -12           -12.2345  ->  -1
dqctm621 comparetotmag  -12.0         -12.2345  ->  -1
dqctm622 comparetotmag  -12.00        -12.2345  ->  -1
dqctm623 comparetotmag  -12.000       -12.2345  ->  -1
dqctm624 comparetotmag  -12.0000      -12.2345  ->  -1
dqctm625 comparetotmag  -12.00000     -12.2345  ->  -1
dqctm626 comparetotmag  -12.000000    -12.2345  ->  -1
dqctm627 comparetotmag  -12.0000000   -12.2345  ->  -1
dqctm628 comparetotmag  -12.00000000  -12.2345  ->  -1
dqctm629 comparetotmag  -12.000000000 -12.2345  ->  -1
dqctm630 comparetotmag  -12.1234 -12            ->   1
dqctm631 comparetotmag  -12.1234 -12.0          ->   1
dqctm632 comparetotmag  -12.1234 -12.00         ->   1
dqctm633 comparetotmag  -12.1234 -12.000        ->   1
dqctm634 comparetotmag  -12.1234 -12.0000       ->   1
dqctm635 comparetotmag  -12.1234 -12.00000      ->   1
dqctm636 comparetotmag  -12.1234 -12.000000     ->   1
dqctm637 comparetotmag  -12.1234 -12.0000000    ->   1
dqctm638 comparetotmag  -12.1234 -12.00000000   ->   1
dqctm639 comparetotmag  -12.1234 -12.000000000  ->   1

-- extended zeros
dqctm640 comparetotmag   0     0    ->   0
dqctm641 comparetotmag   0    -0    ->   0
dqctm642 comparetotmag   0    -0.0  ->   1
dqctm643 comparetotmag   0     0.0  ->   1
dqctm644 comparetotmag  -0     0    ->   0
dqctm645 comparetotmag  -0    -0    ->   0
dqctm646 comparetotmag  -0    -0.0  ->   1
dqctm647 comparetotmag  -0     0.0  ->   1
dqctm648 comparetotmag   0.0   0    ->  -1
dqctm649 comparetotmag   0.0  -0    ->  -1
dqctm650 comparetotmag   0.0  -0.0  ->   0
dqctm651 comparetotmag   0.0   0.0  ->   0
dqctm652 comparetotmag  -0.0   0    ->  -1
dqctm653 comparetotmag  -0.0  -0    ->  -1
dqctm654 comparetotmag  -0.0  -0.0  ->   0
dqctm655 comparetotmag  -0.0   0.0  ->   0

dqctm656 comparetotmag  -0E1   0.0  ->   1
dqctm657 comparetotmag  -0E2   0.0  ->   1
dqctm658 comparetotmag   0E1   0.0  ->   1
dqctm659 comparetotmag   0E2   0.0  ->   1
dqctm660 comparetotmag  -0E1   0    ->   1
dqctm661 comparetotmag  -0E2   0    ->   1
dqctm662 comparetotmag   0E1   0    ->   1
dqctm663 comparetotmag   0E2   0    ->   1
dqctm664 comparetotmag  -0E1  -0E1  ->   0
dqctm665 comparetotmag  -0E2  -0E1  ->   1
dqctm666 comparetotmag   0E1  -0E1  ->   0
dqctm667 comparetotmag   0E2  -0E1  ->   1
dqctm668 comparetotmag  -0E1  -0E2  ->  -1
dqctm669 comparetotmag  -0E2  -0E2  ->   0
dqctm670 comparetotmag   0E1  -0E2  ->  -1
dqctm671 comparetotmag   0E2  -0E2  ->   0
dqctm672 comparetotmag  -0E1   0E1  ->   0
dqctm673 comparetotmag  -0E2   0E1  ->   1
dqctm674 comparetotmag   0E1   0E1  ->   0
dqctm675 comparetotmag   0E2   0E1  ->   1
dqctm676 comparetotmag  -0E1   0E2  ->  -1
dqctm677 comparetotmag  -0E2   0E2  ->   0
dqctm678 comparetotmag   0E1   0E2  ->  -1
dqctm679 comparetotmag   0E2   0E2  ->   0

-- trailing zeros; unit-y
dqctm680 comparetotmag   12    12            ->   0
dqctm681 comparetotmag   12    12.0          ->   1
dqctm682 comparetotmag   12    12.00         ->   1
dqctm683 comparetotmag   12    12.000        ->   1
dqctm684 comparetotmag   12    12.0000       ->   1
dqctm685 comparetotmag   12    12.00000      ->   1
dqctm686 comparetotmag   12    12.000000     ->   1
dqctm687 comparetotmag   12    12.0000000    ->   1
dqctm688 comparetotmag   12    12.00000000   ->   1
dqctm689 comparetotmag   12    12.000000000  ->   1
dqctm690 comparetotmag   12              12  ->   0
dqctm691 comparetotmag   12.0            12  ->  -1
dqctm692 comparetotmag   12.00           12  ->  -1
dqctm693 comparetotmag   12.000          12  ->  -1
dqctm694 comparetotmag   12.0000         12  ->  -1
dqctm695 comparetotmag   12.00000        12  ->  -1
dqctm696 comparetotmag   12.000000       12  ->  -1
dqctm697 comparetotmag   12.0000000      12  ->  -1
dqctm698 comparetotmag   12.00000000     12  ->  -1
dqctm699 comparetotmag   12.000000000    12  ->  -1

-- old long operand checks
dqctm701 comparetotmag 12345678000  1  ->   1
dqctm702 comparetotmag 1 12345678000   ->  -1
dqctm703 comparetotmag 1234567800   1  ->   1
dqctm704 comparetotmag 1 1234567800    ->  -1
dqctm705 comparetotmag 1234567890   1  ->   1
dqctm706 comparetotmag 1 1234567890    ->  -1
dqctm707 comparetotmag 1234567891   1  ->   1
dqctm708 comparetotmag 1 1234567891    ->  -1
dqctm709 comparetotmag 12345678901  1  ->   1
dqctm710 comparetotmag 1 12345678901   ->  -1
dqctm711 comparetotmag 1234567896   1  ->   1
dqctm712 comparetotmag 1 1234567896    ->  -1
dqctm713 comparetotmag -1234567891  1  ->   1
dqctm714 comparetotmag 1 -1234567891   ->  -1
dqctm715 comparetotmag -12345678901 1  ->   1
dqctm716 comparetotmag 1 -12345678901  ->  -1
dqctm717 comparetotmag -1234567896  1  ->   1
dqctm718 comparetotmag 1 -1234567896   ->  -1

-- old residue cases
dqctm740 comparetotmag  1  0.9999999   ->   1
dqctm741 comparetotmag  1  0.999999    ->   1
dqctm742 comparetotmag  1  0.99999     ->   1
dqctm743 comparetotmag  1  1.0000      ->   1
dqctm744 comparetotmag  1  1.00001     ->  -1
dqctm745 comparetotmag  1  1.000001    ->  -1
dqctm746 comparetotmag  1  1.0000001   ->  -1
dqctm750 comparetotmag  0.9999999  1   ->  -1
dqctm751 comparetotmag  0.999999   1   ->  -1
dqctm752 comparetotmag  0.99999    1   ->  -1
dqctm753 comparetotmag  1.0000     1   ->  -1
dqctm754 comparetotmag  1.00001    1   ->   1
dqctm755 comparetotmag  1.000001   1   ->   1
dqctm756 comparetotmag  1.0000001  1   ->   1

-- Specials
dqctm780 comparetotmag  Inf  -Inf   ->  0
dqctm781 comparetotmag  Inf  -1000  ->  1
dqctm782 comparetotmag  Inf  -1     ->  1
dqctm783 comparetotmag  Inf  -0     ->  1
dqctm784 comparetotmag  Inf   0     ->  1
dqctm785 comparetotmag  Inf   1     ->  1
dqctm786 comparetotmag  Inf   1000  ->  1
dqctm787 comparetotmag  Inf   Inf   ->  0
dqctm788 comparetotmag -1000  Inf   -> -1
dqctm789 comparetotmag -Inf   Inf   ->  0
dqctm790 comparetotmag -1     Inf   -> -1
dqctm791 comparetotmag -0     Inf   -> -1
dqctm792 comparetotmag  0     Inf   -> -1
dqctm793 comparetotmag  1     Inf   -> -1
dqctm794 comparetotmag  1000  Inf   -> -1
dqctm795 comparetotmag  Inf   Inf   ->  0

dqctm800 comparetotmag -Inf  -Inf   ->  0
dqctm801 comparetotmag -Inf  -1000  ->  1
dqctm802 comparetotmag -Inf  -1     ->  1
dqctm803 comparetotmag -Inf  -0     ->  1
dqctm804 comparetotmag -Inf   0     ->  1
dqctm805 comparetotmag -Inf   1     ->  1
dqctm806 comparetotmag -Inf   1000  ->  1
dqctm807 comparetotmag -Inf   Inf   ->  0
dqctm808 comparetotmag -Inf  -Inf   ->  0
dqctm809 comparetotmag -1000 -Inf   -> -1
dqctm810 comparetotmag -1    -Inf   -> -1
dqctm811 comparetotmag -0    -Inf   -> -1
dqctm812 comparetotmag  0    -Inf   -> -1
dqctm813 comparetotmag  1    -Inf   -> -1
dqctm814 comparetotmag  1000 -Inf   -> -1
dqctm815 comparetotmag  Inf  -Inf   ->  0

dqctm821 comparetotmag  NaN -Inf    ->  1
dqctm822 comparetotmag  NaN -1000   ->  1
dqctm823 comparetotmag  NaN -1      ->  1
dqctm824 comparetotmag  NaN -0      ->  1
dqctm825 comparetotmag  NaN  0      ->  1
dqctm826 comparetotmag  NaN  1      ->  1
dqctm827 comparetotmag  NaN  1000   ->  1
dqctm828 comparetotmag  NaN  Inf    ->  1
dqctm829 comparetotmag  NaN  NaN    ->  0
dqctm830 comparetotmag -Inf  NaN    ->  -1
dqctm831 comparetotmag -1000 NaN    ->  -1
dqctm832 comparetotmag -1    NaN    ->  -1
dqctm833 comparetotmag -0    NaN    ->  -1
dqctm834 comparetotmag  0    NaN    ->  -1
dqctm835 comparetotmag  1    NaN    ->  -1
dqctm836 comparetotmag  1000 NaN    ->  -1
dqctm837 comparetotmag  Inf  NaN    ->  -1
dqctm838 comparetotmag -NaN -NaN    ->  0
dqctm839 comparetotmag +NaN -NaN    ->  0
dqctm840 comparetotmag -NaN +NaN    ->  0

dqctm841 comparetotmag  sNaN -sNaN  ->  0
dqctm842 comparetotmag  sNaN -NaN   ->  -1
dqctm843 comparetotmag  sNaN -Inf   ->  1
dqctm844 comparetotmag  sNaN -1000  ->  1
dqctm845 comparetotmag  sNaN -1     ->  1
dqctm846 comparetotmag  sNaN -0     ->  1
dqctm847 comparetotmag  sNaN  0     ->  1
dqctm848 comparetotmag  sNaN  1     ->  1
dqctm849 comparetotmag  sNaN  1000  ->  1
dqctm850 comparetotmag  sNaN  NaN   ->  -1
dqctm851 comparetotmag  sNaN sNaN   ->  0

dqctm852 comparetotmag -sNaN sNaN   ->  0
dqctm853 comparetotmag -NaN  sNaN   ->  1
dqctm854 comparetotmag -Inf  sNaN   ->  -1
dqctm855 comparetotmag -1000 sNaN   ->  -1
dqctm856 comparetotmag -1    sNaN   ->  -1
dqctm857 comparetotmag -0    sNaN   ->  -1
dqctm858 comparetotmag  0    sNaN   ->  -1
dqctm859 comparetotmag  1    sNaN   ->  -1
dqctm860 comparetotmag  1000 sNaN   ->  -1
dqctm861 comparetotmag  Inf  sNaN   ->  -1
dqctm862 comparetotmag  NaN  sNaN   ->  1
dqctm863 comparetotmag  sNaN sNaN   ->  0

dqctm871 comparetotmag  -sNaN -sNaN  ->  0
dqctm872 comparetotmag  -sNaN -NaN   ->  -1
dqctm873 comparetotmag  -sNaN -Inf   ->  1
dqctm874 comparetotmag  -sNaN -1000  ->  1
dqctm875 comparetotmag  -sNaN -1     ->  1
dqctm876 comparetotmag  -sNaN -0     ->  1
dqctm877 comparetotmag  -sNaN  0     ->  1
dqctm878 comparetotmag  -sNaN  1     ->  1
dqctm879 comparetotmag  -sNaN  1000  ->  1
dqctm880 comparetotmag  -sNaN  NaN   ->  -1
dqctm881 comparetotmag  -sNaN sNaN   ->  0

dqctm882 comparetotmag -sNaN -sNaN   ->  0
dqctm883 comparetotmag -NaN  -sNaN   ->  1
dqctm884 comparetotmag -Inf  -sNaN   ->  -1
dqctm885 comparetotmag -1000 -sNaN   ->  -1
dqctm886 comparetotmag -1    -sNaN   ->  -1
dqctm887 comparetotmag -0    -sNaN   ->  -1
dqctm888 comparetotmag  0    -sNaN   ->  -1
dqctm889 comparetotmag  1    -sNaN   ->  -1
dqctm890 comparetotmag  1000 -sNaN   ->  -1
dqctm891 comparetotmag  Inf  -sNaN   ->  -1
dqctm892 comparetotmag  NaN  -sNaN   ->  1
dqctm893 comparetotmag  sNaN -sNaN   ->  0

-- NaNs with payload
dqctm960 comparetotmag  NaN9 -Inf   ->  1
dqctm961 comparetotmag  NaN8  999   ->  1
dqctm962 comparetotmag  NaN77 Inf   ->  1
dqctm963 comparetotmag -NaN67 NaN5  ->  1
dqctm964 comparetotmag -Inf  -NaN4  ->  -1
dqctm965 comparetotmag -999  -NaN33 ->  -1
dqctm966 comparetotmag  Inf   NaN2  ->  -1

dqctm970 comparetotmag -NaN41 -NaN42 -> -1
dqctm971 comparetotmag +NaN41 -NaN42 -> -1
dqctm972 comparetotmag -NaN41 +NaN42 -> -1
dqctm973 comparetotmag +NaN41 +NaN42 -> -1
dqctm974 comparetotmag -NaN42 -NaN01 ->  1
dqctm975 comparetotmag +NaN42 -NaN01 ->  1
dqctm976 comparetotmag -NaN42 +NaN01 ->  1
dqctm977 comparetotmag +NaN42 +NaN01 ->  1

dqctm980 comparetotmag -sNaN771 -sNaN772 -> -1
dqctm981 comparetotmag +sNaN771 -sNaN772 -> -1
dqctm982 comparetotmag -sNaN771 +sNaN772 -> -1
dqctm983 comparetotmag +sNaN771 +sNaN772 -> -1
dqctm984 comparetotmag -sNaN772 -sNaN771 ->  1
dqctm985 comparetotmag +sNaN772 -sNaN771 ->  1
dqctm986 comparetotmag -sNaN772 +sNaN771 ->  1
dqctm987 comparetotmag +sNaN772 +sNaN771 ->  1

dqctm991 comparetotmag -sNaN99 -Inf    ->  1
dqctm992 comparetotmag  sNaN98 -11     ->  1
dqctm993 comparetotmag  sNaN97  NaN    -> -1
dqctm994 comparetotmag  sNaN16 sNaN94  -> -1
dqctm995 comparetotmag  NaN85  sNaN83  ->  1
dqctm996 comparetotmag -Inf    sNaN92  -> -1
dqctm997 comparetotmag  088    sNaN81  -> -1
dqctm998 comparetotmag  Inf    sNaN90  -> -1
dqctm999 comparetotmag  NaN   -sNaN89  ->  1

-- spread zeros
dqctm1110 comparetotmag   0E-6143  0        ->  -1
dqctm1111 comparetotmag   0E-6143 -0        ->  -1
dqctm1112 comparetotmag  -0E-6143  0        ->  -1
dqctm1113 comparetotmag  -0E-6143 -0        ->  -1
dqctm1114 comparetotmag   0E-6143  0E+6144   ->  -1
dqctm1115 comparetotmag   0E-6143 -0E+6144   ->  -1
dqctm1116 comparetotmag  -0E-6143  0E+6144   ->  -1
dqctm1117 comparetotmag  -0E-6143 -0E+6144   ->  -1
dqctm1118 comparetotmag   0       0E+6144   ->  -1
dqctm1119 comparetotmag   0      -0E+6144   ->  -1
dqctm1120 comparetotmag  -0       0E+6144   ->  -1
dqctm1121 comparetotmag  -0      -0E+6144   ->  -1

dqctm1130 comparetotmag   0E+6144  0        ->   1
dqctm1131 comparetotmag   0E+6144 -0        ->   1
dqctm1132 comparetotmag  -0E+6144  0        ->   1
dqctm1133 comparetotmag  -0E+6144 -0        ->   1
dqctm1134 comparetotmag   0E+6144  0E-6143   ->   1
dqctm1135 comparetotmag   0E+6144 -0E-6143   ->   1
dqctm1136 comparetotmag  -0E+6144  0E-6143   ->   1
dqctm1137 comparetotmag  -0E+6144 -0E-6143   ->   1
dqctm1138 comparetotmag   0       0E-6143   ->   1
dqctm1139 comparetotmag   0      -0E-6143   ->   1
dqctm1140 comparetotmag  -0       0E-6143   ->   1
dqctm1141 comparetotmag  -0      -0E-6143   ->   1

-- Null tests
dqctm9990 comparetotmag 10  # -> NaN Invalid_operation
dqctm9991 comparetotmag  # 10 -> NaN Invalid_operation

Added test/dectest/dqCopy.decTest.

















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
------------------------------------------------------------------------
-- dqCopy.decTest -- quiet decQuad copy                               --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Sanity check
dqcpy001 copy       +7.50  -> 7.50

-- Infinities
dqcpy011 copy  Infinity    -> Infinity
dqcpy012 copy  -Infinity   -> -Infinity

-- NaNs, 0 payload
dqcpy021 copy         NaN  -> NaN
dqcpy022 copy        -NaN  -> -NaN
dqcpy023 copy        sNaN  -> sNaN
dqcpy024 copy       -sNaN  -> -sNaN

-- NaNs, non-0 payload
dqcpy031 copy       NaN10  -> NaN10
dqcpy032 copy      -NaN10  -> -NaN10
dqcpy033 copy      sNaN10  -> sNaN10
dqcpy034 copy     -sNaN10  -> -sNaN10
dqcpy035 copy       NaN7   -> NaN7
dqcpy036 copy      -NaN7   -> -NaN7
dqcpy037 copy      sNaN101 -> sNaN101
dqcpy038 copy     -sNaN101 -> -sNaN101

-- finites
dqcpy101 copy          7   -> 7
dqcpy102 copy         -7   -> -7
dqcpy103 copy         75   -> 75
dqcpy104 copy        -75   -> -75
dqcpy105 copy       7.50   -> 7.50
dqcpy106 copy      -7.50   -> -7.50
dqcpy107 copy       7.500  -> 7.500
dqcpy108 copy      -7.500  -> -7.500

-- zeros
dqcpy111 copy          0   -> 0
dqcpy112 copy         -0   -> -0
dqcpy113 copy       0E+4   -> 0E+4
dqcpy114 copy      -0E+4   -> -0E+4
dqcpy115 copy     0.0000   -> 0.0000
dqcpy116 copy    -0.0000   -> -0.0000
dqcpy117 copy      0E-141  -> 0E-141
dqcpy118 copy     -0E-141  -> -0E-141

-- full coefficients, alternating bits
dqcpy121 copy   2682682682682682682682682682682682    ->  2682682682682682682682682682682682
dqcpy122 copy  -2682682682682682682682682682682682    -> -2682682682682682682682682682682682
dqcpy123 copy   1341341341341341341341341341341341    ->  1341341341341341341341341341341341
dqcpy124 copy  -1341341341341341341341341341341341    -> -1341341341341341341341341341341341

-- Nmax, Nmin, Ntiny
dqcpy131 copy  9.999999999999999999999999999999999E+6144   ->  9.999999999999999999999999999999999E+6144
dqcpy132 copy  1E-6143                                     ->  1E-6143
dqcpy133 copy  1.000000000000000000000000000000000E-6143   ->  1.000000000000000000000000000000000E-6143
dqcpy134 copy  1E-6176                                     ->  1E-6176

dqcpy135 copy  -1E-6176                                    -> -1E-6176
dqcpy136 copy  -1.000000000000000000000000000000000E-6143  -> -1.000000000000000000000000000000000E-6143
dqcpy137 copy  -1E-6143                                    -> -1E-6143
dqcpy138 copy  -9.999999999999999999999999999999999E+6144  -> -9.999999999999999999999999999999999E+6144

Added test/dectest/dqCopyAbs.decTest.

















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
------------------------------------------------------------------------
-- dqCopyAbs.decTest -- quiet decQuad copy and set sign to zero       --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Sanity check
dqcpa001 copyabs       +7.50  -> 7.50

-- Infinities
dqcpa011 copyabs  Infinity    -> Infinity
dqcpa012 copyabs  -Infinity   -> Infinity

-- NaNs, 0 payload
dqcpa021 copyabs         NaN  -> NaN
dqcpa022 copyabs        -NaN  -> NaN
dqcpa023 copyabs        sNaN  -> sNaN
dqcpa024 copyabs       -sNaN  -> sNaN

-- NaNs, non-0 payload
dqcpa031 copyabs       NaN10  -> NaN10
dqcpa032 copyabs      -NaN15  -> NaN15
dqcpa033 copyabs      sNaN15  -> sNaN15
dqcpa034 copyabs     -sNaN10  -> sNaN10
dqcpa035 copyabs       NaN7   -> NaN7
dqcpa036 copyabs      -NaN7   -> NaN7
dqcpa037 copyabs      sNaN101 -> sNaN101
dqcpa038 copyabs     -sNaN101 -> sNaN101

-- finites
dqcpa101 copyabs          7   -> 7
dqcpa102 copyabs         -7   -> 7
dqcpa103 copyabs         75   -> 75
dqcpa104 copyabs        -75   -> 75
dqcpa105 copyabs       7.10   -> 7.10
dqcpa106 copyabs      -7.10   -> 7.10
dqcpa107 copyabs       7.500  -> 7.500
dqcpa108 copyabs      -7.500  -> 7.500

-- zeros
dqcpa111 copyabs          0   -> 0
dqcpa112 copyabs         -0   -> 0
dqcpa113 copyabs       0E+6   -> 0E+6
dqcpa114 copyabs      -0E+6   -> 0E+6
dqcpa115 copyabs     0.0000   -> 0.0000
dqcpa116 copyabs    -0.0000   -> 0.0000
dqcpa117 copyabs      0E-141  -> 0E-141
dqcpa118 copyabs     -0E-141  -> 0E-141

-- full coefficients, alternating bits
dqcpa121 copyabs   2682682682682682682682682682682682    ->  2682682682682682682682682682682682
dqcpa122 copyabs  -2682682682682682682682682682682682    ->  2682682682682682682682682682682682
dqcpa123 copyabs   1341341341341341341341341341341341    ->  1341341341341341341341341341341341
dqcpa124 copyabs  -1341341341341341341341341341341341    ->  1341341341341341341341341341341341

-- Nmax, Nmin, Ntiny
dqcpa131 copyabs  9.999999999999999999999999999999999E+6144   ->  9.999999999999999999999999999999999E+6144
dqcpa132 copyabs  1E-6143                                     ->  1E-6143
dqcpa133 copyabs  1.000000000000000000000000000000000E-6143   ->  1.000000000000000000000000000000000E-6143
dqcpa134 copyabs  1E-6176                                     ->  1E-6176

dqcpa135 copyabs  -1E-6176                                    ->  1E-6176
dqcpa136 copyabs  -1.000000000000000000000000000000000E-6143  ->  1.000000000000000000000000000000000E-6143
dqcpa137 copyabs  -1E-6143                                    ->  1E-6143
dqcpa138 copyabs  -9.999999999999999999999999999999999E+6144  ->  9.999999999999999999999999999999999E+6144

Added test/dectest/dqCopyNegate.decTest.

















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
------------------------------------------------------------------------
-- dqCopyNegate.decTest -- quiet decQuad copy and negate              --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Sanity check
dqcpn001 copynegate       +7.50  -> -7.50

-- Infinities
dqcpn011 copynegate  Infinity    -> -Infinity
dqcpn012 copynegate  -Infinity   -> Infinity

-- NaNs, 0 payload
dqcpn021 copynegate         NaN  -> -NaN
dqcpn022 copynegate        -NaN  -> NaN
dqcpn023 copynegate        sNaN  -> -sNaN
dqcpn024 copynegate       -sNaN  -> sNaN

-- NaNs, non-0 payload
dqcpn031 copynegate       NaN13  -> -NaN13
dqcpn032 copynegate      -NaN13  -> NaN13
dqcpn033 copynegate      sNaN13  -> -sNaN13
dqcpn034 copynegate     -sNaN13  -> sNaN13
dqcpn035 copynegate       NaN70  -> -NaN70
dqcpn036 copynegate      -NaN70  -> NaN70
dqcpn037 copynegate      sNaN101 -> -sNaN101
dqcpn038 copynegate     -sNaN101 -> sNaN101

-- finites
dqcpn101 copynegate          7   -> -7
dqcpn102 copynegate         -7   -> 7
dqcpn103 copynegate         75   -> -75
dqcpn104 copynegate        -75   -> 75
dqcpn105 copynegate       7.50   -> -7.50
dqcpn106 copynegate      -7.50   -> 7.50
dqcpn107 copynegate       7.500  -> -7.500
dqcpn108 copynegate      -7.500  -> 7.500

-- zeros
dqcpn111 copynegate          0   -> -0
dqcpn112 copynegate         -0   -> 0
dqcpn113 copynegate       0E+4   -> -0E+4
dqcpn114 copynegate      -0E+4   -> 0E+4
dqcpn115 copynegate     0.0000   -> -0.0000
dqcpn116 copynegate    -0.0000   -> 0.0000
dqcpn117 copynegate      0E-141  -> -0E-141
dqcpn118 copynegate     -0E-141  -> 0E-141

-- full coefficients, alternating bits
dqcpn121 copynegate   2682682682682682682682682682682682    -> -2682682682682682682682682682682682
dqcpn122 copynegate  -2682682682682682682682682682682682    ->  2682682682682682682682682682682682
dqcpn123 copynegate   1341341341341341341341341341341341    -> -1341341341341341341341341341341341
dqcpn124 copynegate  -1341341341341341341341341341341341    ->  1341341341341341341341341341341341

-- Nmax, Nmin, Ntiny
dqcpn131 copynegate  9.999999999999999999999999999999999E+6144   -> -9.999999999999999999999999999999999E+6144
dqcpn132 copynegate  1E-6143                                     -> -1E-6143
dqcpn133 copynegate  1.000000000000000000000000000000000E-6143   -> -1.000000000000000000000000000000000E-6143
dqcpn134 copynegate  1E-6176                                     -> -1E-6176

dqcpn135 copynegate  -1E-6176                                    ->  1E-6176
dqcpn136 copynegate  -1.000000000000000000000000000000000E-6143  ->  1.000000000000000000000000000000000E-6143
dqcpn137 copynegate  -1E-6143                                    ->  1E-6143
dqcpn138 copynegate  -9.999999999999999999999999999999999E+6144  ->  9.999999999999999999999999999999999E+6144

Added test/dectest/dqCopySign.decTest.































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
------------------------------------------------------------------------
-- dqCopySign.decTest -- quiet decQuad copy with sign from rhs        --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Sanity check
dqcps001 copysign       +7.50     11 -> 7.50

-- Infinities
dqcps011 copysign  Infinity       11 -> Infinity
dqcps012 copysign  -Infinity      11 -> Infinity

-- NaNs, 0 payload
dqcps021 copysign         NaN     11 -> NaN
dqcps022 copysign        -NaN     11 -> NaN
dqcps023 copysign        sNaN     11 -> sNaN
dqcps024 copysign       -sNaN     11 -> sNaN

-- NaNs, non-0 payload
dqcps031 copysign       NaN10     11 -> NaN10
dqcps032 copysign      -NaN10     11 -> NaN10
dqcps033 copysign      sNaN10     11 -> sNaN10
dqcps034 copysign     -sNaN10     11 -> sNaN10
dqcps035 copysign       NaN7      11 -> NaN7
dqcps036 copysign      -NaN7      11 -> NaN7
dqcps037 copysign      sNaN101    11 -> sNaN101
dqcps038 copysign     -sNaN101    11 -> sNaN101

-- finites
dqcps101 copysign          7      11 -> 7
dqcps102 copysign         -7      11 -> 7
dqcps103 copysign         75      11 -> 75
dqcps104 copysign        -75      11 -> 75
dqcps105 copysign       7.50      11 -> 7.50
dqcps106 copysign      -7.50      11 -> 7.50
dqcps107 copysign       7.500     11 -> 7.500
dqcps108 copysign      -7.500     11 -> 7.500

-- zeros
dqcps111 copysign          0      11 -> 0
dqcps112 copysign         -0      11 -> 0
dqcps113 copysign       0E+4      11 -> 0E+4
dqcps114 copysign      -0E+4      11 -> 0E+4
dqcps115 copysign     0.0000      11 -> 0.0000
dqcps116 copysign    -0.0000      11 -> 0.0000
dqcps117 copysign      0E-141     11 -> 0E-141
dqcps118 copysign     -0E-141     11 -> 0E-141

-- full coefficients, alternating bits
dqcps121 copysign   2682682682682682682682682682682682 8  ->  2682682682682682682682682682682682
dqcps122 copysign  -2682682682682682682682682682682682 8  ->  2682682682682682682682682682682682
dqcps123 copysign   1341341341341341341341341341341341 8  ->  1341341341341341341341341341341341
dqcps124 copysign  -1341341341341341341341341341341341 8  ->  1341341341341341341341341341341341

-- Nmax, Nmin, Ntiny
dqcps131 copysign  9.999999999999999999999999999999999E+6144 8 ->  9.999999999999999999999999999999999E+6144
dqcps132 copysign  1E-6143                                   8 ->  1E-6143
dqcps133 copysign  1.000000000000000000000000000000000E-6143 8 ->  1.000000000000000000000000000000000E-6143
dqcps134 copysign  1E-6176                                   8 ->  1E-6176

dqcps135 copysign  -1E-6176                                   8 ->  1E-6176
dqcps136 copysign  -1.000000000000000000000000000000000E-6143 8 ->  1.000000000000000000000000000000000E-6143
dqcps137 copysign  -1E-6143                                   8 ->  1E-6143
dqcps138 copysign  -9.999999999999999999999999999999999E+6144 8 ->  9.999999999999999999999999999999999E+6144

-- repeat with negative RHS

-- Infinities
dqcps211 copysign  Infinity       -34 -> -Infinity
dqcps212 copysign  -Infinity      -34 -> -Infinity

-- NaNs, 0 payload
dqcps221 copysign         NaN     -34 -> -NaN
dqcps222 copysign        -NaN     -34 -> -NaN
dqcps223 copysign        sNaN     -34 -> -sNaN
dqcps224 copysign       -sNaN     -34 -> -sNaN

-- NaNs, non-0 payload
dqcps231 copysign       NaN10     -34 -> -NaN10
dqcps232 copysign      -NaN10     -34 -> -NaN10
dqcps233 copysign      sNaN10     -34 -> -sNaN10
dqcps234 copysign     -sNaN10     -34 -> -sNaN10
dqcps235 copysign       NaN7      -34 -> -NaN7
dqcps236 copysign      -NaN7      -34 -> -NaN7
dqcps237 copysign      sNaN101    -34 -> -sNaN101
dqcps238 copysign     -sNaN101    -34 -> -sNaN101

-- finites
dqcps301 copysign          7      -34 -> -7
dqcps302 copysign         -7      -34 -> -7
dqcps303 copysign         75      -34 -> -75
dqcps304 copysign        -75      -34 -> -75
dqcps305 copysign       7.50      -34 -> -7.50
dqcps306 copysign      -7.50      -34 -> -7.50
dqcps307 copysign       7.500     -34 -> -7.500
dqcps308 copysign      -7.500     -34 -> -7.500

-- zeros
dqcps311 copysign          0      -34 -> -0
dqcps312 copysign         -0      -34 -> -0
dqcps313 copysign       0E+4      -34 -> -0E+4
dqcps314 copysign      -0E+4      -34 -> -0E+4
dqcps315 copysign     0.0000      -34 -> -0.0000
dqcps316 copysign    -0.0000      -34 -> -0.0000
dqcps317 copysign      0E-141     -34 -> -0E-141
dqcps318 copysign     -0E-141     -34 -> -0E-141

-- full coefficients, alternating bits
dqcps321 copysign   2682682682682682682682682682682682 -9 -> -2682682682682682682682682682682682
dqcps322 copysign  -2682682682682682682682682682682682 -9 -> -2682682682682682682682682682682682
dqcps323 copysign   1341341341341341341341341341341341 -9 -> -1341341341341341341341341341341341
dqcps324 copysign  -1341341341341341341341341341341341 -9 -> -1341341341341341341341341341341341

-- Nmax, Nmin, Ntiny
dqcps331 copysign  9.999999999999999999999999999999999E+6144 -1  -> -9.999999999999999999999999999999999E+6144
dqcps332 copysign  1E-6143                                   -1  -> -1E-6143
dqcps333 copysign  1.000000000000000000000000000000000E-6143 -1  -> -1.000000000000000000000000000000000E-6143
dqcps334 copysign  1E-6176                                   -1  -> -1E-6176

dqcps335 copysign  -1E-6176                                   -3 -> -1E-6176
dqcps336 copysign  -1.000000000000000000000000000000000E-6143 -3 -> -1.000000000000000000000000000000000E-6143
dqcps337 copysign  -1E-6143                                   -3 -> -1E-6143
dqcps338 copysign  -9.999999999999999999999999999999999E+6144 -3 -> -9.999999999999999999999999999999999E+6144

-- Other kinds of RHS
dqcps401 copysign          701    -34 -> -701
dqcps402 copysign         -720    -34 -> -720
dqcps403 copysign          701    -0  -> -701
dqcps404 copysign         -720    -0  -> -720
dqcps405 copysign          701    +0  ->  701
dqcps406 copysign         -720    +0  ->  720
dqcps407 copysign          701    +34 ->  701
dqcps408 copysign         -720    +34 ->  720

dqcps413 copysign          701    -Inf  -> -701
dqcps414 copysign         -720    -Inf  -> -720
dqcps415 copysign          701    +Inf  ->  701
dqcps416 copysign         -720    +Inf  ->  720

dqcps420 copysign          701    -NaN  -> -701
dqcps421 copysign         -720    -NaN  -> -720
dqcps422 copysign          701    +NaN  ->  701
dqcps423 copysign         -720    +NaN  ->  720
dqcps425 copysign         -720    +NaN8 ->  720

dqcps426 copysign          701    -sNaN  -> -701
dqcps427 copysign         -720    -sNaN  -> -720
dqcps428 copysign          701    +sNaN  ->  701
dqcps429 copysign         -720    +sNaN  ->  720
dqcps430 copysign         -720    +sNaN3 ->  720

Added test/dectest/dqDivide.decTest.































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
------------------------------------------------------------------------
-- dqDivide.decTest -- decQuad division                               --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks
dqdiv001 divide  1     1    ->  1
dqdiv002 divide  2     1    ->  2
dqdiv003 divide  1     2    ->  0.5
dqdiv004 divide  2     2    ->  1
dqdiv005 divide  0     1    ->  0
dqdiv006 divide  0     2    ->  0
dqdiv007 divide  1     3    ->  0.3333333333333333333333333333333333 Inexact Rounded
dqdiv008 divide  2     3    ->  0.6666666666666666666666666666666667 Inexact Rounded
dqdiv009 divide  3     3    ->  1

dqdiv010 divide  2.4   1    ->  2.4
dqdiv011 divide  2.4   -1   ->  -2.4
dqdiv012 divide  -2.4  1    ->  -2.4
dqdiv013 divide  -2.4  -1   ->  2.4
dqdiv014 divide  2.40  1    ->  2.40
dqdiv015 divide  2.400 1    ->  2.400
dqdiv016 divide  2.4   2    ->  1.2
dqdiv017 divide  2.400 2    ->  1.200
dqdiv018 divide  2.    2    ->  1
dqdiv019 divide  20    20   ->  1

dqdiv020 divide  187   187    ->  1
dqdiv021 divide  5     2      ->  2.5
dqdiv022 divide  50    20     ->  2.5
dqdiv023 divide  500   200    ->  2.5
dqdiv024 divide  50.0  20.0   ->  2.5
dqdiv025 divide  5.00  2.00   ->  2.5
dqdiv026 divide  5     2.0    ->  2.5
dqdiv027 divide  5     2.000  ->  2.5
dqdiv028 divide  5     0.20   ->  25
dqdiv029 divide  5     0.200  ->  25
dqdiv030 divide  10    1      ->  10
dqdiv031 divide  100   1      ->  100
dqdiv032 divide  1000  1      ->  1000
dqdiv033 divide  1000  100    ->  10

dqdiv035 divide  1     2      ->  0.5
dqdiv036 divide  1     4      ->  0.25
dqdiv037 divide  1     8      ->  0.125
dqdiv038 divide  1     16     ->  0.0625
dqdiv039 divide  1     32     ->  0.03125
dqdiv040 divide  1     64     ->  0.015625
dqdiv041 divide  1    -2      ->  -0.5
dqdiv042 divide  1    -4      ->  -0.25
dqdiv043 divide  1    -8      ->  -0.125
dqdiv044 divide  1    -16     ->  -0.0625
dqdiv045 divide  1    -32     ->  -0.03125
dqdiv046 divide  1    -64     ->  -0.015625
dqdiv047 divide -1     2      ->  -0.5
dqdiv048 divide -1     4      ->  -0.25
dqdiv049 divide -1     8      ->  -0.125
dqdiv050 divide -1     16     ->  -0.0625
dqdiv051 divide -1     32     ->  -0.03125
dqdiv052 divide -1     64     ->  -0.015625
dqdiv053 divide -1    -2      ->  0.5
dqdiv054 divide -1    -4      ->  0.25
dqdiv055 divide -1    -8      ->  0.125
dqdiv056 divide -1    -16     ->  0.0625
dqdiv057 divide -1    -32     ->  0.03125
dqdiv058 divide -1    -64     ->  0.015625

-- bcdTime
dqdiv060 divide  1 7                   -> 0.1428571428571428571428571428571429 Inexact Rounded
dqdiv061 divide 1.2345678  1.9876543   -> 0.6211179680490717123193907511985359 Inexact Rounded

--               1234567890123456
dqdiv067 divide  9999999999999999999999999999999999  1 ->  9999999999999999999999999999999999
dqdiv068 divide  999999999999999999999999999999999   1 ->  999999999999999999999999999999999
dqdiv069 divide  99999999999999999999999999999999    1 ->  99999999999999999999999999999999
dqdiv070 divide  99999999999999999                   1 ->  99999999999999999
dqdiv071 divide  9999999999999999                    1 ->  9999999999999999
dqdiv072 divide  999999999999999                     1 ->  999999999999999
dqdiv073 divide  99999999999999                      1 ->  99999999999999
dqdiv074 divide  9999999999999                       1 ->  9999999999999
dqdiv075 divide  999999999999                        1 ->  999999999999
dqdiv076 divide  99999999999                         1 ->  99999999999
dqdiv077 divide  9999999999                          1 ->  9999999999
dqdiv078 divide  999999999                           1 ->  999999999
dqdiv079 divide  99999999                            1 ->  99999999
dqdiv080 divide  9999999                             1 ->  9999999
dqdiv081 divide  999999                              1 ->  999999
dqdiv082 divide  99999                               1 ->  99999
dqdiv083 divide  9999                                1 ->  9999
dqdiv084 divide  999                                 1 ->  999
dqdiv085 divide  99                                  1 ->  99
dqdiv086 divide  9                                   1 ->  9

dqdiv090 divide  0.            1    ->  0
dqdiv091 divide  .0            1    ->  0.0
dqdiv092 divide  0.00          1    ->  0.00
dqdiv093 divide  0.00E+9       1    ->  0E+7
dqdiv094 divide  0.0000E-50    1    ->  0E-54

dqdiv095 divide  1            1E-8  ->  1E+8
dqdiv096 divide  1            1E-9  ->  1E+9
dqdiv097 divide  1            1E-10 ->  1E+10
dqdiv098 divide  1            1E-11 ->  1E+11
dqdiv099 divide  1            1E-12 ->  1E+12

dqdiv100 divide  1  1   -> 1
dqdiv101 divide  1  2   -> 0.5
dqdiv102 divide  1  3   -> 0.3333333333333333333333333333333333 Inexact Rounded
dqdiv103 divide  1  4   -> 0.25
dqdiv104 divide  1  5   -> 0.2
dqdiv105 divide  1  6   -> 0.1666666666666666666666666666666667 Inexact Rounded
dqdiv106 divide  1  7   -> 0.1428571428571428571428571428571429 Inexact Rounded
dqdiv107 divide  1  8   -> 0.125
dqdiv108 divide  1  9   -> 0.1111111111111111111111111111111111 Inexact Rounded
dqdiv109 divide  1  10  -> 0.1
dqdiv110 divide  1  1   -> 1
dqdiv111 divide  2  1   -> 2
dqdiv112 divide  3  1   -> 3
dqdiv113 divide  4  1   -> 4
dqdiv114 divide  5  1   -> 5
dqdiv115 divide  6  1   -> 6
dqdiv116 divide  7  1   -> 7
dqdiv117 divide  8  1   -> 8
dqdiv118 divide  9  1   -> 9
dqdiv119 divide  10 1   -> 10

dqdiv120 divide  3E+1 0.001  -> 3E+4
dqdiv121 divide  2.200 2     -> 1.100

dqdiv130 divide  12345  4.999  -> 2469.493898779755951190238047609522  Inexact Rounded
dqdiv131 divide  12345  4.99   -> 2473.947895791583166332665330661323  Inexact Rounded
dqdiv132 divide  12345  4.9    -> 2519.387755102040816326530612244898  Inexact Rounded
dqdiv133 divide  12345  5      -> 2469
dqdiv134 divide  12345  5.1    -> 2420.588235294117647058823529411765  Inexact Rounded
dqdiv135 divide  12345  5.01   -> 2464.071856287425149700598802395210  Inexact Rounded
dqdiv136 divide  12345  5.001  -> 2468.506298740251949610077984403119  Inexact Rounded

-- test possibly imprecise results
dqdiv220 divide 391   597 ->  0.6549413735343383584589614740368509  Inexact Rounded
dqdiv221 divide 391  -597 -> -0.6549413735343383584589614740368509  Inexact Rounded
dqdiv222 divide -391  597 -> -0.6549413735343383584589614740368509  Inexact Rounded
dqdiv223 divide -391 -597 ->  0.6549413735343383584589614740368509  Inexact Rounded

-- test some cases that are close to exponent overflow
dqdiv270 divide 1 1e6144                  -> 1E-6144                 Subnormal
dqdiv271 divide 1 0.9e6144                -> 1.11111111111111111111111111111111E-6144  Rounded Inexact Subnormal Underflow
dqdiv272 divide 1 0.99e6144               -> 1.01010101010101010101010101010101E-6144  Rounded Inexact Subnormal Underflow
dqdiv273 divide 1 0.9999999999999999e6144 -> 1.00000000000000010000000000000001E-6144  Rounded Inexact Subnormal Underflow
dqdiv274 divide 9e6144    1               -> 9.000000000000000000000000000000000E+6144 Clamped
dqdiv275 divide 9.9e6144  1               -> 9.900000000000000000000000000000000E+6144 Clamped
dqdiv276 divide 9.99e6144 1               -> 9.990000000000000000000000000000000E+6144 Clamped
dqdiv277 divide 9.999999999999999e6144 1  -> 9.999999999999999000000000000000000E+6144 Clamped

dqdiv278 divide 1 0.9999999999999999999999999999999999e6144 -> 1.00000000000000000000000000000000E-6144  Rounded Inexact Subnormal Underflow
dqdiv279 divide 9.999999999999999999999999999999999e6144 1  -> 9.999999999999999999999999999999999E+6144

-- Divide into 0 tests
dqdiv301 divide    0    7     -> 0
dqdiv302 divide    0    7E-5  -> 0E+5
dqdiv303 divide    0    7E-1  -> 0E+1
dqdiv304 divide    0    7E+1  -> 0.0
dqdiv305 divide    0    7E+5  -> 0.00000
dqdiv306 divide    0    7E+6  -> 0.000000
dqdiv307 divide    0    7E+7  -> 0E-7
dqdiv308 divide    0   70E-5  -> 0E+5
dqdiv309 divide    0   70E-1  -> 0E+1
dqdiv310 divide    0   70E+0  -> 0
dqdiv311 divide    0   70E+1  -> 0.0
dqdiv312 divide    0   70E+5  -> 0.00000
dqdiv313 divide    0   70E+6  -> 0.000000
dqdiv314 divide    0   70E+7  -> 0E-7
dqdiv315 divide    0  700E-5  -> 0E+5
dqdiv316 divide    0  700E-1  -> 0E+1
dqdiv317 divide    0  700E+0  -> 0
dqdiv318 divide    0  700E+1  -> 0.0
dqdiv319 divide    0  700E+5  -> 0.00000
dqdiv320 divide    0  700E+6  -> 0.000000
dqdiv321 divide    0  700E+7  -> 0E-7
dqdiv322 divide    0  700E+77 -> 0E-77

dqdiv331 divide 0E-3    7E-5  -> 0E+2
dqdiv332 divide 0E-3    7E-1  -> 0.00
dqdiv333 divide 0E-3    7E+1  -> 0.0000
dqdiv334 divide 0E-3    7E+5  -> 0E-8
dqdiv335 divide 0E-1    7E-5  -> 0E+4
dqdiv336 divide 0E-1    7E-1  -> 0
dqdiv337 divide 0E-1    7E+1  -> 0.00
dqdiv338 divide 0E-1    7E+5  -> 0.000000
dqdiv339 divide 0E+1    7E-5  -> 0E+6
dqdiv340 divide 0E+1    7E-1  -> 0E+2
dqdiv341 divide 0E+1    7E+1  -> 0
dqdiv342 divide 0E+1    7E+5  -> 0.0000
dqdiv343 divide 0E+3    7E-5  -> 0E+8
dqdiv344 divide 0E+3    7E-1  -> 0E+4
dqdiv345 divide 0E+3    7E+1  -> 0E+2
dqdiv346 divide 0E+3    7E+5  -> 0.00

-- These were 'input rounding'
dqdiv441 divide 12345678000 1 -> 12345678000
dqdiv442 divide 1 12345678000 -> 8.100000664200054464404466081166219E-11 Inexact Rounded
dqdiv443 divide 1234567800  1 -> 1234567800
dqdiv444 divide 1 1234567800  -> 8.100000664200054464404466081166219E-10 Inexact Rounded
dqdiv445 divide 1234567890  1 -> 1234567890
dqdiv446 divide 1 1234567890  -> 8.100000073710000670761006103925156E-10 Inexact Rounded
dqdiv447 divide 1234567891  1 -> 1234567891
dqdiv448 divide 1 1234567891  -> 8.100000067149000556665214614754629E-10 Inexact Rounded
dqdiv449 divide 12345678901 1 -> 12345678901
dqdiv450 divide 1 12345678901 -> 8.100000073053900658873130042376760E-11 Inexact Rounded
dqdiv451 divide 1234567896  1 -> 1234567896
dqdiv452 divide 1 1234567896  -> 8.100000034344000145618560617422697E-10 Inexact Rounded

-- high-lows
dqdiv453 divide 1e+1   1    ->   1E+1
dqdiv454 divide 1e+1   1.0  ->   1E+1
dqdiv455 divide 1e+1   1.00 ->   1E+1
dqdiv456 divide 1e+2   2    ->   5E+1
dqdiv457 divide 1e+2   2.0  ->   5E+1
dqdiv458 divide 1e+2   2.00 ->   5E+1

-- some from IEEE discussions
dqdiv460 divide 3e0      2e0     -> 1.5
dqdiv461 divide 30e-1    2e0     -> 1.5
dqdiv462 divide 300e-2   2e0     -> 1.50
dqdiv464 divide 3000e-3  2e0     -> 1.500
dqdiv465 divide 3e0      20e-1   -> 1.5
dqdiv466 divide 30e-1    20e-1   -> 1.5
dqdiv467 divide 300e-2   20e-1   -> 1.5
dqdiv468 divide 3000e-3  20e-1   -> 1.50
dqdiv469 divide 3e0      200e-2  -> 1.5
dqdiv470 divide 30e-1    200e-2  -> 1.5
dqdiv471 divide 300e-2   200e-2  -> 1.5
dqdiv472 divide 3000e-3  200e-2  -> 1.5
dqdiv473 divide 3e0      2000e-3 -> 1.5
dqdiv474 divide 30e-1    2000e-3 -> 1.5
dqdiv475 divide 300e-2   2000e-3 -> 1.5
dqdiv476 divide 3000e-3  2000e-3 -> 1.5

-- some reciprocals
dqdiv480 divide 1        1.0E+33 -> 1E-33
dqdiv481 divide 1        10E+33  -> 1E-34
dqdiv482 divide 1        1.0E-33 -> 1E+33
dqdiv483 divide 1        10E-33  -> 1E+32

-- RMS discussion table
dqdiv484 divide 0e5     1e3 ->   0E+2
dqdiv485 divide 0e5     2e3 ->   0E+2
dqdiv486 divide 0e5    10e2 ->   0E+3
dqdiv487 divide 0e5    20e2 ->   0E+3
dqdiv488 divide 0e5   100e1 ->   0E+4
dqdiv489 divide 0e5   200e1 ->   0E+4

dqdiv491 divide 1e5     1e3 ->   1E+2
dqdiv492 divide 1e5     2e3 ->   5E+1
dqdiv493 divide 1e5    10e2 ->   1E+2
dqdiv494 divide 1e5    20e2 ->   5E+1
dqdiv495 divide 1e5   100e1 ->   1E+2
dqdiv496 divide 1e5   200e1 ->   5E+1

-- tryzeros cases
rounding:    half_up
dqdiv497  divide  0E+6108 1000E-33  -> 0E+6111 Clamped
dqdiv498  divide  0E-6170 1000E+33  -> 0E-6176 Clamped

rounding:    half_up

-- focus on trailing zeros issues
dqdiv500 divide  1      9.9    ->  0.1010101010101010101010101010101010  Inexact Rounded
dqdiv501 divide  1      9.09   ->  0.1100110011001100110011001100110011  Inexact Rounded
dqdiv502 divide  1      9.009  ->  0.1110001110001110001110001110001110  Inexact Rounded

dqdiv511 divide 1         2    -> 0.5
dqdiv512 divide 1.0       2    -> 0.5
dqdiv513 divide 1.00      2    -> 0.50
dqdiv514 divide 1.000     2    -> 0.500
dqdiv515 divide 1.0000    2    -> 0.5000
dqdiv516 divide 1.00000   2    -> 0.50000
dqdiv517 divide 1.000000  2    -> 0.500000
dqdiv518 divide 1.0000000 2    -> 0.5000000
dqdiv519 divide 1.00      2.00 -> 0.5

dqdiv521 divide 2    1         -> 2
dqdiv522 divide 2    1.0       -> 2
dqdiv523 divide 2    1.00      -> 2
dqdiv524 divide 2    1.000     -> 2
dqdiv525 divide 2    1.0000    -> 2
dqdiv526 divide 2    1.00000   -> 2
dqdiv527 divide 2    1.000000  -> 2
dqdiv528 divide 2    1.0000000 -> 2
dqdiv529 divide 2.00 1.00      -> 2

dqdiv530 divide  2.40   2      ->  1.20
dqdiv531 divide  2.40   4      ->  0.60
dqdiv532 divide  2.40  10      ->  0.24
dqdiv533 divide  2.40   2.0    ->  1.2
dqdiv534 divide  2.40   4.0    ->  0.6
dqdiv535 divide  2.40  10.0    ->  0.24
dqdiv536 divide  2.40   2.00   ->  1.2
dqdiv537 divide  2.40   4.00   ->  0.6
dqdiv538 divide  2.40  10.00   ->  0.24
dqdiv539 divide  0.9    0.1    ->  9
dqdiv540 divide  0.9    0.01   ->  9E+1
dqdiv541 divide  0.9    0.001  ->  9E+2
dqdiv542 divide  5      2      ->  2.5
dqdiv543 divide  5      2.0    ->  2.5
dqdiv544 divide  5      2.00   ->  2.5
dqdiv545 divide  5      20     ->  0.25
dqdiv546 divide  5      20.0   ->  0.25
dqdiv547 divide  2.400  2      ->  1.200
dqdiv548 divide  2.400  2.0    ->  1.20
dqdiv549 divide  2.400  2.400  ->  1

dqdiv550 divide  240    1      ->  240
dqdiv551 divide  240    10     ->  24
dqdiv552 divide  240    100    ->  2.4
dqdiv553 divide  240    1000   ->  0.24
dqdiv554 divide  2400   1      ->  2400
dqdiv555 divide  2400   10     ->  240
dqdiv556 divide  2400   100    ->  24
dqdiv557 divide  2400   1000   ->  2.4

-- +ve exponent
dqdiv600 divide  2.4E+9     2  ->  1.2E+9
dqdiv601 divide  2.40E+9    2  ->  1.20E+9
dqdiv602 divide  2.400E+9   2  ->  1.200E+9
dqdiv603 divide  2.4000E+9  2  ->  1.2000E+9
dqdiv604 divide  24E+8      2  ->  1.2E+9
dqdiv605 divide  240E+7     2  ->  1.20E+9
dqdiv606 divide  2400E+6    2  ->  1.200E+9
dqdiv607 divide  24000E+5   2  ->  1.2000E+9

-- more zeros, etc.
dqdiv731 divide 5.00 1E-3    -> 5.00E+3
dqdiv732 divide 00.00 0.000  -> NaN Division_undefined
dqdiv733 divide 00.00 0E-3   -> NaN Division_undefined
dqdiv734 divide  0    -0     -> NaN Division_undefined
dqdiv735 divide -0     0     -> NaN Division_undefined
dqdiv736 divide -0    -0     -> NaN Division_undefined

dqdiv741 divide  0    -1     -> -0
dqdiv742 divide -0    -1     ->  0
dqdiv743 divide  0     1     ->  0
dqdiv744 divide -0     1     -> -0
dqdiv745 divide -1     0     -> -Infinity Division_by_zero
dqdiv746 divide -1    -0     ->  Infinity Division_by_zero
dqdiv747 divide  1     0     ->  Infinity Division_by_zero
dqdiv748 divide  1    -0     -> -Infinity Division_by_zero

dqdiv751 divide  0.0  -1     -> -0.0
dqdiv752 divide -0.0  -1     ->  0.0
dqdiv753 divide  0.0   1     ->  0.0
dqdiv754 divide -0.0   1     -> -0.0
dqdiv755 divide -1.0   0     -> -Infinity Division_by_zero
dqdiv756 divide -1.0  -0     ->  Infinity Division_by_zero
dqdiv757 divide  1.0   0     ->  Infinity Division_by_zero
dqdiv758 divide  1.0  -0     -> -Infinity Division_by_zero

dqdiv761 divide  0    -1.0   -> -0E+1
dqdiv762 divide -0    -1.0   ->  0E+1
dqdiv763 divide  0     1.0   ->  0E+1
dqdiv764 divide -0     1.0   -> -0E+1
dqdiv765 divide -1     0.0   -> -Infinity Division_by_zero
dqdiv766 divide -1    -0.0   ->  Infinity Division_by_zero
dqdiv767 divide  1     0.0   ->  Infinity Division_by_zero
dqdiv768 divide  1    -0.0   -> -Infinity Division_by_zero

dqdiv771 divide  0.0  -1.0   -> -0
dqdiv772 divide -0.0  -1.0   ->  0
dqdiv773 divide  0.0   1.0   ->  0
dqdiv774 divide -0.0   1.0   -> -0
dqdiv775 divide -1.0   0.0   -> -Infinity Division_by_zero
dqdiv776 divide -1.0  -0.0   ->  Infinity Division_by_zero
dqdiv777 divide  1.0   0.0   ->  Infinity Division_by_zero
dqdiv778 divide  1.0  -0.0   -> -Infinity Division_by_zero

-- Specials
dqdiv780 divide  Inf  -Inf   ->  NaN Invalid_operation
dqdiv781 divide  Inf  -1000  -> -Infinity
dqdiv782 divide  Inf  -1     -> -Infinity
dqdiv783 divide  Inf  -0     -> -Infinity
dqdiv784 divide  Inf   0     ->  Infinity
dqdiv785 divide  Inf   1     ->  Infinity
dqdiv786 divide  Inf   1000  ->  Infinity
dqdiv787 divide  Inf   Inf   ->  NaN Invalid_operation
dqdiv788 divide -1000  Inf   -> -0E-6176 Clamped
dqdiv789 divide -Inf   Inf   ->  NaN Invalid_operation
dqdiv790 divide -1     Inf   -> -0E-6176 Clamped
dqdiv791 divide -0     Inf   -> -0E-6176 Clamped
dqdiv792 divide  0     Inf   ->  0E-6176 Clamped
dqdiv793 divide  1     Inf   ->  0E-6176 Clamped
dqdiv794 divide  1000  Inf   ->  0E-6176 Clamped
dqdiv795 divide  Inf   Inf   ->  NaN Invalid_operation

dqdiv800 divide -Inf  -Inf   ->  NaN Invalid_operation
dqdiv801 divide -Inf  -1000  ->  Infinity
dqdiv802 divide -Inf  -1     ->  Infinity
dqdiv803 divide -Inf  -0     ->  Infinity
dqdiv804 divide -Inf   0     -> -Infinity
dqdiv805 divide -Inf   1     -> -Infinity
dqdiv806 divide -Inf   1000  -> -Infinity
dqdiv807 divide -Inf   Inf   ->  NaN Invalid_operation
dqdiv808 divide -1000  Inf   -> -0E-6176 Clamped
dqdiv809 divide -Inf  -Inf   ->  NaN Invalid_operation
dqdiv810 divide -1    -Inf   ->  0E-6176 Clamped
dqdiv811 divide -0    -Inf   ->  0E-6176 Clamped
dqdiv812 divide  0    -Inf   -> -0E-6176 Clamped
dqdiv813 divide  1    -Inf   -> -0E-6176 Clamped
dqdiv814 divide  1000 -Inf   -> -0E-6176 Clamped
dqdiv815 divide  Inf  -Inf   ->  NaN Invalid_operation

dqdiv821 divide  NaN -Inf    ->  NaN
dqdiv822 divide  NaN -1000   ->  NaN
dqdiv823 divide  NaN -1      ->  NaN
dqdiv824 divide  NaN -0      ->  NaN
dqdiv825 divide  NaN  0      ->  NaN
dqdiv826 divide  NaN  1      ->  NaN
dqdiv827 divide  NaN  1000   ->  NaN
dqdiv828 divide  NaN  Inf    ->  NaN
dqdiv829 divide  NaN  NaN    ->  NaN
dqdiv830 divide -Inf  NaN    ->  NaN
dqdiv831 divide -1000 NaN    ->  NaN
dqdiv832 divide -1    NaN    ->  NaN
dqdiv833 divide -0    NaN    ->  NaN
dqdiv834 divide  0    NaN    ->  NaN
dqdiv835 divide  1    NaN    ->  NaN
dqdiv836 divide  1000 NaN    ->  NaN
dqdiv837 divide  Inf  NaN    ->  NaN

dqdiv841 divide  sNaN -Inf   ->  NaN  Invalid_operation
dqdiv842 divide  sNaN -1000  ->  NaN  Invalid_operation
dqdiv843 divide  sNaN -1     ->  NaN  Invalid_operation
dqdiv844 divide  sNaN -0     ->  NaN  Invalid_operation
dqdiv845 divide  sNaN  0     ->  NaN  Invalid_operation
dqdiv846 divide  sNaN  1     ->  NaN  Invalid_operation
dqdiv847 divide  sNaN  1000  ->  NaN  Invalid_operation
dqdiv848 divide  sNaN  NaN   ->  NaN  Invalid_operation
dqdiv849 divide  sNaN sNaN   ->  NaN  Invalid_operation
dqdiv850 divide  NaN  sNaN   ->  NaN  Invalid_operation
dqdiv851 divide -Inf  sNaN   ->  NaN  Invalid_operation
dqdiv852 divide -1000 sNaN   ->  NaN  Invalid_operation
dqdiv853 divide -1    sNaN   ->  NaN  Invalid_operation
dqdiv854 divide -0    sNaN   ->  NaN  Invalid_operation
dqdiv855 divide  0    sNaN   ->  NaN  Invalid_operation
dqdiv856 divide  1    sNaN   ->  NaN  Invalid_operation
dqdiv857 divide  1000 sNaN   ->  NaN  Invalid_operation
dqdiv858 divide  Inf  sNaN   ->  NaN  Invalid_operation
dqdiv859 divide  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqdiv861 divide  NaN9 -Inf   ->  NaN9
dqdiv862 divide  NaN8  1000  ->  NaN8
dqdiv863 divide  NaN7  Inf   ->  NaN7
dqdiv864 divide  NaN6  NaN5  ->  NaN6
dqdiv865 divide -Inf   NaN4  ->  NaN4
dqdiv866 divide -1000  NaN3  ->  NaN3
dqdiv867 divide  Inf   NaN2  ->  NaN2

dqdiv871 divide  sNaN99 -Inf    ->  NaN99 Invalid_operation
dqdiv872 divide  sNaN98 -1      ->  NaN98 Invalid_operation
dqdiv873 divide  sNaN97  NaN    ->  NaN97 Invalid_operation
dqdiv874 divide  sNaN96 sNaN94  ->  NaN96 Invalid_operation
dqdiv875 divide  NaN95  sNaN93  ->  NaN93 Invalid_operation
dqdiv876 divide -Inf    sNaN92  ->  NaN92 Invalid_operation
dqdiv877 divide  0      sNaN91  ->  NaN91 Invalid_operation
dqdiv878 divide  Inf    sNaN90  ->  NaN90 Invalid_operation
dqdiv879 divide  NaN    sNaN89  ->  NaN89 Invalid_operation

dqdiv881 divide  -NaN9  -Inf   ->  -NaN9
dqdiv882 divide  -NaN8   1000  ->  -NaN8
dqdiv883 divide  -NaN7   Inf   ->  -NaN7
dqdiv884 divide  -NaN6  -NaN5  ->  -NaN6
dqdiv885 divide  -Inf   -NaN4  ->  -NaN4
dqdiv886 divide  -1000  -NaN3  ->  -NaN3
dqdiv887 divide   Inf   -NaN2  ->  -NaN2

dqdiv891 divide -sNaN99 -Inf    -> -NaN99 Invalid_operation
dqdiv892 divide -sNaN98 -1      -> -NaN98 Invalid_operation
dqdiv893 divide -sNaN97  NaN    -> -NaN97 Invalid_operation
dqdiv894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation
dqdiv895 divide -NaN95  -sNaN93 -> -NaN93 Invalid_operation
dqdiv896 divide -Inf    -sNaN92 -> -NaN92 Invalid_operation
dqdiv897 divide  0      -sNaN91 -> -NaN91 Invalid_operation
dqdiv898 divide  Inf    -sNaN90 -> -NaN90 Invalid_operation
dqdiv899 divide -NaN    -sNaN89 -> -NaN89 Invalid_operation

-- Various flavours of divide by 0
dqdiv901 divide    0       0   ->  NaN Division_undefined
dqdiv902 divide    0.0E5   0   ->  NaN Division_undefined
dqdiv903 divide    0.000   0   ->  NaN Division_undefined
dqdiv904 divide    0.0001  0   ->  Infinity Division_by_zero
dqdiv905 divide    0.01    0   ->  Infinity Division_by_zero
dqdiv906 divide    0.1     0   ->  Infinity Division_by_zero
dqdiv907 divide    1       0   ->  Infinity Division_by_zero
dqdiv908 divide    1       0.0 ->  Infinity Division_by_zero
dqdiv909 divide   10       0.0 ->  Infinity Division_by_zero
dqdiv910 divide   1E+100   0.0 ->  Infinity Division_by_zero
dqdiv911 divide   1E+100   0   ->  Infinity Division_by_zero

dqdiv921 divide   -0.0001  0   -> -Infinity Division_by_zero
dqdiv922 divide   -0.01    0   -> -Infinity Division_by_zero
dqdiv923 divide   -0.1     0   -> -Infinity Division_by_zero
dqdiv924 divide   -1       0   -> -Infinity Division_by_zero
dqdiv925 divide   -1       0.0 -> -Infinity Division_by_zero
dqdiv926 divide  -10       0.0 -> -Infinity Division_by_zero
dqdiv927 divide  -1E+100   0.0 -> -Infinity Division_by_zero
dqdiv928 divide  -1E+100   0   -> -Infinity Division_by_zero

dqdiv931 divide    0.0001 -0   -> -Infinity Division_by_zero
dqdiv932 divide    0.01   -0   -> -Infinity Division_by_zero
dqdiv933 divide    0.1    -0   -> -Infinity Division_by_zero
dqdiv934 divide    1      -0   -> -Infinity Division_by_zero
dqdiv935 divide    1      -0.0 -> -Infinity Division_by_zero
dqdiv936 divide   10      -0.0 -> -Infinity Division_by_zero
dqdiv937 divide   1E+100  -0.0 -> -Infinity Division_by_zero
dqdiv938 divide   1E+100  -0   -> -Infinity Division_by_zero

dqdiv941 divide   -0.0001 -0   ->  Infinity Division_by_zero
dqdiv942 divide   -0.01   -0   ->  Infinity Division_by_zero
dqdiv943 divide   -0.1    -0   ->  Infinity Division_by_zero
dqdiv944 divide   -1      -0   ->  Infinity Division_by_zero
dqdiv945 divide   -1      -0.0 ->  Infinity Division_by_zero
dqdiv946 divide  -10      -0.0 ->  Infinity Division_by_zero
dqdiv947 divide  -1E+100  -0.0 ->  Infinity Division_by_zero
dqdiv948 divide  -1E+100  -0   ->  Infinity Division_by_zero

-- Examples from SQL proposal (Krishna Kulkarni)
dqdiv1021  divide 1E0          1E0 -> 1
dqdiv1022  divide 1E0          2E0 -> 0.5
dqdiv1023  divide 1E0          3E0 -> 0.3333333333333333333333333333333333 Inexact Rounded
dqdiv1024  divide 100E-2   1000E-3 -> 1
dqdiv1025  divide 24E-1        2E0 -> 1.2
dqdiv1026  divide 2400E-3      2E0 -> 1.200
dqdiv1027  divide 5E0          2E0 -> 2.5
dqdiv1028  divide 5E0        20E-1 -> 2.5
dqdiv1029  divide 5E0      2000E-3 -> 2.5
dqdiv1030  divide 5E0         2E-1 -> 25
dqdiv1031  divide 5E0        20E-2 -> 25
dqdiv1032  divide 480E-2       3E0 -> 1.60
dqdiv1033  divide 47E-1        2E0 -> 2.35

-- ECMAScript bad examples
rounding:    half_down
dqdiv1040  divide 5 9  -> 0.5555555555555555555555555555555556 Inexact Rounded
rounding:    half_even
dqdiv1041  divide 6 11 -> 0.5454545454545454545454545454545455 Inexact Rounded

-- overflow and underflow tests .. note subnormal results
-- signs
dqdiv1751 divide  1e+4277  1e-3311 ->  Infinity Overflow Inexact Rounded
dqdiv1752 divide  1e+4277 -1e-3311 -> -Infinity Overflow Inexact Rounded
dqdiv1753 divide -1e+4277  1e-3311 -> -Infinity Overflow Inexact Rounded
dqdiv1754 divide -1e+4277 -1e-3311 ->  Infinity Overflow Inexact Rounded
dqdiv1755 divide  1e-4277  1e+3311 ->  0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqdiv1756 divide  1e-4277 -1e+3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqdiv1757 divide -1e-4277  1e+3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqdiv1758 divide -1e-4277 -1e+3311 ->  0E-6176 Underflow Subnormal Inexact Rounded Clamped

-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
dqdiv1760 divide 1e-6069 1e+101 -> 1E-6170 Subnormal
dqdiv1761 divide 1e-6069 1e+102 -> 1E-6171 Subnormal
dqdiv1762 divide 1e-6069 1e+103 -> 1E-6172 Subnormal
dqdiv1763 divide 1e-6069 1e+104 -> 1E-6173 Subnormal
dqdiv1764 divide 1e-6069 1e+105 -> 1E-6174 Subnormal
dqdiv1765 divide 1e-6069 1e+106 -> 1E-6175 Subnormal
dqdiv1766 divide 1e-6069 1e+107 -> 1E-6176 Subnormal
dqdiv1767 divide 1e-6069 1e+108 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqdiv1768 divide 1e-6069 1e+109 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqdiv1769 divide 1e-6069 1e+110 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-- [no equivalent of 'subnormal' for overflow]
dqdiv1770 divide 1e+40 1e-6101 -> 1.000000000000000000000000000000E+6141 Clamped
dqdiv1771 divide 1e+40 1e-6102 -> 1.0000000000000000000000000000000E+6142  Clamped
dqdiv1772 divide 1e+40 1e-6103 -> 1.00000000000000000000000000000000E+6143  Clamped
dqdiv1773 divide 1e+40 1e-6104 -> 1.000000000000000000000000000000000E+6144  Clamped
dqdiv1774 divide 1e+40 1e-6105 -> Infinity Overflow Inexact Rounded
dqdiv1775 divide 1e+40 1e-6106 -> Infinity Overflow Inexact Rounded
dqdiv1776 divide 1e+40 1e-6107 -> Infinity Overflow Inexact Rounded
dqdiv1777 divide 1e+40 1e-6108 -> Infinity Overflow Inexact Rounded
dqdiv1778 divide 1e+40 1e-6109 -> Infinity Overflow Inexact Rounded
dqdiv1779 divide 1e+40 1e-6110 -> Infinity Overflow Inexact Rounded

dqdiv1801 divide  1.0000E-6172  1     -> 1.0000E-6172 Subnormal
dqdiv1802 divide  1.000E-6172   1e+1  -> 1.000E-6173  Subnormal
dqdiv1803 divide  1.00E-6172    1e+2  -> 1.00E-6174   Subnormal
dqdiv1804 divide  1.0E-6172     1e+3  -> 1.0E-6175    Subnormal
dqdiv1805 divide  1.0E-6172     1e+4  -> 1E-6176     Subnormal Rounded
dqdiv1806 divide  1.3E-6172     1e+4  -> 1E-6176     Underflow Subnormal Inexact Rounded
dqdiv1807 divide  1.5E-6172     1e+4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqdiv1808 divide  1.7E-6172     1e+4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqdiv1809 divide  2.3E-6172     1e+4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqdiv1810 divide  2.5E-6172     1e+4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqdiv1811 divide  2.7E-6172     1e+4  -> 3E-6176     Underflow Subnormal Inexact Rounded
dqdiv1812 divide  1.49E-6172    1e+4  -> 1E-6176     Underflow Subnormal Inexact Rounded
dqdiv1813 divide  1.50E-6172    1e+4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqdiv1814 divide  1.51E-6172    1e+4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqdiv1815 divide  2.49E-6172    1e+4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqdiv1816 divide  2.50E-6172    1e+4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqdiv1817 divide  2.51E-6172    1e+4  -> 3E-6176     Underflow Subnormal Inexact Rounded

dqdiv1818 divide  1E-6172       1e+4  -> 1E-6176     Subnormal
dqdiv1819 divide  3E-6172       1e+5  -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped
dqdiv1820 divide  5E-6172       1e+5  -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped
dqdiv1821 divide  7E-6172       1e+5  -> 1E-6176     Underflow Subnormal Inexact Rounded
dqdiv1822 divide  9E-6172       1e+5  -> 1E-6176     Underflow Subnormal Inexact Rounded
dqdiv1823 divide  9.9E-6172     1e+5  -> 1E-6176     Underflow Subnormal Inexact Rounded

dqdiv1824 divide  1E-6172      -1e+4  -> -1E-6176    Subnormal
dqdiv1825 divide  3E-6172      -1e+5  -> -0E-6176    Underflow Subnormal Inexact Rounded Clamped
dqdiv1826 divide -5E-6172       1e+5  -> -0E-6176    Underflow Subnormal Inexact Rounded Clamped
dqdiv1827 divide  7E-6172      -1e+5  -> -1E-6176    Underflow Subnormal Inexact Rounded
dqdiv1828 divide -9E-6172       1e+5  -> -1E-6176    Underflow Subnormal Inexact Rounded
dqdiv1829 divide  9.9E-6172    -1e+5  -> -1E-6176    Underflow Subnormal Inexact Rounded
dqdiv1830 divide  3.0E-6172    -1e+5  -> -0E-6176    Underflow Subnormal Inexact Rounded Clamped

dqdiv1831 divide  1.0E-5977     1e+200 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqdiv1832 divide  1.0E-5977     1e+199 -> 1E-6176   Subnormal Rounded
dqdiv1833 divide  1.0E-5977     1e+198 -> 1.0E-6175 Subnormal
dqdiv1834 divide  2.0E-5977     2e+198 -> 1.0E-6175 Subnormal
dqdiv1835 divide  4.0E-5977     4e+198 -> 1.0E-6175 Subnormal
dqdiv1836 divide 10.0E-5977    10e+198 -> 1.0E-6175 Subnormal
dqdiv1837 divide 30.0E-5977    30e+198 -> 1.0E-6175 Subnormal
dqdiv1838 divide 40.0E-5982    40e+166 -> 1.0E-6148 Subnormal
dqdiv1839 divide 40.0E-5982    40e+165 -> 1.0E-6147 Subnormal
dqdiv1840 divide 40.0E-5982    40e+164 -> 1.0E-6146 Subnormal

-- randoms
dqdiv2010  divide  -5231195652931651968034356117118850         -7243718664422548573203260970.34995          ->   722169.9095831284624736051460550680 Inexact Rounded
dqdiv2011  divide  -89584669773927.82711237350022515352        -42077943728529635884.21142627532985         ->   0.000002129017291146471565928125887527266 Inexact Rounded
dqdiv2012  divide  -2.828201693360723203806974891946180E-232    812596541221823960386384403089240.9         ->  -3.480450075640521320040055759125120E-265 Inexact Rounded
dqdiv2013  divide  -6442775372761069267502937539408720          24904085056.69185465145182606089196         ->  -258703556388226463687701.4884719589 Inexact Rounded
dqdiv2014  divide   5.535520011272625629610079879714705        -44343664650.57203052003068113531208         ->  -1.248322630728089308975940533493562E-10 Inexact Rounded
dqdiv2015  divide   65919273712517865964325.99419625010        -314733354141381737378622515.7789054         ->  -0.0002094448295521490616379784758911632 Inexact Rounded
dqdiv2016  divide  -7.779172568193197107115275140431129E+759   -140453015639.3988987652895178782143         ->   5.538629792161641534962774244238115E+748 Inexact Rounded
dqdiv2017  divide   644314832597569.0181226067518178797        -115024585257425.1635759521565201075         ->  -5.601540150356479257367687450922795 Inexact Rounded
dqdiv2018  divide   6.898640941579611450676592553286870E-47    -11272429881407851485163914999.25943         ->  -6.119923578285338689371137648319280E-75 Inexact Rounded
dqdiv2019  divide  -3591344544888727133.30819750163254          5329395.423792795661446561090331037         ->  -673874662941.1968525589460533725290 Inexact Rounded
dqdiv2020  divide  -7.682356781384631313156462724425838E+747   -6.60375855512219057281922141809940E+703     ->   1.163330960279556016678379128875149E+44 Inexact Rounded
dqdiv2021  divide  -4511495596596941820863224.274679699         3365395017.263329795449661616090724         ->  -1340554548115304.904166888018346299 Inexact Rounded
dqdiv2022  divide   5.211164127840931517263639608151299         164.5566381356276567012533847006453         ->   0.03166790587655228864478260157156510 Inexact Rounded
dqdiv2023  divide  -49891.2243893458830384077684620383         -47179.9312961860747554053371171530          ->   1.057467084386767291602189656430268 Inexact Rounded
dqdiv2024  divide   15065477.47214268488077415462413353         4366211.120892953261309529740552596         ->   3.450469309661227984244545513441359 Inexact Rounded
dqdiv2025  divide   1.575670269440761846109602429612644E+370    653199649324740300.006185482643439          ->   2.412233795700359170904588548041481E+352 Inexact Rounded
dqdiv2026  divide  -2112422311733448924573432192.620145        -80067206.03590693153848215848613406         ->   26383115089417660175.20102646756574 Inexact Rounded
dqdiv2027  divide  -67096536051279809.32218611548721839        -869685412881941081664251990181.1049         ->   7.715035236584805921278566365231168E-14 Inexact Rounded
dqdiv2028  divide  -58612908548962047.21866913425488972        -978449597531.3873665583475633831644         ->   59903.86085991703091236507859837023 Inexact Rounded
dqdiv2029  divide  -133032412010942.1476864138213319796        -7.882059293498670705446528648201359E-428    ->   1.687787506504433064549515681693715E+441 Inexact Rounded
dqdiv2030  divide   1.83746698338966029492299716360513E+977    -9.897926608979649951672839879128603E+154    ->  -1.856416051542212552042390218062458E+822 Inexact Rounded
dqdiv2031  divide  -113742475841399236307128962.1507063         8298602.203049834732657567965262989         ->  -13706221006665137826.16557393919929 Inexact Rounded
dqdiv2032  divide   196.4787574650754152995941808331862         929.6553388472318094427422117172394         ->   0.2113458066176526651006917922814018 Inexact Rounded
dqdiv2033  divide   71931221465.43867996282803628130350         3838685934206426257090718.402248853         ->   1.873850132527423413607199513324021E-14 Inexact Rounded
dqdiv2034  divide   488.4282502289651653783596246312885        -80.68940956806634280078706577953188         ->  -6.053189047280693318844801899473272 Inexact Rounded
dqdiv2035  divide   9.001764344963921754981762913247394E-162   -8.585540973667205753734967645386919E-729    ->  -1.048479574271827326396012573232934E+567 Inexact Rounded
dqdiv2036  divide  -7.404133959409894743706402857145471E-828   -51.38159929460289711134684843086265         ->   1.441008855516029461032061785219773E-829 Inexact Rounded
dqdiv2037  divide   2.967520235574419794048994436040717E-613   -6252513855.91394894949879262731889          ->  -4.746123405656409127572998751885338E-623 Inexact Rounded
dqdiv2038  divide  -18826852654824040505.83920366765051        -6336924877942437992590557460147340          ->   2.970976146546494669807886278519194E-15 Inexact Rounded
dqdiv2039  divide  -8.101406784809197604949584001735949E+561    4.823300306948942821076681658771635E+361    ->  -1.679639721610839204738445747238987E+200 Inexact Rounded
dqdiv2040  divide  -6.11981977773094052331062585191723E+295     1.507610253755339328302779005586534E+238    ->  -4.059285058911577244044418416044763E+57 Inexact Rounded
dqdiv2041  divide   6.472638850046815880599220534274055E-596   -4.475233712083047516933911786159972         ->  -1.446324207062261745520496475778879E-596 Inexact Rounded
dqdiv2042  divide  -84438593330.71277839631144509397112        -586684596204401664208947.4054879633         ->   1.439250218550041228759983937772504E-13 Inexact Rounded
dqdiv2043  divide   9.354533233294022616695815656704369E-24     405.500390626135304252144163591746          ->   2.306911028827774549740571229736198E-26 Inexact Rounded
dqdiv2044  divide   985606423350210.7374876650149957881        -36811563697.41925681866694859828794         ->  -26774.36990864119445335813354717711 Inexact Rounded
dqdiv2045  divide  -8.187280774177715706278002247766311E-123   -38784124393.91212870828430001300068         ->   2.110987653356139147357240727794365E-133 Inexact Rounded
dqdiv2046  divide  -4.612203126350070903459245798371657E+912    7.971562182727956290901984736800519E+64     ->  -5.785820922708683237098826662769748E+847 Inexact Rounded
dqdiv2047  divide   4.661015909421485298247928967977089E+888   -6.360911253323922338737311563845581E+388    ->  -7.327591478321365980156654539638836E+499 Inexact Rounded
dqdiv2048  divide   9156078172903.257500003260710833030         7.189796653262147139071634237964074E-90     ->   1.273482215766000994365201545096026E+102 Inexact Rounded
dqdiv2049  divide  -1.710722303327476586373477781276586E-311   -3167561628260156837329323.729380695         ->   5.400754599578613984875752958645655E-336 Inexact Rounded
dqdiv2050  divide  -4.647935210881806238321616345413021E-878    209388.5431867744648177308460639582         ->  -2.219765771394593733140494297388140E-883 Inexact Rounded
dqdiv2051  divide   5958.694728395760992719084781582700         4.541510156564315632536353171846096E-746    ->   1.312051393253638664947852693005480E+749 Inexact Rounded
dqdiv2052  divide  -7.935732544649702175256699886872093E-489   -7.433329073664793138998765647467971E+360    ->   1.067587949626076917672271619664656E-849 Inexact Rounded
dqdiv2053  divide  -2746650864601157.863589959939901350         7.016684945507647528907184694359598E+548    ->  -3.914456593009309529351254950429932E-534 Inexact Rounded
dqdiv2054  divide   3605149408631197365447953.994569178        -75614025825649082.78264864428237833         ->  -47678315.88472693507060063188020532 Inexact Rounded
dqdiv2055  divide   788194320921798404906375214.196349         -6.222718148433247384932573401976337E-418    ->  -1.266639918634671803982222244977287E+444 Inexact Rounded
dqdiv2056  divide   5620722730534752.758208943447603211         6.843552841168538319123000917657759E-139    ->   8.213164800485434666629970443739554E+153 Inexact Rounded
dqdiv2057  divide   7304534676713703938102.403949019402        -576169.3685010935108153023803590835         ->  -12677756014201995.31969237144394772 Inexact Rounded
dqdiv2058  divide   8067918762.134621639254916786945547        -8.774771480055536009105596163864758E+954    ->  -9.194448858836332156766764605125245E-946 Inexact Rounded
dqdiv2059  divide   8.702093454123046507578256899537563E-324   -5.875399733016018404580201176576293E-401    ->  -1.481106622452052581470443526957335E+77 Inexact Rounded
dqdiv2060  divide  -41426.01662518451861386352415092356         90.00146621684478300510769802013464         ->  -460.2815750287318692732067709176200 Inexact Rounded

-- Null tests
dqdiv9998 divide 10  # -> NaN Invalid_operation
dqdiv9999 divide  # 10 -> NaN Invalid_operation

Added test/dectest/dqDivideInt.decTest.





































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
------------------------------------------------------------------------
-- dqDivideInt.decTest -- decQuad integer division                    --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even


dqdvi001 divideint  1     1    ->  1
dqdvi002 divideint  2     1    ->  2
dqdvi003 divideint  1     2    ->  0
dqdvi004 divideint  2     2    ->  1
dqdvi005 divideint  0     1    ->  0
dqdvi006 divideint  0     2    ->  0
dqdvi007 divideint  1     3    ->  0
dqdvi008 divideint  2     3    ->  0
dqdvi009 divideint  3     3    ->  1

dqdvi010 divideint  2.4   1    ->  2
dqdvi011 divideint  2.4   -1   ->  -2
dqdvi012 divideint  -2.4  1    ->  -2
dqdvi013 divideint  -2.4  -1   ->  2
dqdvi014 divideint  2.40  1    ->  2
dqdvi015 divideint  2.400 1    ->  2
dqdvi016 divideint  2.4   2    ->  1
dqdvi017 divideint  2.400 2    ->  1
dqdvi018 divideint  2.    2    ->  1
dqdvi019 divideint  20    20   ->  1

dqdvi020 divideint  187   187  ->  1
dqdvi021 divideint  5     2    ->  2
dqdvi022 divideint  5     2.0    ->  2
dqdvi023 divideint  5     2.000  ->  2
dqdvi024 divideint  5     0.200  ->  25
dqdvi025 divideint  5     0.200  ->  25

dqdvi030 divideint  1     2      ->  0
dqdvi031 divideint  1     4      ->  0
dqdvi032 divideint  1     8      ->  0
dqdvi033 divideint  1     16     ->  0
dqdvi034 divideint  1     32     ->  0
dqdvi035 divideint  1     64     ->  0
dqdvi040 divideint  1    -2      -> -0
dqdvi041 divideint  1    -4      -> -0
dqdvi042 divideint  1    -8      -> -0
dqdvi043 divideint  1    -16     -> -0
dqdvi044 divideint  1    -32     -> -0
dqdvi045 divideint  1    -64     -> -0
dqdvi050 divideint -1     2      -> -0
dqdvi051 divideint -1     4      -> -0
dqdvi052 divideint -1     8      -> -0
dqdvi053 divideint -1     16     -> -0
dqdvi054 divideint -1     32     -> -0
dqdvi055 divideint -1     64     -> -0
dqdvi060 divideint -1    -2      ->  0
dqdvi061 divideint -1    -4      ->  0
dqdvi062 divideint -1    -8      ->  0
dqdvi063 divideint -1    -16     ->  0
dqdvi064 divideint -1    -32     ->  0
dqdvi065 divideint -1    -64     ->  0

-- similar with powers of ten
dqdvi160 divideint  1     1         ->  1
dqdvi161 divideint  1     10        ->  0
dqdvi162 divideint  1     100       ->  0
dqdvi163 divideint  1     1000      ->  0
dqdvi164 divideint  1     10000     ->  0
dqdvi165 divideint  1     100000    ->  0
dqdvi166 divideint  1     1000000   ->  0
dqdvi167 divideint  1     10000000  ->  0
dqdvi168 divideint  1     100000000 ->  0
dqdvi170 divideint  1    -1         -> -1
dqdvi171 divideint  1    -10        -> -0
dqdvi172 divideint  1    -100       -> -0
dqdvi173 divideint  1    -1000      -> -0
dqdvi174 divideint  1    -10000     -> -0
dqdvi175 divideint  1    -100000    -> -0
dqdvi176 divideint  1    -1000000   -> -0
dqdvi177 divideint  1    -10000000  -> -0
dqdvi178 divideint  1    -100000000 -> -0
dqdvi180 divideint -1     1         -> -1
dqdvi181 divideint -1     10        -> -0
dqdvi182 divideint -1     100       -> -0
dqdvi183 divideint -1     1000      -> -0
dqdvi184 divideint -1     10000     -> -0
dqdvi185 divideint -1     100000    -> -0
dqdvi186 divideint -1     1000000   -> -0
dqdvi187 divideint -1     10000000  -> -0
dqdvi188 divideint -1     100000000 -> -0
dqdvi190 divideint -1    -1         ->  1
dqdvi191 divideint -1    -10        ->  0
dqdvi192 divideint -1    -100       ->  0
dqdvi193 divideint -1    -1000      ->  0
dqdvi194 divideint -1    -10000     ->  0
dqdvi195 divideint -1    -100000    ->  0
dqdvi196 divideint -1    -1000000   ->  0
dqdvi197 divideint -1    -10000000  ->  0
dqdvi198 divideint -1    -100000000 ->  0

-- some long operand (at p=9) cases
dqdvi070 divideint  999999999     1  ->  999999999
dqdvi071 divideint  999999999.4   1  ->  999999999
dqdvi072 divideint  999999999.5   1  ->  999999999
dqdvi073 divideint  999999999.9   1  ->  999999999
dqdvi074 divideint  999999999.999 1  ->  999999999

dqdvi090 divideint  0.            1    ->  0
dqdvi091 divideint  .0            1    ->  0
dqdvi092 divideint  0.00          1    ->  0
dqdvi093 divideint  0.00E+9       1    ->  0
dqdvi094 divideint  0.0000E-50    1    ->  0

dqdvi100 divideint  1  1   -> 1
dqdvi101 divideint  1  2   -> 0
dqdvi102 divideint  1  3   -> 0
dqdvi103 divideint  1  4   -> 0
dqdvi104 divideint  1  5   -> 0
dqdvi105 divideint  1  6   -> 0
dqdvi106 divideint  1  7   -> 0
dqdvi107 divideint  1  8   -> 0
dqdvi108 divideint  1  9   -> 0
dqdvi109 divideint  1  10  -> 0
dqdvi110 divideint  1  1   -> 1
dqdvi111 divideint  2  1   -> 2
dqdvi112 divideint  3  1   -> 3
dqdvi113 divideint  4  1   -> 4
dqdvi114 divideint  5  1   -> 5
dqdvi115 divideint  6  1   -> 6
dqdvi116 divideint  7  1   -> 7
dqdvi117 divideint  8  1   -> 8
dqdvi118 divideint  9  1   -> 9
dqdvi119 divideint  10 1   -> 10

-- from DiagBigDecimal
dqdvi131 divideint  101.3   1     ->  101
dqdvi132 divideint  101.0   1     ->  101
dqdvi133 divideint  101.3   3     ->  33
dqdvi134 divideint  101.0   3     ->  33
dqdvi135 divideint  2.4     1     ->  2
dqdvi136 divideint  2.400   1     ->  2
dqdvi137 divideint  18      18    ->  1
dqdvi138 divideint  1120    1000  ->  1
dqdvi139 divideint  2.4     2     ->  1
dqdvi140 divideint  2.400   2     ->  1
dqdvi141 divideint  0.5     2.000 ->  0
dqdvi142 divideint  8.005   7     ->  1
dqdvi143 divideint  5       2     ->  2
dqdvi144 divideint  0       2     ->  0
dqdvi145 divideint  0.00    2     ->  0

-- Others
dqdvi150 divideint  12345  4.999  ->  2469
dqdvi151 divideint  12345  4.99   ->  2473
dqdvi152 divideint  12345  4.9    ->  2519
dqdvi153 divideint  12345  5      ->  2469
dqdvi154 divideint  12345  5.1    ->  2420
dqdvi155 divideint  12345  5.01   ->  2464
dqdvi156 divideint  12345  5.001  ->  2468
dqdvi157 divideint    101  7.6    ->  13

-- Various flavours of divideint by 0
dqdvi201 divideint  0      0   -> NaN Division_undefined
dqdvi202 divideint  0.0E5  0   -> NaN Division_undefined
dqdvi203 divideint  0.000  0   -> NaN Division_undefined
dqdvi204 divideint  0.0001 0   -> Infinity Division_by_zero
dqdvi205 divideint  0.01   0   -> Infinity Division_by_zero
dqdvi206 divideint  0.1    0   -> Infinity Division_by_zero
dqdvi207 divideint  1      0   -> Infinity Division_by_zero
dqdvi208 divideint  1      0.0 -> Infinity Division_by_zero
dqdvi209 divideint 10      0.0 -> Infinity Division_by_zero
dqdvi210 divideint 1E+100  0.0 -> Infinity Division_by_zero
dqdvi211 divideint 1E+380  0   -> Infinity Division_by_zero
dqdvi214 divideint  -0.0001 0   -> -Infinity Division_by_zero
dqdvi215 divideint  -0.01   0   -> -Infinity Division_by_zero
dqdvi216 divideint  -0.1    0   -> -Infinity Division_by_zero
dqdvi217 divideint  -1      0   -> -Infinity Division_by_zero
dqdvi218 divideint  -1      0.0 -> -Infinity Division_by_zero
dqdvi219 divideint -10      0.0 -> -Infinity Division_by_zero
dqdvi220 divideint -1E+100  0.0 -> -Infinity Division_by_zero
dqdvi221 divideint -1E+380  0   -> -Infinity Division_by_zero

-- test some cases that are close to exponent overflow
dqdvi270 divideint 1 1e384          -> 0
dqdvi271 divideint 1 0.9e384        -> 0
dqdvi272 divideint 1 0.99e384       -> 0
dqdvi273 divideint 1 0.9999999999999999e384       -> 0
dqdvi274 divideint 9e384    1       -> NaN Division_impossible
dqdvi275 divideint 9.9e384  1       -> NaN Division_impossible
dqdvi276 divideint 9.99e384 1       -> NaN Division_impossible
dqdvi277 divideint 9.999999999999999e384 1 -> NaN Division_impossible

dqdvi280 divideint 0.1 9e-383       -> NaN Division_impossible
dqdvi281 divideint 0.1 99e-383      -> NaN Division_impossible
dqdvi282 divideint 0.1 999e-383     -> NaN Division_impossible
dqdvi283 divideint 0.1 9e-382       -> NaN Division_impossible
dqdvi284 divideint 0.1 99e-382      -> NaN Division_impossible

-- GD edge cases: lhs smaller than rhs but more digits
dqdvi301  divideint  0.9      2      ->  0
dqdvi302  divideint  0.9      2.0    ->  0
dqdvi303  divideint  0.9      2.1    ->  0
dqdvi304  divideint  0.9      2.00   ->  0
dqdvi305  divideint  0.9      2.01   ->  0
dqdvi306  divideint  0.12     1      ->  0
dqdvi307  divideint  0.12     1.0    ->  0
dqdvi308  divideint  0.12     1.00   ->  0
dqdvi309  divideint  0.12     1.0    ->  0
dqdvi310  divideint  0.12     1.00   ->  0
dqdvi311  divideint  0.12     2      ->  0
dqdvi312  divideint  0.12     2.0    ->  0
dqdvi313  divideint  0.12     2.1    ->  0
dqdvi314  divideint  0.12     2.00   ->  0
dqdvi315  divideint  0.12     2.01   ->  0

-- edge cases of impossible
dqdvi330  divideint  1234567987654321987654321890123456  10    ->  123456798765432198765432189012345
dqdvi331  divideint  1234567987654321987654321890123456   1    ->  1234567987654321987654321890123456
dqdvi332  divideint  1234567987654321987654321890123456   0.1  ->  NaN Division_impossible
dqdvi333  divideint  1234567987654321987654321890123456   0.01 ->  NaN Division_impossible

-- overflow and underflow tests [from divide]
dqdvi1051 divideint  1e+277  1e-311 ->  NaN Division_impossible
dqdvi1052 divideint  1e+277 -1e-311 ->  NaN Division_impossible
dqdvi1053 divideint -1e+277  1e-311 ->  NaN Division_impossible
dqdvi1054 divideint -1e+277 -1e-311 ->  NaN Division_impossible
dqdvi1055 divideint  1e-277  1e+311 ->  0
dqdvi1056 divideint  1e-277 -1e+311 -> -0
dqdvi1057 divideint -1e-277  1e+311 -> -0
dqdvi1058 divideint -1e-277 -1e+311 ->  0

-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
dqdvi1060 divideint 1e-291 1e+101 -> 0
dqdvi1061 divideint 1e-291 1e+102 -> 0
dqdvi1062 divideint 1e-291 1e+103 -> 0
dqdvi1063 divideint 1e-291 1e+104 -> 0
dqdvi1064 divideint 1e-291 1e+105 -> 0
dqdvi1065 divideint 1e-291 1e+106 -> 0
dqdvi1066 divideint 1e-291 1e+107 -> 0
dqdvi1067 divideint 1e-291 1e+108 -> 0
dqdvi1068 divideint 1e-291 1e+109 -> 0
dqdvi1069 divideint 1e-291 1e+110 -> 0

dqdvi1101 divideint  1.0000E-394  1     -> 0
dqdvi1102 divideint  1.000E-394   1e+1  -> 0
dqdvi1103 divideint  1.00E-394    1e+2  -> 0

dqdvi1118 divideint  1E-394       1e+4  -> 0
dqdvi1119 divideint  3E-394      -1e+5  -> -0
dqdvi1120 divideint  5E-394       1e+5  -> 0

dqdvi1124 divideint  1E-394      -1e+4  -> -0
dqdvi1130 divideint  3.0E-394    -1e+5  -> -0

dqdvi1131 divideint  1.0E-199     1e+200 -> 0
dqdvi1132 divideint  1.0E-199     1e+199 -> 0
dqdvi1133 divideint  1.0E-199     1e+198 -> 0
dqdvi1134 divideint  2.0E-199     2e+198 -> 0
dqdvi1135 divideint  4.0E-199     4e+198 -> 0

-- long operand checks
dqdvi401 divideint 12345678000 100 -> 123456780
dqdvi402 divideint 1 12345678000   -> 0
dqdvi403 divideint 1234567800  10  -> 123456780
dqdvi404 divideint 1 1234567800    -> 0
dqdvi405 divideint 1234567890  10  -> 123456789
dqdvi406 divideint 1 1234567890    -> 0
dqdvi407 divideint 1234567891  10  -> 123456789
dqdvi408 divideint 1 1234567891    -> 0
dqdvi409 divideint 12345678901 100 -> 123456789
dqdvi410 divideint 1 12345678901   -> 0
dqdvi411 divideint 1234567896  10  -> 123456789
dqdvi412 divideint 1 1234567896    -> 0
dqdvi413 divideint 12345678948 100 -> 123456789
dqdvi414 divideint 12345678949 100 -> 123456789
dqdvi415 divideint 12345678950 100 -> 123456789
dqdvi416 divideint 12345678951 100 -> 123456789
dqdvi417 divideint 12345678999 100 -> 123456789
dqdvi441 divideint 12345678000 1 -> 12345678000
dqdvi442 divideint 1 12345678000 -> 0
dqdvi443 divideint 1234567800  1 -> 1234567800
dqdvi444 divideint 1 1234567800  -> 0
dqdvi445 divideint 1234567890  1 -> 1234567890
dqdvi446 divideint 1 1234567890  -> 0
dqdvi447 divideint 1234567891  1 -> 1234567891
dqdvi448 divideint 1 1234567891  -> 0
dqdvi449 divideint 12345678901 1 -> 12345678901
dqdvi450 divideint 1 12345678901 -> 0
dqdvi451 divideint 1234567896  1 -> 1234567896
dqdvi452 divideint 1 1234567896  -> 0

-- more zeros, etc.
dqdvi531 divideint 5.00 1E-3    -> 5000
dqdvi532 divideint 00.00 0.000  -> NaN Division_undefined
dqdvi533 divideint 00.00 0E-3   -> NaN Division_undefined
dqdvi534 divideint  0    -0     -> NaN Division_undefined
dqdvi535 divideint -0     0     -> NaN Division_undefined
dqdvi536 divideint -0    -0     -> NaN Division_undefined

dqdvi541 divideint  0    -1     -> -0
dqdvi542 divideint -0    -1     ->  0
dqdvi543 divideint  0     1     ->  0
dqdvi544 divideint -0     1     -> -0
dqdvi545 divideint -1     0     -> -Infinity Division_by_zero
dqdvi546 divideint -1    -0     ->  Infinity Division_by_zero
dqdvi547 divideint  1     0     ->  Infinity Division_by_zero
dqdvi548 divideint  1    -0     -> -Infinity Division_by_zero

dqdvi551 divideint  0.0  -1     -> -0
dqdvi552 divideint -0.0  -1     ->  0
dqdvi553 divideint  0.0   1     ->  0
dqdvi554 divideint -0.0   1     -> -0
dqdvi555 divideint -1.0   0     -> -Infinity Division_by_zero
dqdvi556 divideint -1.0  -0     ->  Infinity Division_by_zero
dqdvi557 divideint  1.0   0     ->  Infinity Division_by_zero
dqdvi558 divideint  1.0  -0     -> -Infinity Division_by_zero

dqdvi561 divideint  0    -1.0   -> -0
dqdvi562 divideint -0    -1.0   ->  0
dqdvi563 divideint  0     1.0   ->  0
dqdvi564 divideint -0     1.0   -> -0
dqdvi565 divideint -1     0.0   -> -Infinity Division_by_zero
dqdvi566 divideint -1    -0.0   ->  Infinity Division_by_zero
dqdvi567 divideint  1     0.0   ->  Infinity Division_by_zero
dqdvi568 divideint  1    -0.0   -> -Infinity Division_by_zero

dqdvi571 divideint  0.0  -1.0   -> -0
dqdvi572 divideint -0.0  -1.0   ->  0
dqdvi573 divideint  0.0   1.0   ->  0
dqdvi574 divideint -0.0   1.0   -> -0
dqdvi575 divideint -1.0   0.0   -> -Infinity Division_by_zero
dqdvi576 divideint -1.0  -0.0   ->  Infinity Division_by_zero
dqdvi577 divideint  1.0   0.0   ->  Infinity Division_by_zero
dqdvi578 divideint  1.0  -0.0   -> -Infinity Division_by_zero

-- Specials
dqdvi580 divideint  Inf  -Inf   ->  NaN Invalid_operation
dqdvi581 divideint  Inf  -1000  -> -Infinity
dqdvi582 divideint  Inf  -1     -> -Infinity
dqdvi583 divideint  Inf  -0     -> -Infinity
dqdvi584 divideint  Inf   0     ->  Infinity
dqdvi585 divideint  Inf   1     ->  Infinity
dqdvi586 divideint  Inf   1000  ->  Infinity
dqdvi587 divideint  Inf   Inf   ->  NaN Invalid_operation
dqdvi588 divideint -1000  Inf   -> -0
dqdvi589 divideint -Inf   Inf   ->  NaN Invalid_operation
dqdvi590 divideint -1     Inf   -> -0
dqdvi591 divideint -0     Inf   -> -0
dqdvi592 divideint  0     Inf   ->  0
dqdvi593 divideint  1     Inf   ->  0
dqdvi594 divideint  1000  Inf   ->  0
dqdvi595 divideint  Inf   Inf   ->  NaN Invalid_operation

dqdvi600 divideint -Inf  -Inf   ->  NaN Invalid_operation
dqdvi601 divideint -Inf  -1000  ->  Infinity
dqdvi602 divideint -Inf  -1     ->  Infinity
dqdvi603 divideint -Inf  -0     ->  Infinity
dqdvi604 divideint -Inf   0     -> -Infinity
dqdvi605 divideint -Inf   1     -> -Infinity
dqdvi606 divideint -Inf   1000  -> -Infinity
dqdvi607 divideint -Inf   Inf   ->  NaN Invalid_operation
dqdvi608 divideint -1000  Inf   -> -0
dqdvi609 divideint -Inf  -Inf   ->  NaN Invalid_operation
dqdvi610 divideint -1    -Inf   ->  0
dqdvi611 divideint -0    -Inf   ->  0
dqdvi612 divideint  0    -Inf   -> -0
dqdvi613 divideint  1    -Inf   -> -0
dqdvi614 divideint  1000 -Inf   -> -0
dqdvi615 divideint  Inf  -Inf   ->  NaN Invalid_operation

dqdvi621 divideint  NaN -Inf    ->  NaN
dqdvi622 divideint  NaN -1000   ->  NaN
dqdvi623 divideint  NaN -1      ->  NaN
dqdvi624 divideint  NaN -0      ->  NaN
dqdvi625 divideint  NaN  0      ->  NaN
dqdvi626 divideint  NaN  1      ->  NaN
dqdvi627 divideint  NaN  1000   ->  NaN
dqdvi628 divideint  NaN  Inf    ->  NaN
dqdvi629 divideint  NaN  NaN    ->  NaN
dqdvi630 divideint -Inf  NaN    ->  NaN
dqdvi631 divideint -1000 NaN    ->  NaN
dqdvi632 divideint -1    NaN    ->  NaN
dqdvi633 divideint -0    NaN    ->  NaN
dqdvi634 divideint  0    NaN    ->  NaN
dqdvi635 divideint  1    NaN    ->  NaN
dqdvi636 divideint  1000 NaN    ->  NaN
dqdvi637 divideint  Inf  NaN    ->  NaN

dqdvi641 divideint  sNaN -Inf   ->  NaN  Invalid_operation
dqdvi642 divideint  sNaN -1000  ->  NaN  Invalid_operation
dqdvi643 divideint  sNaN -1     ->  NaN  Invalid_operation
dqdvi644 divideint  sNaN -0     ->  NaN  Invalid_operation
dqdvi645 divideint  sNaN  0     ->  NaN  Invalid_operation
dqdvi646 divideint  sNaN  1     ->  NaN  Invalid_operation
dqdvi647 divideint  sNaN  1000  ->  NaN  Invalid_operation
dqdvi648 divideint  sNaN  NaN   ->  NaN  Invalid_operation
dqdvi649 divideint  sNaN sNaN   ->  NaN  Invalid_operation
dqdvi650 divideint  NaN  sNaN   ->  NaN  Invalid_operation
dqdvi651 divideint -Inf  sNaN   ->  NaN  Invalid_operation
dqdvi652 divideint -1000 sNaN   ->  NaN  Invalid_operation
dqdvi653 divideint -1    sNaN   ->  NaN  Invalid_operation
dqdvi654 divideint -0    sNaN   ->  NaN  Invalid_operation
dqdvi655 divideint  0    sNaN   ->  NaN  Invalid_operation
dqdvi656 divideint  1    sNaN   ->  NaN  Invalid_operation
dqdvi657 divideint  1000 sNaN   ->  NaN  Invalid_operation
dqdvi658 divideint  Inf  sNaN   ->  NaN  Invalid_operation
dqdvi659 divideint  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqdvi661 divideint  NaN9 -Inf   ->  NaN9
dqdvi662 divideint  NaN8  1000  ->  NaN8
dqdvi663 divideint  NaN7  Inf   ->  NaN7
dqdvi664 divideint -NaN6  NaN5  -> -NaN6
dqdvi665 divideint -Inf   NaN4  ->  NaN4
dqdvi666 divideint -1000  NaN3  ->  NaN3
dqdvi667 divideint  Inf  -NaN2  -> -NaN2

dqdvi671 divideint -sNaN99 -Inf    -> -NaN99 Invalid_operation
dqdvi672 divideint  sNaN98 -1      ->  NaN98 Invalid_operation
dqdvi673 divideint  sNaN97  NaN    ->  NaN97 Invalid_operation
dqdvi674 divideint  sNaN96 sNaN94  ->  NaN96 Invalid_operation
dqdvi675 divideint  NaN95  sNaN93  ->  NaN93 Invalid_operation
dqdvi676 divideint -Inf    sNaN92  ->  NaN92 Invalid_operation
dqdvi677 divideint  0      sNaN91  ->  NaN91 Invalid_operation
dqdvi678 divideint  Inf   -sNaN90  -> -NaN90 Invalid_operation
dqdvi679 divideint  NaN    sNaN89  ->  NaN89 Invalid_operation

-- Null tests
dqdvi900 divideint  10  # -> NaN Invalid_operation
dqdvi901 divideint   # 10 -> NaN Invalid_operation

Added test/dectest/dqEncode.decTest.













































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
------------------------------------------------------------------------
-- dqEncode.decTest -- decimal sixteen-byte format testcases          --
-- Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
-- [Previously called decimal128.decTest]
version: 2.55

-- This set of tests is for the sixteen-byte concrete representation.
-- Its characteristics are:
--
--   1 bit  sign
--   5 bits combination field
--  12 bits exponent continuation
-- 110 bits coefficient continuation
--
-- Total exponent length 14 bits
-- Total coefficient length 114 bits (34 digits)
--
-- Elimit = 12287 (maximum encoded exponent)
-- Emax   =  6144 (largest exponent value)
-- Emin   = -6143 (smallest exponent value)
-- bias   =  6176 (subtracted from encoded exponent) = -Etiny

-- The testcases here have only exactly representable data on the
-- 'left-hand-side'; rounding from strings is tested in 'base'
-- testcase groups.

extended:    1
clamp:       1
precision:   34
rounding:    half_up
maxExponent: 6144
minExponent: -6143

-- General testcases
-- (mostly derived from the Strawman 4 document and examples)
decq001 apply   #A20780000000000000000000000003D0 -> -7.50
decq002 apply   -7.50             -> #A20780000000000000000000000003D0
-- derivative canonical plain strings
decq003 apply   #A20840000000000000000000000003D0 -> -7.50E+3
decq004 apply   -7.50E+3          -> #A20840000000000000000000000003D0
decq005 apply   #A20800000000000000000000000003D0 -> -750
decq006 apply   -750              -> #A20800000000000000000000000003D0
decq007 apply   #A207c0000000000000000000000003D0 -> -75.0
decq008 apply   -75.0             -> #A207c0000000000000000000000003D0
decq009 apply   #A20740000000000000000000000003D0 -> -0.750
decq010 apply   -0.750            -> #A20740000000000000000000000003D0
decq011 apply   #A20700000000000000000000000003D0 -> -0.0750
decq012 apply   -0.0750           -> #A20700000000000000000000000003D0
decq013 apply   #A20680000000000000000000000003D0 -> -0.000750
decq014 apply   -0.000750         -> #A20680000000000000000000000003D0
decq015 apply   #A20600000000000000000000000003D0 -> -0.00000750
decq016 apply   -0.00000750       -> #A20600000000000000000000000003D0
decq017 apply   #A205c0000000000000000000000003D0 -> -7.50E-7
decq018 apply   -7.50E-7          -> #A205c0000000000000000000000003D0

-- Normality
decq020 apply   1234567890123456789012345678901234   -> #2608134b9c1e28e56f3c127177823534
decq021 apply  -1234567890123456789012345678901234   -> #a608134b9c1e28e56f3c127177823534
decq022 apply   1111111111111111111111111111111111   -> #26080912449124491244912449124491

-- Nmax and similar
decq031 apply   9.999999999999999999999999999999999E+6144  -> #77ffcff3fcff3fcff3fcff3fcff3fcff
decq032 apply   #77ffcff3fcff3fcff3fcff3fcff3fcff -> 9.999999999999999999999999999999999E+6144
decq033 apply   1.234567890123456789012345678901234E+6144 -> #47ffd34b9c1e28e56f3c127177823534
decq034 apply   #47ffd34b9c1e28e56f3c127177823534 -> 1.234567890123456789012345678901234E+6144
-- fold-downs (more below)
decq035 apply   1.23E+6144    -> #47ffd300000000000000000000000000 Clamped
decq036 apply   #47ffd300000000000000000000000000       -> 1.230000000000000000000000000000000E+6144
decq037 apply   1E+6144       -> #47ffc000000000000000000000000000 Clamped
decq038 apply   #47ffc000000000000000000000000000       -> 1.000000000000000000000000000000000E+6144

decq051 apply   12345                   -> #220800000000000000000000000049c5
decq052 apply   #220800000000000000000000000049c5       -> 12345
decq053 apply   1234                    -> #22080000000000000000000000000534
decq054 apply   #22080000000000000000000000000534       -> 1234
decq055 apply   123                     -> #220800000000000000000000000000a3
decq056 apply   #220800000000000000000000000000a3       -> 123
decq057 apply   12                      -> #22080000000000000000000000000012
decq058 apply   #22080000000000000000000000000012       -> 12
decq059 apply   1                       -> #22080000000000000000000000000001
decq060 apply   #22080000000000000000000000000001       -> 1
decq061 apply   1.23                    -> #220780000000000000000000000000a3
decq062 apply   #220780000000000000000000000000a3       -> 1.23
decq063 apply   123.45                  -> #220780000000000000000000000049c5
decq064 apply   #220780000000000000000000000049c5       -> 123.45

-- Nmin and below
decq071 apply   1E-6143                                    -> #00084000000000000000000000000001
decq072 apply   #00084000000000000000000000000001          -> 1E-6143
decq073 apply   1.000000000000000000000000000000000E-6143  -> #04000000000000000000000000000000
decq074 apply   #04000000000000000000000000000000          -> 1.000000000000000000000000000000000E-6143
decq075 apply   1.000000000000000000000000000000001E-6143  -> #04000000000000000000000000000001
decq076 apply   #04000000000000000000000000000001          -> 1.000000000000000000000000000000001E-6143

decq077 apply   0.100000000000000000000000000000000E-6143  -> #00000800000000000000000000000000      Subnormal
decq078 apply   #00000800000000000000000000000000          -> 1.00000000000000000000000000000000E-6144  Subnormal
decq079 apply   0.000000000000000000000000000000010E-6143  -> #00000000000000000000000000000010      Subnormal
decq080 apply   #00000000000000000000000000000010          -> 1.0E-6175              Subnormal
decq081 apply   0.00000000000000000000000000000001E-6143   -> #00004000000000000000000000000001      Subnormal
decq082 apply   #00004000000000000000000000000001          -> 1E-6175                Subnormal
decq083 apply   0.000000000000000000000000000000001E-6143  -> #00000000000000000000000000000001      Subnormal
decq084 apply   #00000000000000000000000000000001          -> 1E-6176                 Subnormal

-- underflows cannot be tested for simple copies, check edge cases
decq090 apply   1e-6176                  -> #00000000000000000000000000000001  Subnormal
decq100 apply   999999999999999999999999999999999e-6176 -> #00000ff3fcff3fcff3fcff3fcff3fcff  Subnormal

-- same again, negatives
-- Nmax and similar
decq122 apply  -9.999999999999999999999999999999999E+6144  -> #f7ffcff3fcff3fcff3fcff3fcff3fcff
decq123 apply   #f7ffcff3fcff3fcff3fcff3fcff3fcff -> -9.999999999999999999999999999999999E+6144
decq124 apply  -1.234567890123456789012345678901234E+6144 -> #c7ffd34b9c1e28e56f3c127177823534
decq125 apply   #c7ffd34b9c1e28e56f3c127177823534 -> -1.234567890123456789012345678901234E+6144
-- fold-downs (more below)
decq130 apply  -1.23E+6144    -> #c7ffd300000000000000000000000000 Clamped
decq131 apply   #c7ffd300000000000000000000000000       -> -1.230000000000000000000000000000000E+6144
decq132 apply  -1E+6144       -> #c7ffc000000000000000000000000000 Clamped
decq133 apply   #c7ffc000000000000000000000000000       -> -1.000000000000000000000000000000000E+6144

decq151 apply  -12345                   -> #a20800000000000000000000000049c5
decq152 apply   #a20800000000000000000000000049c5       -> -12345
decq153 apply  -1234                    -> #a2080000000000000000000000000534
decq154 apply   #a2080000000000000000000000000534       -> -1234
decq155 apply  -123                     -> #a20800000000000000000000000000a3
decq156 apply   #a20800000000000000000000000000a3       -> -123
decq157 apply  -12                      -> #a2080000000000000000000000000012
decq158 apply   #a2080000000000000000000000000012       -> -12
decq159 apply  -1                       -> #a2080000000000000000000000000001
decq160 apply   #a2080000000000000000000000000001       -> -1
decq161 apply  -1.23                    -> #a20780000000000000000000000000a3
decq162 apply   #a20780000000000000000000000000a3       -> -1.23
decq163 apply  -123.45                  -> #a20780000000000000000000000049c5
decq164 apply   #a20780000000000000000000000049c5       -> -123.45

-- Nmin and below
decq171 apply  -1E-6143                                    -> #80084000000000000000000000000001
decq172 apply   #80084000000000000000000000000001          -> -1E-6143
decq173 apply  -1.000000000000000000000000000000000E-6143  -> #84000000000000000000000000000000
decq174 apply   #84000000000000000000000000000000          -> -1.000000000000000000000000000000000E-6143
decq175 apply  -1.000000000000000000000000000000001E-6143  -> #84000000000000000000000000000001
decq176 apply   #84000000000000000000000000000001          -> -1.000000000000000000000000000000001E-6143

decq177 apply  -0.100000000000000000000000000000000E-6143  -> #80000800000000000000000000000000      Subnormal
decq178 apply   #80000800000000000000000000000000          -> -1.00000000000000000000000000000000E-6144  Subnormal
decq179 apply  -0.000000000000000000000000000000010E-6143  -> #80000000000000000000000000000010      Subnormal
decq180 apply   #80000000000000000000000000000010          -> -1.0E-6175              Subnormal
decq181 apply  -0.00000000000000000000000000000001E-6143   -> #80004000000000000000000000000001      Subnormal
decq182 apply   #80004000000000000000000000000001          -> -1E-6175                Subnormal
decq183 apply  -0.000000000000000000000000000000001E-6143  -> #80000000000000000000000000000001      Subnormal
decq184 apply   #80000000000000000000000000000001          -> -1E-6176                 Subnormal

-- underflow edge cases
decq190 apply   -1e-6176                  -> #80000000000000000000000000000001  Subnormal
decq200 apply   -999999999999999999999999999999999e-6176 -> #80000ff3fcff3fcff3fcff3fcff3fcff  Subnormal

-- zeros
decq400 apply   0E-8000                 -> #00000000000000000000000000000000  Clamped
decq401 apply   0E-6177                 -> #00000000000000000000000000000000  Clamped
decq402 apply   0E-6176                 -> #00000000000000000000000000000000
decq403 apply   #00000000000000000000000000000000       -> 0E-6176
decq404 apply   0.000000000000000000000000000000000E-6143  -> #00000000000000000000000000000000
decq405 apply   #00000000000000000000000000000000       -> 0E-6176
decq406 apply   0E-2                    -> #22078000000000000000000000000000
decq407 apply   #22078000000000000000000000000000       -> 0.00
decq408 apply   0                       -> #22080000000000000000000000000000
decq409 apply   #22080000000000000000000000000000       -> 0
decq410 apply   0E+3                    -> #2208c000000000000000000000000000
decq411 apply   #2208c000000000000000000000000000       -> 0E+3
decq412 apply   0E+6111                 -> #43ffc000000000000000000000000000
decq413 apply   #43ffc000000000000000000000000000       -> 0E+6111
-- clamped zeros...
decq414 apply   0E+6112                 -> #43ffc000000000000000000000000000  Clamped
decq415 apply   #43ffc000000000000000000000000000       -> 0E+6111
decq416 apply   0E+6144                 -> #43ffc000000000000000000000000000  Clamped
decq417 apply   #43ffc000000000000000000000000000       -> 0E+6111
decq418 apply   0E+8000                 -> #43ffc000000000000000000000000000  Clamped
decq419 apply   #43ffc000000000000000000000000000       -> 0E+6111

-- negative zeros
decq420 apply  -0E-8000                 -> #80000000000000000000000000000000  Clamped
decq421 apply  -0E-6177                 -> #80000000000000000000000000000000  Clamped
decq422 apply  -0E-6176                 -> #80000000000000000000000000000000
decq423 apply   #80000000000000000000000000000000       -> -0E-6176
decq424 apply  -0.000000000000000000000000000000000E-6143  -> #80000000000000000000000000000000
decq425 apply   #80000000000000000000000000000000       -> -0E-6176
decq426 apply  -0E-2                    -> #a2078000000000000000000000000000
decq427 apply   #a2078000000000000000000000000000       -> -0.00
decq428 apply  -0                       -> #a2080000000000000000000000000000
decq429 apply   #a2080000000000000000000000000000       -> -0
decq430 apply  -0E+3                    -> #a208c000000000000000000000000000
decq431 apply   #a208c000000000000000000000000000       -> -0E+3
decq432 apply  -0E+6111                 -> #c3ffc000000000000000000000000000
decq433 apply   #c3ffc000000000000000000000000000       -> -0E+6111
-- clamped zeros...
decq434 apply  -0E+6112                 -> #c3ffc000000000000000000000000000  Clamped
decq435 apply   #c3ffc000000000000000000000000000       -> -0E+6111
decq436 apply  -0E+6144                 -> #c3ffc000000000000000000000000000  Clamped
decq437 apply   #c3ffc000000000000000000000000000       -> -0E+6111
decq438 apply  -0E+8000                 -> #c3ffc000000000000000000000000000  Clamped
decq439 apply   #c3ffc000000000000000000000000000       -> -0E+6111

-- exponent lengths
decq440 apply   #22080000000000000000000000000007       -> 7
decq441 apply   7 -> #22080000000000000000000000000007
decq442 apply   #220a4000000000000000000000000007       -> 7E+9
decq443 apply   7E+9 -> #220a4000000000000000000000000007
decq444 apply   #2220c000000000000000000000000007       -> 7E+99
decq445 apply   7E+99 -> #2220c000000000000000000000000007
decq446 apply   #2301c000000000000000000000000007       -> 7E+999
decq447 apply   7E+999 -> #2301c000000000000000000000000007
decq448 apply   #43e3c000000000000000000000000007       -> 7E+5999
decq449 apply   7E+5999 -> #43e3c000000000000000000000000007

-- Specials
decq500 apply   Infinity                          -> #78000000000000000000000000000000
decq501 apply   #78787878787878787878787878787878 -> #78000000000000000000000000000000
decq502 apply   #78000000000000000000000000000000 -> Infinity
decq503 apply   #79797979797979797979797979797979 -> #78000000000000000000000000000000
decq504 apply   #79000000000000000000000000000000 -> Infinity
decq505 apply   #7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #78000000000000000000000000000000
decq506 apply   #7a000000000000000000000000000000 -> Infinity
decq507 apply   #7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #78000000000000000000000000000000
decq508 apply   #7b000000000000000000000000000000 -> Infinity

decq509 apply   NaN                               -> #7c000000000000000000000000000000
decq510 apply   #7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #7c003c7c7c7c7c7c7c7c7c7c7c7c7c7c
decq511 apply   #7c000000000000000000000000000000 -> NaN
decq512 apply   #7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #7c003d7d7d7d7d7d7d7d7d7d7d7d7d7d
decq513 apply   #7d000000000000000000000000000000 -> NaN
decq514 apply   #7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #7e003e7e7c7e7e7e7e7c7e7e7e7e7c7e
decq515 apply   #7e000000000000000000000000000000 -> sNaN
decq516 apply   #7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #7e003f7f7c7f7f7f7f7c7f7f7f7f7c7f
decq517 apply   #7f000000000000000000000000000000 -> sNaN
decq518 apply   #7fffffffffffffffffffffffffffffff -> sNaN999999999999999999999999999999999
decq519 apply   #7fffffffffffffffffffffffffffffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff

decq520 apply   -Infinity                         -> #f8000000000000000000000000000000
decq521 apply   #f8787878787878787878787878787878 -> #f8000000000000000000000000000000
decq522 apply   #f8000000000000000000000000000000 -> -Infinity
decq523 apply   #f9797979797979797979797979797979 -> #f8000000000000000000000000000000
decq524 apply   #f9000000000000000000000000000000 -> -Infinity
decq525 apply   #fa7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #f8000000000000000000000000000000
decq526 apply   #fa000000000000000000000000000000 -> -Infinity
decq527 apply   #fb7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #f8000000000000000000000000000000
decq528 apply   #fb000000000000000000000000000000 -> -Infinity

decq529 apply   -NaN                              -> #fc000000000000000000000000000000
decq530 apply   #fc7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #fc003c7c7c7c7c7c7c7c7c7c7c7c7c7c
decq531 apply   #fc000000000000000000000000000000 -> -NaN
decq532 apply   #fd7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #fc003d7d7d7d7d7d7d7d7d7d7d7d7d7d
decq533 apply   #fd000000000000000000000000000000 -> -NaN
decq534 apply   #fe7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #fe003e7e7c7e7e7e7e7c7e7e7e7e7c7e
decq535 apply   #fe000000000000000000000000000000 -> -sNaN
decq536 apply   #ff7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #fe003f7f7c7f7f7f7f7c7f7f7f7f7c7f
decq537 apply   #ff000000000000000000000000000000 -> -sNaN
decq538 apply   #ffffffffffffffffffffffffffffffff -> -sNaN999999999999999999999999999999999
decq539 apply   #ffffffffffffffffffffffffffffffff -> #fe000ff3fcff3fcff3fcff3fcff3fcff

decq540 apply   NaN               -> #7c000000000000000000000000000000
decq541 apply   NaN0              -> #7c000000000000000000000000000000
decq542 apply   NaN1              -> #7c000000000000000000000000000001
decq543 apply   NaN12             -> #7c000000000000000000000000000012
decq544 apply   NaN79             -> #7c000000000000000000000000000079
decq545 apply   NaN12345          -> #7c0000000000000000000000000049c5
decq546 apply   NaN123456         -> #7c000000000000000000000000028e56
decq547 apply   NaN799799         -> #7c0000000000000000000000000f7fdf
decq548 apply   NaN799799799799799799799799799799799  -> #7c003dff7fdff7fdff7fdff7fdff7fdf
decq549 apply   NaN999999999999999999999999999999999  -> #7c000ff3fcff3fcff3fcff3fcff3fcff
decq550 apply     9999999999999999999999999999999999  -> #6e080ff3fcff3fcff3fcff3fcff3fcff

-- fold-down full sequence
decq601 apply   1E+6144                 -> #47ffc000000000000000000000000000 Clamped
decq602 apply   #47ffc000000000000000000000000000       -> 1.000000000000000000000000000000000E+6144
decq603 apply   1E+6143                 -> #43ffc800000000000000000000000000 Clamped
decq604 apply   #43ffc800000000000000000000000000       -> 1.00000000000000000000000000000000E+6143
decq605 apply   1E+6142                 -> #43ffc100000000000000000000000000 Clamped
decq606 apply   #43ffc100000000000000000000000000       -> 1.0000000000000000000000000000000E+6142
decq607 apply   1E+6141                 -> #43ffc010000000000000000000000000 Clamped
decq608 apply   #43ffc010000000000000000000000000       -> 1.000000000000000000000000000000E+6141
decq609 apply   1E+6140                 -> #43ffc002000000000000000000000000 Clamped
decq610 apply   #43ffc002000000000000000000000000       -> 1.00000000000000000000000000000E+6140
decq611 apply   1E+6139                 -> #43ffc000400000000000000000000000 Clamped
decq612 apply   #43ffc000400000000000000000000000       -> 1.0000000000000000000000000000E+6139
decq613 apply   1E+6138                 -> #43ffc000040000000000000000000000 Clamped
decq614 apply   #43ffc000040000000000000000000000       -> 1.000000000000000000000000000E+6138
decq615 apply   1E+6137                 -> #43ffc000008000000000000000000000 Clamped
decq616 apply   #43ffc000008000000000000000000000       -> 1.00000000000000000000000000E+6137
decq617 apply   1E+6136                 -> #43ffc000001000000000000000000000 Clamped
decq618 apply   #43ffc000001000000000000000000000       -> 1.0000000000000000000000000E+6136
decq619 apply   1E+6135                 -> #43ffc000000100000000000000000000 Clamped
decq620 apply   #43ffc000000100000000000000000000       -> 1.000000000000000000000000E+6135
decq621 apply   1E+6134                 -> #43ffc000000020000000000000000000 Clamped
decq622 apply   #43ffc000000020000000000000000000       -> 1.00000000000000000000000E+6134
decq623 apply   1E+6133                 -> #43ffc000000004000000000000000000 Clamped
decq624 apply   #43ffc000000004000000000000000000       -> 1.0000000000000000000000E+6133
decq625 apply   1E+6132                 -> #43ffc000000000400000000000000000 Clamped
decq626 apply   #43ffc000000000400000000000000000       -> 1.000000000000000000000E+6132
decq627 apply   1E+6131                 -> #43ffc000000000080000000000000000 Clamped
decq628 apply   #43ffc000000000080000000000000000       -> 1.00000000000000000000E+6131
decq629 apply   1E+6130                 -> #43ffc000000000010000000000000000 Clamped
decq630 apply   #43ffc000000000010000000000000000       -> 1.0000000000000000000E+6130
decq631 apply   1E+6129                 -> #43ffc000000000001000000000000000 Clamped
decq632 apply   #43ffc000000000001000000000000000       -> 1.000000000000000000E+6129
decq633 apply   1E+6128                 -> #43ffc000000000000200000000000000 Clamped
decq634 apply   #43ffc000000000000200000000000000       -> 1.00000000000000000E+6128
decq635 apply   1E+6127                 -> #43ffc000000000000040000000000000 Clamped
decq636 apply   #43ffc000000000000040000000000000       -> 1.0000000000000000E+6127
decq637 apply   1E+6126                 -> #43ffc000000000000004000000000000 Clamped
decq638 apply   #43ffc000000000000004000000000000       -> 1.000000000000000E+6126
decq639 apply   1E+6125                 -> #43ffc000000000000000800000000000 Clamped
decq640 apply   #43ffc000000000000000800000000000       -> 1.00000000000000E+6125
decq641 apply   1E+6124                 -> #43ffc000000000000000100000000000 Clamped
decq642 apply   #43ffc000000000000000100000000000       -> 1.0000000000000E+6124
decq643 apply   1E+6123                 -> #43ffc000000000000000010000000000 Clamped
decq644 apply   #43ffc000000000000000010000000000       -> 1.000000000000E+6123
decq645 apply   1E+6122                 -> #43ffc000000000000000002000000000 Clamped
decq646 apply   #43ffc000000000000000002000000000       -> 1.00000000000E+6122
decq647 apply   1E+6121                 -> #43ffc000000000000000000400000000 Clamped
decq648 apply   #43ffc000000000000000000400000000       -> 1.0000000000E+6121
decq649 apply   1E+6120                 -> #43ffc000000000000000000040000000 Clamped
decq650 apply   #43ffc000000000000000000040000000       -> 1.000000000E+6120
decq651 apply   1E+6119                 -> #43ffc000000000000000000008000000 Clamped
decq652 apply   #43ffc000000000000000000008000000       -> 1.00000000E+6119
decq653 apply   1E+6118                 -> #43ffc000000000000000000001000000 Clamped
decq654 apply   #43ffc000000000000000000001000000       -> 1.0000000E+6118
decq655 apply   1E+6117                 -> #43ffc000000000000000000000100000 Clamped
decq656 apply   #43ffc000000000000000000000100000       -> 1.000000E+6117
decq657 apply   1E+6116                 -> #43ffc000000000000000000000020000 Clamped
decq658 apply   #43ffc000000000000000000000020000       -> 1.00000E+6116
decq659 apply   1E+6115                 -> #43ffc000000000000000000000004000 Clamped
decq660 apply   #43ffc000000000000000000000004000       -> 1.0000E+6115
decq661 apply   1E+6114                 -> #43ffc000000000000000000000000400 Clamped
decq662 apply   #43ffc000000000000000000000000400       -> 1.000E+6114
decq663 apply   1E+6113                 -> #43ffc000000000000000000000000080 Clamped
decq664 apply   #43ffc000000000000000000000000080       -> 1.00E+6113
decq665 apply   1E+6112                 -> #43ffc000000000000000000000000010 Clamped
decq666 apply   #43ffc000000000000000000000000010       -> 1.0E+6112
decq667 apply   1E+6111                 -> #43ffc000000000000000000000000001
decq668 apply   #43ffc000000000000000000000000001       -> 1E+6111
decq669 apply   1E+6110                 -> #43ff8000000000000000000000000001
decq670 apply   #43ff8000000000000000000000000001       -> 1E+6110

-- Selected DPD codes
decq700 apply   #22080000000000000000000000000000       -> 0
decq701 apply   #22080000000000000000000000000009       -> 9
decq702 apply   #22080000000000000000000000000010       -> 10
decq703 apply   #22080000000000000000000000000019       -> 19
decq704 apply   #22080000000000000000000000000020       -> 20
decq705 apply   #22080000000000000000000000000029       -> 29
decq706 apply   #22080000000000000000000000000030       -> 30
decq707 apply   #22080000000000000000000000000039       -> 39
decq708 apply   #22080000000000000000000000000040       -> 40
decq709 apply   #22080000000000000000000000000049       -> 49
decq710 apply   #22080000000000000000000000000050       -> 50
decq711 apply   #22080000000000000000000000000059       -> 59
decq712 apply   #22080000000000000000000000000060       -> 60
decq713 apply   #22080000000000000000000000000069       -> 69
decq714 apply   #22080000000000000000000000000070       -> 70
decq715 apply   #22080000000000000000000000000071       -> 71
decq716 apply   #22080000000000000000000000000072       -> 72
decq717 apply   #22080000000000000000000000000073       -> 73
decq718 apply   #22080000000000000000000000000074       -> 74
decq719 apply   #22080000000000000000000000000075       -> 75
decq720 apply   #22080000000000000000000000000076       -> 76
decq721 apply   #22080000000000000000000000000077       -> 77
decq722 apply   #22080000000000000000000000000078       -> 78
decq723 apply   #22080000000000000000000000000079       -> 79

decq730 apply   #2208000000000000000000000000029e       -> 994
decq731 apply   #2208000000000000000000000000029f       -> 995
decq732 apply   #220800000000000000000000000002a0       -> 520
decq733 apply   #220800000000000000000000000002a1       -> 521

-- DPD: one of each of the huffman groups
decq740 apply   #220800000000000000000000000003f7       -> 777
decq741 apply   #220800000000000000000000000003f8       -> 778
decq742 apply   #220800000000000000000000000003eb       -> 787
decq743 apply   #2208000000000000000000000000037d       -> 877
decq744 apply   #2208000000000000000000000000039f       -> 997
decq745 apply   #220800000000000000000000000003bf       -> 979
decq746 apply   #220800000000000000000000000003df       -> 799
decq747 apply   #2208000000000000000000000000006e       -> 888


-- DPD all-highs cases (includes the 24 redundant codes)
decq750 apply   #2208000000000000000000000000006e       -> 888
decq751 apply   #2208000000000000000000000000016e       -> 888
decq752 apply   #2208000000000000000000000000026e       -> 888
decq753 apply   #2208000000000000000000000000036e       -> 888
decq754 apply   #2208000000000000000000000000006f       -> 889
decq755 apply   #2208000000000000000000000000016f       -> 889
decq756 apply   #2208000000000000000000000000026f       -> 889
decq757 apply   #2208000000000000000000000000036f       -> 889

decq760 apply   #2208000000000000000000000000007e       -> 898
decq761 apply   #2208000000000000000000000000017e       -> 898
decq762 apply   #2208000000000000000000000000027e       -> 898
decq763 apply   #2208000000000000000000000000037e       -> 898
decq764 apply   #2208000000000000000000000000007f       -> 899
decq765 apply   #2208000000000000000000000000017f       -> 899
decq766 apply   #2208000000000000000000000000027f       -> 899
decq767 apply   #2208000000000000000000000000037f       -> 899

decq770 apply   #220800000000000000000000000000ee       -> 988
decq771 apply   #220800000000000000000000000001ee       -> 988
decq772 apply   #220800000000000000000000000002ee       -> 988
decq773 apply   #220800000000000000000000000003ee       -> 988
decq774 apply   #220800000000000000000000000000ef       -> 989
decq775 apply   #220800000000000000000000000001ef       -> 989
decq776 apply   #220800000000000000000000000002ef       -> 989
decq777 apply   #220800000000000000000000000003ef       -> 989

decq780 apply   #220800000000000000000000000000fe       -> 998
decq781 apply   #220800000000000000000000000001fe       -> 998
decq782 apply   #220800000000000000000000000002fe       -> 998
decq783 apply   #220800000000000000000000000003fe       -> 998
decq784 apply   #220800000000000000000000000000ff       -> 999
decq785 apply   #220800000000000000000000000001ff       -> 999
decq786 apply   #220800000000000000000000000002ff       -> 999
decq787 apply   #220800000000000000000000000003ff       -> 999

-- Miscellaneous (testers' queries, etc.)

decq790 apply   #2208000000000000000000000000c000       -> 30000
decq791 apply   #22080000000000000000000000007800       -> 890000
decq792 apply   30000 -> #2208000000000000000000000000c000
decq793 apply   890000 -> #22080000000000000000000000007800

-- values around [u]int32 edges (zeros done earlier)
decq800 apply -2147483646  -> #a208000000000000000000008c78af46
decq801 apply -2147483647  -> #a208000000000000000000008c78af47
decq802 apply -2147483648  -> #a208000000000000000000008c78af48
decq803 apply -2147483649  -> #a208000000000000000000008c78af49
decq804 apply  2147483646  -> #2208000000000000000000008c78af46
decq805 apply  2147483647  -> #2208000000000000000000008c78af47
decq806 apply  2147483648  -> #2208000000000000000000008c78af48
decq807 apply  2147483649  -> #2208000000000000000000008c78af49
decq808 apply  4294967294  -> #22080000000000000000000115afb55a
decq809 apply  4294967295  -> #22080000000000000000000115afb55b
decq810 apply  4294967296  -> #22080000000000000000000115afb57a
decq811 apply  4294967297  -> #22080000000000000000000115afb57b

decq820 apply  #a208000000000000000000008c78af46 -> -2147483646
decq821 apply  #a208000000000000000000008c78af47 -> -2147483647
decq822 apply  #a208000000000000000000008c78af48 -> -2147483648
decq823 apply  #a208000000000000000000008c78af49 -> -2147483649
decq824 apply  #2208000000000000000000008c78af46 ->  2147483646
decq825 apply  #2208000000000000000000008c78af47 ->  2147483647
decq826 apply  #2208000000000000000000008c78af48 ->  2147483648
decq827 apply  #2208000000000000000000008c78af49 ->  2147483649
decq828 apply  #22080000000000000000000115afb55a ->  4294967294
decq829 apply  #22080000000000000000000115afb55b ->  4294967295
decq830 apply  #22080000000000000000000115afb57a ->  4294967296
decq831 apply  #22080000000000000000000115afb57b ->  4294967297

Added test/dectest/dqFMA.decTest.































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
------------------------------------------------------------------------
-- dqFMA.decTest -- decQuad Fused Multiply Add                        --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- These tests comprese three parts:
--   1. Sanity checks and other three-operand tests (especially those
--      where the fused operation makes a difference)
--   2. Multiply tests (third operand is neutral zero [0E+emax])
--   3. Addition tests (first operand is 1)
-- The multiply and addition tests are extensive because FMA may have
-- its own dedicated multiplication or addition routine(s), and they
-- also inherently check the left-to-right properties.

-- Sanity checks
dqfma0001 fma  1   1   1 ->   2
dqfma0002 fma  1   1   2 ->   3
dqfma0003 fma  2   2   3 ->   7
dqfma0004 fma  9   9   9 ->  90
dqfma0005 fma -1   1   1 ->   0
dqfma0006 fma -1   1   2 ->   1
dqfma0007 fma -2   2   3 ->  -1
dqfma0008 fma -9   9   9 -> -72
dqfma0011 fma  1  -1   1 ->   0
dqfma0012 fma  1  -1   2 ->   1
dqfma0013 fma  2  -2   3 ->  -1
dqfma0014 fma  9  -9   9 -> -72
dqfma0015 fma  1   1  -1 ->   0
dqfma0016 fma  1   1  -2 ->  -1
dqfma0017 fma  2   2  -3 ->   1
dqfma0018 fma  9   9  -9 ->  72

-- non-integer exacts
dqfma0100  fma    25.2   63.6   -438  ->  1164.72
dqfma0101  fma   0.301  0.380    334  ->  334.114380
dqfma0102  fma    49.2   -4.8   23.3  ->  -212.86
dqfma0103  fma    4.22  0.079  -94.6  ->  -94.26662
dqfma0104  fma     903  0.797  0.887  ->  720.578
dqfma0105  fma    6.13   -161   65.9  ->  -921.03
dqfma0106  fma    28.2    727   5.45  ->  20506.85
dqfma0107  fma       4    605    688  ->  3108
dqfma0108  fma    93.3   0.19  0.226  ->  17.953
dqfma0109  fma   0.169   -341   5.61  ->  -52.019
dqfma0110  fma   -72.2     30  -51.2  ->  -2217.2
dqfma0111  fma  -0.409     13   20.4  ->  15.083
dqfma0112  fma     317   77.0   19.0  ->  24428.0
dqfma0113  fma      47   6.58   1.62  ->  310.88
dqfma0114  fma    1.36  0.984  0.493  ->  1.83124
dqfma0115  fma    72.7    274   1.56  ->  19921.36
dqfma0116  fma     335    847     83  ->  283828
dqfma0117  fma     666  0.247   25.4  ->  189.902
dqfma0118  fma   -3.87   3.06   78.0  ->  66.1578
dqfma0119  fma   0.742    192   35.6  ->  178.064
dqfma0120  fma   -91.6   5.29  0.153  ->  -484.411

-- cases where result is different from separate multiply + add; each
-- is preceded by the result of unfused multiply and add
-- [this is about 20% of all similar  cases in general]
--                                                                                                            ->  4.500119002100000209469729375698778E+38
dqfma0202  fma       68537985861355864457.5694      6565875762972086605.85969       35892634447236753.172812  ->  4.500119002100000209469729375698779E+38 Inexact Rounded
--                                                                                                            ->  5.996248469584594346858881620185514E+41
dqfma0208  fma          89261822344727628571.9      6717595845654131383336.89      5061036497288796076266.11  ->  5.996248469584594346858881620185513E+41 Inexact Rounded
--                                                                                                            ->  1.899242968678256924021594770874070E+34
dqfma0210  fma       320506237232448685.495971       59257597764017967.984448      3205615239077711589912.85  ->  1.899242968678256924021594770874071E+34 Inexact Rounded
--                                                                                                            ->  7.078596978842809537929699954860309E+37
dqfma0215  fma        220247843259112263.17995       321392340287987979002.80        47533279819997167655440  ->  7.078596978842809537929699954860308E+37 Inexact Rounded
--                                                                                                            ->  1.224955667581427559754106862350743E+37
dqfma0226  fma       23880729790368880412.1449       512947333827064719.55407      217117438419590824502.963  ->  1.224955667581427559754106862350744E+37 Inexact Rounded
--                                                                                                            ->  -2.530094043253148806272276368579144E+42
dqfma0229  fma        2539892357016099706.4126      -996142232667504817717435       53682082598315949425.937  ->  -2.530094043253148806272276368579143E+42 Inexact Rounded
--                                                                                                            ->  1.713387085759711954319391412788454E+37
dqfma0233  fma        4546339491341624464.0804            3768717864169205581       83578980278690395184.620  ->  1.713387085759711954319391412788453E+37 Inexact Rounded
--                                                                                                            ->  4.062275663405823716411579117771547E+35
dqfma0235  fma        409242119433816131.42253      992633815166741501.477249        70179636544416756129546  ->  4.062275663405823716411579117771548E+35 Inexact Rounded
--                                                                                                            ->  6.002604327732568490562249875306823E+47
dqfma0258  fma        817941336593541742159684       733867339769310729266598      78563844650942419311830.8  ->  6.002604327732568490562249875306822E+47 Inexact Rounded
--                                                                                                            ->  -2.027022514381452197510103395283874E+39
dqfma0264  fma       387617310169161270.737532     -5229442703414956061216.62      57665666816652967150473.5  ->  -2.027022514381452197510103395283873E+39 Inexact Rounded
--                                                                                                            ->  -7.856525039803554001144089842730361E+37
dqfma0267  fma      -847655845720565274701.210        92685316564117739.83984      22780950041376424429.5686  ->  -7.856525039803554001144089842730360E+37 Inexact Rounded
--                                                                                                            ->  1.695515562011520746125607502237559E+38
dqfma0268  fma          21590290365127685.3675       7853139227576541379426.8       -3275859437236180.761544  ->  1.695515562011520746125607502237558E+38 Inexact Rounded
--                                                                                                            ->  -8.448422935783289219748115038014710E+38
dqfma0269  fma      -974320636272862697.971586      867109103641860247440.756        -9775170775902454762.98  ->  -8.448422935783289219748115038014709E+38 Inexact Rounded

-- Cases where multiply would overflow or underflow if separate
dqfma0300  fma   9e+6144    10   0         -> Infinity  Overflow Inexact Rounded
dqfma0301  fma   1e+6144    10   0         -> Infinity  Overflow Inexact Rounded
dqfma0302  fma   1e+6144    10   -1e+6144  -> 9.000000000000000000000000000000000E+6144 Clamped
dqfma0303  fma   1e+6144    10   -9e+6144  -> 1.000000000000000000000000000000000E+6144 Clamped
-- subnormal etc.
dqfma0305  fma   1e-6176    0.1  0         -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqfma0306  fma   1e-6176    0.1  1         -> 1.000000000000000000000000000000000 Inexact Rounded
dqfma0307  fma   1e-6176    0.1  1e-6176   -> 1E-6176 Underflow Subnormal Inexact Rounded

-- Infinite combinations
dqfma0800 fma  Inf   Inf   Inf    ->  Infinity
dqfma0801 fma  Inf   Inf  -Inf    ->  NaN Invalid_operation
dqfma0802 fma  Inf  -Inf   Inf    ->  NaN Invalid_operation
dqfma0803 fma  Inf  -Inf  -Inf    -> -Infinity
dqfma0804 fma -Inf   Inf   Inf    ->  NaN Invalid_operation
dqfma0805 fma -Inf   Inf  -Inf    -> -Infinity
dqfma0806 fma -Inf  -Inf   Inf    ->  Infinity
dqfma0807 fma -Inf  -Inf  -Inf    ->  NaN Invalid_operation

-- Triple NaN propagation
dqfma0900 fma  NaN2  NaN3  NaN5   ->  NaN2
dqfma0901 fma  0     NaN3  NaN5   ->  NaN3
dqfma0902 fma  0     0     NaN5   ->  NaN5
-- first sNaN wins (consider qNaN from earlier sNaN being
-- overridden by an sNaN in third operand)
dqfma0903 fma  sNaN1 sNaN2 sNaN3  ->  NaN1 Invalid_operation
dqfma0904 fma  0     sNaN2 sNaN3  ->  NaN2 Invalid_operation
dqfma0905 fma  0     0     sNaN3  ->  NaN3 Invalid_operation
dqfma0906 fma  sNaN1 sNaN2 sNaN3  ->  NaN1 Invalid_operation
dqfma0907 fma  NaN7  sNaN2 sNaN3  ->  NaN2 Invalid_operation
dqfma0908 fma  NaN7  NaN5  sNaN3  ->  NaN3 Invalid_operation

-- MULTIPLICATION TESTS ------------------------------------------------
rounding:    half_even

-- sanity checks
dqfma2000 fma  2      2   0e+6144  -> 4
dqfma2001 fma  2      3   0e+6144  -> 6
dqfma2002 fma  5      1   0e+6144  -> 5
dqfma2003 fma  5      2   0e+6144  -> 10
dqfma2004 fma  1.20   2   0e+6144  -> 2.40
dqfma2005 fma  1.20   0   0e+6144  -> 0.00
dqfma2006 fma  1.20  -2   0e+6144  -> -2.40
dqfma2007 fma  -1.20  2   0e+6144  -> -2.40
dqfma2008 fma  -1.20  0   0e+6144  -> 0.00
dqfma2009 fma  -1.20 -2   0e+6144  -> 2.40
dqfma2010 fma  5.09 7.1   0e+6144  -> 36.139
dqfma2011 fma  2.5    4   0e+6144  -> 10.0
dqfma2012 fma  2.50   4   0e+6144  -> 10.00
dqfma2013 fma  1.23456789 1.0000000000000000000000000000   0e+6144  -> 1.234567890000000000000000000000000 Rounded
dqfma2015 fma  2.50   4   0e+6144  -> 10.00
dqfma2016 fma   9.99999999999999999  9.99999999999999999   0e+6144  ->  99.99999999999999980000000000000000 Inexact Rounded
dqfma2017 fma   9.99999999999999999 -9.99999999999999999   0e+6144  -> -99.99999999999999980000000000000000 Inexact Rounded
dqfma2018 fma  -9.99999999999999999  9.99999999999999999   0e+6144  -> -99.99999999999999980000000000000000 Inexact Rounded
dqfma2019 fma  -9.99999999999999999 -9.99999999999999999   0e+6144  ->  99.99999999999999980000000000000000 Inexact Rounded

-- zeros, etc.
dqfma2021 fma   0      0       0e+6144  ->  0
dqfma2022 fma   0     -0       0e+6144  ->  0
dqfma2023 fma  -0      0       0e+6144  ->  0
dqfma2024 fma  -0     -0       0e+6144  ->  0
dqfma2025 fma  -0.0   -0.0     0e+6144  ->  0.00
dqfma2026 fma  -0.0   -0.0     0e+6144  ->  0.00
dqfma2027 fma  -0.0   -0.0     0e+6144  ->  0.00
dqfma2028 fma  -0.0   -0.0     0e+6144  ->  0.00
dqfma2030 fma   5.00   1E-3    0e+6144  ->  0.00500
dqfma2031 fma   00.00  0.000   0e+6144  ->  0.00000
dqfma2032 fma   00.00  0E-3    0e+6144  ->  0.00000     -- rhs is 0
dqfma2033 fma   0E-3   00.00   0e+6144  ->  0.00000     -- lhs is 0
dqfma2034 fma  -5.00   1E-3    0e+6144  -> -0.00500
dqfma2035 fma  -00.00  0.000   0e+6144  ->  0.00000
dqfma2036 fma  -00.00  0E-3    0e+6144  ->  0.00000     -- rhs is 0
dqfma2037 fma  -0E-3   00.00   0e+6144  ->  0.00000     -- lhs is 0
dqfma2038 fma   5.00  -1E-3    0e+6144  -> -0.00500
dqfma2039 fma   00.00 -0.000   0e+6144  ->  0.00000
dqfma2040 fma   00.00 -0E-3    0e+6144  ->  0.00000     -- rhs is 0
dqfma2041 fma   0E-3  -00.00   0e+6144  ->  0.00000     -- lhs is 0
dqfma2042 fma  -5.00  -1E-3    0e+6144  ->  0.00500
dqfma2043 fma  -00.00 -0.000   0e+6144  ->  0.00000
dqfma2044 fma  -00.00 -0E-3    0e+6144  ->  0.00000     -- rhs is 0
dqfma2045 fma  -0E-3  -00.00   0e+6144  ->  0.00000     -- lhs is 0

-- examples from decarith
dqfma2050 fma  1.20 3          0e+6144  -> 3.60
dqfma2051 fma  7    3          0e+6144  -> 21
dqfma2052 fma  0.9  0.8        0e+6144  -> 0.72
dqfma2053 fma  0.9  -0         0e+6144  -> 0.0
dqfma2054 fma  654321 654321   0e+6144  -> 428135971041

dqfma2060 fma  123.45 1e7    0e+6144  ->  1.2345E+9
dqfma2061 fma  123.45 1e8    0e+6144  ->  1.2345E+10
dqfma2062 fma  123.45 1e+9   0e+6144  ->  1.2345E+11
dqfma2063 fma  123.45 1e10   0e+6144  ->  1.2345E+12
dqfma2064 fma  123.45 1e11   0e+6144  ->  1.2345E+13
dqfma2065 fma  123.45 1e12   0e+6144  ->  1.2345E+14
dqfma2066 fma  123.45 1e13   0e+6144  ->  1.2345E+15


-- test some intermediate lengths
--                    1234567890123456
dqfma2080 fma  0.1 1230123456456789       0e+6144  -> 123012345645678.9
dqfma2084 fma  0.1 1230123456456789       0e+6144  -> 123012345645678.9
dqfma2090 fma  1230123456456789     0.1   0e+6144  -> 123012345645678.9
dqfma2094 fma  1230123456456789     0.1   0e+6144  -> 123012345645678.9

-- test some more edge cases and carries
dqfma2101 fma  9 9     0e+6144  -> 81
dqfma2102 fma  9 90     0e+6144  -> 810
dqfma2103 fma  9 900     0e+6144  -> 8100
dqfma2104 fma  9 9000     0e+6144  -> 81000
dqfma2105 fma  9 90000     0e+6144  -> 810000
dqfma2106 fma  9 900000     0e+6144  -> 8100000
dqfma2107 fma  9 9000000     0e+6144  -> 81000000
dqfma2108 fma  9 90000000     0e+6144  -> 810000000
dqfma2109 fma  9 900000000     0e+6144  -> 8100000000
dqfma2110 fma  9 9000000000     0e+6144  -> 81000000000
dqfma2111 fma  9 90000000000     0e+6144  -> 810000000000
dqfma2112 fma  9 900000000000     0e+6144  -> 8100000000000
dqfma2113 fma  9 9000000000000     0e+6144  -> 81000000000000
dqfma2114 fma  9 90000000000000     0e+6144  -> 810000000000000
dqfma2115 fma  9 900000000000000     0e+6144  -> 8100000000000000
--dqfma2116 fma  9 9000000000000000     0e+6144  -> 81000000000000000
--dqfma2117 fma  9 90000000000000000     0e+6144  -> 810000000000000000
--dqfma2118 fma  9 900000000000000000     0e+6144  -> 8100000000000000000
--dqfma2119 fma  9 9000000000000000000     0e+6144  -> 81000000000000000000
--dqfma2120 fma  9 90000000000000000000     0e+6144  -> 810000000000000000000
--dqfma2121 fma  9 900000000000000000000     0e+6144  -> 8100000000000000000000
--dqfma2122 fma  9 9000000000000000000000     0e+6144  -> 81000000000000000000000
--dqfma2123 fma  9 90000000000000000000000     0e+6144  -> 810000000000000000000000
-- test some more edge cases without carries
dqfma2131 fma  3 3     0e+6144  -> 9
dqfma2132 fma  3 30     0e+6144  -> 90
dqfma2133 fma  3 300     0e+6144  -> 900
dqfma2134 fma  3 3000     0e+6144  -> 9000
dqfma2135 fma  3 30000     0e+6144  -> 90000
dqfma2136 fma  3 300000     0e+6144  -> 900000
dqfma2137 fma  3 3000000     0e+6144  -> 9000000
dqfma2138 fma  3 30000000     0e+6144  -> 90000000
dqfma2139 fma  3 300000000     0e+6144  -> 900000000
dqfma2140 fma  3 3000000000     0e+6144  -> 9000000000
dqfma2141 fma  3 30000000000     0e+6144  -> 90000000000
dqfma2142 fma  3 300000000000     0e+6144  -> 900000000000
dqfma2143 fma  3 3000000000000     0e+6144  -> 9000000000000
dqfma2144 fma  3 30000000000000     0e+6144  -> 90000000000000
dqfma2145 fma  3 300000000000000     0e+6144  -> 900000000000000
dqfma2146 fma  3 3000000000000000     0e+6144  -> 9000000000000000
dqfma2147 fma  3 30000000000000000     0e+6144  -> 90000000000000000
dqfma2148 fma  3 300000000000000000     0e+6144  -> 900000000000000000
dqfma2149 fma  3 3000000000000000000     0e+6144  -> 9000000000000000000
dqfma2150 fma  3 30000000000000000000     0e+6144  -> 90000000000000000000
dqfma2151 fma  3 300000000000000000000     0e+6144  -> 900000000000000000000
dqfma2152 fma  3 3000000000000000000000     0e+6144  -> 9000000000000000000000
dqfma2153 fma  3 30000000000000000000000     0e+6144  -> 90000000000000000000000

dqfma2263 fma  30269.587755640502150977251770554 4.8046009735990873395936309640543   0e+6144  -> 145433.2908011933696719165119928296 Inexact Rounded

-- test some edge cases with exact rounding
dqfma2301 fma  900000000000000000 9     0e+6144  -> 8100000000000000000
dqfma2302 fma  900000000000000000 90     0e+6144  -> 81000000000000000000
dqfma2303 fma  900000000000000000 900     0e+6144  -> 810000000000000000000
dqfma2304 fma  900000000000000000 9000     0e+6144  -> 8100000000000000000000
dqfma2305 fma  900000000000000000 90000     0e+6144  -> 81000000000000000000000
dqfma2306 fma  900000000000000000 900000     0e+6144  -> 810000000000000000000000
dqfma2307 fma  900000000000000000 9000000     0e+6144  -> 8100000000000000000000000
dqfma2308 fma  900000000000000000 90000000     0e+6144  -> 81000000000000000000000000
dqfma2309 fma  900000000000000000 900000000     0e+6144  -> 810000000000000000000000000
dqfma2310 fma  900000000000000000 9000000000     0e+6144  -> 8100000000000000000000000000
dqfma2311 fma  900000000000000000 90000000000     0e+6144  -> 81000000000000000000000000000
dqfma2312 fma  900000000000000000 900000000000     0e+6144  -> 810000000000000000000000000000
dqfma2313 fma  900000000000000000 9000000000000     0e+6144  -> 8100000000000000000000000000000
dqfma2314 fma  900000000000000000 90000000000000     0e+6144  -> 81000000000000000000000000000000
dqfma2315 fma  900000000000000000 900000000000000     0e+6144  -> 810000000000000000000000000000000
dqfma2316 fma  900000000000000000 9000000000000000     0e+6144  -> 8100000000000000000000000000000000
dqfma2317 fma  9000000000000000000 9000000000000000     0e+6144  -> 8.100000000000000000000000000000000E+34  Rounded
dqfma2318 fma  90000000000000000000 9000000000000000     0e+6144  -> 8.100000000000000000000000000000000E+35  Rounded
dqfma2319 fma  900000000000000000000 9000000000000000     0e+6144  -> 8.100000000000000000000000000000000E+36  Rounded
dqfma2320 fma  9000000000000000000000 9000000000000000     0e+6144  -> 8.100000000000000000000000000000000E+37  Rounded
dqfma2321 fma  90000000000000000000000 9000000000000000     0e+6144  -> 8.100000000000000000000000000000000E+38  Rounded
dqfma2322 fma  900000000000000000000000 9000000000000000     0e+6144  -> 8.100000000000000000000000000000000E+39  Rounded
dqfma2323 fma  9000000000000000000000000 9000000000000000     0e+6144  -> 8.100000000000000000000000000000000E+40  Rounded

-- tryzeros cases
dqfma2504  fma   0E-4260 1000E-4260    0e+6144  -> 0E-6176 Clamped
dqfma2505  fma   100E+4260 0E+4260     0e+6144  -> 0E+6111 Clamped

-- mixed with zeros
dqfma2541 fma   0    -1       0e+6144  ->  0
dqfma2542 fma  -0    -1       0e+6144  ->  0
dqfma2543 fma   0     1       0e+6144  ->  0
dqfma2544 fma  -0     1       0e+6144  ->  0
dqfma2545 fma  -1     0       0e+6144  ->  0
dqfma2546 fma  -1    -0       0e+6144  ->  0
dqfma2547 fma   1     0       0e+6144  ->  0
dqfma2548 fma   1    -0       0e+6144  ->  0

dqfma2551 fma   0.0  -1       0e+6144  ->  0.0
dqfma2552 fma  -0.0  -1       0e+6144  ->  0.0
dqfma2553 fma   0.0   1       0e+6144  ->  0.0
dqfma2554 fma  -0.0   1       0e+6144  ->  0.0
dqfma2555 fma  -1.0   0       0e+6144  ->  0.0
dqfma2556 fma  -1.0  -0       0e+6144  ->  0.0
dqfma2557 fma   1.0   0       0e+6144  ->  0.0
dqfma2558 fma   1.0  -0       0e+6144  ->  0.0

dqfma2561 fma   0    -1.0     0e+6144  ->  0.0
dqfma2562 fma  -0    -1.0     0e+6144  ->  0.0
dqfma2563 fma   0     1.0     0e+6144  ->  0.0
dqfma2564 fma  -0     1.0     0e+6144  ->  0.0
dqfma2565 fma  -1     0.0     0e+6144  ->  0.0
dqfma2566 fma  -1    -0.0     0e+6144  ->  0.0
dqfma2567 fma   1     0.0     0e+6144  ->  0.0
dqfma2568 fma   1    -0.0     0e+6144  ->  0.0

dqfma2571 fma   0.0  -1.0     0e+6144  ->  0.00
dqfma2572 fma  -0.0  -1.0     0e+6144  ->  0.00
dqfma2573 fma   0.0   1.0     0e+6144  ->  0.00
dqfma2574 fma  -0.0   1.0     0e+6144  ->  0.00
dqfma2575 fma  -1.0   0.0     0e+6144  ->  0.00
dqfma2576 fma  -1.0  -0.0     0e+6144  ->  0.00
dqfma2577 fma   1.0   0.0     0e+6144  ->  0.00
dqfma2578 fma   1.0  -0.0     0e+6144  ->  0.00
dqfma2579 fma   1.0   0.0     0e+6144  ->  0.00
dqfma2530 fma  -1.0  -0.0     0e+6144  ->  0.00
dqfma2531 fma  -1.0   0.0     0e+6144  ->  0.00
dqfma2532 fma   1.0  -0.0    -0e+6144  -> -0.00
dqfma2533 fma   1.0   0.0    -0e+6144  ->  0.00
dqfma2534 fma  -1.0  -0.0    -0e+6144  ->  0.00
dqfma2535 fma  -1.0   0.0    -0e+6144  -> -0.00


-- Specials
dqfma2580 fma   Inf  -Inf     0e+6144  -> -Infinity
dqfma2581 fma   Inf  -1000    0e+6144  -> -Infinity
dqfma2582 fma   Inf  -1       0e+6144  -> -Infinity
dqfma2583 fma   Inf  -0       0e+6144  ->  NaN  Invalid_operation
dqfma2584 fma   Inf   0       0e+6144  ->  NaN  Invalid_operation
dqfma2585 fma   Inf   1       0e+6144  ->  Infinity
dqfma2586 fma   Inf   1000    0e+6144  ->  Infinity
dqfma2587 fma   Inf   Inf     0e+6144  ->  Infinity
dqfma2588 fma  -1000  Inf     0e+6144  -> -Infinity
dqfma2589 fma  -Inf   Inf     0e+6144  -> -Infinity
dqfma2590 fma  -1     Inf     0e+6144  -> -Infinity
dqfma2591 fma  -0     Inf     0e+6144  ->  NaN  Invalid_operation
dqfma2592 fma   0     Inf     0e+6144  ->  NaN  Invalid_operation
dqfma2593 fma   1     Inf     0e+6144  ->  Infinity
dqfma2594 fma   1000  Inf     0e+6144  ->  Infinity
dqfma2595 fma   Inf   Inf     0e+6144  ->  Infinity

dqfma2600 fma  -Inf  -Inf     0e+6144  ->  Infinity
dqfma2601 fma  -Inf  -1000    0e+6144  ->  Infinity
dqfma2602 fma  -Inf  -1       0e+6144  ->  Infinity
dqfma2603 fma  -Inf  -0       0e+6144  ->  NaN  Invalid_operation
dqfma2604 fma  -Inf   0       0e+6144  ->  NaN  Invalid_operation
dqfma2605 fma  -Inf   1       0e+6144  -> -Infinity
dqfma2606 fma  -Inf   1000    0e+6144  -> -Infinity
dqfma2607 fma  -Inf   Inf     0e+6144  -> -Infinity
dqfma2608 fma  -1000  Inf     0e+6144  -> -Infinity
dqfma2609 fma  -Inf  -Inf     0e+6144  ->  Infinity
dqfma2610 fma  -1    -Inf     0e+6144  ->  Infinity
dqfma2611 fma  -0    -Inf     0e+6144  ->  NaN  Invalid_operation
dqfma2612 fma   0    -Inf     0e+6144  ->  NaN  Invalid_operation
dqfma2613 fma   1    -Inf     0e+6144  -> -Infinity
dqfma2614 fma   1000 -Inf     0e+6144  -> -Infinity
dqfma2615 fma   Inf  -Inf     0e+6144  -> -Infinity

dqfma2621 fma   NaN -Inf      0e+6144  ->  NaN
dqfma2622 fma   NaN -1000     0e+6144  ->  NaN
dqfma2623 fma   NaN -1        0e+6144  ->  NaN
dqfma2624 fma   NaN -0        0e+6144  ->  NaN
dqfma2625 fma   NaN  0        0e+6144  ->  NaN
dqfma2626 fma   NaN  1        0e+6144  ->  NaN
dqfma2627 fma   NaN  1000     0e+6144  ->  NaN
dqfma2628 fma   NaN  Inf      0e+6144  ->  NaN
dqfma2629 fma   NaN  NaN      0e+6144  ->  NaN
dqfma2630 fma  -Inf  NaN      0e+6144  ->  NaN
dqfma2631 fma  -1000 NaN      0e+6144  ->  NaN
dqfma2632 fma  -1    NaN      0e+6144  ->  NaN
dqfma2633 fma  -0    NaN      0e+6144  ->  NaN
dqfma2634 fma   0    NaN      0e+6144  ->  NaN
dqfma2635 fma   1    NaN      0e+6144  ->  NaN
dqfma2636 fma   1000 NaN      0e+6144  ->  NaN
dqfma2637 fma   Inf  NaN      0e+6144  ->  NaN

dqfma2641 fma   sNaN -Inf     0e+6144  ->  NaN  Invalid_operation
dqfma2642 fma   sNaN -1000    0e+6144  ->  NaN  Invalid_operation
dqfma2643 fma   sNaN -1       0e+6144  ->  NaN  Invalid_operation
dqfma2644 fma   sNaN -0       0e+6144  ->  NaN  Invalid_operation
dqfma2645 fma   sNaN  0       0e+6144  ->  NaN  Invalid_operation
dqfma2646 fma   sNaN  1       0e+6144  ->  NaN  Invalid_operation
dqfma2647 fma   sNaN  1000    0e+6144  ->  NaN  Invalid_operation
dqfma2648 fma   sNaN  NaN     0e+6144  ->  NaN  Invalid_operation
dqfma2649 fma   sNaN sNaN     0e+6144  ->  NaN  Invalid_operation
dqfma2650 fma   NaN  sNaN     0e+6144  ->  NaN  Invalid_operation
dqfma2651 fma  -Inf  sNaN     0e+6144  ->  NaN  Invalid_operation
dqfma2652 fma  -1000 sNaN     0e+6144  ->  NaN  Invalid_operation
dqfma2653 fma  -1    sNaN     0e+6144  ->  NaN  Invalid_operation
dqfma2654 fma  -0    sNaN     0e+6144  ->  NaN  Invalid_operation
dqfma2655 fma   0    sNaN     0e+6144  ->  NaN  Invalid_operation
dqfma2656 fma   1    sNaN     0e+6144  ->  NaN  Invalid_operation
dqfma2657 fma   1000 sNaN     0e+6144  ->  NaN  Invalid_operation
dqfma2658 fma   Inf  sNaN     0e+6144  ->  NaN  Invalid_operation
dqfma2659 fma   NaN  sNaN     0e+6144  ->  NaN  Invalid_operation

-- propagating NaNs
dqfma2661 fma   NaN9 -Inf     0e+6144  ->  NaN9
dqfma2662 fma   NaN8  999     0e+6144  ->  NaN8
dqfma2663 fma   NaN71 Inf     0e+6144  ->  NaN71
dqfma2664 fma   NaN6  NaN5    0e+6144  ->  NaN6
dqfma2665 fma  -Inf   NaN4    0e+6144  ->  NaN4
dqfma2666 fma  -999   NaN33   0e+6144  ->  NaN33
dqfma2667 fma   Inf   NaN2    0e+6144  ->  NaN2

dqfma2671 fma   sNaN99 -Inf      0e+6144  ->  NaN99 Invalid_operation
dqfma2672 fma   sNaN98 -11       0e+6144  ->  NaN98 Invalid_operation
dqfma2673 fma   sNaN97  NaN      0e+6144  ->  NaN97 Invalid_operation
dqfma2674 fma   sNaN16 sNaN94    0e+6144  ->  NaN16 Invalid_operation
dqfma2675 fma   NaN95  sNaN93    0e+6144  ->  NaN93 Invalid_operation
dqfma2676 fma  -Inf    sNaN92    0e+6144  ->  NaN92 Invalid_operation
dqfma2677 fma   088    sNaN91    0e+6144  ->  NaN91 Invalid_operation
dqfma2678 fma   Inf    sNaN90    0e+6144  ->  NaN90 Invalid_operation
dqfma2679 fma   NaN    sNaN89    0e+6144  ->  NaN89 Invalid_operation

dqfma2681 fma  -NaN9 -Inf     0e+6144  -> -NaN9
dqfma2682 fma  -NaN8  999     0e+6144  -> -NaN8
dqfma2683 fma  -NaN71 Inf     0e+6144  -> -NaN71
dqfma2684 fma  -NaN6 -NaN5    0e+6144  -> -NaN6
dqfma2685 fma  -Inf  -NaN4    0e+6144  -> -NaN4
dqfma2686 fma  -999  -NaN33   0e+6144  -> -NaN33
dqfma2687 fma   Inf  -NaN2    0e+6144  -> -NaN2

dqfma2691 fma  -sNaN99 -Inf      0e+6144  -> -NaN99 Invalid_operation
dqfma2692 fma  -sNaN98 -11       0e+6144  -> -NaN98 Invalid_operation
dqfma2693 fma  -sNaN97  NaN      0e+6144  -> -NaN97 Invalid_operation
dqfma2694 fma  -sNaN16 -sNaN94   0e+6144  -> -NaN16 Invalid_operation
dqfma2695 fma  -NaN95  -sNaN93   0e+6144  -> -NaN93 Invalid_operation
dqfma2696 fma  -Inf    -sNaN92   0e+6144  -> -NaN92 Invalid_operation
dqfma2697 fma   088    -sNaN91   0e+6144  -> -NaN91 Invalid_operation
dqfma2698 fma   Inf    -sNaN90   0e+6144  -> -NaN90 Invalid_operation
dqfma2699 fma  -NaN    -sNaN89   0e+6144  -> -NaN89 Invalid_operation

dqfma2701 fma  -NaN  -Inf     0e+6144  -> -NaN
dqfma2702 fma  -NaN   999     0e+6144  -> -NaN
dqfma2703 fma  -NaN   Inf     0e+6144  -> -NaN
dqfma2704 fma  -NaN  -NaN     0e+6144  -> -NaN
dqfma2705 fma  -Inf  -NaN0    0e+6144  -> -NaN
dqfma2706 fma  -999  -NaN     0e+6144  -> -NaN
dqfma2707 fma   Inf  -NaN     0e+6144  -> -NaN

dqfma2711 fma  -sNaN   -Inf      0e+6144  -> -NaN Invalid_operation
dqfma2712 fma  -sNaN   -11       0e+6144  -> -NaN Invalid_operation
dqfma2713 fma  -sNaN00  NaN      0e+6144  -> -NaN Invalid_operation
dqfma2714 fma  -sNaN   -sNaN     0e+6144  -> -NaN Invalid_operation
dqfma2715 fma  -NaN    -sNaN     0e+6144  -> -NaN Invalid_operation
dqfma2716 fma  -Inf    -sNaN     0e+6144  -> -NaN Invalid_operation
dqfma2717 fma   088    -sNaN     0e+6144  -> -NaN Invalid_operation
dqfma2718 fma   Inf    -sNaN     0e+6144  -> -NaN Invalid_operation
dqfma2719 fma  -NaN    -sNaN     0e+6144  -> -NaN Invalid_operation

-- overflow and underflow tests .. note subnormal results
-- signs
dqfma2751 fma   1e+4277  1e+3311   0e+6144  ->  Infinity Overflow Inexact Rounded
dqfma2752 fma   1e+4277 -1e+3311   0e+6144  -> -Infinity Overflow Inexact Rounded
dqfma2753 fma  -1e+4277  1e+3311   0e+6144  -> -Infinity Overflow Inexact Rounded
dqfma2754 fma  -1e+4277 -1e+3311   0e+6144  ->  Infinity Overflow Inexact Rounded
dqfma2755 fma   1e-4277  1e-3311   0e+6144  ->  0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqfma2756 fma   1e-4277 -1e-3311   0e+6144  -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqfma2757 fma  -1e-4277  1e-3311   0e+6144  -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqfma2758 fma  -1e-4277 -1e-3311   0e+6144  ->  0E-6176 Underflow Subnormal Inexact Rounded Clamped

-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
dqfma2760 fma  1e-6069 1e-101   0e+6144  -> 1E-6170 Subnormal
dqfma2761 fma  1e-6069 1e-102   0e+6144  -> 1E-6171 Subnormal
dqfma2762 fma  1e-6069 1e-103   0e+6144  -> 1E-6172 Subnormal
dqfma2763 fma  1e-6069 1e-104   0e+6144  -> 1E-6173 Subnormal
dqfma2764 fma  1e-6069 1e-105   0e+6144  -> 1E-6174 Subnormal
dqfma2765 fma  1e-6069 1e-106   0e+6144  -> 1E-6175 Subnormal
dqfma2766 fma  1e-6069 1e-107   0e+6144  -> 1E-6176 Subnormal
dqfma2767 fma  1e-6069 1e-108   0e+6144  -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqfma2768 fma  1e-6069 1e-109   0e+6144  -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqfma2769 fma  1e-6069 1e-110   0e+6144  -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-- [no equivalent of 'subnormal' for overflow]
dqfma2770 fma  1e+40 1e+6101   0e+6144  -> 1.000000000000000000000000000000E+6141 Clamped
dqfma2771 fma  1e+40 1e+6102   0e+6144  -> 1.0000000000000000000000000000000E+6142  Clamped
dqfma2772 fma  1e+40 1e+6103   0e+6144  -> 1.00000000000000000000000000000000E+6143  Clamped
dqfma2773 fma  1e+40 1e+6104   0e+6144  -> 1.000000000000000000000000000000000E+6144  Clamped
dqfma2774 fma  1e+40 1e+6105   0e+6144  -> Infinity Overflow Inexact Rounded
dqfma2775 fma  1e+40 1e+6106   0e+6144  -> Infinity Overflow Inexact Rounded
dqfma2776 fma  1e+40 1e+6107   0e+6144  -> Infinity Overflow Inexact Rounded
dqfma2777 fma  1e+40 1e+6108   0e+6144  -> Infinity Overflow Inexact Rounded
dqfma2778 fma  1e+40 1e+6109   0e+6144  -> Infinity Overflow Inexact Rounded
dqfma2779 fma  1e+40 1e+6110   0e+6144  -> Infinity Overflow Inexact Rounded

dqfma2801 fma   1.0000E-6172  1       0e+6144  -> 1.0000E-6172 Subnormal
dqfma2802 fma   1.000E-6172   1e-1    0e+6144  -> 1.000E-6173  Subnormal
dqfma2803 fma   1.00E-6172    1e-2    0e+6144  -> 1.00E-6174   Subnormal
dqfma2804 fma   1.0E-6172     1e-3    0e+6144  -> 1.0E-6175    Subnormal
dqfma2805 fma   1.0E-6172     1e-4    0e+6144  -> 1E-6176     Subnormal Rounded
dqfma2806 fma   1.3E-6172     1e-4    0e+6144  -> 1E-6176     Underflow Subnormal Inexact Rounded
dqfma2807 fma   1.5E-6172     1e-4    0e+6144  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqfma2808 fma   1.7E-6172     1e-4    0e+6144  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqfma2809 fma   2.3E-6172     1e-4    0e+6144  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqfma2810 fma   2.5E-6172     1e-4    0e+6144  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqfma2811 fma   2.7E-6172     1e-4    0e+6144  -> 3E-6176     Underflow Subnormal Inexact Rounded
dqfma2812 fma   1.49E-6172    1e-4    0e+6144  -> 1E-6176     Underflow Subnormal Inexact Rounded
dqfma2813 fma   1.50E-6172    1e-4    0e+6144  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqfma2814 fma   1.51E-6172    1e-4    0e+6144  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqfma2815 fma   2.49E-6172    1e-4    0e+6144  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqfma2816 fma   2.50E-6172    1e-4    0e+6144  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqfma2817 fma   2.51E-6172    1e-4    0e+6144  -> 3E-6176     Underflow Subnormal Inexact Rounded

dqfma2818 fma   1E-6172       1e-4    0e+6144  -> 1E-6176     Subnormal
dqfma2819 fma   3E-6172       1e-5    0e+6144  -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped
dqfma2820 fma   5E-6172       1e-5    0e+6144  -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped
dqfma2821 fma   7E-6172       1e-5    0e+6144  -> 1E-6176     Underflow Subnormal Inexact Rounded
dqfma2822 fma   9E-6172       1e-5    0e+6144  -> 1E-6176     Underflow Subnormal Inexact Rounded
dqfma2823 fma   9.9E-6172     1e-5    0e+6144  -> 1E-6176     Underflow Subnormal Inexact Rounded

dqfma2824 fma   1E-6172      -1e-4    0e+6144  -> -1E-6176    Subnormal
dqfma2825 fma   3E-6172      -1e-5    0e+6144  -> -0E-6176    Underflow Subnormal Inexact Rounded Clamped
dqfma2826 fma  -5E-6172       1e-5    0e+6144  -> -0E-6176    Underflow Subnormal Inexact Rounded Clamped
dqfma2827 fma   7E-6172      -1e-5    0e+6144  -> -1E-6176    Underflow Subnormal Inexact Rounded
dqfma2828 fma  -9E-6172       1e-5    0e+6144  -> -1E-6176    Underflow Subnormal Inexact Rounded
dqfma2829 fma   9.9E-6172    -1e-5    0e+6144  -> -1E-6176    Underflow Subnormal Inexact Rounded
dqfma2830 fma   3.0E-6172    -1e-5    0e+6144  -> -0E-6176    Underflow Subnormal Inexact Rounded Clamped

dqfma2831 fma   1.0E-5977     1e-200   0e+6144  -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqfma2832 fma   1.0E-5977     1e-199   0e+6144  -> 1E-6176    Subnormal Rounded
dqfma2833 fma   1.0E-5977     1e-198   0e+6144  -> 1.0E-6175    Subnormal
dqfma2834 fma   2.0E-5977     2e-198   0e+6144  -> 4.0E-6175    Subnormal
dqfma2835 fma   4.0E-5977     4e-198   0e+6144  -> 1.60E-6174   Subnormal
dqfma2836 fma  10.0E-5977    10e-198   0e+6144  -> 1.000E-6173  Subnormal
dqfma2837 fma  30.0E-5977    30e-198   0e+6144  -> 9.000E-6173  Subnormal
dqfma2838 fma  40.0E-5982    40e-166   0e+6144  -> 1.6000E-6145 Subnormal
dqfma2839 fma  40.0E-5982    40e-165   0e+6144  -> 1.6000E-6144 Subnormal
dqfma2840 fma  40.0E-5982    40e-164   0e+6144  -> 1.6000E-6143

-- Long operand overflow may be a different path
dqfma2870 fma  100  9.999E+6143       0e+6144  ->  Infinity Inexact Overflow Rounded
dqfma2871 fma  100 -9.999E+6143       0e+6144  -> -Infinity Inexact Overflow Rounded
dqfma2872 fma       9.999E+6143 100   0e+6144  ->  Infinity Inexact Overflow Rounded
dqfma2873 fma      -9.999E+6143 100   0e+6144  -> -Infinity Inexact Overflow Rounded

-- check for double-rounded subnormals
dqfma2881 fma   1.2347E-6133 1.2347E-40    0e+6144  ->  1.524E-6173 Inexact Rounded Subnormal Underflow
dqfma2882 fma   1.234E-6133 1.234E-40      0e+6144  ->  1.523E-6173 Inexact Rounded Subnormal Underflow
dqfma2883 fma   1.23E-6133  1.23E-40       0e+6144  ->  1.513E-6173 Inexact Rounded Subnormal Underflow
dqfma2884 fma   1.2E-6133   1.2E-40        0e+6144  ->  1.44E-6173  Subnormal
dqfma2885 fma   1.2E-6133   1.2E-41        0e+6144  ->  1.44E-6174  Subnormal
dqfma2886 fma   1.2E-6133   1.2E-42        0e+6144  ->  1.4E-6175   Subnormal Inexact Rounded Underflow
dqfma2887 fma   1.2E-6133   1.3E-42        0e+6144  ->  1.6E-6175   Subnormal Inexact Rounded Underflow
dqfma2888 fma   1.3E-6133   1.3E-42        0e+6144  ->  1.7E-6175   Subnormal Inexact Rounded Underflow
dqfma2889 fma   1.3E-6133   1.3E-43        0e+6144  ->    2E-6176   Subnormal Inexact Rounded Underflow
dqfma2890 fma   1.3E-6134   1.3E-43        0e+6144  ->    0E-6176   Clamped Subnormal Inexact Rounded Underflow

dqfma2891 fma   1.2345E-39    1.234E-6133   0e+6144  ->  1.5234E-6172 Inexact Rounded Subnormal Underflow
dqfma2892 fma   1.23456E-39   1.234E-6133   0e+6144  ->  1.5234E-6172 Inexact Rounded Subnormal Underflow
dqfma2893 fma   1.2345E-40   1.234E-6133   0e+6144  ->  1.523E-6173  Inexact Rounded Subnormal Underflow
dqfma2894 fma   1.23456E-40  1.234E-6133   0e+6144  ->  1.523E-6173  Inexact Rounded Subnormal Underflow
dqfma2895 fma   1.2345E-41   1.234E-6133   0e+6144  ->  1.52E-6174   Inexact Rounded Subnormal Underflow
dqfma2896 fma   1.23456E-41  1.234E-6133   0e+6144  ->  1.52E-6174   Inexact Rounded Subnormal Underflow

-- Now explore the case where we get a normal result with Underflow
-- prove operands are exact
dqfma2906 fma   9.999999999999999999999999999999999E-6143  1                         0e+6144  -> 9.999999999999999999999999999999999E-6143
dqfma2907 fma                        1  0.09999999999999999999999999999999999       0e+6144  -> 0.09999999999999999999999999999999999
-- the next rounds to Nmin
dqfma2908 fma   9.999999999999999999999999999999999E-6143  0.09999999999999999999999999999999999       0e+6144  -> 1.000000000000000000000000000000000E-6143 Underflow Inexact Subnormal Rounded

-- hugest
dqfma2909 fma  9999999999999999999999999999999999 9999999999999999999999999999999999   0e+6144  -> 9.999999999999999999999999999999998E+67 Inexact Rounded

-- Examples from SQL proposal (Krishna Kulkarni)
precision:   34
rounding:    half_up
maxExponent: 6144
minExponent: -6143
dqfma21001  fma  130E-2  120E-2   0e+6144  -> 1.5600
dqfma21002  fma  130E-2  12E-1    0e+6144  -> 1.560
dqfma21003  fma  130E-2  1E0      0e+6144  -> 1.30
dqfma21004  fma  1E2     1E4      0e+6144  -> 1E+6

-- Null tests
dqfma2990 fma  10  #   0e+6144  -> NaN Invalid_operation
dqfma2991 fma   # 10   0e+6144  -> NaN Invalid_operation


-- ADDITION TESTS ------------------------------------------------------
rounding:    half_even

-- [first group are 'quick confidence check']
dqadd3001 fma  1  1       1       ->  2
dqadd3002 fma  1  2       3       ->  5
dqadd3003 fma  1  '5.75'  '3.3'   ->  9.05
dqadd3004 fma  1  '5'     '-3'    ->  2
dqadd3005 fma  1  '-5'    '-3'    ->  -8
dqadd3006 fma  1  '-7'    '2.5'   ->  -4.5
dqadd3007 fma  1  '0.7'   '0.3'   ->  1.0
dqadd3008 fma  1  '1.25'  '1.25'  ->  2.50
dqadd3009 fma  1  '1.23456789'  '1.00000000' -> '2.23456789'
dqadd3010 fma  1  '1.23456789'  '1.00000011' -> '2.23456800'

--             1234567890123456      1234567890123456
dqadd3011 fma  1  '0.4444444444444444444444444444444446'  '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Inexact Rounded
dqadd3012 fma  1  '0.4444444444444444444444444444444445'  '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Rounded
dqadd3013 fma  1  '0.4444444444444444444444444444444444'  '0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
dqadd3014 fma  1    '4444444444444444444444444444444444' '0.49'   -> '4444444444444444444444444444444444' Inexact Rounded
dqadd3015 fma  1    '4444444444444444444444444444444444' '0.499'  -> '4444444444444444444444444444444444' Inexact Rounded
dqadd3016 fma  1    '4444444444444444444444444444444444' '0.4999' -> '4444444444444444444444444444444444' Inexact Rounded
dqadd3017 fma  1    '4444444444444444444444444444444444' '0.5000' -> '4444444444444444444444444444444444' Inexact Rounded
dqadd3018 fma  1    '4444444444444444444444444444444444' '0.5001' -> '4444444444444444444444444444444445' Inexact Rounded
dqadd3019 fma  1    '4444444444444444444444444444444444' '0.501'  -> '4444444444444444444444444444444445' Inexact Rounded
dqadd3020 fma  1    '4444444444444444444444444444444444' '0.51'   -> '4444444444444444444444444444444445' Inexact Rounded

dqadd3021 fma  1  0 1 -> 1
dqadd3022 fma  1  1 1 -> 2
dqadd3023 fma  1  2 1 -> 3
dqadd3024 fma  1  3 1 -> 4
dqadd3025 fma  1  4 1 -> 5
dqadd3026 fma  1  5 1 -> 6
dqadd3027 fma  1  6 1 -> 7
dqadd3028 fma  1  7 1 -> 8
dqadd3029 fma  1  8 1 -> 9
dqadd3030 fma  1  9 1 -> 10

-- some carrying effects
dqadd3031 fma  1  '0.9998'  '0.0000' -> '0.9998'
dqadd3032 fma  1  '0.9998'  '0.0001' -> '0.9999'
dqadd3033 fma  1  '0.9998'  '0.0002' -> '1.0000'
dqadd3034 fma  1  '0.9998'  '0.0003' -> '1.0001'

dqadd3035 fma  1  '70'  '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqadd3036 fma  1  '700'  '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqadd3037 fma  1  '7000'  '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqadd3038 fma  1  '70000'  '10000e+34' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
dqadd3039 fma  1  '700000'  '10000e+34' -> '1.000000000000000000000000000000007E+38' Rounded

-- symmetry:
dqadd3040 fma  1  '10000e+34'  '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqadd3041 fma  1  '10000e+34'  '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqadd3042 fma  1  '10000e+34'  '7000' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqadd3044 fma  1  '10000e+34'  '70000' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
dqadd3045 fma  1  '10000e+34'  '700000' -> '1.000000000000000000000000000000007E+38' Rounded

-- same, without rounding
dqadd3046 fma  1  '10000e+9'  '7' -> '10000000000007'
dqadd3047 fma  1  '10000e+9'  '70' -> '10000000000070'
dqadd3048 fma  1  '10000e+9'  '700' -> '10000000000700'
dqadd3049 fma  1  '10000e+9'  '7000' -> '10000000007000'
dqadd3050 fma  1  '10000e+9'  '70000' -> '10000000070000'
dqadd3051 fma  1  '10000e+9'  '700000' -> '10000000700000'
dqadd3052 fma  1  '10000e+9'  '7000000' -> '10000007000000'

-- examples from decarith
dqadd3053 fma  1  '12' '7.00' -> '19.00'
dqadd3054 fma  1  '1.3' '-1.07' -> '0.23'
dqadd3055 fma  1  '1.3' '-1.30' -> '0.00'
dqadd3056 fma  1  '1.3' '-2.07' -> '-0.77'
dqadd3057 fma  1  '1E+2' '1E+4' -> '1.01E+4'

-- leading zero preservation
dqadd3061 fma  1  1 '0.0001' -> '1.0001'
dqadd3062 fma  1  1 '0.00001' -> '1.00001'
dqadd3063 fma  1  1 '0.000001' -> '1.000001'
dqadd3064 fma  1  1 '0.0000001' -> '1.0000001'
dqadd3065 fma  1  1 '0.00000001' -> '1.00000001'

-- some funny zeros [in case of bad signum]
dqadd3070 fma  1  1  0    -> 1
dqadd3071 fma  1  1 0.    -> 1
dqadd3072 fma  1  1  .0   -> 1.0
dqadd3073 fma  1  1 0.0   -> 1.0
dqadd3074 fma  1  1 0.00  -> 1.00
dqadd3075 fma  1   0  1   -> 1
dqadd3076 fma  1  0.  1   -> 1
dqadd3077 fma  1   .0 1   -> 1.0
dqadd3078 fma  1  0.0 1   -> 1.0
dqadd3079 fma  1  0.00 1  -> 1.00

-- some carries
dqadd3080 fma  1  999999998 1  -> 999999999
dqadd3081 fma  1  999999999 1  -> 1000000000
dqadd3082 fma  1   99999999 1  -> 100000000
dqadd3083 fma  1    9999999 1  -> 10000000
dqadd3084 fma  1     999999 1  -> 1000000
dqadd3085 fma  1      99999 1  -> 100000
dqadd3086 fma  1       9999 1  -> 10000
dqadd3087 fma  1        999 1  -> 1000
dqadd3088 fma  1         99 1  -> 100
dqadd3089 fma  1          9 1  -> 10


-- more LHS swaps
dqadd3090 fma  1  '-56267E-10'   0 ->  '-0.0000056267'
dqadd3091 fma  1  '-56267E-6'    0 ->  '-0.056267'
dqadd3092 fma  1  '-56267E-5'    0 ->  '-0.56267'
dqadd3093 fma  1  '-56267E-4'    0 ->  '-5.6267'
dqadd3094 fma  1  '-56267E-3'    0 ->  '-56.267'
dqadd3095 fma  1  '-56267E-2'    0 ->  '-562.67'
dqadd3096 fma  1  '-56267E-1'    0 ->  '-5626.7'
dqadd3097 fma  1  '-56267E-0'    0 ->  '-56267'
dqadd3098 fma  1  '-5E-10'       0 ->  '-5E-10'
dqadd3099 fma  1  '-5E-7'        0 ->  '-5E-7'
dqadd3100 fma  1  '-5E-6'        0 ->  '-0.000005'
dqadd3101 fma  1  '-5E-5'        0 ->  '-0.00005'
dqadd3102 fma  1  '-5E-4'        0 ->  '-0.0005'
dqadd3103 fma  1  '-5E-1'        0 ->  '-0.5'
dqadd3104 fma  1  '-5E0'         0 ->  '-5'
dqadd3105 fma  1  '-5E1'         0 ->  '-50'
dqadd3106 fma  1  '-5E5'         0 ->  '-500000'
dqadd3107 fma  1  '-5E33'        0 ->  '-5000000000000000000000000000000000'
dqadd3108 fma  1  '-5E34'        0 ->  '-5.000000000000000000000000000000000E+34'  Rounded
dqadd3109 fma  1  '-5E35'        0 ->  '-5.000000000000000000000000000000000E+35'  Rounded
dqadd3110 fma  1  '-5E36'        0 ->  '-5.000000000000000000000000000000000E+36'  Rounded
dqadd3111 fma  1  '-5E100'       0 ->  '-5.000000000000000000000000000000000E+100' Rounded

-- more RHS swaps
dqadd3113 fma  1  0  '-56267E-10' ->  '-0.0000056267'
dqadd3114 fma  1  0  '-56267E-6'  ->  '-0.056267'
dqadd3116 fma  1  0  '-56267E-5'  ->  '-0.56267'
dqadd3117 fma  1  0  '-56267E-4'  ->  '-5.6267'
dqadd3119 fma  1  0  '-56267E-3'  ->  '-56.267'
dqadd3120 fma  1  0  '-56267E-2'  ->  '-562.67'
dqadd3121 fma  1  0  '-56267E-1'  ->  '-5626.7'
dqadd3122 fma  1  0  '-56267E-0'  ->  '-56267'
dqadd3123 fma  1  0  '-5E-10'     ->  '-5E-10'
dqadd3124 fma  1  0  '-5E-7'      ->  '-5E-7'
dqadd3125 fma  1  0  '-5E-6'      ->  '-0.000005'
dqadd3126 fma  1  0  '-5E-5'      ->  '-0.00005'
dqadd3127 fma  1  0  '-5E-4'      ->  '-0.0005'
dqadd3128 fma  1  0  '-5E-1'      ->  '-0.5'
dqadd3129 fma  1  0  '-5E0'       ->  '-5'
dqadd3130 fma  1  0  '-5E1'       ->  '-50'
dqadd3131 fma  1  0  '-5E5'       ->  '-500000'
dqadd3132 fma  1  0  '-5E33'      ->  '-5000000000000000000000000000000000'
dqadd3133 fma  1  0  '-5E34'      ->  '-5.000000000000000000000000000000000E+34'   Rounded
dqadd3134 fma  1  0  '-5E35'      ->  '-5.000000000000000000000000000000000E+35'   Rounded
dqadd3135 fma  1  0  '-5E36'      ->  '-5.000000000000000000000000000000000E+36'   Rounded
dqadd3136 fma  1  0  '-5E100'     ->  '-5.000000000000000000000000000000000E+100'  Rounded

-- related
dqadd3137 fma  1   1  '0E-39'      ->  '1.000000000000000000000000000000000'  Rounded
dqadd3138 fma  1  -1  '0E-39'      ->  '-1.000000000000000000000000000000000' Rounded
dqadd3139 fma  1  '0E-39' 1        ->  '1.000000000000000000000000000000000'  Rounded
dqadd3140 fma  1  '0E-39' -1       ->  '-1.000000000000000000000000000000000' Rounded
dqadd3141 fma  1  1E+29   0.0000   ->  '100000000000000000000000000000.0000'
dqadd3142 fma  1  1E+29   0.00000  ->  '100000000000000000000000000000.0000'  Rounded
dqadd3143 fma  1  0.000   1E+30    ->  '1000000000000000000000000000000.000'
dqadd3144 fma  1  0.0000  1E+30    ->  '1000000000000000000000000000000.000'  Rounded

-- [some of the next group are really constructor tests]
dqadd3146 fma  1  '00.0'  0       ->  '0.0'
dqadd3147 fma  1  '0.00'  0       ->  '0.00'
dqadd3148 fma  1   0      '0.00'  ->  '0.00'
dqadd3149 fma  1   0      '00.0'  ->  '0.0'
dqadd3150 fma  1  '00.0'  '0.00'  ->  '0.00'
dqadd3151 fma  1  '0.00'  '00.0'  ->  '0.00'
dqadd3152 fma  1  '3'     '.3'    ->  '3.3'
dqadd3153 fma  1  '3.'    '.3'    ->  '3.3'
dqadd3154 fma  1  '3.0'   '.3'    ->  '3.3'
dqadd3155 fma  1  '3.00'  '.3'    ->  '3.30'
dqadd3156 fma  1  '3'     '3'     ->  '6'
dqadd3157 fma  1  '3'     '+3'    ->  '6'
dqadd3158 fma  1  '3'     '-3'    ->  '0'
dqadd3159 fma  1  '0.3'   '-0.3'  ->  '0.0'
dqadd3160 fma  1  '0.03'  '-0.03' ->  '0.00'

-- try borderline precision, with carries, etc.
dqadd3161 fma  1  '1E+12' '-1'    -> '999999999999'
dqadd3162 fma  1  '1E+12'  '1.11' -> '1000000000001.11'
dqadd3163 fma  1  '1.11'  '1E+12' -> '1000000000001.11'
dqadd3164 fma  1  '-1'    '1E+12' -> '999999999999'
dqadd3165 fma  1  '7E+12' '-1'    -> '6999999999999'
dqadd3166 fma  1  '7E+12'  '1.11' -> '7000000000001.11'
dqadd3167 fma  1  '1.11'  '7E+12' -> '7000000000001.11'
dqadd3168 fma  1  '-1'    '7E+12' -> '6999999999999'

rounding: half_up
dqadd3170 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555567' -> '5.000000000000000000000000000000001' Inexact Rounded
dqadd3171 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555566' -> '5.000000000000000000000000000000001' Inexact Rounded
dqadd3172 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555565' -> '5.000000000000000000000000000000001' Inexact Rounded
dqadd3173 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555564' -> '5.000000000000000000000000000000000' Inexact Rounded
dqadd3174 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555553' -> '4.999999999999999999999999999999999' Inexact Rounded
dqadd3175 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555552' -> '4.999999999999999999999999999999999' Inexact Rounded
dqadd3176 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555551' -> '4.999999999999999999999999999999999' Inexact Rounded
dqadd3177 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555550' -> '4.999999999999999999999999999999999' Rounded
dqadd3178 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555545' -> '4.999999999999999999999999999999999' Inexact Rounded
dqadd3179 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555544' -> '4.999999999999999999999999999999998' Inexact Rounded
dqadd3180 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555543' -> '4.999999999999999999999999999999998' Inexact Rounded
dqadd3181 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555542' -> '4.999999999999999999999999999999998' Inexact Rounded
dqadd3182 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555541' -> '4.999999999999999999999999999999998' Inexact Rounded
dqadd3183 fma  1  '4.444444444444444444444444444444444'  '0.5555555555555555555555555555555540' -> '4.999999999999999999999999999999998' Rounded

-- and some more, including residue effects and different roundings
rounding: half_up
dqadd3200 fma  1  '1231234567890123456784560123456789' 0             -> '1231234567890123456784560123456789'
dqadd3201 fma  1  '1231234567890123456784560123456789' 0.000000001   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3202 fma  1  '1231234567890123456784560123456789' 0.000001      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3203 fma  1  '1231234567890123456784560123456789' 0.1           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3204 fma  1  '1231234567890123456784560123456789' 0.4           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3205 fma  1  '1231234567890123456784560123456789' 0.49          -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3206 fma  1  '1231234567890123456784560123456789' 0.499999      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3207 fma  1  '1231234567890123456784560123456789' 0.499999999   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3208 fma  1  '1231234567890123456784560123456789' 0.5           -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3209 fma  1  '1231234567890123456784560123456789' 0.500000001   -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3210 fma  1  '1231234567890123456784560123456789' 0.500001      -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3211 fma  1  '1231234567890123456784560123456789' 0.51          -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3212 fma  1  '1231234567890123456784560123456789' 0.6           -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3213 fma  1  '1231234567890123456784560123456789' 0.9           -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3214 fma  1  '1231234567890123456784560123456789' 0.99999       -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3215 fma  1  '1231234567890123456784560123456789' 0.999999999   -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3216 fma  1  '1231234567890123456784560123456789' 1             -> '1231234567890123456784560123456790'
dqadd3217 fma  1  '1231234567890123456784560123456789' 1.000000001   -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3218 fma  1  '1231234567890123456784560123456789' 1.00001       -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3219 fma  1  '1231234567890123456784560123456789' 1.1           -> '1231234567890123456784560123456790' Inexact Rounded

rounding: half_even
dqadd3220 fma  1  '1231234567890123456784560123456789' 0             -> '1231234567890123456784560123456789'
dqadd3221 fma  1  '1231234567890123456784560123456789' 0.000000001   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3222 fma  1  '1231234567890123456784560123456789' 0.000001      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3223 fma  1  '1231234567890123456784560123456789' 0.1           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3224 fma  1  '1231234567890123456784560123456789' 0.4           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3225 fma  1  '1231234567890123456784560123456789' 0.49          -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3226 fma  1  '1231234567890123456784560123456789' 0.499999      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3227 fma  1  '1231234567890123456784560123456789' 0.499999999   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3228 fma  1  '1231234567890123456784560123456789' 0.5           -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3229 fma  1  '1231234567890123456784560123456789' 0.500000001   -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3230 fma  1  '1231234567890123456784560123456789' 0.500001      -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3231 fma  1  '1231234567890123456784560123456789' 0.51          -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3232 fma  1  '1231234567890123456784560123456789' 0.6           -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3233 fma  1  '1231234567890123456784560123456789' 0.9           -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3234 fma  1  '1231234567890123456784560123456789' 0.99999       -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3235 fma  1  '1231234567890123456784560123456789' 0.999999999   -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3236 fma  1  '1231234567890123456784560123456789' 1             -> '1231234567890123456784560123456790'
dqadd3237 fma  1  '1231234567890123456784560123456789' 1.00000001    -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3238 fma  1  '1231234567890123456784560123456789' 1.00001       -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3239 fma  1  '1231234567890123456784560123456789' 1.1           -> '1231234567890123456784560123456790' Inexact Rounded
-- critical few with even bottom digit...
dqadd3240 fma  1  '1231234567890123456784560123456788' 0.499999999   -> '1231234567890123456784560123456788' Inexact Rounded
dqadd3241 fma  1  '1231234567890123456784560123456788' 0.5           -> '1231234567890123456784560123456788' Inexact Rounded
dqadd3242 fma  1  '1231234567890123456784560123456788' 0.500000001   -> '1231234567890123456784560123456789' Inexact Rounded

rounding: down
dqadd3250 fma  1  '1231234567890123456784560123456789' 0             -> '1231234567890123456784560123456789'
dqadd3251 fma  1  '1231234567890123456784560123456789' 0.000000001   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3252 fma  1  '1231234567890123456784560123456789' 0.000001      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3253 fma  1  '1231234567890123456784560123456789' 0.1           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3254 fma  1  '1231234567890123456784560123456789' 0.4           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3255 fma  1  '1231234567890123456784560123456789' 0.49          -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3256 fma  1  '1231234567890123456784560123456789' 0.499999      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3257 fma  1  '1231234567890123456784560123456789' 0.499999999   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3258 fma  1  '1231234567890123456784560123456789' 0.5           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3259 fma  1  '1231234567890123456784560123456789' 0.500000001   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3260 fma  1  '1231234567890123456784560123456789' 0.500001      -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3261 fma  1  '1231234567890123456784560123456789' 0.51          -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3262 fma  1  '1231234567890123456784560123456789' 0.6           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3263 fma  1  '1231234567890123456784560123456789' 0.9           -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3264 fma  1  '1231234567890123456784560123456789' 0.99999       -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3265 fma  1  '1231234567890123456784560123456789' 0.999999999   -> '1231234567890123456784560123456789' Inexact Rounded
dqadd3266 fma  1  '1231234567890123456784560123456789' 1             -> '1231234567890123456784560123456790'
dqadd3267 fma  1  '1231234567890123456784560123456789' 1.00000001    -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3268 fma  1  '1231234567890123456784560123456789' 1.00001       -> '1231234567890123456784560123456790' Inexact Rounded
dqadd3269 fma  1  '1231234567890123456784560123456789' 1.1           -> '1231234567890123456784560123456790' Inexact Rounded

-- 1 in last place tests
rounding: half_up
dqadd3301 fma  1   -1   1      ->   0
dqadd3302 fma  1    0   1      ->   1
dqadd3303 fma  1    1   1      ->   2
dqadd3304 fma  1   12   1      ->  13
dqadd3305 fma  1   98   1      ->  99
dqadd3306 fma  1   99   1      -> 100
dqadd3307 fma  1  100   1      -> 101
dqadd3308 fma  1  101   1      -> 102
dqadd3309 fma  1   -1  -1      ->  -2
dqadd3310 fma  1    0  -1      ->  -1
dqadd3311 fma  1    1  -1      ->   0
dqadd3312 fma  1   12  -1      ->  11
dqadd3313 fma  1   98  -1      ->  97
dqadd3314 fma  1   99  -1      ->  98
dqadd3315 fma  1  100  -1      ->  99
dqadd3316 fma  1  101  -1      -> 100

dqadd3321 fma  1  -0.01  0.01    ->  0.00
dqadd3322 fma  1   0.00  0.01    ->  0.01
dqadd3323 fma  1   0.01  0.01    ->  0.02
dqadd3324 fma  1   0.12  0.01    ->  0.13
dqadd3325 fma  1   0.98  0.01    ->  0.99
dqadd3326 fma  1   0.99  0.01    ->  1.00
dqadd3327 fma  1   1.00  0.01    ->  1.01
dqadd3328 fma  1   1.01  0.01    ->  1.02
dqadd3329 fma  1  -0.01 -0.01    -> -0.02
dqadd3330 fma  1   0.00 -0.01    -> -0.01
dqadd3331 fma  1   0.01 -0.01    ->  0.00
dqadd3332 fma  1   0.12 -0.01    ->  0.11
dqadd3333 fma  1   0.98 -0.01    ->  0.97
dqadd3334 fma  1   0.99 -0.01    ->  0.98
dqadd3335 fma  1   1.00 -0.01    ->  0.99
dqadd3336 fma  1   1.01 -0.01    ->  1.00

-- some more cases where adding 0 affects the coefficient
dqadd3340 fma  1  1E+3    0    ->         1000
dqadd3341 fma  1  1E+33   0    ->    1000000000000000000000000000000000
dqadd3342 fma  1  1E+34   0    ->   1.000000000000000000000000000000000E+34  Rounded
dqadd3343 fma  1  1E+35   0    ->   1.000000000000000000000000000000000E+35  Rounded
-- which simply follow from these cases ...
dqadd3344 fma  1  1E+3    1    ->         1001
dqadd3345 fma  1  1E+33   1    ->    1000000000000000000000000000000001
dqadd3346 fma  1  1E+34   1    ->   1.000000000000000000000000000000000E+34  Inexact Rounded
dqadd3347 fma  1  1E+35   1    ->   1.000000000000000000000000000000000E+35  Inexact Rounded
dqadd3348 fma  1  1E+3    7    ->         1007
dqadd3349 fma  1  1E+33   7    ->    1000000000000000000000000000000007
dqadd3350 fma  1  1E+34   7    ->   1.000000000000000000000000000000001E+34  Inexact Rounded
dqadd3351 fma  1  1E+35   7    ->   1.000000000000000000000000000000000E+35  Inexact Rounded

-- tryzeros cases
rounding:    half_up
dqadd3360  fma  1  0E+50 10000E+1  -> 1.0000E+5
dqadd3361  fma  1  0E-50 10000E+1  -> 100000.0000000000000000000000000000 Rounded
dqadd3362  fma  1  10000E+1 0E-50  -> 100000.0000000000000000000000000000 Rounded
dqadd3363  fma  1  10000E+1 10000E-50  -> 100000.0000000000000000000000000000 Rounded Inexact
dqadd3364  fma  1  9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0E+6111
--            1 234567890123456789012345678901234

-- a curiosity from JSR 13 testing
rounding:    half_down
dqadd3370 fma  1   999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
dqadd3371 fma  1  9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
rounding:    half_up
dqadd3372 fma  1   999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
dqadd3373 fma  1  9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
rounding:    half_even
dqadd3374 fma  1   999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
dqadd3375 fma  1  9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact

-- ulp replacement tests
dqadd3400 fma  1    1   77e-32      ->  1.00000000000000000000000000000077
dqadd3401 fma  1    1   77e-33      ->  1.000000000000000000000000000000077
dqadd3402 fma  1    1   77e-34      ->  1.000000000000000000000000000000008 Inexact Rounded
dqadd3403 fma  1    1   77e-35      ->  1.000000000000000000000000000000001 Inexact Rounded
dqadd3404 fma  1    1   77e-36      ->  1.000000000000000000000000000000000 Inexact Rounded
dqadd3405 fma  1    1   77e-37      ->  1.000000000000000000000000000000000 Inexact Rounded
dqadd3406 fma  1    1   77e-299     ->  1.000000000000000000000000000000000 Inexact Rounded

dqadd3410 fma  1   10   77e-32      ->  10.00000000000000000000000000000077
dqadd3411 fma  1   10   77e-33      ->  10.00000000000000000000000000000008 Inexact Rounded
dqadd3412 fma  1   10   77e-34      ->  10.00000000000000000000000000000001 Inexact Rounded
dqadd3413 fma  1   10   77e-35      ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd3414 fma  1   10   77e-36      ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd3415 fma  1   10   77e-37      ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd3416 fma  1   10   77e-299     ->  10.00000000000000000000000000000000 Inexact Rounded

dqadd3420 fma  1   77e-32       1   ->  1.00000000000000000000000000000077
dqadd3421 fma  1   77e-33       1   ->  1.000000000000000000000000000000077
dqadd3422 fma  1   77e-34       1   ->  1.000000000000000000000000000000008 Inexact Rounded
dqadd3423 fma  1   77e-35       1   ->  1.000000000000000000000000000000001 Inexact Rounded
dqadd3424 fma  1   77e-36       1   ->  1.000000000000000000000000000000000 Inexact Rounded
dqadd3425 fma  1   77e-37       1   ->  1.000000000000000000000000000000000 Inexact Rounded
dqadd3426 fma  1   77e-299      1   ->  1.000000000000000000000000000000000 Inexact Rounded

dqadd3430 fma  1   77e-32      10   ->  10.00000000000000000000000000000077
dqadd3431 fma  1   77e-33      10   ->  10.00000000000000000000000000000008 Inexact Rounded
dqadd3432 fma  1   77e-34      10   ->  10.00000000000000000000000000000001 Inexact Rounded
dqadd3433 fma  1   77e-35      10   ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd3434 fma  1   77e-36      10   ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd3435 fma  1   77e-37      10   ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd3436 fma  1   77e-299     10   ->  10.00000000000000000000000000000000 Inexact Rounded

-- negative ulps
dqadd36440 fma  1    1   -77e-32      ->  0.99999999999999999999999999999923
dqadd36441 fma  1    1   -77e-33      ->  0.999999999999999999999999999999923
dqadd36442 fma  1    1   -77e-34      ->  0.9999999999999999999999999999999923
dqadd36443 fma  1    1   -77e-35      ->  0.9999999999999999999999999999999992 Inexact Rounded
dqadd36444 fma  1    1   -77e-36      ->  0.9999999999999999999999999999999999 Inexact Rounded
dqadd36445 fma  1    1   -77e-37      ->  1.000000000000000000000000000000000 Inexact Rounded
dqadd36446 fma  1    1   -77e-99      ->  1.000000000000000000000000000000000 Inexact Rounded

dqadd36450 fma  1   10   -77e-32      ->   9.99999999999999999999999999999923
dqadd36451 fma  1   10   -77e-33      ->   9.999999999999999999999999999999923
dqadd36452 fma  1   10   -77e-34      ->   9.999999999999999999999999999999992 Inexact Rounded
dqadd36453 fma  1   10   -77e-35      ->   9.999999999999999999999999999999999 Inexact Rounded
dqadd36454 fma  1   10   -77e-36      ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd36455 fma  1   10   -77e-37      ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd36456 fma  1   10   -77e-99      ->  10.00000000000000000000000000000000 Inexact Rounded

dqadd36460 fma  1   -77e-32       1   ->  0.99999999999999999999999999999923
dqadd36461 fma  1   -77e-33       1   ->  0.999999999999999999999999999999923
dqadd36462 fma  1   -77e-34       1   ->  0.9999999999999999999999999999999923
dqadd36463 fma  1   -77e-35       1   ->  0.9999999999999999999999999999999992 Inexact Rounded
dqadd36464 fma  1   -77e-36       1   ->  0.9999999999999999999999999999999999 Inexact Rounded
dqadd36465 fma  1   -77e-37       1   ->  1.000000000000000000000000000000000 Inexact Rounded
dqadd36466 fma  1   -77e-99       1   ->  1.000000000000000000000000000000000 Inexact Rounded

dqadd36470 fma  1   -77e-32      10   ->   9.99999999999999999999999999999923
dqadd36471 fma  1   -77e-33      10   ->   9.999999999999999999999999999999923
dqadd36472 fma  1   -77e-34      10   ->   9.999999999999999999999999999999992 Inexact Rounded
dqadd36473 fma  1   -77e-35      10   ->   9.999999999999999999999999999999999 Inexact Rounded
dqadd36474 fma  1   -77e-36      10   ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd36475 fma  1   -77e-37      10   ->  10.00000000000000000000000000000000 Inexact Rounded
dqadd36476 fma  1   -77e-99      10   ->  10.00000000000000000000000000000000 Inexact Rounded

-- negative ulps
dqadd36480 fma  1   -1    77e-32      ->  -0.99999999999999999999999999999923
dqadd36481 fma  1   -1    77e-33      ->  -0.999999999999999999999999999999923
dqadd36482 fma  1   -1    77e-34      ->  -0.9999999999999999999999999999999923
dqadd36483 fma  1   -1    77e-35      ->  -0.9999999999999999999999999999999992 Inexact Rounded
dqadd36484 fma  1   -1    77e-36      ->  -0.9999999999999999999999999999999999 Inexact Rounded
dqadd36485 fma  1   -1    77e-37      ->  -1.000000000000000000000000000000000 Inexact Rounded
dqadd36486 fma  1   -1    77e-99      ->  -1.000000000000000000000000000000000 Inexact Rounded

dqadd36490 fma  1  -10    77e-32      ->   -9.99999999999999999999999999999923
dqadd36491 fma  1  -10    77e-33      ->   -9.999999999999999999999999999999923
dqadd36492 fma  1  -10    77e-34      ->   -9.999999999999999999999999999999992 Inexact Rounded
dqadd36493 fma  1  -10    77e-35      ->   -9.999999999999999999999999999999999 Inexact Rounded
dqadd36494 fma  1  -10    77e-36      ->  -10.00000000000000000000000000000000 Inexact Rounded
dqadd36495 fma  1  -10    77e-37      ->  -10.00000000000000000000000000000000 Inexact Rounded
dqadd36496 fma  1  -10    77e-99      ->  -10.00000000000000000000000000000000 Inexact Rounded

dqadd36500 fma  1    77e-32      -1   ->  -0.99999999999999999999999999999923
dqadd36501 fma  1    77e-33      -1   ->  -0.999999999999999999999999999999923
dqadd36502 fma  1    77e-34      -1   ->  -0.9999999999999999999999999999999923
dqadd36503 fma  1    77e-35      -1   ->  -0.9999999999999999999999999999999992 Inexact Rounded
dqadd36504 fma  1    77e-36      -1   ->  -0.9999999999999999999999999999999999 Inexact Rounded
dqadd36505 fma  1    77e-37      -1   ->  -1.000000000000000000000000000000000 Inexact Rounded
dqadd36506 fma  1    77e-99      -1   ->  -1.000000000000000000000000000000000 Inexact Rounded

dqadd36510 fma  1    77e-32      -10  ->   -9.99999999999999999999999999999923
dqadd36511 fma  1    77e-33      -10  ->   -9.999999999999999999999999999999923
dqadd36512 fma  1    77e-34      -10  ->   -9.999999999999999999999999999999992 Inexact Rounded
dqadd36513 fma  1    77e-35      -10  ->   -9.999999999999999999999999999999999 Inexact Rounded
dqadd36514 fma  1    77e-36      -10  ->  -10.00000000000000000000000000000000 Inexact Rounded
dqadd36515 fma  1    77e-37      -10  ->  -10.00000000000000000000000000000000 Inexact Rounded
dqadd36516 fma  1    77e-99      -10  ->  -10.00000000000000000000000000000000 Inexact Rounded

-- and some more residue effects and different roundings
rounding: half_up
dqadd36540 fma  1  '9876543219876543216543210123456789' 0             -> '9876543219876543216543210123456789'
dqadd36541 fma  1  '9876543219876543216543210123456789' 0.000000001   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36542 fma  1  '9876543219876543216543210123456789' 0.000001      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36543 fma  1  '9876543219876543216543210123456789' 0.1           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36544 fma  1  '9876543219876543216543210123456789' 0.4           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36545 fma  1  '9876543219876543216543210123456789' 0.49          -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36546 fma  1  '9876543219876543216543210123456789' 0.499999      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36547 fma  1  '9876543219876543216543210123456789' 0.499999999   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36548 fma  1  '9876543219876543216543210123456789' 0.5           -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36549 fma  1  '9876543219876543216543210123456789' 0.500000001   -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36550 fma  1  '9876543219876543216543210123456789' 0.500001      -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36551 fma  1  '9876543219876543216543210123456789' 0.51          -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36552 fma  1  '9876543219876543216543210123456789' 0.6           -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36553 fma  1  '9876543219876543216543210123456789' 0.9           -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36554 fma  1  '9876543219876543216543210123456789' 0.99999       -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36555 fma  1  '9876543219876543216543210123456789' 0.999999999   -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36556 fma  1  '9876543219876543216543210123456789' 1             -> '9876543219876543216543210123456790'
dqadd36557 fma  1  '9876543219876543216543210123456789' 1.000000001   -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36558 fma  1  '9876543219876543216543210123456789' 1.00001       -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36559 fma  1  '9876543219876543216543210123456789' 1.1           -> '9876543219876543216543210123456790' Inexact Rounded

rounding: half_even
dqadd36560 fma  1  '9876543219876543216543210123456789' 0             -> '9876543219876543216543210123456789'
dqadd36561 fma  1  '9876543219876543216543210123456789' 0.000000001   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36562 fma  1  '9876543219876543216543210123456789' 0.000001      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36563 fma  1  '9876543219876543216543210123456789' 0.1           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36564 fma  1  '9876543219876543216543210123456789' 0.4           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36565 fma  1  '9876543219876543216543210123456789' 0.49          -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36566 fma  1  '9876543219876543216543210123456789' 0.499999      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36567 fma  1  '9876543219876543216543210123456789' 0.499999999   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd36568 fma  1  '9876543219876543216543210123456789' 0.5           -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36569 fma  1  '9876543219876543216543210123456789' 0.500000001   -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36570 fma  1  '9876543219876543216543210123456789' 0.500001      -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36571 fma  1  '9876543219876543216543210123456789' 0.51          -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36572 fma  1  '9876543219876543216543210123456789' 0.6           -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36573 fma  1  '9876543219876543216543210123456789' 0.9           -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36574 fma  1  '9876543219876543216543210123456789' 0.99999       -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36575 fma  1  '9876543219876543216543210123456789' 0.999999999   -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36576 fma  1  '9876543219876543216543210123456789' 1             -> '9876543219876543216543210123456790'
dqadd36577 fma  1  '9876543219876543216543210123456789' 1.00000001    -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36578 fma  1  '9876543219876543216543210123456789' 1.00001       -> '9876543219876543216543210123456790' Inexact Rounded
dqadd36579 fma  1  '9876543219876543216543210123456789' 1.1           -> '9876543219876543216543210123456790' Inexact Rounded

-- critical few with even bottom digit...
dqadd37540 fma  1  '9876543219876543216543210123456788' 0.499999999   -> '9876543219876543216543210123456788' Inexact Rounded
dqadd37541 fma  1  '9876543219876543216543210123456788' 0.5           -> '9876543219876543216543210123456788' Inexact Rounded
dqadd37542 fma  1  '9876543219876543216543210123456788' 0.500000001   -> '9876543219876543216543210123456789' Inexact Rounded

rounding: down
dqadd37550 fma  1  '9876543219876543216543210123456789' 0             -> '9876543219876543216543210123456789'
dqadd37551 fma  1  '9876543219876543216543210123456789' 0.000000001   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37552 fma  1  '9876543219876543216543210123456789' 0.000001      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37553 fma  1  '9876543219876543216543210123456789' 0.1           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37554 fma  1  '9876543219876543216543210123456789' 0.4           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37555 fma  1  '9876543219876543216543210123456789' 0.49          -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37556 fma  1  '9876543219876543216543210123456789' 0.499999      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37557 fma  1  '9876543219876543216543210123456789' 0.499999999   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37558 fma  1  '9876543219876543216543210123456789' 0.5           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37559 fma  1  '9876543219876543216543210123456789' 0.500000001   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37560 fma  1  '9876543219876543216543210123456789' 0.500001      -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37561 fma  1  '9876543219876543216543210123456789' 0.51          -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37562 fma  1  '9876543219876543216543210123456789' 0.6           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37563 fma  1  '9876543219876543216543210123456789' 0.9           -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37564 fma  1  '9876543219876543216543210123456789' 0.99999       -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37565 fma  1  '9876543219876543216543210123456789' 0.999999999   -> '9876543219876543216543210123456789' Inexact Rounded
dqadd37566 fma  1  '9876543219876543216543210123456789' 1             -> '9876543219876543216543210123456790'
dqadd37567 fma  1  '9876543219876543216543210123456789' 1.00000001    -> '9876543219876543216543210123456790' Inexact Rounded
dqadd37568 fma  1  '9876543219876543216543210123456789' 1.00001       -> '9876543219876543216543210123456790' Inexact Rounded
dqadd37569 fma  1  '9876543219876543216543210123456789' 1.1           -> '9876543219876543216543210123456790' Inexact Rounded

-- more zeros, etc.
rounding: half_even

dqadd37701 fma  1  5.00 1.00E-3 -> 5.00100
dqadd37702 fma  1  00.00 0.000  -> 0.000
dqadd37703 fma  1  00.00 0E-3   -> 0.000
dqadd37704 fma  1  0E-3  00.00  -> 0.000

dqadd37710 fma  1  0E+3  00.00  -> 0.00
dqadd37711 fma  1  0E+3  00.0   -> 0.0
dqadd37712 fma  1  0E+3  00.    -> 0
dqadd37713 fma  1  0E+3  00.E+1 -> 0E+1
dqadd37714 fma  1  0E+3  00.E+2 -> 0E+2
dqadd37715 fma  1  0E+3  00.E+3 -> 0E+3
dqadd37716 fma  1  0E+3  00.E+4 -> 0E+3
dqadd37717 fma  1  0E+3  00.E+5 -> 0E+3
dqadd37718 fma  1  0E+3  -00.0   -> 0.0
dqadd37719 fma  1  0E+3  -00.    -> 0
dqadd37731 fma  1  0E+3  -00.E+1 -> 0E+1

dqadd37720 fma  1  00.00  0E+3  -> 0.00
dqadd37721 fma  1  00.0   0E+3  -> 0.0
dqadd37722 fma  1  00.    0E+3  -> 0
dqadd37723 fma  1  00.E+1 0E+3  -> 0E+1
dqadd37724 fma  1  00.E+2 0E+3  -> 0E+2
dqadd37725 fma  1  00.E+3 0E+3  -> 0E+3
dqadd37726 fma  1  00.E+4 0E+3  -> 0E+3
dqadd37727 fma  1  00.E+5 0E+3  -> 0E+3
dqadd37728 fma  1  -00.00 0E+3  -> 0.00
dqadd37729 fma  1  -00.0  0E+3  -> 0.0
dqadd37730 fma  1  -00.   0E+3  -> 0

dqadd37732 fma  1   0     0     ->  0
dqadd37733 fma  1   0    -0     ->  0
dqadd37734 fma  1  -0     0     ->  0
dqadd37735 fma  1  -0    -0     -> -0     -- IEEE 854 special case

dqadd37736 fma  1   1    -1     ->  0
dqadd37737 fma  1  -1    -1     -> -2
dqadd37738 fma  1   1     1     ->  2
dqadd37739 fma  1  -1     1     ->  0

dqadd37741 fma  1   0    -1     -> -1
dqadd37742 fma  1  -0    -1     -> -1
dqadd37743 fma  1   0     1     ->  1
dqadd37744 fma  1  -0     1     ->  1
dqadd37745 fma  1  -1     0     -> -1
dqadd37746 fma  1  -1    -0     -> -1
dqadd37747 fma  1   1     0     ->  1
dqadd37748 fma  1   1    -0     ->  1

dqadd37751 fma  1   0.0  -1     -> -1.0
dqadd37752 fma  1  -0.0  -1     -> -1.0
dqadd37753 fma  1   0.0   1     ->  1.0
dqadd37754 fma  1  -0.0   1     ->  1.0
dqadd37755 fma  1  -1.0   0     -> -1.0
dqadd37756 fma  1  -1.0  -0     -> -1.0
dqadd37757 fma  1   1.0   0     ->  1.0
dqadd37758 fma  1   1.0  -0     ->  1.0

dqadd37761 fma  1   0    -1.0   -> -1.0
dqadd37762 fma  1  -0    -1.0   -> -1.0
dqadd37763 fma  1   0     1.0   ->  1.0
dqadd37764 fma  1  -0     1.0   ->  1.0
dqadd37765 fma  1  -1     0.0   -> -1.0
dqadd37766 fma  1  -1    -0.0   -> -1.0
dqadd37767 fma  1   1     0.0   ->  1.0
dqadd37768 fma  1   1    -0.0   ->  1.0

dqadd37771 fma  1   0.0  -1.0   -> -1.0
dqadd37772 fma  1  -0.0  -1.0   -> -1.0
dqadd37773 fma  1   0.0   1.0   ->  1.0
dqadd37774 fma  1  -0.0   1.0   ->  1.0
dqadd37775 fma  1  -1.0   0.0   -> -1.0
dqadd37776 fma  1  -1.0  -0.0   -> -1.0
dqadd37777 fma  1   1.0   0.0   ->  1.0
dqadd37778 fma  1   1.0  -0.0   ->  1.0

-- Specials
dqadd37780 fma  1  -Inf  -Inf   -> -Infinity
dqadd37781 fma  1  -Inf  -1000  -> -Infinity
dqadd37782 fma  1  -Inf  -1     -> -Infinity
dqadd37783 fma  1  -Inf  -0     -> -Infinity
dqadd37784 fma  1  -Inf   0     -> -Infinity
dqadd37785 fma  1  -Inf   1     -> -Infinity
dqadd37786 fma  1  -Inf   1000  -> -Infinity
dqadd37787 fma  1  -1000 -Inf   -> -Infinity
dqadd37788 fma  1  -Inf  -Inf   -> -Infinity
dqadd37789 fma  1  -1    -Inf   -> -Infinity
dqadd37790 fma  1  -0    -Inf   -> -Infinity
dqadd37791 fma  1   0    -Inf   -> -Infinity
dqadd37792 fma  1   1    -Inf   -> -Infinity
dqadd37793 fma  1   1000 -Inf   -> -Infinity
dqadd37794 fma  1   Inf  -Inf   ->  NaN  Invalid_operation

dqadd37800 fma  1   Inf  -Inf   ->  NaN  Invalid_operation
dqadd37801 fma  1   Inf  -1000  ->  Infinity
dqadd37802 fma  1   Inf  -1     ->  Infinity
dqadd37803 fma  1   Inf  -0     ->  Infinity
dqadd37804 fma  1   Inf   0     ->  Infinity
dqadd37805 fma  1   Inf   1     ->  Infinity
dqadd37806 fma  1   Inf   1000  ->  Infinity
dqadd37807 fma  1   Inf   Inf   ->  Infinity
dqadd37808 fma  1  -1000  Inf   ->  Infinity
dqadd37809 fma  1  -Inf   Inf   ->  NaN  Invalid_operation
dqadd37810 fma  1  -1     Inf   ->  Infinity
dqadd37811 fma  1  -0     Inf   ->  Infinity
dqadd37812 fma  1   0     Inf   ->  Infinity
dqadd37813 fma  1   1     Inf   ->  Infinity
dqadd37814 fma  1   1000  Inf   ->  Infinity
dqadd37815 fma  1   Inf   Inf   ->  Infinity

dqadd37821 fma  1   NaN -Inf    ->  NaN
dqadd37822 fma  1   NaN -1000   ->  NaN
dqadd37823 fma  1   NaN -1      ->  NaN
dqadd37824 fma  1   NaN -0      ->  NaN
dqadd37825 fma  1   NaN  0      ->  NaN
dqadd37826 fma  1   NaN  1      ->  NaN
dqadd37827 fma  1   NaN  1000   ->  NaN
dqadd37828 fma  1   NaN  Inf    ->  NaN
dqadd37829 fma  1   NaN  NaN    ->  NaN
dqadd37830 fma  1  -Inf  NaN    ->  NaN
dqadd37831 fma  1  -1000 NaN    ->  NaN
dqadd37832 fma  1  -1    NaN    ->  NaN
dqadd37833 fma  1  -0    NaN    ->  NaN
dqadd37834 fma  1   0    NaN    ->  NaN
dqadd37835 fma  1   1    NaN    ->  NaN
dqadd37836 fma  1   1000 NaN    ->  NaN
dqadd37837 fma  1   Inf  NaN    ->  NaN

dqadd37841 fma  1   sNaN -Inf   ->  NaN  Invalid_operation
dqadd37842 fma  1   sNaN -1000  ->  NaN  Invalid_operation
dqadd37843 fma  1   sNaN -1     ->  NaN  Invalid_operation
dqadd37844 fma  1   sNaN -0     ->  NaN  Invalid_operation
dqadd37845 fma  1   sNaN  0     ->  NaN  Invalid_operation
dqadd37846 fma  1   sNaN  1     ->  NaN  Invalid_operation
dqadd37847 fma  1   sNaN  1000  ->  NaN  Invalid_operation
dqadd37848 fma  1   sNaN  NaN   ->  NaN  Invalid_operation
dqadd37849 fma  1   sNaN sNaN   ->  NaN  Invalid_operation
dqadd37850 fma  1   NaN  sNaN   ->  NaN  Invalid_operation
dqadd37851 fma  1  -Inf  sNaN   ->  NaN  Invalid_operation
dqadd37852 fma  1  -1000 sNaN   ->  NaN  Invalid_operation
dqadd37853 fma  1  -1    sNaN   ->  NaN  Invalid_operation
dqadd37854 fma  1  -0    sNaN   ->  NaN  Invalid_operation
dqadd37855 fma  1   0    sNaN   ->  NaN  Invalid_operation
dqadd37856 fma  1   1    sNaN   ->  NaN  Invalid_operation
dqadd37857 fma  1   1000 sNaN   ->  NaN  Invalid_operation
dqadd37858 fma  1   Inf  sNaN   ->  NaN  Invalid_operation
dqadd37859 fma  1   NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqadd37861 fma  1   NaN1   -Inf    ->  NaN1
dqadd37862 fma  1  +NaN2   -1000   ->  NaN2
dqadd37863 fma  1   NaN3    1000   ->  NaN3
dqadd37864 fma  1   NaN4    Inf    ->  NaN4
dqadd37865 fma  1   NaN5   +NaN6   ->  NaN5
dqadd37866 fma  1  -Inf     NaN7   ->  NaN7
dqadd37867 fma  1  -1000    NaN8   ->  NaN8
dqadd37868 fma  1   1000    NaN9   ->  NaN9
dqadd37869 fma  1   Inf    +NaN10  ->  NaN10
dqadd37871 fma  1   sNaN11  -Inf   ->  NaN11  Invalid_operation
dqadd37872 fma  1   sNaN12  -1000  ->  NaN12  Invalid_operation
dqadd37873 fma  1   sNaN13   1000  ->  NaN13  Invalid_operation
dqadd37874 fma  1   sNaN14   NaN17 ->  NaN14  Invalid_operation
dqadd37875 fma  1   sNaN15  sNaN18 ->  NaN15  Invalid_operation
dqadd37876 fma  1   NaN16   sNaN19 ->  NaN19  Invalid_operation
dqadd37877 fma  1  -Inf    +sNaN20 ->  NaN20  Invalid_operation
dqadd37878 fma  1  -1000    sNaN21 ->  NaN21  Invalid_operation
dqadd37879 fma  1   1000    sNaN22 ->  NaN22  Invalid_operation
dqadd37880 fma  1   Inf     sNaN23 ->  NaN23  Invalid_operation
dqadd37881 fma  1  +NaN25  +sNaN24 ->  NaN24  Invalid_operation
dqadd37882 fma  1  -NaN26    NaN28 -> -NaN26
dqadd37883 fma  1  -sNaN27  sNaN29 -> -NaN27  Invalid_operation
dqadd37884 fma  1   1000    -NaN30 -> -NaN30
dqadd37885 fma  1   1000   -sNaN31 -> -NaN31  Invalid_operation

-- Here we explore near the boundary of rounding a subnormal to Nmin
dqadd37575 fma  1   1E-6143 -1E-6176 ->  9.99999999999999999999999999999999E-6144 Subnormal
dqadd37576 fma  1  -1E-6143 +1E-6176 -> -9.99999999999999999999999999999999E-6144 Subnormal

-- check overflow edge case
--               1234567890123456
dqadd37972 apply       9.999999999999999999999999999999999E+6144         -> 9.999999999999999999999999999999999E+6144
dqadd37973 fma  1      9.999999999999999999999999999999999E+6144  1      -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd37974 fma  1       9999999999999999999999999999999999E+6111  1      -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd37975 fma  1       9999999999999999999999999999999999E+6111  1E+6111  -> Infinity Overflow Inexact Rounded
dqadd37976 fma  1       9999999999999999999999999999999999E+6111  9E+6110  -> Infinity Overflow Inexact Rounded
dqadd37977 fma  1       9999999999999999999999999999999999E+6111  8E+6110  -> Infinity Overflow Inexact Rounded
dqadd37978 fma  1       9999999999999999999999999999999999E+6111  7E+6110  -> Infinity Overflow Inexact Rounded
dqadd37979 fma  1       9999999999999999999999999999999999E+6111  6E+6110  -> Infinity Overflow Inexact Rounded
dqadd37980 fma  1       9999999999999999999999999999999999E+6111  5E+6110  -> Infinity Overflow Inexact Rounded
dqadd37981 fma  1       9999999999999999999999999999999999E+6111  4E+6110  -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd37982 fma  1       9999999999999999999999999999999999E+6111  3E+6110  -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd37983 fma  1       9999999999999999999999999999999999E+6111  2E+6110  -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd37984 fma  1       9999999999999999999999999999999999E+6111  1E+6110  -> 9.999999999999999999999999999999999E+6144 Inexact Rounded

dqadd37985 apply      -9.999999999999999999999999999999999E+6144         -> -9.999999999999999999999999999999999E+6144
dqadd37986 fma  1     -9.999999999999999999999999999999999E+6144 -1      -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd37987 fma  1      -9999999999999999999999999999999999E+6111 -1      -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd37988 fma  1      -9999999999999999999999999999999999E+6111 -1E+6111  -> -Infinity Overflow Inexact Rounded
dqadd37989 fma  1      -9999999999999999999999999999999999E+6111 -9E+6110  -> -Infinity Overflow Inexact Rounded
dqadd37990 fma  1      -9999999999999999999999999999999999E+6111 -8E+6110  -> -Infinity Overflow Inexact Rounded
dqadd37991 fma  1      -9999999999999999999999999999999999E+6111 -7E+6110  -> -Infinity Overflow Inexact Rounded
dqadd37992 fma  1      -9999999999999999999999999999999999E+6111 -6E+6110  -> -Infinity Overflow Inexact Rounded
dqadd37993 fma  1      -9999999999999999999999999999999999E+6111 -5E+6110  -> -Infinity Overflow Inexact Rounded
dqadd37994 fma  1      -9999999999999999999999999999999999E+6111 -4E+6110  -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd37995 fma  1      -9999999999999999999999999999999999E+6111 -3E+6110  -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd37996 fma  1      -9999999999999999999999999999999999E+6111 -2E+6110  -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
dqadd37997 fma  1      -9999999999999999999999999999999999E+6111 -1E+6110  -> -9.999999999999999999999999999999999E+6144 Inexact Rounded

-- And for round down full and subnormal results
rounding:     down
dqadd371100 fma  1  1e+2 -1e-6143    -> 99.99999999999999999999999999999999 Rounded Inexact
dqadd371101 fma  1  1e+1 -1e-6143    -> 9.999999999999999999999999999999999  Rounded Inexact
dqadd371103 fma  1    +1 -1e-6143    -> 0.9999999999999999999999999999999999  Rounded Inexact
dqadd371104 fma  1  1e-1 -1e-6143    -> 0.09999999999999999999999999999999999  Rounded Inexact
dqadd371105 fma  1  1e-2 -1e-6143    -> 0.009999999999999999999999999999999999  Rounded Inexact
dqadd371106 fma  1  1e-3 -1e-6143    -> 0.0009999999999999999999999999999999999  Rounded Inexact
dqadd371107 fma  1  1e-4 -1e-6143    -> 0.00009999999999999999999999999999999999  Rounded Inexact
dqadd371108 fma  1  1e-5 -1e-6143    -> 0.000009999999999999999999999999999999999  Rounded Inexact
dqadd371109 fma  1  1e-6 -1e-6143    -> 9.999999999999999999999999999999999E-7  Rounded Inexact

rounding:     ceiling
dqadd371110 fma  1  -1e+2 +1e-6143   -> -99.99999999999999999999999999999999 Rounded Inexact
dqadd371111 fma  1  -1e+1 +1e-6143   -> -9.999999999999999999999999999999999  Rounded Inexact
dqadd371113 fma  1     -1 +1e-6143   -> -0.9999999999999999999999999999999999  Rounded Inexact
dqadd371114 fma  1  -1e-1 +1e-6143   -> -0.09999999999999999999999999999999999  Rounded Inexact
dqadd371115 fma  1  -1e-2 +1e-6143   -> -0.009999999999999999999999999999999999  Rounded Inexact
dqadd371116 fma  1  -1e-3 +1e-6143   -> -0.0009999999999999999999999999999999999  Rounded Inexact
dqadd371117 fma  1  -1e-4 +1e-6143   -> -0.00009999999999999999999999999999999999  Rounded Inexact
dqadd371118 fma  1  -1e-5 +1e-6143   -> -0.000009999999999999999999999999999999999  Rounded Inexact
dqadd371119 fma  1  -1e-6 +1e-6143   -> -9.999999999999999999999999999999999E-7  Rounded Inexact

-- tests based on Gunnar Degnbol's edge case
rounding:     half_even

dqadd371300 fma  1  1E34  -0.5                 ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371310 fma  1  1E34  -0.51                ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371311 fma  1  1E34  -0.501               ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371312 fma  1  1E34  -0.5001              ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371313 fma  1  1E34  -0.50001             ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371314 fma  1  1E34  -0.500001            ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371315 fma  1  1E34  -0.5000001           ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371316 fma  1  1E34  -0.50000001          ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371317 fma  1  1E34  -0.500000001         ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371318 fma  1  1E34  -0.5000000001        ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371319 fma  1  1E34  -0.50000000001       ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371320 fma  1  1E34  -0.500000000001      ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371321 fma  1  1E34  -0.5000000000001     ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371322 fma  1  1E34  -0.50000000000001    ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371323 fma  1  1E34  -0.500000000000001   ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371324 fma  1  1E34  -0.5000000000000001  ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371325 fma  1  1E34  -0.5000000000000000  ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371326 fma  1  1E34  -0.500000000000000   ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371327 fma  1  1E34  -0.50000000000000    ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371328 fma  1  1E34  -0.5000000000000     ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371329 fma  1  1E34  -0.500000000000      ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371330 fma  1  1E34  -0.50000000000       ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371331 fma  1  1E34  -0.5000000000        ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371332 fma  1  1E34  -0.500000000         ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371333 fma  1  1E34  -0.50000000          ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371334 fma  1  1E34  -0.5000000           ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371335 fma  1  1E34  -0.500000            ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371336 fma  1  1E34  -0.50000             ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371337 fma  1  1E34  -0.5000              ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371338 fma  1  1E34  -0.500               ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371339 fma  1  1E34  -0.50                ->  1.000000000000000000000000000000000E+34 Inexact Rounded

dqadd371340 fma  1  1E34  -5000000.000010001   ->  9999999999999999999999999995000000      Inexact Rounded
dqadd371341 fma  1  1E34  -5000000.000000001   ->  9999999999999999999999999995000000      Inexact Rounded

dqadd371349 fma  1  9999999999999999999999999999999999 0.4                 ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371350 fma  1  9999999999999999999999999999999999 0.49                ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371351 fma  1  9999999999999999999999999999999999 0.499               ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371352 fma  1  9999999999999999999999999999999999 0.4999              ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371353 fma  1  9999999999999999999999999999999999 0.49999             ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371354 fma  1  9999999999999999999999999999999999 0.499999            ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371355 fma  1  9999999999999999999999999999999999 0.4999999           ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371356 fma  1  9999999999999999999999999999999999 0.49999999          ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371357 fma  1  9999999999999999999999999999999999 0.499999999         ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371358 fma  1  9999999999999999999999999999999999 0.4999999999        ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371359 fma  1  9999999999999999999999999999999999 0.49999999999       ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371360 fma  1  9999999999999999999999999999999999 0.499999999999      ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371361 fma  1  9999999999999999999999999999999999 0.4999999999999     ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371362 fma  1  9999999999999999999999999999999999 0.49999999999999    ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371363 fma  1  9999999999999999999999999999999999 0.499999999999999   ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371364 fma  1  9999999999999999999999999999999999 0.4999999999999999  ->  9999999999999999999999999999999999      Inexact Rounded
dqadd371365 fma  1  9999999999999999999999999999999999 0.5000000000000000  ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371367 fma  1  9999999999999999999999999999999999 0.500000000000000   ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371368 fma  1  9999999999999999999999999999999999 0.50000000000000    ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371369 fma  1  9999999999999999999999999999999999 0.5000000000000     ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371370 fma  1  9999999999999999999999999999999999 0.500000000000      ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371371 fma  1  9999999999999999999999999999999999 0.50000000000       ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371372 fma  1  9999999999999999999999999999999999 0.5000000000        ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371373 fma  1  9999999999999999999999999999999999 0.500000000         ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371374 fma  1  9999999999999999999999999999999999 0.50000000          ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371375 fma  1  9999999999999999999999999999999999 0.5000000           ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371376 fma  1  9999999999999999999999999999999999 0.500000            ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371377 fma  1  9999999999999999999999999999999999 0.50000             ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371378 fma  1  9999999999999999999999999999999999 0.5000              ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371379 fma  1  9999999999999999999999999999999999 0.500               ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371380 fma  1  9999999999999999999999999999999999 0.50                ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371381 fma  1  9999999999999999999999999999999999 0.5                 ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371382 fma  1  9999999999999999999999999999999999 0.5000000000000001  ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371383 fma  1  9999999999999999999999999999999999 0.500000000000001   ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371384 fma  1  9999999999999999999999999999999999 0.50000000000001    ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371385 fma  1  9999999999999999999999999999999999 0.5000000000001     ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371386 fma  1  9999999999999999999999999999999999 0.500000000001      ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371387 fma  1  9999999999999999999999999999999999 0.50000000001       ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371388 fma  1  9999999999999999999999999999999999 0.5000000001        ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371389 fma  1  9999999999999999999999999999999999 0.500000001         ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371390 fma  1  9999999999999999999999999999999999 0.50000001          ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371391 fma  1  9999999999999999999999999999999999 0.5000001           ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371392 fma  1  9999999999999999999999999999999999 0.500001            ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371393 fma  1  9999999999999999999999999999999999 0.50001             ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371394 fma  1  9999999999999999999999999999999999 0.5001              ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371395 fma  1  9999999999999999999999999999999999 0.501               ->  1.000000000000000000000000000000000E+34 Inexact Rounded
dqadd371396 fma  1  9999999999999999999999999999999999 0.51                ->  1.000000000000000000000000000000000E+34 Inexact Rounded

-- More GD edge cases, where difference between the unadjusted
-- exponents is larger than the maximum precision and one side is 0
dqadd371420 fma  1   0 1.123456789987654321123456789012345     -> 1.123456789987654321123456789012345
dqadd371421 fma  1   0 1.123456789987654321123456789012345E-1  -> 0.1123456789987654321123456789012345
dqadd371422 fma  1   0 1.123456789987654321123456789012345E-2  -> 0.01123456789987654321123456789012345
dqadd371423 fma  1   0 1.123456789987654321123456789012345E-3  -> 0.001123456789987654321123456789012345
dqadd371424 fma  1   0 1.123456789987654321123456789012345E-4  -> 0.0001123456789987654321123456789012345
dqadd371425 fma  1   0 1.123456789987654321123456789012345E-5  -> 0.00001123456789987654321123456789012345
dqadd371426 fma  1   0 1.123456789987654321123456789012345E-6  -> 0.000001123456789987654321123456789012345
dqadd371427 fma  1   0 1.123456789987654321123456789012345E-7  -> 1.123456789987654321123456789012345E-7
dqadd371428 fma  1   0 1.123456789987654321123456789012345E-8  -> 1.123456789987654321123456789012345E-8
dqadd371429 fma  1   0 1.123456789987654321123456789012345E-9  -> 1.123456789987654321123456789012345E-9
dqadd371430 fma  1   0 1.123456789987654321123456789012345E-10 -> 1.123456789987654321123456789012345E-10
dqadd371431 fma  1   0 1.123456789987654321123456789012345E-11 -> 1.123456789987654321123456789012345E-11
dqadd371432 fma  1   0 1.123456789987654321123456789012345E-12 -> 1.123456789987654321123456789012345E-12
dqadd371433 fma  1   0 1.123456789987654321123456789012345E-13 -> 1.123456789987654321123456789012345E-13
dqadd371434 fma  1   0 1.123456789987654321123456789012345E-14 -> 1.123456789987654321123456789012345E-14
dqadd371435 fma  1   0 1.123456789987654321123456789012345E-15 -> 1.123456789987654321123456789012345E-15
dqadd371436 fma  1   0 1.123456789987654321123456789012345E-16 -> 1.123456789987654321123456789012345E-16
dqadd371437 fma  1   0 1.123456789987654321123456789012345E-17 -> 1.123456789987654321123456789012345E-17
dqadd371438 fma  1   0 1.123456789987654321123456789012345E-18 -> 1.123456789987654321123456789012345E-18
dqadd371439 fma  1   0 1.123456789987654321123456789012345E-19 -> 1.123456789987654321123456789012345E-19
dqadd371440 fma  1   0 1.123456789987654321123456789012345E-20 -> 1.123456789987654321123456789012345E-20
dqadd371441 fma  1   0 1.123456789987654321123456789012345E-21 -> 1.123456789987654321123456789012345E-21
dqadd371442 fma  1   0 1.123456789987654321123456789012345E-22 -> 1.123456789987654321123456789012345E-22
dqadd371443 fma  1   0 1.123456789987654321123456789012345E-23 -> 1.123456789987654321123456789012345E-23
dqadd371444 fma  1   0 1.123456789987654321123456789012345E-24 -> 1.123456789987654321123456789012345E-24
dqadd371445 fma  1   0 1.123456789987654321123456789012345E-25 -> 1.123456789987654321123456789012345E-25
dqadd371446 fma  1   0 1.123456789987654321123456789012345E-26 -> 1.123456789987654321123456789012345E-26
dqadd371447 fma  1   0 1.123456789987654321123456789012345E-27 -> 1.123456789987654321123456789012345E-27
dqadd371448 fma  1   0 1.123456789987654321123456789012345E-28 -> 1.123456789987654321123456789012345E-28
dqadd371449 fma  1   0 1.123456789987654321123456789012345E-29 -> 1.123456789987654321123456789012345E-29
dqadd371450 fma  1   0 1.123456789987654321123456789012345E-30 -> 1.123456789987654321123456789012345E-30
dqadd371451 fma  1   0 1.123456789987654321123456789012345E-31 -> 1.123456789987654321123456789012345E-31
dqadd371452 fma  1   0 1.123456789987654321123456789012345E-32 -> 1.123456789987654321123456789012345E-32
dqadd371453 fma  1   0 1.123456789987654321123456789012345E-33 -> 1.123456789987654321123456789012345E-33
dqadd371454 fma  1   0 1.123456789987654321123456789012345E-34 -> 1.123456789987654321123456789012345E-34
dqadd371455 fma  1   0 1.123456789987654321123456789012345E-35 -> 1.123456789987654321123456789012345E-35
dqadd371456 fma  1   0 1.123456789987654321123456789012345E-36 -> 1.123456789987654321123456789012345E-36

-- same, reversed 0
dqadd371460 fma  1  1.123456789987654321123456789012345     0 -> 1.123456789987654321123456789012345
dqadd371461 fma  1  1.123456789987654321123456789012345E-1  0 -> 0.1123456789987654321123456789012345
dqadd371462 fma  1  1.123456789987654321123456789012345E-2  0 -> 0.01123456789987654321123456789012345
dqadd371463 fma  1  1.123456789987654321123456789012345E-3  0 -> 0.001123456789987654321123456789012345
dqadd371464 fma  1  1.123456789987654321123456789012345E-4  0 -> 0.0001123456789987654321123456789012345
dqadd371465 fma  1  1.123456789987654321123456789012345E-5  0 -> 0.00001123456789987654321123456789012345
dqadd371466 fma  1  1.123456789987654321123456789012345E-6  0 -> 0.000001123456789987654321123456789012345
dqadd371467 fma  1  1.123456789987654321123456789012345E-7  0 -> 1.123456789987654321123456789012345E-7
dqadd371468 fma  1  1.123456789987654321123456789012345E-8  0 -> 1.123456789987654321123456789012345E-8
dqadd371469 fma  1  1.123456789987654321123456789012345E-9  0 -> 1.123456789987654321123456789012345E-9
dqadd371470 fma  1  1.123456789987654321123456789012345E-10 0 -> 1.123456789987654321123456789012345E-10
dqadd371471 fma  1  1.123456789987654321123456789012345E-11 0 -> 1.123456789987654321123456789012345E-11
dqadd371472 fma  1  1.123456789987654321123456789012345E-12 0 -> 1.123456789987654321123456789012345E-12
dqadd371473 fma  1  1.123456789987654321123456789012345E-13 0 -> 1.123456789987654321123456789012345E-13
dqadd371474 fma  1  1.123456789987654321123456789012345E-14 0 -> 1.123456789987654321123456789012345E-14
dqadd371475 fma  1  1.123456789987654321123456789012345E-15 0 -> 1.123456789987654321123456789012345E-15
dqadd371476 fma  1  1.123456789987654321123456789012345E-16 0 -> 1.123456789987654321123456789012345E-16
dqadd371477 fma  1  1.123456789987654321123456789012345E-17 0 -> 1.123456789987654321123456789012345E-17
dqadd371478 fma  1  1.123456789987654321123456789012345E-18 0 -> 1.123456789987654321123456789012345E-18
dqadd371479 fma  1  1.123456789987654321123456789012345E-19 0 -> 1.123456789987654321123456789012345E-19
dqadd371480 fma  1  1.123456789987654321123456789012345E-20 0 -> 1.123456789987654321123456789012345E-20
dqadd371481 fma  1  1.123456789987654321123456789012345E-21 0 -> 1.123456789987654321123456789012345E-21
dqadd371482 fma  1  1.123456789987654321123456789012345E-22 0 -> 1.123456789987654321123456789012345E-22
dqadd371483 fma  1  1.123456789987654321123456789012345E-23 0 -> 1.123456789987654321123456789012345E-23
dqadd371484 fma  1  1.123456789987654321123456789012345E-24 0 -> 1.123456789987654321123456789012345E-24
dqadd371485 fma  1  1.123456789987654321123456789012345E-25 0 -> 1.123456789987654321123456789012345E-25
dqadd371486 fma  1  1.123456789987654321123456789012345E-26 0 -> 1.123456789987654321123456789012345E-26
dqadd371487 fma  1  1.123456789987654321123456789012345E-27 0 -> 1.123456789987654321123456789012345E-27
dqadd371488 fma  1  1.123456789987654321123456789012345E-28 0 -> 1.123456789987654321123456789012345E-28
dqadd371489 fma  1  1.123456789987654321123456789012345E-29 0 -> 1.123456789987654321123456789012345E-29
dqadd371490 fma  1  1.123456789987654321123456789012345E-30 0 -> 1.123456789987654321123456789012345E-30
dqadd371491 fma  1  1.123456789987654321123456789012345E-31 0 -> 1.123456789987654321123456789012345E-31
dqadd371492 fma  1  1.123456789987654321123456789012345E-32 0 -> 1.123456789987654321123456789012345E-32
dqadd371493 fma  1  1.123456789987654321123456789012345E-33 0 -> 1.123456789987654321123456789012345E-33
dqadd371494 fma  1  1.123456789987654321123456789012345E-34 0 -> 1.123456789987654321123456789012345E-34
dqadd371495 fma  1  1.123456789987654321123456789012345E-35 0 -> 1.123456789987654321123456789012345E-35
dqadd371496 fma  1  1.123456789987654321123456789012345E-36 0 -> 1.123456789987654321123456789012345E-36

-- same, Es on the 0
dqadd371500 fma  1  1.123456789987654321123456789012345  0E-0   -> 1.123456789987654321123456789012345
dqadd371501 fma  1  1.123456789987654321123456789012345  0E-1   -> 1.123456789987654321123456789012345
dqadd371502 fma  1  1.123456789987654321123456789012345  0E-2   -> 1.123456789987654321123456789012345
dqadd371503 fma  1  1.123456789987654321123456789012345  0E-3   -> 1.123456789987654321123456789012345
dqadd371504 fma  1  1.123456789987654321123456789012345  0E-4   -> 1.123456789987654321123456789012345
dqadd371505 fma  1  1.123456789987654321123456789012345  0E-5   -> 1.123456789987654321123456789012345
dqadd371506 fma  1  1.123456789987654321123456789012345  0E-6   -> 1.123456789987654321123456789012345
dqadd371507 fma  1  1.123456789987654321123456789012345  0E-7   -> 1.123456789987654321123456789012345
dqadd371508 fma  1  1.123456789987654321123456789012345  0E-8   -> 1.123456789987654321123456789012345
dqadd371509 fma  1  1.123456789987654321123456789012345  0E-9   -> 1.123456789987654321123456789012345
dqadd371510 fma  1  1.123456789987654321123456789012345  0E-10  -> 1.123456789987654321123456789012345
dqadd371511 fma  1  1.123456789987654321123456789012345  0E-11  -> 1.123456789987654321123456789012345
dqadd371512 fma  1  1.123456789987654321123456789012345  0E-12  -> 1.123456789987654321123456789012345
dqadd371513 fma  1  1.123456789987654321123456789012345  0E-13  -> 1.123456789987654321123456789012345
dqadd371514 fma  1  1.123456789987654321123456789012345  0E-14  -> 1.123456789987654321123456789012345
dqadd371515 fma  1  1.123456789987654321123456789012345  0E-15  -> 1.123456789987654321123456789012345
dqadd371516 fma  1  1.123456789987654321123456789012345  0E-16  -> 1.123456789987654321123456789012345
dqadd371517 fma  1  1.123456789987654321123456789012345  0E-17  -> 1.123456789987654321123456789012345
dqadd371518 fma  1  1.123456789987654321123456789012345  0E-18  -> 1.123456789987654321123456789012345
dqadd371519 fma  1  1.123456789987654321123456789012345  0E-19  -> 1.123456789987654321123456789012345
dqadd371520 fma  1  1.123456789987654321123456789012345  0E-20  -> 1.123456789987654321123456789012345
dqadd371521 fma  1  1.123456789987654321123456789012345  0E-21  -> 1.123456789987654321123456789012345
dqadd371522 fma  1  1.123456789987654321123456789012345  0E-22  -> 1.123456789987654321123456789012345
dqadd371523 fma  1  1.123456789987654321123456789012345  0E-23  -> 1.123456789987654321123456789012345
dqadd371524 fma  1  1.123456789987654321123456789012345  0E-24  -> 1.123456789987654321123456789012345
dqadd371525 fma  1  1.123456789987654321123456789012345  0E-25  -> 1.123456789987654321123456789012345
dqadd371526 fma  1  1.123456789987654321123456789012345  0E-26  -> 1.123456789987654321123456789012345
dqadd371527 fma  1  1.123456789987654321123456789012345  0E-27  -> 1.123456789987654321123456789012345
dqadd371528 fma  1  1.123456789987654321123456789012345  0E-28  -> 1.123456789987654321123456789012345
dqadd371529 fma  1  1.123456789987654321123456789012345  0E-29  -> 1.123456789987654321123456789012345
dqadd371530 fma  1  1.123456789987654321123456789012345  0E-30  -> 1.123456789987654321123456789012345
dqadd371531 fma  1  1.123456789987654321123456789012345  0E-31  -> 1.123456789987654321123456789012345
dqadd371532 fma  1  1.123456789987654321123456789012345  0E-32  -> 1.123456789987654321123456789012345
dqadd371533 fma  1  1.123456789987654321123456789012345  0E-33  -> 1.123456789987654321123456789012345
-- next four flag Rounded because the 0 extends the result
dqadd371534 fma  1  1.123456789987654321123456789012345  0E-34  -> 1.123456789987654321123456789012345 Rounded
dqadd371535 fma  1  1.123456789987654321123456789012345  0E-35  -> 1.123456789987654321123456789012345 Rounded
dqadd371536 fma  1  1.123456789987654321123456789012345  0E-36  -> 1.123456789987654321123456789012345 Rounded
dqadd371537 fma  1  1.123456789987654321123456789012345  0E-37  -> 1.123456789987654321123456789012345 Rounded

-- sum of two opposite-sign operands is exactly 0 and floor => -0
rounding:    half_up
-- exact zeros from zeros
dqadd371600 fma  1   0        0E-19  ->  0E-19
dqadd371601 fma  1  -0        0E-19  ->  0E-19
dqadd371602 fma  1   0       -0E-19  ->  0E-19
dqadd371603 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd371611 fma  1  -11      11    ->  0
dqadd371612 fma  1   11     -11    ->  0

rounding:    half_down
-- exact zeros from zeros
dqadd371620 fma  1   0        0E-19  ->  0E-19
dqadd371621 fma  1  -0        0E-19  ->  0E-19
dqadd371622 fma  1   0       -0E-19  ->  0E-19
dqadd371623 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd371631 fma  1  -11      11    ->  0
dqadd371632 fma  1   11     -11    ->  0

rounding:    half_even
-- exact zeros from zeros
dqadd371640 fma  1   0        0E-19  ->  0E-19
dqadd371641 fma  1  -0        0E-19  ->  0E-19
dqadd371642 fma  1   0       -0E-19  ->  0E-19
dqadd371643 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd371651 fma  1  -11      11    ->  0
dqadd371652 fma  1   11     -11    ->  0

rounding:    up
-- exact zeros from zeros
dqadd371660 fma  1   0        0E-19  ->  0E-19
dqadd371661 fma  1  -0        0E-19  ->  0E-19
dqadd371662 fma  1   0       -0E-19  ->  0E-19
dqadd371663 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd371671 fma  1  -11      11    ->  0
dqadd371672 fma  1   11     -11    ->  0

rounding:    down
-- exact zeros from zeros
dqadd371680 fma  1   0        0E-19  ->  0E-19
dqadd371681 fma  1  -0        0E-19  ->  0E-19
dqadd371682 fma  1   0       -0E-19  ->  0E-19
dqadd371683 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd371691 fma  1  -11      11    ->  0
dqadd371692 fma  1   11     -11    ->  0

rounding:    ceiling
-- exact zeros from zeros
dqadd371700 fma  1   0        0E-19  ->  0E-19
dqadd371701 fma  1  -0        0E-19  ->  0E-19
dqadd371702 fma  1   0       -0E-19  ->  0E-19
dqadd371703 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd371711 fma  1  -11      11    ->  0
dqadd371712 fma  1   11     -11    ->  0

-- and the extra-special ugly case; unusual minuses marked by -- *
rounding:    floor
-- exact zeros from zeros
dqadd371720 fma  1   0        0E-19  ->  0E-19
dqadd371721 fma  1  -0        0E-19  -> -0E-19           -- *
dqadd371722 fma  1   0       -0E-19  -> -0E-19           -- *
dqadd371723 fma  1  -0       -0E-19  -> -0E-19
-- exact zeros from non-zeros
dqadd371731 fma  1  -11      11    ->  -0                -- *
dqadd371732 fma  1   11     -11    ->  -0                -- *

-- Examples from SQL proposal (Krishna Kulkarni)
dqadd371741 fma  1  130E-2    120E-2    -> 2.50
dqadd371742 fma  1  130E-2    12E-1     -> 2.50
dqadd371743 fma  1  130E-2    1E0       -> 2.30
dqadd371744 fma  1  1E2       1E4       -> 1.01E+4
dqadd371745 fma  1  130E-2   -120E-2 -> 0.10
dqadd371746 fma  1  130E-2   -12E-1  -> 0.10
dqadd371747 fma  1  130E-2   -1E0    -> 0.30
dqadd371748 fma  1  1E2      -1E4    -> -9.9E+3

-- Gappy coefficients; check residue handling even with full coefficient gap
rounding: half_even

dqadd375001 fma  1  1239876543211234567894567890123456 1      -> 1239876543211234567894567890123457
dqadd375002 fma  1  1239876543211234567894567890123456 0.6    -> 1239876543211234567894567890123457  Inexact Rounded
dqadd375003 fma  1  1239876543211234567894567890123456 0.06   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375004 fma  1  1239876543211234567894567890123456 6E-3   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375005 fma  1  1239876543211234567894567890123456 6E-4   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375006 fma  1  1239876543211234567894567890123456 6E-5   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375007 fma  1  1239876543211234567894567890123456 6E-6   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375008 fma  1  1239876543211234567894567890123456 6E-7   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375009 fma  1  1239876543211234567894567890123456 6E-8   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375010 fma  1  1239876543211234567894567890123456 6E-9   -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375011 fma  1  1239876543211234567894567890123456 6E-10  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375012 fma  1  1239876543211234567894567890123456 6E-11  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375013 fma  1  1239876543211234567894567890123456 6E-12  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375014 fma  1  1239876543211234567894567890123456 6E-13  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375015 fma  1  1239876543211234567894567890123456 6E-14  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375016 fma  1  1239876543211234567894567890123456 6E-15  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375017 fma  1  1239876543211234567894567890123456 6E-16  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375018 fma  1  1239876543211234567894567890123456 6E-17  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375019 fma  1  1239876543211234567894567890123456 6E-18  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375020 fma  1  1239876543211234567894567890123456 6E-19  -> 1239876543211234567894567890123456  Inexact Rounded
dqadd375021 fma  1  1239876543211234567894567890123456 6E-20  -> 1239876543211234567894567890123456  Inexact Rounded

-- widening second argument at gap
dqadd375030 fma  1  12398765432112345678945678 1                       -> 12398765432112345678945679
dqadd375031 fma  1  12398765432112345678945678 0.1                     -> 12398765432112345678945678.1
dqadd375032 fma  1  12398765432112345678945678 0.12                    -> 12398765432112345678945678.12
dqadd375033 fma  1  12398765432112345678945678 0.123                   -> 12398765432112345678945678.123
dqadd375034 fma  1  12398765432112345678945678 0.1234                  -> 12398765432112345678945678.1234
dqadd375035 fma  1  12398765432112345678945678 0.12345                 -> 12398765432112345678945678.12345
dqadd375036 fma  1  12398765432112345678945678 0.123456                -> 12398765432112345678945678.123456
dqadd375037 fma  1  12398765432112345678945678 0.1234567               -> 12398765432112345678945678.1234567
dqadd375038 fma  1  12398765432112345678945678 0.12345678              -> 12398765432112345678945678.12345678
dqadd375039 fma  1  12398765432112345678945678 0.123456789             -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd375040 fma  1  12398765432112345678945678 0.123456785             -> 12398765432112345678945678.12345678 Inexact Rounded
dqadd375041 fma  1  12398765432112345678945678 0.1234567850            -> 12398765432112345678945678.12345678 Inexact Rounded
dqadd375042 fma  1  12398765432112345678945678 0.1234567851            -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd375043 fma  1  12398765432112345678945678 0.12345678501           -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd375044 fma  1  12398765432112345678945678 0.123456785001          -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd375045 fma  1  12398765432112345678945678 0.1234567850001         -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd375046 fma  1  12398765432112345678945678 0.12345678500001        -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd375047 fma  1  12398765432112345678945678 0.123456785000001       -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd375048 fma  1  12398765432112345678945678 0.1234567850000001      -> 12398765432112345678945678.12345679 Inexact Rounded
dqadd375049 fma  1  12398765432112345678945678 0.1234567850000000      -> 12398765432112345678945678.12345678 Inexact Rounded
--                               90123456
rounding: half_even
dqadd375050 fma  1  12398765432112345678945678 0.0234567750000000      -> 12398765432112345678945678.02345678 Inexact Rounded
dqadd375051 fma  1  12398765432112345678945678 0.0034567750000000      -> 12398765432112345678945678.00345678 Inexact Rounded
dqadd375052 fma  1  12398765432112345678945678 0.0004567750000000      -> 12398765432112345678945678.00045678 Inexact Rounded
dqadd375053 fma  1  12398765432112345678945678 0.0000567750000000      -> 12398765432112345678945678.00005678 Inexact Rounded
dqadd375054 fma  1  12398765432112345678945678 0.0000067750000000      -> 12398765432112345678945678.00000678 Inexact Rounded
dqadd375055 fma  1  12398765432112345678945678 0.0000007750000000      -> 12398765432112345678945678.00000078 Inexact Rounded
dqadd375056 fma  1  12398765432112345678945678 0.0000000750000000      -> 12398765432112345678945678.00000008 Inexact Rounded
dqadd375057 fma  1  12398765432112345678945678 0.0000000050000000      -> 12398765432112345678945678.00000000 Inexact Rounded
dqadd375060 fma  1  12398765432112345678945678 0.0234567750000001      -> 12398765432112345678945678.02345678 Inexact Rounded
dqadd375061 fma  1  12398765432112345678945678 0.0034567750000001      -> 12398765432112345678945678.00345678 Inexact Rounded
dqadd375062 fma  1  12398765432112345678945678 0.0004567750000001      -> 12398765432112345678945678.00045678 Inexact Rounded
dqadd375063 fma  1  12398765432112345678945678 0.0000567750000001      -> 12398765432112345678945678.00005678 Inexact Rounded
dqadd375064 fma  1  12398765432112345678945678 0.0000067750000001      -> 12398765432112345678945678.00000678 Inexact Rounded
dqadd375065 fma  1  12398765432112345678945678 0.0000007750000001      -> 12398765432112345678945678.00000078 Inexact Rounded
dqadd375066 fma  1  12398765432112345678945678 0.0000000750000001      -> 12398765432112345678945678.00000008 Inexact Rounded
dqadd375067 fma  1  12398765432112345678945678 0.0000000050000001      -> 12398765432112345678945678.00000001 Inexact Rounded
-- far-out residues (full coefficient gap is 16+15 digits)
rounding: up
dqadd375070 fma  1  12398765432112345678945678 1E-8                    -> 12398765432112345678945678.00000001
dqadd375071 fma  1  12398765432112345678945678 1E-9                    -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375072 fma  1  12398765432112345678945678 1E-10                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375073 fma  1  12398765432112345678945678 1E-11                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375074 fma  1  12398765432112345678945678 1E-12                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375075 fma  1  12398765432112345678945678 1E-13                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375076 fma  1  12398765432112345678945678 1E-14                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375077 fma  1  12398765432112345678945678 1E-15                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375078 fma  1  12398765432112345678945678 1E-16                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375079 fma  1  12398765432112345678945678 1E-17                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375080 fma  1  12398765432112345678945678 1E-18                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375081 fma  1  12398765432112345678945678 1E-19                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375082 fma  1  12398765432112345678945678 1E-20                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375083 fma  1  12398765432112345678945678 1E-25                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375084 fma  1  12398765432112345678945678 1E-30                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375085 fma  1  12398765432112345678945678 1E-31                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375086 fma  1  12398765432112345678945678 1E-32                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375087 fma  1  12398765432112345678945678 1E-33                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375088 fma  1  12398765432112345678945678 1E-34                   -> 12398765432112345678945678.00000001 Inexact Rounded
dqadd375089 fma  1  12398765432112345678945678 1E-35                   -> 12398765432112345678945678.00000001 Inexact Rounded

-- Null tests
dqadd39990 fma  1  10  # -> NaN Invalid_operation
dqadd39991 fma  1   # 10 -> NaN Invalid_operation


Added test/dectest/dqInvert.decTest.











































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
------------------------------------------------------------------------
-- dqInvert.decTest -- digitwise logical INVERT for decQuads          --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Sanity check (truth table)
dqinv001 invert             0 -> 1111111111111111111111111111111111
dqinv002 invert             1 -> 1111111111111111111111111111111110
dqinv003 invert            10 -> 1111111111111111111111111111111101
dqinv004 invert     111111111 -> 1111111111111111111111111000000000
dqinv005 invert     000000000 -> 1111111111111111111111111111111111
-- and at msd and msd-1
dqinv007 invert 0000000000000000000000000000000000 ->   1111111111111111111111111111111111
dqinv008 invert 1000000000000000000000000000000000 ->    111111111111111111111111111111111
dqinv009 invert 0000000000000000000000000000000000 ->   1111111111111111111111111111111111
dqinv010 invert 0100000000000000000000000000000000 ->   1011111111111111111111111111111111
dqinv011 invert 0111111111111111111111111111111111 ->   1000000000000000000000000000000000
dqinv012 invert 1111111111111111111111111111111111 ->                  0
dqinv013 invert 0011111111111111111111111111111111 ->   1100000000000000000000000000000000
dqinv014 invert 0111111111111111111111111111111111 ->   1000000000000000000000000000000000

-- Various lengths
dqinv600 invert 0111111111111111111011111111111111 ->   1000000000000000000100000000000000
dqinv601 invert 0011111111111111110101111111111111 ->   1100000000000000001010000000000000
dqinv602 invert 0101111111111111101110111111111111 ->   1010000000000000010001000000000000
dqinv603 invert 0110111111111111011111011111111111 ->   1001000000000000100000100000000000
dqinv604 invert 0111011111111110111111101111111111 ->   1000100000000001000000010000000000
dqinv605 invert 0111101111111101111111110111111111 ->   1000010000000010000000001000000000
dqinv606 invert 0111110111111011111111111011111111 ->   1000001000000100000000000100000000
dqinv607 invert 0111111011110111111111111101111111 ->   1000000100001000000000000010000000
dqinv608 invert 0111111101101111111111111110111111 ->   1000000010010000000000000001000000
dqinv609 invert 0111111110011111111111111111011111 ->   1000000001100000000000000000100000
dqinv610 invert 0111111110011111111111111111101111 ->   1000000001100000000000000000010000
dqinv611 invert 0111111101101111111111111111110111 ->   1000000010010000000000000000001000
dqinv612 invert 0111111011110111111111111111111011 ->   1000000100001000000000000000000100
dqinv613 invert 0111110111111011111111111111111101 ->   1000001000000100000000000000000010
dqinv614 invert 0111101111111101111111111111111110 ->   1000010000000010000000000000000001
dqinv615 invert 0111011111111110111111111111111111 ->   1000100000000001000000000000000000
dqinv616 invert 0110111111111111011111111111111110 ->   1001000000000000100000000000000001
dqinv617 invert 0101111111111111101111111111111101 ->   1010000000000000010000000000000010
dqinv618 invert 0011111111111111110111111111111011 ->   1100000000000000001000000000000100
dqinv619 invert 0101111111111111111011111111110111 ->   1010000000000000000100000000001000
dqinv620 invert 0110111111111111111101111111101111 ->   1001000000000000000010000000010000
dqinv621 invert 0111011111111111111110111111011111 ->   1000100000000000000001000000100000
dqinv622 invert 0111101111111111111111011110111111 ->   1000010000000000000000100001000000
dqinv623 invert 0111110111111111111111101101111111 ->   1000001000000000000000010010000000
dqinv624 invert 0111111011111111111111110011111111 ->   1000000100000000000000001100000000
dqinv625 invert 0111111101111111111111110011111111 ->   1000000010000000000000001100000000
dqinv626 invert 0111111110111111111111101101111111 ->   1000000001000000000000010010000000
dqinv627 invert 0111111111011111111111011110111111 ->   1000000000100000000000100001000000
dqinv628 invert 0111111111101111111110111111011111 ->   1000000000010000000001000000100000
dqinv629 invert 0111111111110111111101111111101111 ->   1000000000001000000010000000010000
dqinv630 invert 0111111111111011111011111111110111 ->   1000000000000100000100000000001000
dqinv631 invert 0111111111111101110111111111111011 ->   1000000000000010001000000000000100
dqinv632 invert 0111111111111110101111111111111101 ->   1000000000000001010000000000000010
dqinv633 invert 0111111111111111011111111111111110 ->   1000000000000000100000000000000001

dqinv021 invert 111111111     -> 1111111111111111111111111000000000
dqinv022 invert 111111111111  -> 1111111111111111111111000000000000
dqinv023 invert  11111111     -> 1111111111111111111111111100000000
dqinv025 invert   1111111     -> 1111111111111111111111111110000000
dqinv026 invert    111111     -> 1111111111111111111111111111000000
dqinv027 invert     11111     -> 1111111111111111111111111111100000
dqinv028 invert      1111     -> 1111111111111111111111111111110000
dqinv029 invert       111     -> 1111111111111111111111111111111000
dqinv031 invert        11     -> 1111111111111111111111111111111100
dqinv032 invert         1     -> 1111111111111111111111111111111110
dqinv033 invert 111111111111  -> 1111111111111111111111000000000000
dqinv034 invert 11111111111   -> 1111111111111111111111100000000000
dqinv035 invert 1111111111    -> 1111111111111111111111110000000000
dqinv036 invert 111111111     -> 1111111111111111111111111000000000

dqinv040 invert 011111111   -> 1111111111111111111111111100000000
dqinv041 invert 101111111   -> 1111111111111111111111111010000000
dqinv042 invert 110111111   -> 1111111111111111111111111001000000
dqinv043 invert 111011111   -> 1111111111111111111111111000100000
dqinv044 invert 111101111   -> 1111111111111111111111111000010000
dqinv045 invert 111110111   -> 1111111111111111111111111000001000
dqinv046 invert 111111011   -> 1111111111111111111111111000000100
dqinv047 invert 111111101   -> 1111111111111111111111111000000010
dqinv048 invert 111111110   -> 1111111111111111111111111000000001
dqinv049 invert 011111011   -> 1111111111111111111111111100000100
dqinv050 invert 101111101   -> 1111111111111111111111111010000010
dqinv051 invert 110111110   -> 1111111111111111111111111001000001
dqinv052 invert 111011101   -> 1111111111111111111111111000100010
dqinv053 invert 111101011   -> 1111111111111111111111111000010100
dqinv054 invert 111110111   -> 1111111111111111111111111000001000
dqinv055 invert 111101011   -> 1111111111111111111111111000010100
dqinv056 invert 111011101   -> 1111111111111111111111111000100010
dqinv057 invert 110111110   -> 1111111111111111111111111001000001
dqinv058 invert 101111101   -> 1111111111111111111111111010000010
dqinv059 invert 011111011   -> 1111111111111111111111111100000100

dqinv080 invert 1000000011111111   -> 1111111111111111110111111100000000
dqinv081 invert 0100000101111111   -> 1111111111111111111011111010000000
dqinv082 invert 0010000110111111   -> 1111111111111111111101111001000000
dqinv083 invert 0001000111011111   -> 1111111111111111111110111000100000
dqinv084 invert 0000100111101111   -> 1111111111111111111111011000010000
dqinv085 invert 0000010111110111   -> 1111111111111111111111101000001000
dqinv086 invert 0000001111111011   -> 1111111111111111111111110000000100
dqinv087 invert 0000010111111101   -> 1111111111111111111111101000000010
dqinv088 invert 0000100111111110   -> 1111111111111111111111011000000001
dqinv089 invert 0001000011111011   -> 1111111111111111111110111100000100
dqinv090 invert 0010000101111101   -> 1111111111111111111101111010000010
dqinv091 invert 0100000110111110   -> 1111111111111111111011111001000001
dqinv092 invert 1000000111011101   -> 1111111111111111110111111000100010
dqinv093 invert 0100000111101011   -> 1111111111111111111011111000010100
dqinv094 invert 0010000111110111   -> 1111111111111111111101111000001000
dqinv095 invert 0001000111101011   -> 1111111111111111111110111000010100
dqinv096 invert 0000100111011101   -> 1111111111111111111111011000100010
dqinv097 invert 0000010110111110   -> 1111111111111111111111101001000001
dqinv098 invert 0000001101111101   -> 1111111111111111111111110010000010
dqinv099 invert 0000010011111011   -> 1111111111111111111111101100000100

-- and more thorough MSD/LSD tests [8 and 9 mght be encoded differently...]
dqinv151 invert 1111111111111111111111111111111110 ->                                   1
dqinv152 invert 1111111111111111110000000000000000 ->                    1111111111111111
dqinv153 invert 1000000000000000001111111111111111 ->   111111111111111110000000000000000
dqinv154 invert 1111111111111111111000000000000000 ->                     111111111111111
dqinv155 invert 0100000000000000000111111111111111 ->  1011111111111111111000000000000000
dqinv156 invert 1011111111111111110100000000000000 ->   100000000000000001011111111111111
dqinv157 invert 1101111111111111110111111111111111 ->    10000000000000001000000000000000
dqinv158 invert 1110111111111111110011111111111111 ->     1000000000000001100000000000000

-- non-0/1 should not be accepted, nor should signs
dqinv220 invert 111111112   ->  NaN Invalid_operation
dqinv221 invert 333333333   ->  NaN Invalid_operation
dqinv222 invert 555555555   ->  NaN Invalid_operation
dqinv223 invert 777777777   ->  NaN Invalid_operation
dqinv224 invert 999999999   ->  NaN Invalid_operation
dqinv225 invert 222222222   ->  NaN Invalid_operation
dqinv226 invert 444444444   ->  NaN Invalid_operation
dqinv227 invert 666666666   ->  NaN Invalid_operation
dqinv228 invert 888888888   ->  NaN Invalid_operation
dqinv229 invert 999999999   ->  NaN Invalid_operation
dqinv230 invert 999999999   ->  NaN Invalid_operation
dqinv231 invert 999999999   ->  NaN Invalid_operation
dqinv232 invert 999999999   ->  NaN Invalid_operation
-- a few randoms
dqinv240 invert  567468689  ->  NaN Invalid_operation
dqinv241 invert  567367689  ->  NaN Invalid_operation
dqinv242 invert -631917772  ->  NaN Invalid_operation
dqinv243 invert -756253257  ->  NaN Invalid_operation
dqinv244 invert  835590149  ->  NaN Invalid_operation
-- test MSD
dqinv250 invert  2000000111000111000111000000000000 ->  NaN Invalid_operation
dqinv251 invert  3000000111000111000111000000000000 ->  NaN Invalid_operation
dqinv252 invert  4000000111000111000111000000000000 ->  NaN Invalid_operation
dqinv253 invert  5000000111000111000111000000000000 ->  NaN Invalid_operation
dqinv254 invert  6000000111000111000111000000000000 ->  NaN Invalid_operation
dqinv255 invert  7000000111000111000111000000000000 ->  NaN Invalid_operation
dqinv256 invert  8000000111000111000111000000000000 ->  NaN Invalid_operation
dqinv257 invert  9000000111000111000111000000000000 ->  NaN Invalid_operation
-- test MSD-1
dqinv270 invert  0200000111000111000111001000000000 ->  NaN Invalid_operation
dqinv271 invert  0300000111000111000111000100000000 ->  NaN Invalid_operation
dqinv272 invert  0400000111000111000111000010000000 ->  NaN Invalid_operation
dqinv273 invert  0500000111000111000111000001000000 ->  NaN Invalid_operation
dqinv274 invert  1600000111000111000111000000100000 ->  NaN Invalid_operation
dqinv275 invert  1700000111000111000111000000010000 ->  NaN Invalid_operation
dqinv276 invert  1800000111000111000111000000001000 ->  NaN Invalid_operation
dqinv277 invert  1900000111000111000111000000000100 ->  NaN Invalid_operation
-- test LSD
dqinv280 invert  0010000111000111000111000000000002 ->  NaN Invalid_operation
dqinv281 invert  0001000111000111000111000000000003 ->  NaN Invalid_operation
dqinv282 invert  0000000111000111000111100000000004 ->  NaN Invalid_operation
dqinv283 invert  0000000111000111000111010000000005 ->  NaN Invalid_operation
dqinv284 invert  1000000111000111000111001000000006 ->  NaN Invalid_operation
dqinv285 invert  1000000111000111000111000100000007 ->  NaN Invalid_operation
dqinv286 invert  1000000111000111000111000010000008 ->  NaN Invalid_operation
dqinv287 invert  1000000111000111000111000001000009 ->  NaN Invalid_operation
-- test Middie
dqinv288 invert  0010000111000111000111000020000000 ->  NaN Invalid_operation
dqinv289 invert  0001000111000111000111000030000001 ->  NaN Invalid_operation
dqinv290 invert  0000000111000111000111100040000010 ->  NaN Invalid_operation
dqinv291 invert  0000000111000111000111010050000100 ->  NaN Invalid_operation
dqinv292 invert  1000000111000111000111001060001000 ->  NaN Invalid_operation
dqinv293 invert  1000000111000111000111000170010000 ->  NaN Invalid_operation
dqinv294 invert  1000000111000111000111000080100000 ->  NaN Invalid_operation
dqinv295 invert  1000000111000111000111000091000000 ->  NaN Invalid_operation
-- signs
dqinv296 invert -1000000111000111000111000001000000  ->  NaN Invalid_operation
dqinv299 invert  1000000111000111000111000001000000  ->  111111000111000111000111110111111

-- Nmax, Nmin, Ntiny-like
dqinv341 invert  9.99999999E+2998  -> NaN Invalid_operation
dqinv342 invert  1E-2998           -> NaN Invalid_operation
dqinv343 invert  1.00000000E-2998  -> NaN Invalid_operation
dqinv344 invert  1E-2078           -> NaN Invalid_operation
dqinv345 invert  -1E-2078          -> NaN Invalid_operation
dqinv346 invert  -1.00000000E-2998 -> NaN Invalid_operation
dqinv347 invert  -1E-2998          -> NaN Invalid_operation
dqinv348 invert  -9.99999999E+2998 -> NaN Invalid_operation

-- A few other non-integers
dqinv361 invert  1.0               -> NaN Invalid_operation
dqinv362 invert  1E+1              -> NaN Invalid_operation
dqinv363 invert  0.0               -> NaN Invalid_operation
dqinv364 invert  0E+1              -> NaN Invalid_operation
dqinv365 invert  9.9               -> NaN Invalid_operation
dqinv366 invert  9E+1              -> NaN Invalid_operation

-- All Specials are in error
dqinv788 invert -Inf     -> NaN  Invalid_operation
dqinv794 invert  Inf     -> NaN  Invalid_operation
dqinv821 invert  NaN     -> NaN  Invalid_operation
dqinv841 invert  sNaN    -> NaN  Invalid_operation
-- propagating NaNs
dqinv861 invert  NaN1    -> NaN Invalid_operation
dqinv862 invert +NaN2    -> NaN Invalid_operation
dqinv863 invert  NaN3    -> NaN Invalid_operation
dqinv864 invert  NaN4    -> NaN Invalid_operation
dqinv865 invert  NaN5    -> NaN Invalid_operation
dqinv871 invert  sNaN11  -> NaN Invalid_operation
dqinv872 invert  sNaN12  -> NaN Invalid_operation
dqinv873 invert  sNaN13  -> NaN Invalid_operation
dqinv874 invert  sNaN14  -> NaN Invalid_operation
dqinv875 invert  sNaN15  -> NaN Invalid_operation
dqinv876 invert  NaN16   -> NaN Invalid_operation
dqinv881 invert +NaN25   -> NaN Invalid_operation
dqinv882 invert -NaN26   -> NaN Invalid_operation
dqinv883 invert -sNaN27  -> NaN Invalid_operation

Added test/dectest/dqLogB.decTest.

































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
------------------------------------------------------------------------
-- dqLogB.decTest -- integral 754r adjusted exponent, for decQuads    --
-- Copyright (c) IBM Corporation, 2005, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- basics
dqlogb000 logb  0                 -> -Infinity  Division_by_zero
dqlogb001 logb  1E-6176           -> -6176
dqlogb002 logb  1E-6143           -> -6143
dqlogb003 logb  0.001             -> -3
dqlogb004 logb  0.03              -> -2
dqlogb005 logb  1                 ->  0
dqlogb006 logb  2                 ->  0
dqlogb007 logb  2.5               ->  0
dqlogb008 logb  2.50              ->  0
dqlogb009 logb  2.500             ->  0
dqlogb010 logb  10                ->  1
dqlogb011 logb  70                ->  1
dqlogb012 logb  100               ->  2
dqlogb013 logb  250               ->  2
dqlogb014 logb  9E+6144           ->  6144
dqlogb015 logb +Infinity          ->  Infinity

-- negatives appear to be treated as positives
dqlogb021 logb -0                 -> -Infinity  Division_by_zero
dqlogb022 logb -1E-6176           -> -6176
dqlogb023 logb -9E-6143           -> -6143
dqlogb024 logb -0.001             -> -3
dqlogb025 logb -1                 ->  0
dqlogb026 logb -2                 ->  0
dqlogb027 logb -10                ->  1
dqlogb028 logb -70                ->  1
dqlogb029 logb -100               ->  2
dqlogb030 logb -9E+6144           ->  6144
dqlogb031 logb -Infinity          ->  Infinity

-- zeros
dqlogb111 logb          0   -> -Infinity  Division_by_zero
dqlogb112 logb         -0   -> -Infinity  Division_by_zero
dqlogb113 logb       0E+4   -> -Infinity  Division_by_zero
dqlogb114 logb      -0E+4   -> -Infinity  Division_by_zero
dqlogb115 logb     0.0000   -> -Infinity  Division_by_zero
dqlogb116 logb    -0.0000   -> -Infinity  Division_by_zero
dqlogb117 logb      0E-141  -> -Infinity  Division_by_zero
dqlogb118 logb     -0E-141  -> -Infinity  Division_by_zero

-- full coefficients, alternating bits
dqlogb121 logb   268268268        -> 8
dqlogb122 logb  -268268268        -> 8
dqlogb123 logb   134134134        -> 8
dqlogb124 logb  -134134134        -> 8

-- Nmax, Nmin, Ntiny
dqlogb131 logb  9.999999999999999999999999999999999E+6144   ->  6144
dqlogb132 logb  1E-6143                   -> -6143
dqlogb133 logb  1.000000000000000000000000000000000E-6143   -> -6143
dqlogb134 logb  1E-6176                   -> -6176

dqlogb135 logb  -1E-6176                  -> -6176
dqlogb136 logb  -1.000000000000000000000000000000000E-6143  -> -6143
dqlogb137 logb  -1E-6143                  -> -6143
dqlogb1614 logb  -9.999999999999999999999999999999999E+6144  ->  6144

-- ones
dqlogb0061 logb  1                 ->   0
dqlogb0062 logb  1.0               ->   0
dqlogb0063 logb  1.000000000000000 ->   0

-- notable cases -- exact powers of 10
dqlogb1100 logb 1             -> 0
dqlogb1101 logb 10            -> 1
dqlogb1102 logb 100           -> 2
dqlogb1103 logb 1000          -> 3
dqlogb1104 logb 10000         -> 4
dqlogb1105 logb 100000        -> 5
dqlogb1106 logb 1000000       -> 6
dqlogb1107 logb 10000000      -> 7
dqlogb1108 logb 100000000     -> 8
dqlogb1109 logb 1000000000    -> 9
dqlogb1110 logb 10000000000   -> 10
dqlogb1111 logb 100000000000  -> 11
dqlogb1112 logb 1000000000000 -> 12
dqlogb1113 logb 0.00000000001 -> -11
dqlogb1114 logb 0.0000000001 -> -10
dqlogb1115 logb 0.000000001 -> -9
dqlogb1116 logb 0.00000001 -> -8
dqlogb1117 logb 0.0000001 -> -7
dqlogb1118 logb 0.000001 -> -6
dqlogb1119 logb 0.00001 -> -5
dqlogb1120 logb 0.0001 -> -4
dqlogb1121 logb 0.001 -> -3
dqlogb1122 logb 0.01 -> -2
dqlogb1123 logb 0.1 -> -1
dqlogb1124 logb 1E-99  -> -99
dqlogb1125 logb 1E-100 -> -100
dqlogb1127 logb 1E-299 -> -299
dqlogb1126 logb 1E-6143 -> -6143

-- suggestions from Ilan Nehama
dqlogb1400 logb 10E-3    -> -2
dqlogb1401 logb 10E-2    -> -1
dqlogb1402 logb 100E-2   ->  0
dqlogb1403 logb 1000E-2  ->  1
dqlogb1404 logb 10000E-2 ->  2
dqlogb1405 logb 10E-1    ->  0
dqlogb1406 logb 100E-1   ->  1
dqlogb1407 logb 1000E-1  ->  2
dqlogb1408 logb 10000E-1 ->  3
dqlogb1409 logb 10E0     ->  1
dqlogb1410 logb 100E0    ->  2
dqlogb1411 logb 1000E0   ->  3
dqlogb1412 logb 10000E0  ->  4
dqlogb1413 logb 10E1     ->  2
dqlogb1414 logb 100E1    ->  3
dqlogb1415 logb 1000E1   ->  4
dqlogb1416 logb 10000E1  ->  5
dqlogb1417 logb 10E2     ->  3
dqlogb1418 logb 100E2    ->  4
dqlogb1419 logb 1000E2   ->  5
dqlogb1420 logb 10000E2  ->  6

-- special values
dqlogb820  logb   Infinity ->   Infinity
dqlogb821  logb   0        ->  -Infinity Division_by_zero
dqlogb822  logb   NaN      ->   NaN
dqlogb823  logb   sNaN     ->   NaN     Invalid_operation
-- propagating NaNs
dqlogb824  logb   sNaN123  ->   NaN123  Invalid_operation
dqlogb825  logb   -sNaN321 ->  -NaN321  Invalid_operation
dqlogb826  logb   NaN456   ->   NaN456
dqlogb827  logb   -NaN654  ->  -NaN654
dqlogb828  logb   NaN1     ->   NaN1

-- Null test
dqlogb900  logb #   -> NaN Invalid_operation


Added test/dectest/dqMax.decTest.





































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
------------------------------------------------------------------------
-- dqMax.decTest -- decQuad maxnum                                    --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks
dqmax001 max  -2  -2  -> -2
dqmax002 max  -2  -1  -> -1
dqmax003 max  -2   0  ->  0
dqmax004 max  -2   1  ->  1
dqmax005 max  -2   2  ->  2
dqmax006 max  -1  -2  -> -1
dqmax007 max  -1  -1  -> -1
dqmax008 max  -1   0  ->  0
dqmax009 max  -1   1  ->  1
dqmax010 max  -1   2  ->  2
dqmax011 max   0  -2  ->  0
dqmax012 max   0  -1  ->  0
dqmax013 max   0   0  ->  0
dqmax014 max   0   1  ->  1
dqmax015 max   0   2  ->  2
dqmax016 max   1  -2  ->  1
dqmax017 max   1  -1  ->  1
dqmax018 max   1   0  ->  1
dqmax019 max   1   1  ->  1
dqmax020 max   1   2  ->  2
dqmax021 max   2  -2  ->  2
dqmax022 max   2  -1  ->  2
dqmax023 max   2   0  ->  2
dqmax025 max   2   1  ->  2
dqmax026 max   2   2  ->  2

-- extended zeros
dqmax030 max   0     0   ->  0
dqmax031 max   0    -0   ->  0
dqmax032 max   0    -0.0 ->  0
dqmax033 max   0     0.0 ->  0
dqmax034 max  -0     0   ->  0    -- note: -0 = 0, but 0 chosen
dqmax035 max  -0    -0   -> -0
dqmax036 max  -0    -0.0 -> -0.0
dqmax037 max  -0     0.0 ->  0.0
dqmax038 max   0.0   0   ->  0
dqmax039 max   0.0  -0   ->  0.0
dqmax040 max   0.0  -0.0 ->  0.0
dqmax041 max   0.0   0.0 ->  0.0
dqmax042 max  -0.0   0   ->  0
dqmax043 max  -0.0  -0   -> -0.0
dqmax044 max  -0.0  -0.0 -> -0.0
dqmax045 max  -0.0   0.0 ->  0.0

dqmax050 max  -0E1   0E1 ->  0E+1
dqmax051 max  -0E2   0E2 ->  0E+2
dqmax052 max  -0E2   0E1 ->  0E+1
dqmax053 max  -0E1   0E2 ->  0E+2
dqmax054 max   0E1  -0E1 ->  0E+1
dqmax055 max   0E2  -0E2 ->  0E+2
dqmax056 max   0E2  -0E1 ->  0E+2
dqmax057 max   0E1  -0E2 ->  0E+1

dqmax058 max   0E1   0E1 ->  0E+1
dqmax059 max   0E2   0E2 ->  0E+2
dqmax060 max   0E2   0E1 ->  0E+2
dqmax061 max   0E1   0E2 ->  0E+2
dqmax062 max  -0E1  -0E1 -> -0E+1
dqmax063 max  -0E2  -0E2 -> -0E+2
dqmax064 max  -0E2  -0E1 -> -0E+1
dqmax065 max  -0E1  -0E2 -> -0E+1

-- Specials
dqmax090 max  Inf  -Inf   ->  Infinity
dqmax091 max  Inf  -1000  ->  Infinity
dqmax092 max  Inf  -1     ->  Infinity
dqmax093 max  Inf  -0     ->  Infinity
dqmax094 max  Inf   0     ->  Infinity
dqmax095 max  Inf   1     ->  Infinity
dqmax096 max  Inf   1000  ->  Infinity
dqmax097 max  Inf   Inf   ->  Infinity
dqmax098 max -1000  Inf   ->  Infinity
dqmax099 max -Inf   Inf   ->  Infinity
dqmax100 max -1     Inf   ->  Infinity
dqmax101 max -0     Inf   ->  Infinity
dqmax102 max  0     Inf   ->  Infinity
dqmax103 max  1     Inf   ->  Infinity
dqmax104 max  1000  Inf   ->  Infinity
dqmax105 max  Inf   Inf   ->  Infinity

dqmax120 max -Inf  -Inf   -> -Infinity
dqmax121 max -Inf  -1000  -> -1000
dqmax122 max -Inf  -1     -> -1
dqmax123 max -Inf  -0     -> -0
dqmax124 max -Inf   0     ->  0
dqmax125 max -Inf   1     ->  1
dqmax126 max -Inf   1000  ->  1000
dqmax127 max -Inf   Inf   ->  Infinity
dqmax128 max -Inf  -Inf   ->  -Infinity
dqmax129 max -1000 -Inf   ->  -1000
dqmax130 max -1    -Inf   ->  -1
dqmax131 max -0    -Inf   ->  -0
dqmax132 max  0    -Inf   ->  0
dqmax133 max  1    -Inf   ->  1
dqmax134 max  1000 -Inf   ->  1000
dqmax135 max  Inf  -Inf   ->  Infinity

-- 2004.08.02 754r chooses number over NaN in mixed cases
dqmax141 max  NaN -Inf    -> -Infinity
dqmax142 max  NaN -1000   -> -1000
dqmax143 max  NaN -1      -> -1
dqmax144 max  NaN -0      -> -0
dqmax145 max  NaN  0      ->  0
dqmax146 max  NaN  1      ->  1
dqmax147 max  NaN  1000   ->  1000
dqmax148 max  NaN  Inf    ->  Infinity
dqmax149 max  NaN  NaN    ->  NaN
dqmax150 max -Inf  NaN    -> -Infinity
dqmax151 max -1000 NaN    -> -1000
dqmax152 max -1    NaN    -> -1
dqmax153 max -0    NaN    -> -0
dqmax154 max  0    NaN    ->  0
dqmax155 max  1    NaN    ->  1
dqmax156 max  1000 NaN    ->  1000
dqmax157 max  Inf  NaN    ->  Infinity

dqmax161 max  sNaN -Inf   ->  NaN  Invalid_operation
dqmax162 max  sNaN -1000  ->  NaN  Invalid_operation
dqmax163 max  sNaN -1     ->  NaN  Invalid_operation
dqmax164 max  sNaN -0     ->  NaN  Invalid_operation
dqmax165 max  sNaN  0     ->  NaN  Invalid_operation
dqmax166 max  sNaN  1     ->  NaN  Invalid_operation
dqmax167 max  sNaN  1000  ->  NaN  Invalid_operation
dqmax168 max  sNaN  NaN   ->  NaN  Invalid_operation
dqmax169 max  sNaN sNaN   ->  NaN  Invalid_operation
dqmax170 max  NaN  sNaN   ->  NaN  Invalid_operation
dqmax171 max -Inf  sNaN   ->  NaN  Invalid_operation
dqmax172 max -1000 sNaN   ->  NaN  Invalid_operation
dqmax173 max -1    sNaN   ->  NaN  Invalid_operation
dqmax174 max -0    sNaN   ->  NaN  Invalid_operation
dqmax175 max  0    sNaN   ->  NaN  Invalid_operation
dqmax176 max  1    sNaN   ->  NaN  Invalid_operation
dqmax177 max  1000 sNaN   ->  NaN  Invalid_operation
dqmax178 max  Inf  sNaN   ->  NaN  Invalid_operation
dqmax179 max  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqmax181 max  NaN9  -Inf   -> -Infinity
dqmax182 max  NaN8     9   ->  9
dqmax183 max -NaN7   Inf   ->  Infinity

dqmax184 max -NaN1   NaN11 -> -NaN1
dqmax185 max  NaN2   NaN12 ->  NaN2
dqmax186 max -NaN13 -NaN7  -> -NaN13
dqmax187 max  NaN14 -NaN5  ->  NaN14

dqmax188 max -Inf    NaN4  -> -Infinity
dqmax189 max -9     -NaN3  -> -9
dqmax190 max  Inf    NaN2  ->  Infinity

dqmax191 max  sNaN99 -Inf    ->  NaN99 Invalid_operation
dqmax192 max  sNaN98 -1      ->  NaN98 Invalid_operation
dqmax193 max -sNaN97  NaN    -> -NaN97 Invalid_operation
dqmax194 max  sNaN96 sNaN94  ->  NaN96 Invalid_operation
dqmax195 max  NaN95  sNaN93  ->  NaN93 Invalid_operation
dqmax196 max -Inf    sNaN92  ->  NaN92 Invalid_operation
dqmax197 max  0      sNaN91  ->  NaN91 Invalid_operation
dqmax198 max  Inf   -sNaN90  -> -NaN90 Invalid_operation
dqmax199 max  NaN    sNaN89  ->  NaN89 Invalid_operation

-- old rounding checks
dqmax221 max 12345678000 1  -> 12345678000
dqmax222 max 1 12345678000  -> 12345678000
dqmax223 max 1234567800  1  -> 1234567800
dqmax224 max 1 1234567800   -> 1234567800
dqmax225 max 1234567890  1  -> 1234567890
dqmax226 max 1 1234567890   -> 1234567890
dqmax227 max 1234567891  1  -> 1234567891
dqmax228 max 1 1234567891   -> 1234567891
dqmax229 max 12345678901 1  -> 12345678901
dqmax230 max 1 12345678901  -> 12345678901
dqmax231 max 1234567896  1  -> 1234567896
dqmax232 max 1 1234567896   -> 1234567896
dqmax233 max -1234567891  1 -> 1
dqmax234 max 1 -1234567891  -> 1
dqmax235 max -12345678901 1 -> 1
dqmax236 max 1 -12345678901 -> 1
dqmax237 max -1234567896  1 -> 1
dqmax238 max 1 -1234567896  -> 1

-- from examples
dqmax280 max '3'   '2'  ->  '3'
dqmax281 max '-10' '3'  ->  '3'
dqmax282 max '1.0' '1'  ->  '1'
dqmax283 max '1' '1.0'  ->  '1'
dqmax284 max '7' 'NaN'  ->  '7'

-- expanded list from min/max 754r purple prose
-- [explicit tests for exponent ordering]
dqmax401 max  Inf    1.1     ->  Infinity
dqmax402 max  1.1    1       ->  1.1
dqmax403 max  1      1.0     ->  1
dqmax404 max  1.0    0.1     ->  1.0
dqmax405 max  0.1    0.10    ->  0.1
dqmax406 max  0.10   0.100   ->  0.10
dqmax407 max  0.10   0       ->  0.10
dqmax408 max  0      0.0     ->  0
dqmax409 max  0.0   -0       ->  0.0
dqmax410 max  0.0   -0.0     ->  0.0
dqmax411 max  0.00  -0.0     ->  0.00
dqmax412 max  0.0   -0.00    ->  0.0
dqmax413 max  0     -0.0     ->  0
dqmax414 max  0     -0       ->  0
dqmax415 max -0.0   -0       -> -0.0
dqmax416 max -0     -0.100   -> -0
dqmax417 max -0.100 -0.10    -> -0.100
dqmax418 max -0.10  -0.1     -> -0.10
dqmax419 max -0.1   -1.0     -> -0.1
dqmax420 max -1.0   -1       -> -1.0
dqmax421 max -1     -1.1     -> -1
dqmax423 max -1.1   -Inf     -> -1.1
-- same with operands reversed
dqmax431 max  1.1    Inf     ->  Infinity
dqmax432 max  1      1.1     ->  1.1
dqmax433 max  1.0    1       ->  1
dqmax434 max  0.1    1.0     ->  1.0
dqmax435 max  0.10   0.1     ->  0.1
dqmax436 max  0.100  0.10    ->  0.10
dqmax437 max  0      0.10    ->  0.10
dqmax438 max  0.0    0       ->  0
dqmax439 max -0      0.0     ->  0.0
dqmax440 max -0.0    0.0     ->  0.0
dqmax441 max -0.0    0.00    ->  0.00
dqmax442 max -0.00   0.0     ->  0.0
dqmax443 max -0.0    0       ->  0
dqmax444 max -0      0       ->  0
dqmax445 max -0     -0.0     -> -0.0
dqmax446 max -0.100 -0       -> -0
dqmax447 max -0.10  -0.100   -> -0.100
dqmax448 max -0.1   -0.10    -> -0.10
dqmax449 max -1.0   -0.1     -> -0.1
dqmax450 max -1     -1.0     -> -1.0
dqmax451 max -1.1   -1       -> -1
dqmax453 max -Inf   -1.1     -> -1.1
-- largies
dqmax460 max  1000   1E+3    ->  1E+3
dqmax461 max  1E+3   1000    ->  1E+3
dqmax462 max  1000  -1E+3    ->  1000
dqmax463 max  1E+3  -1000    ->  1E+3
dqmax464 max -1000   1E+3    ->  1E+3
dqmax465 max -1E+3   1000    ->  1000
dqmax466 max -1000  -1E+3    -> -1000
dqmax467 max -1E+3  -1000    -> -1000

-- misalignment traps for little-endian
dqmax471 max      1.0       0.1  -> 1.0
dqmax472 max      0.1       1.0  -> 1.0
dqmax473 max     10.0       0.1  -> 10.0
dqmax474 max      0.1      10.0  -> 10.0
dqmax475 max      100       1.0  -> 100
dqmax476 max      1.0       100  -> 100
dqmax477 max     1000      10.0  -> 1000
dqmax478 max     10.0      1000  -> 1000
dqmax479 max    10000     100.0  -> 10000
dqmax480 max    100.0     10000  -> 10000
dqmax481 max   100000    1000.0  -> 100000
dqmax482 max   1000.0    100000  -> 100000
dqmax483 max  1000000   10000.0  -> 1000000
dqmax484 max  10000.0   1000000  -> 1000000

-- subnormals
dqmax510 max  1.00E-6143       0  ->   1.00E-6143
dqmax511 max  0.1E-6143        0  ->   1E-6144    Subnormal
dqmax512 max  0.10E-6143       0  ->   1.0E-6144  Subnormal
dqmax513 max  0.100E-6143      0  ->   1.00E-6144 Subnormal
dqmax514 max  0.01E-6143       0  ->   1E-6145    Subnormal
dqmax515 max  0.999E-6143      0  ->   9.99E-6144 Subnormal
dqmax516 max  0.099E-6143      0  ->   9.9E-6145  Subnormal
dqmax517 max  0.009E-6143      0  ->   9E-6146    Subnormal
dqmax518 max  0.001E-6143      0  ->   1E-6146    Subnormal
dqmax519 max  0.0009E-6143     0  ->   9E-6147    Subnormal
dqmax520 max  0.0001E-6143     0  ->   1E-6147    Subnormal

dqmax530 max -1.00E-6143       0  ->   0
dqmax531 max -0.1E-6143        0  ->   0
dqmax532 max -0.10E-6143       0  ->   0
dqmax533 max -0.100E-6143      0  ->   0
dqmax534 max -0.01E-6143       0  ->   0
dqmax535 max -0.999E-6143      0  ->   0
dqmax536 max -0.099E-6143      0  ->   0
dqmax537 max -0.009E-6143      0  ->   0
dqmax538 max -0.001E-6143      0  ->   0
dqmax539 max -0.0009E-6143     0  ->   0
dqmax540 max -0.0001E-6143     0  ->   0

-- Null tests
dqmax900 max 10  #  -> NaN Invalid_operation
dqmax901 max  # 10  -> NaN Invalid_operation



Added test/dectest/dqMaxMag.decTest.

































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
------------------------------------------------------------------------
-- dqMaxMag.decTest -- decQuad maxnummag                              --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks
dqmxg001 maxmag  -2  -2  -> -2
dqmxg002 maxmag  -2  -1  -> -2
dqmxg003 maxmag  -2   0  -> -2
dqmxg004 maxmag  -2   1  -> -2
dqmxg005 maxmag  -2   2  ->  2
dqmxg006 maxmag  -1  -2  -> -2
dqmxg007 maxmag  -1  -1  -> -1
dqmxg008 maxmag  -1   0  -> -1
dqmxg009 maxmag  -1   1  ->  1
dqmxg010 maxmag  -1   2  ->  2
dqmxg011 maxmag   0  -2  -> -2
dqmxg012 maxmag   0  -1  -> -1
dqmxg013 maxmag   0   0  ->  0
dqmxg014 maxmag   0   1  ->  1
dqmxg015 maxmag   0   2  ->  2
dqmxg016 maxmag   1  -2  -> -2
dqmxg017 maxmag   1  -1  ->  1
dqmxg018 maxmag   1   0  ->  1
dqmxg019 maxmag   1   1  ->  1
dqmxg020 maxmag   1   2  ->  2
dqmxg021 maxmag   2  -2  ->  2
dqmxg022 maxmag   2  -1  ->  2
dqmxg023 maxmag   2   0  ->  2
dqmxg025 maxmag   2   1  ->  2
dqmxg026 maxmag   2   2  ->  2

-- extended zeros
dqmxg030 maxmag   0     0   ->  0
dqmxg031 maxmag   0    -0   ->  0
dqmxg032 maxmag   0    -0.0 ->  0
dqmxg033 maxmag   0     0.0 ->  0
dqmxg034 maxmag  -0     0   ->  0    -- note: -0 = 0, but 0 chosen
dqmxg035 maxmag  -0    -0   -> -0
dqmxg036 maxmag  -0    -0.0 -> -0.0
dqmxg037 maxmag  -0     0.0 ->  0.0
dqmxg038 maxmag   0.0   0   ->  0
dqmxg039 maxmag   0.0  -0   ->  0.0
dqmxg040 maxmag   0.0  -0.0 ->  0.0
dqmxg041 maxmag   0.0   0.0 ->  0.0
dqmxg042 maxmag  -0.0   0   ->  0
dqmxg043 maxmag  -0.0  -0   -> -0.0
dqmxg044 maxmag  -0.0  -0.0 -> -0.0
dqmxg045 maxmag  -0.0   0.0 ->  0.0

dqmxg050 maxmag  -0E1   0E1 ->  0E+1
dqmxg051 maxmag  -0E2   0E2 ->  0E+2
dqmxg052 maxmag  -0E2   0E1 ->  0E+1
dqmxg053 maxmag  -0E1   0E2 ->  0E+2
dqmxg054 maxmag   0E1  -0E1 ->  0E+1
dqmxg055 maxmag   0E2  -0E2 ->  0E+2
dqmxg056 maxmag   0E2  -0E1 ->  0E+2
dqmxg057 maxmag   0E1  -0E2 ->  0E+1

dqmxg058 maxmag   0E1   0E1 ->  0E+1
dqmxg059 maxmag   0E2   0E2 ->  0E+2
dqmxg060 maxmag   0E2   0E1 ->  0E+2
dqmxg061 maxmag   0E1   0E2 ->  0E+2
dqmxg062 maxmag  -0E1  -0E1 -> -0E+1
dqmxg063 maxmag  -0E2  -0E2 -> -0E+2
dqmxg064 maxmag  -0E2  -0E1 -> -0E+1
dqmxg065 maxmag  -0E1  -0E2 -> -0E+1

-- Specials
dqmxg090 maxmag  Inf  -Inf   ->  Infinity
dqmxg091 maxmag  Inf  -1000  ->  Infinity
dqmxg092 maxmag  Inf  -1     ->  Infinity
dqmxg093 maxmag  Inf  -0     ->  Infinity
dqmxg094 maxmag  Inf   0     ->  Infinity
dqmxg095 maxmag  Inf   1     ->  Infinity
dqmxg096 maxmag  Inf   1000  ->  Infinity
dqmxg097 maxmag  Inf   Inf   ->  Infinity
dqmxg098 maxmag -1000  Inf   ->  Infinity
dqmxg099 maxmag -Inf   Inf   ->  Infinity
dqmxg100 maxmag -1     Inf   ->  Infinity
dqmxg101 maxmag -0     Inf   ->  Infinity
dqmxg102 maxmag  0     Inf   ->  Infinity
dqmxg103 maxmag  1     Inf   ->  Infinity
dqmxg104 maxmag  1000  Inf   ->  Infinity
dqmxg105 maxmag  Inf   Inf   ->  Infinity

dqmxg120 maxmag -Inf  -Inf   -> -Infinity
dqmxg121 maxmag -Inf  -1000  -> -Infinity
dqmxg122 maxmag -Inf  -1     -> -Infinity
dqmxg123 maxmag -Inf  -0     -> -Infinity
dqmxg124 maxmag -Inf   0     -> -Infinity
dqmxg125 maxmag -Inf   1     -> -Infinity
dqmxg126 maxmag -Inf   1000  -> -Infinity
dqmxg127 maxmag -Inf   Inf   ->  Infinity
dqmxg128 maxmag -Inf  -Inf   ->  -Infinity
dqmxg129 maxmag -1000 -Inf   -> -Infinity
dqmxg130 maxmag -1    -Inf   -> -Infinity
dqmxg131 maxmag -0    -Inf   -> -Infinity
dqmxg132 maxmag  0    -Inf   -> -Infinity
dqmxg133 maxmag  1    -Inf   -> -Infinity
dqmxg134 maxmag  1000 -Inf   -> -Infinity
dqmxg135 maxmag  Inf  -Inf   ->  Infinity

-- 2004.08.02 754r chooses number over NaN in mixed cases
dqmxg141 maxmag  NaN -Inf    -> -Infinity
dqmxg142 maxmag  NaN -1000   -> -1000
dqmxg143 maxmag  NaN -1      -> -1
dqmxg144 maxmag  NaN -0      -> -0
dqmxg145 maxmag  NaN  0      ->  0
dqmxg146 maxmag  NaN  1      ->  1
dqmxg147 maxmag  NaN  1000   ->  1000
dqmxg148 maxmag  NaN  Inf    ->  Infinity
dqmxg149 maxmag  NaN  NaN    ->  NaN
dqmxg150 maxmag -Inf  NaN    -> -Infinity
dqmxg151 maxmag -1000 NaN    -> -1000
dqmxg152 maxmag -1    NaN    -> -1
dqmxg153 maxmag -0    NaN    -> -0
dqmxg154 maxmag  0    NaN    ->  0
dqmxg155 maxmag  1    NaN    ->  1
dqmxg156 maxmag  1000 NaN    ->  1000
dqmxg157 maxmag  Inf  NaN    ->  Infinity

dqmxg161 maxmag  sNaN -Inf   ->  NaN  Invalid_operation
dqmxg162 maxmag  sNaN -1000  ->  NaN  Invalid_operation
dqmxg163 maxmag  sNaN -1     ->  NaN  Invalid_operation
dqmxg164 maxmag  sNaN -0     ->  NaN  Invalid_operation
dqmxg165 maxmag  sNaN  0     ->  NaN  Invalid_operation
dqmxg166 maxmag  sNaN  1     ->  NaN  Invalid_operation
dqmxg167 maxmag  sNaN  1000  ->  NaN  Invalid_operation
dqmxg168 maxmag  sNaN  NaN   ->  NaN  Invalid_operation
dqmxg169 maxmag  sNaN sNaN   ->  NaN  Invalid_operation
dqmxg170 maxmag  NaN  sNaN   ->  NaN  Invalid_operation
dqmxg171 maxmag -Inf  sNaN   ->  NaN  Invalid_operation
dqmxg172 maxmag -1000 sNaN   ->  NaN  Invalid_operation
dqmxg173 maxmag -1    sNaN   ->  NaN  Invalid_operation
dqmxg174 maxmag -0    sNaN   ->  NaN  Invalid_operation
dqmxg175 maxmag  0    sNaN   ->  NaN  Invalid_operation
dqmxg176 maxmag  1    sNaN   ->  NaN  Invalid_operation
dqmxg177 maxmag  1000 sNaN   ->  NaN  Invalid_operation
dqmxg178 maxmag  Inf  sNaN   ->  NaN  Invalid_operation
dqmxg179 maxmag  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqmxg181 maxmag  NaN9  -Inf   -> -Infinity
dqmxg182 maxmag  NaN8     9   ->  9
dqmxg183 maxmag -NaN7   Inf   ->  Infinity

dqmxg184 maxmag -NaN1   NaN11 -> -NaN1
dqmxg185 maxmag  NaN2   NaN12 ->  NaN2
dqmxg186 maxmag -NaN13 -NaN7  -> -NaN13
dqmxg187 maxmag  NaN14 -NaN5  ->  NaN14

dqmxg188 maxmag -Inf    NaN4  -> -Infinity
dqmxg189 maxmag -9     -NaN3  -> -9
dqmxg190 maxmag  Inf    NaN2  ->  Infinity

dqmxg191 maxmag  sNaN99 -Inf    ->  NaN99 Invalid_operation
dqmxg192 maxmag  sNaN98 -1      ->  NaN98 Invalid_operation
dqmxg193 maxmag -sNaN97  NaN    -> -NaN97 Invalid_operation
dqmxg194 maxmag  sNaN96 sNaN94  ->  NaN96 Invalid_operation
dqmxg195 maxmag  NaN95  sNaN93  ->  NaN93 Invalid_operation
dqmxg196 maxmag -Inf    sNaN92  ->  NaN92 Invalid_operation
dqmxg197 maxmag  0      sNaN91  ->  NaN91 Invalid_operation
dqmxg198 maxmag  Inf   -sNaN90  -> -NaN90 Invalid_operation
dqmxg199 maxmag  NaN    sNaN89  ->  NaN89 Invalid_operation

-- old rounding checks
dqmxg221 maxmag 12345678000 1  -> 12345678000
dqmxg222 maxmag 1 12345678000  -> 12345678000
dqmxg223 maxmag 1234567800  1  -> 1234567800
dqmxg224 maxmag 1 1234567800   -> 1234567800
dqmxg225 maxmag 1234567890  1  -> 1234567890
dqmxg226 maxmag 1 1234567890   -> 1234567890
dqmxg227 maxmag 1234567891  1  -> 1234567891
dqmxg228 maxmag 1 1234567891   -> 1234567891
dqmxg229 maxmag 12345678901 1  -> 12345678901
dqmxg230 maxmag 1 12345678901  -> 12345678901
dqmxg231 maxmag 1234567896  1  -> 1234567896
dqmxg232 maxmag 1 1234567896   -> 1234567896
dqmxg233 maxmag -1234567891  1 -> -1234567891
dqmxg234 maxmag 1 -1234567891  -> -1234567891
dqmxg235 maxmag -12345678901 1 -> -12345678901
dqmxg236 maxmag 1 -12345678901 -> -12345678901
dqmxg237 maxmag -1234567896  1 -> -1234567896
dqmxg238 maxmag 1 -1234567896  -> -1234567896

-- from examples
dqmxg280 maxmag '3'   '2'  ->  '3'
dqmxg281 maxmag '-10' '3'  ->  '-10'
dqmxg282 maxmag '1.0' '1'  ->  '1'
dqmxg283 maxmag '1' '1.0'  ->  '1'
dqmxg284 maxmag '7' 'NaN'  ->  '7'

-- expanded list from min/max 754r purple prose
-- [explicit tests for exponent ordering]
dqmxg401 maxmag  Inf    1.1     ->  Infinity
dqmxg402 maxmag  1.1    1       ->  1.1
dqmxg403 maxmag  1      1.0     ->  1
dqmxg404 maxmag  1.0    0.1     ->  1.0
dqmxg405 maxmag  0.1    0.10    ->  0.1
dqmxg406 maxmag  0.10   0.100   ->  0.10
dqmxg407 maxmag  0.10   0       ->  0.10
dqmxg408 maxmag  0      0.0     ->  0
dqmxg409 maxmag  0.0   -0       ->  0.0
dqmxg410 maxmag  0.0   -0.0     ->  0.0
dqmxg411 maxmag  0.00  -0.0     ->  0.00
dqmxg412 maxmag  0.0   -0.00    ->  0.0
dqmxg413 maxmag  0     -0.0     ->  0
dqmxg414 maxmag  0     -0       ->  0
dqmxg415 maxmag -0.0   -0       -> -0.0
dqmxg416 maxmag -0     -0.100   -> -0.100
dqmxg417 maxmag -0.100 -0.10    -> -0.100
dqmxg418 maxmag -0.10  -0.1     -> -0.10
dqmxg419 maxmag -0.1   -1.0     -> -1.0
dqmxg420 maxmag -1.0   -1       -> -1.0
dqmxg421 maxmag -1     -1.1     -> -1.1
dqmxg423 maxmag -1.1   -Inf     -> -Infinity
-- same with operands reversed
dqmxg431 maxmag  1.1    Inf     ->  Infinity
dqmxg432 maxmag  1      1.1     ->  1.1
dqmxg433 maxmag  1.0    1       ->  1
dqmxg434 maxmag  0.1    1.0     ->  1.0
dqmxg435 maxmag  0.10   0.1     ->  0.1
dqmxg436 maxmag  0.100  0.10    ->  0.10
dqmxg437 maxmag  0      0.10    ->  0.10
dqmxg438 maxmag  0.0    0       ->  0
dqmxg439 maxmag -0      0.0     ->  0.0
dqmxg440 maxmag -0.0    0.0     ->  0.0
dqmxg441 maxmag -0.0    0.00    ->  0.00
dqmxg442 maxmag -0.00   0.0     ->  0.0
dqmxg443 maxmag -0.0    0       ->  0
dqmxg444 maxmag -0      0       ->  0
dqmxg445 maxmag -0     -0.0     -> -0.0
dqmxg446 maxmag -0.100 -0       -> -0.100
dqmxg447 maxmag -0.10  -0.100   -> -0.100
dqmxg448 maxmag -0.1   -0.10    -> -0.10
dqmxg449 maxmag -1.0   -0.1     -> -1.0
dqmxg450 maxmag -1     -1.0     -> -1.0
dqmxg451 maxmag -1.1   -1       -> -1.1
dqmxg453 maxmag -Inf   -1.1     -> -Infinity
-- largies
dqmxg460 maxmag  1000   1E+3    ->  1E+3
dqmxg461 maxmag  1E+3   1000    ->  1E+3
dqmxg462 maxmag  1000  -1E+3    ->  1000
dqmxg463 maxmag  1E+3  -1000    ->  1E+3
dqmxg464 maxmag -1000   1E+3    ->  1E+3
dqmxg465 maxmag -1E+3   1000    ->  1000
dqmxg466 maxmag -1000  -1E+3    -> -1000
dqmxg467 maxmag -1E+3  -1000    -> -1000

-- subnormals
dqmxg510 maxmag  1.00E-6143       0  ->   1.00E-6143
dqmxg511 maxmag  0.1E-6143        0  ->   1E-6144    Subnormal
dqmxg512 maxmag  0.10E-6143       0  ->   1.0E-6144  Subnormal
dqmxg513 maxmag  0.100E-6143      0  ->   1.00E-6144 Subnormal
dqmxg514 maxmag  0.01E-6143       0  ->   1E-6145    Subnormal
dqmxg515 maxmag  0.999E-6143      0  ->   9.99E-6144 Subnormal
dqmxg516 maxmag  0.099E-6143      0  ->   9.9E-6145  Subnormal
dqmxg517 maxmag  0.009E-6143      0  ->   9E-6146    Subnormal
dqmxg518 maxmag  0.001E-6143      0  ->   1E-6146    Subnormal
dqmxg519 maxmag  0.0009E-6143     0  ->   9E-6147    Subnormal
dqmxg520 maxmag  0.0001E-6143     0  ->   1E-6147    Subnormal

dqmxg530 maxmag -1.00E-6143       0  ->  -1.00E-6143
dqmxg531 maxmag -0.1E-6143        0  ->  -1E-6144    Subnormal
dqmxg532 maxmag -0.10E-6143       0  ->  -1.0E-6144  Subnormal
dqmxg533 maxmag -0.100E-6143      0  ->  -1.00E-6144 Subnormal
dqmxg534 maxmag -0.01E-6143       0  ->  -1E-6145    Subnormal
dqmxg535 maxmag -0.999E-6143      0  ->  -9.99E-6144 Subnormal
dqmxg536 maxmag -0.099E-6143      0  ->  -9.9E-6145  Subnormal
dqmxg537 maxmag -0.009E-6143      0  ->  -9E-6146    Subnormal
dqmxg538 maxmag -0.001E-6143      0  ->  -1E-6146    Subnormal
dqmxg539 maxmag -0.0009E-6143     0  ->  -9E-6147    Subnormal
dqmxg540 maxmag -0.0001E-6143     0  ->  -1E-6147    Subnormal

-- Null tests
dqmxg900 maxmag 10  #  -> NaN Invalid_operation
dqmxg901 maxmag  # 10  -> NaN Invalid_operation

Added test/dectest/dqMin.decTest.











































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
------------------------------------------------------------------------
-- dqMin.decTest -- decQuad minnum                                    --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks
dqmin001 min  -2  -2  -> -2
dqmin002 min  -2  -1  -> -2
dqmin003 min  -2   0  -> -2
dqmin004 min  -2   1  -> -2
dqmin005 min  -2   2  -> -2
dqmin006 min  -1  -2  -> -2
dqmin007 min  -1  -1  -> -1
dqmin008 min  -1   0  -> -1
dqmin009 min  -1   1  -> -1
dqmin010 min  -1   2  -> -1
dqmin011 min   0  -2  -> -2
dqmin012 min   0  -1  -> -1
dqmin013 min   0   0  ->  0
dqmin014 min   0   1  ->  0
dqmin015 min   0   2  ->  0
dqmin016 min   1  -2  -> -2
dqmin017 min   1  -1  -> -1
dqmin018 min   1   0  ->  0
dqmin019 min   1   1  ->  1
dqmin020 min   1   2  ->  1
dqmin021 min   2  -2  -> -2
dqmin022 min   2  -1  -> -1
dqmin023 min   2   0  ->  0
dqmin025 min   2   1  ->  1
dqmin026 min   2   2  ->  2

-- extended zeros
dqmin030 min   0     0   ->  0
dqmin031 min   0    -0   -> -0
dqmin032 min   0    -0.0 -> -0.0
dqmin033 min   0     0.0 ->  0.0
dqmin034 min  -0     0   -> -0
dqmin035 min  -0    -0   -> -0
dqmin036 min  -0    -0.0 -> -0
dqmin037 min  -0     0.0 -> -0
dqmin038 min   0.0   0   ->  0.0
dqmin039 min   0.0  -0   -> -0
dqmin040 min   0.0  -0.0 -> -0.0
dqmin041 min   0.0   0.0 ->  0.0
dqmin042 min  -0.0   0   -> -0.0
dqmin043 min  -0.0  -0   -> -0
dqmin044 min  -0.0  -0.0 -> -0.0
dqmin045 min  -0.0   0.0 -> -0.0

dqmin046 min   0E1  -0E1 -> -0E+1
dqmin047 min  -0E1   0E2 -> -0E+1
dqmin048 min   0E2   0E1 ->  0E+1
dqmin049 min   0E1   0E2 ->  0E+1
dqmin050 min  -0E3  -0E2 -> -0E+3
dqmin051 min  -0E2  -0E3 -> -0E+3

-- Specials
dqmin090 min  Inf  -Inf   -> -Infinity
dqmin091 min  Inf  -1000  -> -1000
dqmin092 min  Inf  -1     -> -1
dqmin093 min  Inf  -0     -> -0
dqmin094 min  Inf   0     ->  0
dqmin095 min  Inf   1     ->  1
dqmin096 min  Inf   1000  ->  1000
dqmin097 min  Inf   Inf   ->  Infinity
dqmin098 min -1000  Inf   -> -1000
dqmin099 min -Inf   Inf   -> -Infinity
dqmin100 min -1     Inf   -> -1
dqmin101 min -0     Inf   -> -0
dqmin102 min  0     Inf   ->  0
dqmin103 min  1     Inf   ->  1
dqmin104 min  1000  Inf   ->  1000
dqmin105 min  Inf   Inf   ->  Infinity

dqmin120 min -Inf  -Inf   -> -Infinity
dqmin121 min -Inf  -1000  -> -Infinity
dqmin122 min -Inf  -1     -> -Infinity
dqmin123 min -Inf  -0     -> -Infinity
dqmin124 min -Inf   0     -> -Infinity
dqmin125 min -Inf   1     -> -Infinity
dqmin126 min -Inf   1000  -> -Infinity
dqmin127 min -Inf   Inf   -> -Infinity
dqmin128 min -Inf  -Inf   -> -Infinity
dqmin129 min -1000 -Inf   -> -Infinity
dqmin130 min -1    -Inf   -> -Infinity
dqmin131 min -0    -Inf   -> -Infinity
dqmin132 min  0    -Inf   -> -Infinity
dqmin133 min  1    -Inf   -> -Infinity
dqmin134 min  1000 -Inf   -> -Infinity
dqmin135 min  Inf  -Inf   -> -Infinity

-- 2004.08.02 754r chooses number over NaN in mixed cases
dqmin141 min  NaN -Inf    ->  -Infinity
dqmin142 min  NaN -1000   ->  -1000
dqmin143 min  NaN -1      ->  -1
dqmin144 min  NaN -0      ->  -0
dqmin145 min  NaN  0      ->  0
dqmin146 min  NaN  1      ->  1
dqmin147 min  NaN  1000   ->  1000
dqmin148 min  NaN  Inf    ->  Infinity
dqmin149 min  NaN  NaN    ->  NaN
dqmin150 min -Inf  NaN    -> -Infinity
dqmin151 min -1000 NaN    -> -1000
dqmin152 min -1   -NaN    -> -1
dqmin153 min -0    NaN    -> -0
dqmin154 min  0   -NaN    ->  0
dqmin155 min  1    NaN    ->  1
dqmin156 min  1000 NaN    ->  1000
dqmin157 min  Inf  NaN    ->  Infinity

dqmin161 min  sNaN -Inf   ->  NaN  Invalid_operation
dqmin162 min  sNaN -1000  ->  NaN  Invalid_operation
dqmin163 min  sNaN -1     ->  NaN  Invalid_operation
dqmin164 min  sNaN -0     ->  NaN  Invalid_operation
dqmin165 min -sNaN  0     -> -NaN  Invalid_operation
dqmin166 min -sNaN  1     -> -NaN  Invalid_operation
dqmin167 min  sNaN  1000  ->  NaN  Invalid_operation
dqmin168 min  sNaN  NaN   ->  NaN  Invalid_operation
dqmin169 min  sNaN sNaN   ->  NaN  Invalid_operation
dqmin170 min  NaN  sNaN   ->  NaN  Invalid_operation
dqmin171 min -Inf  sNaN   ->  NaN  Invalid_operation
dqmin172 min -1000 sNaN   ->  NaN  Invalid_operation
dqmin173 min -1    sNaN   ->  NaN  Invalid_operation
dqmin174 min -0    sNaN   ->  NaN  Invalid_operation
dqmin175 min  0    sNaN   ->  NaN  Invalid_operation
dqmin176 min  1    sNaN   ->  NaN  Invalid_operation
dqmin177 min  1000 sNaN   ->  NaN  Invalid_operation
dqmin178 min  Inf  sNaN   ->  NaN  Invalid_operation
dqmin179 min  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqmin181 min  NaN9   -Inf   -> -Infinity
dqmin182 min -NaN8    9990  ->  9990
dqmin183 min  NaN71   Inf   ->  Infinity

dqmin184 min  NaN1    NaN54 ->  NaN1
dqmin185 min  NaN22  -NaN53 ->  NaN22
dqmin186 min -NaN3    NaN6  -> -NaN3
dqmin187 min -NaN44   NaN7  -> -NaN44

dqmin188 min -Inf     NaN41 -> -Infinity
dqmin189 min -9999   -NaN33 -> -9999
dqmin190 min  Inf     NaN2  ->  Infinity

dqmin191 min  sNaN99 -Inf    ->  NaN99 Invalid_operation
dqmin192 min  sNaN98 -11     ->  NaN98 Invalid_operation
dqmin193 min -sNaN97  NaN8   -> -NaN97 Invalid_operation
dqmin194 min  sNaN69 sNaN94  ->  NaN69 Invalid_operation
dqmin195 min  NaN95  sNaN93  ->  NaN93 Invalid_operation
dqmin196 min -Inf    sNaN92  ->  NaN92 Invalid_operation
dqmin197 min  088    sNaN91  ->  NaN91 Invalid_operation
dqmin198 min  Inf   -sNaN90  -> -NaN90 Invalid_operation
dqmin199 min  NaN    sNaN86  ->  NaN86 Invalid_operation

-- old rounding checks
dqmin221 min -12345678000 1  -> -12345678000
dqmin222 min 1 -12345678000  -> -12345678000
dqmin223 min -1234567800  1  -> -1234567800
dqmin224 min 1 -1234567800   -> -1234567800
dqmin225 min -1234567890  1  -> -1234567890
dqmin226 min 1 -1234567890   -> -1234567890
dqmin227 min -1234567891  1  -> -1234567891
dqmin228 min 1 -1234567891   -> -1234567891
dqmin229 min -12345678901 1  -> -12345678901
dqmin230 min 1 -12345678901  -> -12345678901
dqmin231 min -1234567896  1  -> -1234567896
dqmin232 min 1 -1234567896   -> -1234567896
dqmin233 min 1234567891  1   -> 1
dqmin234 min 1 1234567891    -> 1
dqmin235 min 12345678901 1   -> 1
dqmin236 min 1 12345678901   -> 1
dqmin237 min 1234567896  1   -> 1
dqmin238 min 1 1234567896    -> 1

-- from examples
dqmin280 min '3'   '2'  ->  '2'
dqmin281 min '-10' '3'  ->  '-10'
dqmin282 min '1.0' '1'  ->  '1.0'
dqmin283 min '1' '1.0'  ->  '1.0'
dqmin284 min '7' 'NaN'  ->  '7'

-- expanded list from min/max 754r purple prose
-- [explicit tests for exponent ordering]
dqmin401 min  Inf    1.1     ->  1.1
dqmin402 min  1.1    1       ->  1
dqmin403 min  1      1.0     ->  1.0
dqmin404 min  1.0    0.1     ->  0.1
dqmin405 min  0.1    0.10    ->  0.10
dqmin406 min  0.10   0.100   ->  0.100
dqmin407 min  0.10   0       ->  0
dqmin408 min  0      0.0     ->  0.0
dqmin409 min  0.0   -0       -> -0
dqmin410 min  0.0   -0.0     -> -0.0
dqmin411 min  0.00  -0.0     -> -0.0
dqmin412 min  0.0   -0.00    -> -0.00
dqmin413 min  0     -0.0     -> -0.0
dqmin414 min  0     -0       -> -0
dqmin415 min -0.0   -0       -> -0
dqmin416 min -0     -0.100   -> -0.100
dqmin417 min -0.100 -0.10    -> -0.10
dqmin418 min -0.10  -0.1     -> -0.1
dqmin419 min -0.1   -1.0     -> -1.0
dqmin420 min -1.0   -1       -> -1
dqmin421 min -1     -1.1     -> -1.1
dqmin423 min -1.1   -Inf     -> -Infinity
-- same with operands reversed
dqmin431 min  1.1    Inf     ->  1.1
dqmin432 min  1      1.1     ->  1
dqmin433 min  1.0    1       ->  1.0
dqmin434 min  0.1    1.0     ->  0.1
dqmin435 min  0.10   0.1     ->  0.10
dqmin436 min  0.100  0.10    ->  0.100
dqmin437 min  0      0.10    ->  0
dqmin438 min  0.0    0       ->  0.0
dqmin439 min -0      0.0     -> -0
dqmin440 min -0.0    0.0     -> -0.0
dqmin441 min -0.0    0.00    -> -0.0
dqmin442 min -0.00   0.0     -> -0.00
dqmin443 min -0.0    0       -> -0.0
dqmin444 min -0      0       -> -0
dqmin445 min -0     -0.0     -> -0
dqmin446 min -0.100 -0       -> -0.100
dqmin447 min -0.10  -0.100   -> -0.10
dqmin448 min -0.1   -0.10    -> -0.1
dqmin449 min -1.0   -0.1     -> -1.0
dqmin450 min -1     -1.0     -> -1
dqmin451 min -1.1   -1       -> -1.1
dqmin453 min -Inf   -1.1     -> -Infinity
-- largies
dqmin460 min  1000   1E+3    ->  1000
dqmin461 min  1E+3   1000    ->  1000
dqmin462 min  1000  -1E+3    -> -1E+3
dqmin463 min  1E+3  -384    -> -384
dqmin464 min -384   1E+3    -> -384
dqmin465 min -1E+3   1000    -> -1E+3
dqmin466 min -384  -1E+3    -> -1E+3
dqmin467 min -1E+3  -384    -> -1E+3

-- misalignment traps for little-endian
dqmin471 min      1.0       0.1  -> 0.1
dqmin472 min      0.1       1.0  -> 0.1
dqmin473 min     10.0       0.1  -> 0.1
dqmin474 min      0.1      10.0  -> 0.1
dqmin475 min      100       1.0  -> 1.0
dqmin476 min      1.0       100  -> 1.0
dqmin477 min     1000      10.0  -> 10.0
dqmin478 min     10.0      1000  -> 10.0
dqmin479 min    10000     100.0  -> 100.0
dqmin480 min    100.0     10000  -> 100.0
dqmin481 min   100000    1000.0  -> 1000.0
dqmin482 min   1000.0    100000  -> 1000.0
dqmin483 min  1000000   10000.0  -> 10000.0
dqmin484 min  10000.0   1000000  -> 10000.0

-- subnormals
dqmin510 min  1.00E-6143       0  ->   0
dqmin511 min  0.1E-6143        0  ->   0
dqmin512 min  0.10E-6143       0  ->   0
dqmin513 min  0.100E-6143      0  ->   0
dqmin514 min  0.01E-6143       0  ->   0
dqmin515 min  0.999E-6143      0  ->   0
dqmin516 min  0.099E-6143      0  ->   0
dqmin517 min  0.009E-6143      0  ->   0
dqmin518 min  0.001E-6143      0  ->   0
dqmin519 min  0.0009E-6143     0  ->   0
dqmin520 min  0.0001E-6143     0  ->   0

dqmin530 min -1.00E-6143       0  ->  -1.00E-6143
dqmin531 min -0.1E-6143        0  ->  -1E-6144    Subnormal
dqmin532 min -0.10E-6143       0  ->  -1.0E-6144  Subnormal
dqmin533 min -0.100E-6143      0  ->  -1.00E-6144 Subnormal
dqmin534 min -0.01E-6143       0  ->  -1E-6145    Subnormal
dqmin535 min -0.999E-6143      0  ->  -9.99E-6144 Subnormal
dqmin536 min -0.099E-6143      0  ->  -9.9E-6145  Subnormal
dqmin537 min -0.009E-6143      0  ->  -9E-6146    Subnormal
dqmin538 min -0.001E-6143      0  ->  -1E-6146    Subnormal
dqmin539 min -0.0009E-6143     0  ->  -9E-6147    Subnormal
dqmin540 min -0.0001E-6143     0  ->  -1E-6147    Subnormal


-- Null tests
dqmin900 min 10  # -> NaN Invalid_operation
dqmin901 min  # 10 -> NaN Invalid_operation

Added test/dectest/dqMinMag.decTest.











































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
------------------------------------------------------------------------
-- dqMinMag.decTest -- decQuad minnummag                              --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks
dqmng001 minmag  -2  -2  -> -2
dqmng002 minmag  -2  -1  -> -1
dqmng003 minmag  -2   0  ->  0
dqmng004 minmag  -2   1  ->  1
dqmng005 minmag  -2   2  -> -2
dqmng006 minmag  -1  -2  -> -1
dqmng007 minmag  -1  -1  -> -1
dqmng008 minmag  -1   0  ->  0
dqmng009 minmag  -1   1  -> -1
dqmng010 minmag  -1   2  -> -1
dqmng011 minmag   0  -2  ->  0
dqmng012 minmag   0  -1  ->  0
dqmng013 minmag   0   0  ->  0
dqmng014 minmag   0   1  ->  0
dqmng015 minmag   0   2  ->  0
dqmng016 minmag   1  -2  ->  1
dqmng017 minmag   1  -1  -> -1
dqmng018 minmag   1   0  ->  0
dqmng019 minmag   1   1  ->  1
dqmng020 minmag   1   2  ->  1
dqmng021 minmag   2  -2  -> -2
dqmng022 minmag   2  -1  -> -1
dqmng023 minmag   2   0  ->  0
dqmng025 minmag   2   1  ->  1
dqmng026 minmag   2   2  ->  2

-- extended zeros
dqmng030 minmag   0     0   ->  0
dqmng031 minmag   0    -0   -> -0
dqmng032 minmag   0    -0.0 -> -0.0
dqmng033 minmag   0     0.0 ->  0.0
dqmng034 minmag  -0     0   -> -0
dqmng035 minmag  -0    -0   -> -0
dqmng036 minmag  -0    -0.0 -> -0
dqmng037 minmag  -0     0.0 -> -0
dqmng038 minmag   0.0   0   ->  0.0
dqmng039 minmag   0.0  -0   -> -0
dqmng040 minmag   0.0  -0.0 -> -0.0
dqmng041 minmag   0.0   0.0 ->  0.0
dqmng042 minmag  -0.0   0   -> -0.0
dqmng043 minmag  -0.0  -0   -> -0
dqmng044 minmag  -0.0  -0.0 -> -0.0
dqmng045 minmag  -0.0   0.0 -> -0.0

dqmng046 minmag   0E1  -0E1 -> -0E+1
dqmng047 minmag  -0E1   0E2 -> -0E+1
dqmng048 minmag   0E2   0E1 ->  0E+1
dqmng049 minmag   0E1   0E2 ->  0E+1
dqmng050 minmag  -0E3  -0E2 -> -0E+3
dqmng051 minmag  -0E2  -0E3 -> -0E+3

-- Specials
dqmng090 minmag  Inf  -Inf   -> -Infinity
dqmng091 minmag  Inf  -1000  -> -1000
dqmng092 minmag  Inf  -1     -> -1
dqmng093 minmag  Inf  -0     -> -0
dqmng094 minmag  Inf   0     ->  0
dqmng095 minmag  Inf   1     ->  1
dqmng096 minmag  Inf   1000  ->  1000
dqmng097 minmag  Inf   Inf   ->  Infinity
dqmng098 minmag -1000  Inf   -> -1000
dqmng099 minmag -Inf   Inf   -> -Infinity
dqmng100 minmag -1     Inf   -> -1
dqmng101 minmag -0     Inf   -> -0
dqmng102 minmag  0     Inf   ->  0
dqmng103 minmag  1     Inf   ->  1
dqmng104 minmag  1000  Inf   ->  1000
dqmng105 minmag  Inf   Inf   ->  Infinity

dqmng120 minmag -Inf  -Inf   -> -Infinity
dqmng121 minmag -Inf  -1000  -> -1000
dqmng122 minmag -Inf  -1     -> -1
dqmng123 minmag -Inf  -0     -> -0
dqmng124 minmag -Inf   0     ->  0
dqmng125 minmag -Inf   1     ->  1
dqmng126 minmag -Inf   1000  ->  1000
dqmng127 minmag -Inf   Inf   -> -Infinity
dqmng128 minmag -Inf  -Inf   -> -Infinity
dqmng129 minmag -1000 -Inf   -> -1000
dqmng130 minmag -1    -Inf   -> -1
dqmng131 minmag -0    -Inf   -> -0
dqmng132 minmag  0    -Inf   ->  0
dqmng133 minmag  1    -Inf   ->  1
dqmng134 minmag  1000 -Inf   ->  1000
dqmng135 minmag  Inf  -Inf   -> -Infinity

-- 2004.08.02 754r chooses number over NaN in mixed cases
dqmng141 minmag  NaN -Inf    ->  -Infinity
dqmng142 minmag  NaN -1000   ->  -1000
dqmng143 minmag  NaN -1      ->  -1
dqmng144 minmag  NaN -0      ->  -0
dqmng145 minmag  NaN  0      ->  0
dqmng146 minmag  NaN  1      ->  1
dqmng147 minmag  NaN  1000   ->  1000
dqmng148 minmag  NaN  Inf    ->  Infinity
dqmng149 minmag  NaN  NaN    ->  NaN
dqmng150 minmag -Inf  NaN    -> -Infinity
dqmng151 minmag -1000 NaN    -> -1000
dqmng152 minmag -1   -NaN    -> -1
dqmng153 minmag -0    NaN    -> -0
dqmng154 minmag  0   -NaN    ->  0
dqmng155 minmag  1    NaN    ->  1
dqmng156 minmag  1000 NaN    ->  1000
dqmng157 minmag  Inf  NaN    ->  Infinity

dqmng161 minmag  sNaN -Inf   ->  NaN  Invalid_operation
dqmng162 minmag  sNaN -1000  ->  NaN  Invalid_operation
dqmng163 minmag  sNaN -1     ->  NaN  Invalid_operation
dqmng164 minmag  sNaN -0     ->  NaN  Invalid_operation
dqmng165 minmag -sNaN  0     -> -NaN  Invalid_operation
dqmng166 minmag -sNaN  1     -> -NaN  Invalid_operation
dqmng167 minmag  sNaN  1000  ->  NaN  Invalid_operation
dqmng168 minmag  sNaN  NaN   ->  NaN  Invalid_operation
dqmng169 minmag  sNaN sNaN   ->  NaN  Invalid_operation
dqmng170 minmag  NaN  sNaN   ->  NaN  Invalid_operation
dqmng171 minmag -Inf  sNaN   ->  NaN  Invalid_operation
dqmng172 minmag -1000 sNaN   ->  NaN  Invalid_operation
dqmng173 minmag -1    sNaN   ->  NaN  Invalid_operation
dqmng174 minmag -0    sNaN   ->  NaN  Invalid_operation
dqmng175 minmag  0    sNaN   ->  NaN  Invalid_operation
dqmng176 minmag  1    sNaN   ->  NaN  Invalid_operation
dqmng177 minmag  1000 sNaN   ->  NaN  Invalid_operation
dqmng178 minmag  Inf  sNaN   ->  NaN  Invalid_operation
dqmng179 minmag  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqmng181 minmag  NaN9   -Inf   -> -Infinity
dqmng182 minmag -NaN8    9990  ->  9990
dqmng183 minmag  NaN71   Inf   ->  Infinity

dqmng184 minmag  NaN1    NaN54 ->  NaN1
dqmng185 minmag  NaN22  -NaN53 ->  NaN22
dqmng186 minmag -NaN3    NaN6  -> -NaN3
dqmng187 minmag -NaN44   NaN7  -> -NaN44

dqmng188 minmag -Inf     NaN41 -> -Infinity
dqmng189 minmag -9999   -NaN33 -> -9999
dqmng190 minmag  Inf     NaN2  ->  Infinity

dqmng191 minmag  sNaN99 -Inf    ->  NaN99 Invalid_operation
dqmng192 minmag  sNaN98 -11     ->  NaN98 Invalid_operation
dqmng193 minmag -sNaN97  NaN8   -> -NaN97 Invalid_operation
dqmng194 minmag  sNaN69 sNaN94  ->  NaN69 Invalid_operation
dqmng195 minmag  NaN95  sNaN93  ->  NaN93 Invalid_operation
dqmng196 minmag -Inf    sNaN92  ->  NaN92 Invalid_operation
dqmng197 minmag  088    sNaN91  ->  NaN91 Invalid_operation
dqmng198 minmag  Inf   -sNaN90  -> -NaN90 Invalid_operation
dqmng199 minmag  NaN    sNaN86  ->  NaN86 Invalid_operation

-- old rounding checks
dqmng221 minmag -12345678000 1  -> 1
dqmng222 minmag 1 -12345678000  -> 1
dqmng223 minmag -1234567800  1  -> 1
dqmng224 minmag 1 -1234567800   -> 1
dqmng225 minmag -1234567890  1  -> 1
dqmng226 minmag 1 -1234567890   -> 1
dqmng227 minmag -1234567891  1  -> 1
dqmng228 minmag 1 -1234567891   -> 1
dqmng229 minmag -12345678901 1  -> 1
dqmng230 minmag 1 -12345678901  -> 1
dqmng231 minmag -1234567896  1  -> 1
dqmng232 minmag 1 -1234567896   -> 1
dqmng233 minmag 1234567891  1   -> 1
dqmng234 minmag 1 1234567891    -> 1
dqmng235 minmag 12345678901 1   -> 1
dqmng236 minmag 1 12345678901   -> 1
dqmng237 minmag 1234567896  1   -> 1
dqmng238 minmag 1 1234567896    -> 1

-- from examples
dqmng280 minmag '3'   '2'  ->  '2'
dqmng281 minmag '-10' '3'  ->  '3'
dqmng282 minmag '1.0' '1'  ->  '1.0'
dqmng283 minmag '1' '1.0'  ->  '1.0'
dqmng284 minmag '7' 'NaN'  ->  '7'

-- expanded list from min/max 754r purple prose
-- [explicit tests for exponent ordering]
dqmng401 minmag  Inf    1.1     ->  1.1
dqmng402 minmag  1.1    1       ->  1
dqmng403 minmag  1      1.0     ->  1.0
dqmng404 minmag  1.0    0.1     ->  0.1
dqmng405 minmag  0.1    0.10    ->  0.10
dqmng406 minmag  0.10   0.100   ->  0.100
dqmng407 minmag  0.10   0       ->  0
dqmng408 minmag  0      0.0     ->  0.0
dqmng409 minmag  0.0   -0       -> -0
dqmng410 minmag  0.0   -0.0     -> -0.0
dqmng411 minmag  0.00  -0.0     -> -0.0
dqmng412 minmag  0.0   -0.00    -> -0.00
dqmng413 minmag  0     -0.0     -> -0.0
dqmng414 minmag  0     -0       -> -0
dqmng415 minmag -0.0   -0       -> -0
dqmng416 minmag -0     -0.100   -> -0
dqmng417 minmag -0.100 -0.10    -> -0.10
dqmng418 minmag -0.10  -0.1     -> -0.1
dqmng419 minmag -0.1   -1.0     -> -0.1
dqmng420 minmag -1.0   -1       -> -1
dqmng421 minmag -1     -1.1     -> -1
dqmng423 minmag -1.1   -Inf     -> -1.1
-- same with operands reversed
dqmng431 minmag  1.1    Inf     ->  1.1
dqmng432 minmag  1      1.1     ->  1
dqmng433 minmag  1.0    1       ->  1.0
dqmng434 minmag  0.1    1.0     ->  0.1
dqmng435 minmag  0.10   0.1     ->  0.10
dqmng436 minmag  0.100  0.10    ->  0.100
dqmng437 minmag  0      0.10    ->  0
dqmng438 minmag  0.0    0       ->  0.0
dqmng439 minmag -0      0.0     -> -0
dqmng440 minmag -0.0    0.0     -> -0.0
dqmng441 minmag -0.0    0.00    -> -0.0
dqmng442 minmag -0.00   0.0     -> -0.00
dqmng443 minmag -0.0    0       -> -0.0
dqmng444 minmag -0      0       -> -0
dqmng445 minmag -0     -0.0     -> -0
dqmng446 minmag -0.100 -0       -> -0
dqmng447 minmag -0.10  -0.100   -> -0.10
dqmng448 minmag -0.1   -0.10    -> -0.1
dqmng449 minmag -1.0   -0.1     -> -0.1
dqmng450 minmag -1     -1.0     -> -1
dqmng451 minmag -1.1   -1       -> -1
dqmng453 minmag -Inf   -1.1     -> -1.1
-- largies
dqmng460 minmag  1000   1E+3    ->  1000
dqmng461 minmag  1E+3   1000    ->  1000
dqmng462 minmag  1000  -1E+3    -> -1E+3
dqmng463 minmag  1E+3   -384    -> -384
dqmng464 minmag -384    1E+3    -> -384
dqmng465 minmag -1E+3   1000    -> -1E+3
dqmng466 minmag -384   -1E+3    -> -384
dqmng467 minmag -1E+3   -384    -> -384

-- subnormals
dqmng510 minmag  1.00E-6143       0  ->   0
dqmng511 minmag  0.1E-6143        0  ->   0
dqmng512 minmag  0.10E-6143       0  ->   0
dqmng513 minmag  0.100E-6143      0  ->   0
dqmng514 minmag  0.01E-6143       0  ->   0
dqmng515 minmag  0.999E-6143      0  ->   0
dqmng516 minmag  0.099E-6143      0  ->   0
dqmng517 minmag  0.009E-6143      0  ->   0
dqmng518 minmag  0.001E-6143      0  ->   0
dqmng519 minmag  0.0009E-6143     0  ->   0
dqmng520 minmag  0.0001E-6143     0  ->   0

dqmng530 minmag -1.00E-6143       0  ->   0
dqmng531 minmag -0.1E-6143        0  ->   0
dqmng532 minmag -0.10E-6143       0  ->   0
dqmng533 minmag -0.100E-6143      0  ->   0
dqmng534 minmag -0.01E-6143       0  ->   0
dqmng535 minmag -0.999E-6143      0  ->   0
dqmng536 minmag -0.099E-6143      0  ->   0
dqmng537 minmag -0.009E-6143      0  ->   0
dqmng538 minmag -0.001E-6143      0  ->   0
dqmng539 minmag -0.0009E-6143     0  ->   0
dqmng540 minmag -0.0001E-6143     0  ->   0


-- Null tests
dqmng900 minmag 10  # -> NaN Invalid_operation
dqmng901 minmag  # 10 -> NaN Invalid_operation

Added test/dectest/dqMinus.decTest.

















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
------------------------------------------------------------------------
-- dqMinus.decTest -- decQuad 0-x                                     --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Sanity check
dqmns001 minus       +7.50  -> -7.50

-- Infinities
dqmns011 minus  Infinity    -> -Infinity
dqmns012 minus  -Infinity   -> Infinity

-- NaNs, 0 payload
dqmns021 minus         NaN  -> NaN
dqmns022 minus        -NaN  -> -NaN
dqmns023 minus        sNaN  -> NaN  Invalid_operation
dqmns024 minus       -sNaN  -> -NaN Invalid_operation

-- NaNs, non-0 payload
dqmns031 minus       NaN13  -> NaN13
dqmns032 minus      -NaN13  -> -NaN13
dqmns033 minus      sNaN13  -> NaN13   Invalid_operation
dqmns034 minus     -sNaN13  -> -NaN13  Invalid_operation
dqmns035 minus       NaN70  -> NaN70
dqmns036 minus      -NaN70  -> -NaN70
dqmns037 minus      sNaN101 -> NaN101  Invalid_operation
dqmns038 minus     -sNaN101 -> -NaN101 Invalid_operation

-- finites
dqmns101 minus          7   -> -7
dqmns102 minus         -7   -> 7
dqmns103 minus         75   -> -75
dqmns104 minus        -75   -> 75
dqmns105 minus       7.50   -> -7.50
dqmns106 minus      -7.50   -> 7.50
dqmns107 minus       7.500  -> -7.500
dqmns108 minus      -7.500  -> 7.500

-- zeros
dqmns111 minus          0   -> 0
dqmns112 minus         -0   -> 0
dqmns113 minus       0E+4   -> 0E+4
dqmns114 minus      -0E+4   -> 0E+4
dqmns115 minus     0.0000   -> 0.0000
dqmns116 minus    -0.0000   -> 0.0000
dqmns117 minus      0E-141  -> 0E-141
dqmns118 minus     -0E-141  -> 0E-141

-- full coefficients, alternating bits
dqmns121 minus   2682682682682682682682682682682682    -> -2682682682682682682682682682682682
dqmns122 minus  -2682682682682682682682682682682682    ->  2682682682682682682682682682682682
dqmns123 minus   1341341341341341341341341341341341    -> -1341341341341341341341341341341341
dqmns124 minus  -1341341341341341341341341341341341    ->  1341341341341341341341341341341341

-- Nmax, Nmin, Ntiny
dqmns131 minus  9.999999999999999999999999999999999E+6144   -> -9.999999999999999999999999999999999E+6144
dqmns132 minus  1E-6143                                     -> -1E-6143
dqmns133 minus  1.000000000000000000000000000000000E-6143   -> -1.000000000000000000000000000000000E-6143
dqmns134 minus  1E-6176                                     -> -1E-6176 Subnormal

dqmns135 minus  -1E-6176                                    ->  1E-6176 Subnormal
dqmns136 minus  -1.000000000000000000000000000000000E-6143  ->  1.000000000000000000000000000000000E-6143
dqmns137 minus  -1E-6143                                    ->  1E-6143
dqmns138 minus  -9.999999999999999999999999999999999E+6144  ->  9.999999999999999999999999999999999E+6144

Added test/dectest/dqMultiply.decTest.



















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
------------------------------------------------------------------------
-- dqMultiply.decTest -- decQuad multiplication                       --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests are for decQuads only; all arguments are
-- representable in a decQuad
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks
dqmul000 multiply 2      2 -> 4
dqmul001 multiply 2      3 -> 6
dqmul002 multiply 5      1 -> 5
dqmul003 multiply 5      2 -> 10
dqmul004 multiply 1.20   2 -> 2.40
dqmul005 multiply 1.20   0 -> 0.00
dqmul006 multiply 1.20  -2 -> -2.40
dqmul007 multiply -1.20  2 -> -2.40
dqmul008 multiply -1.20  0 -> -0.00
dqmul009 multiply -1.20 -2 -> 2.40
dqmul010 multiply 5.09 7.1 -> 36.139
dqmul011 multiply 2.5    4 -> 10.0
dqmul012 multiply 2.50   4 -> 10.00
dqmul013 multiply 1.23456789 1.0000000000000000000000000000 -> 1.234567890000000000000000000000000 Rounded
dqmul015 multiply 2.50   4 -> 10.00
dqmul016 multiply  9.99999999999999999  9.99999999999999999 ->  99.99999999999999980000000000000000 Inexact Rounded
dqmul017 multiply  9.99999999999999999 -9.99999999999999999 -> -99.99999999999999980000000000000000 Inexact Rounded
dqmul018 multiply -9.99999999999999999  9.99999999999999999 -> -99.99999999999999980000000000000000 Inexact Rounded
dqmul019 multiply -9.99999999999999999 -9.99999999999999999 ->  99.99999999999999980000000000000000 Inexact Rounded

-- zeros, etc.
dqmul021 multiply  0      0     ->  0
dqmul022 multiply  0     -0     -> -0
dqmul023 multiply -0      0     -> -0
dqmul024 multiply -0     -0     ->  0
dqmul025 multiply -0.0   -0.0   ->  0.00
dqmul026 multiply -0.0   -0.0   ->  0.00
dqmul027 multiply -0.0   -0.0   ->  0.00
dqmul028 multiply -0.0   -0.0   ->  0.00
dqmul030 multiply  5.00   1E-3  ->  0.00500
dqmul031 multiply  00.00  0.000 ->  0.00000
dqmul032 multiply  00.00  0E-3  ->  0.00000     -- rhs is 0
dqmul033 multiply  0E-3   00.00 ->  0.00000     -- lhs is 0
dqmul034 multiply -5.00   1E-3  -> -0.00500
dqmul035 multiply -00.00  0.000 -> -0.00000
dqmul036 multiply -00.00  0E-3  -> -0.00000     -- rhs is 0
dqmul037 multiply -0E-3   00.00 -> -0.00000     -- lhs is 0
dqmul038 multiply  5.00  -1E-3  -> -0.00500
dqmul039 multiply  00.00 -0.000 -> -0.00000
dqmul040 multiply  00.00 -0E-3  -> -0.00000     -- rhs is 0
dqmul041 multiply  0E-3  -00.00 -> -0.00000     -- lhs is 0
dqmul042 multiply -5.00  -1E-3  ->  0.00500
dqmul043 multiply -00.00 -0.000 ->  0.00000
dqmul044 multiply -00.00 -0E-3  ->  0.00000     -- rhs is 0
dqmul045 multiply -0E-3  -00.00 ->  0.00000     -- lhs is 0

-- examples from decarith
dqmul050 multiply 1.20 3        -> 3.60
dqmul051 multiply 7    3        -> 21
dqmul052 multiply 0.9  0.8      -> 0.72
dqmul053 multiply 0.9  -0       -> -0.0
dqmul054 multiply 654321 654321 -> 428135971041

dqmul060 multiply 123.45 1e7  ->  1.2345E+9
dqmul061 multiply 123.45 1e8  ->  1.2345E+10
dqmul062 multiply 123.45 1e+9 ->  1.2345E+11
dqmul063 multiply 123.45 1e10 ->  1.2345E+12
dqmul064 multiply 123.45 1e11 ->  1.2345E+13
dqmul065 multiply 123.45 1e12 ->  1.2345E+14
dqmul066 multiply 123.45 1e13 ->  1.2345E+15


-- test some intermediate lengths
--                    1234567890123456
dqmul080 multiply 0.1 1230123456456789     -> 123012345645678.9
dqmul084 multiply 0.1 1230123456456789     -> 123012345645678.9
dqmul090 multiply 1230123456456789     0.1 -> 123012345645678.9
dqmul094 multiply 1230123456456789     0.1 -> 123012345645678.9

-- test some more edge cases and carries
dqmul101 multiply 9 9   -> 81
dqmul102 multiply 9 90   -> 810
dqmul103 multiply 9 900   -> 8100
dqmul104 multiply 9 9000   -> 81000
dqmul105 multiply 9 90000   -> 810000
dqmul106 multiply 9 900000   -> 8100000
dqmul107 multiply 9 9000000   -> 81000000
dqmul108 multiply 9 90000000   -> 810000000
dqmul109 multiply 9 900000000   -> 8100000000
dqmul110 multiply 9 9000000000   -> 81000000000
dqmul111 multiply 9 90000000000   -> 810000000000
dqmul112 multiply 9 900000000000   -> 8100000000000
dqmul113 multiply 9 9000000000000   -> 81000000000000
dqmul114 multiply 9 90000000000000   -> 810000000000000
dqmul115 multiply 9 900000000000000   -> 8100000000000000
--dqmul116 multiply 9 9000000000000000   -> 81000000000000000
--dqmul117 multiply 9 90000000000000000   -> 810000000000000000
--dqmul118 multiply 9 900000000000000000   -> 8100000000000000000
--dqmul119 multiply 9 9000000000000000000   -> 81000000000000000000
--dqmul120 multiply 9 90000000000000000000   -> 810000000000000000000
--dqmul121 multiply 9 900000000000000000000   -> 8100000000000000000000
--dqmul122 multiply 9 9000000000000000000000   -> 81000000000000000000000
--dqmul123 multiply 9 90000000000000000000000   -> 810000000000000000000000
-- test some more edge cases without carries
dqmul131 multiply 3 3   -> 9
dqmul132 multiply 3 30   -> 90
dqmul133 multiply 3 300   -> 900
dqmul134 multiply 3 3000   -> 9000
dqmul135 multiply 3 30000   -> 90000
dqmul136 multiply 3 300000   -> 900000
dqmul137 multiply 3 3000000   -> 9000000
dqmul138 multiply 3 30000000   -> 90000000
dqmul139 multiply 3 300000000   -> 900000000
dqmul140 multiply 3 3000000000   -> 9000000000
dqmul141 multiply 3 30000000000   -> 90000000000
dqmul142 multiply 3 300000000000   -> 900000000000
dqmul143 multiply 3 3000000000000   -> 9000000000000
dqmul144 multiply 3 30000000000000   -> 90000000000000
dqmul145 multiply 3 300000000000000   -> 900000000000000
dqmul146 multiply 3 3000000000000000   -> 9000000000000000
dqmul147 multiply 3 30000000000000000   -> 90000000000000000
dqmul148 multiply 3 300000000000000000   -> 900000000000000000
dqmul149 multiply 3 3000000000000000000   -> 9000000000000000000
dqmul150 multiply 3 30000000000000000000   -> 90000000000000000000
dqmul151 multiply 3 300000000000000000000   -> 900000000000000000000
dqmul152 multiply 3 3000000000000000000000   -> 9000000000000000000000
dqmul153 multiply 3 30000000000000000000000   -> 90000000000000000000000

dqmul263 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165119928296 Inexact Rounded

-- test some edge cases with exact rounding
dqmul301 multiply 900000000000000000 9   -> 8100000000000000000
dqmul302 multiply 900000000000000000 90   -> 81000000000000000000
dqmul303 multiply 900000000000000000 900   -> 810000000000000000000
dqmul304 multiply 900000000000000000 9000   -> 8100000000000000000000
dqmul305 multiply 900000000000000000 90000   -> 81000000000000000000000
dqmul306 multiply 900000000000000000 900000   -> 810000000000000000000000
dqmul307 multiply 900000000000000000 9000000   -> 8100000000000000000000000
dqmul308 multiply 900000000000000000 90000000   -> 81000000000000000000000000
dqmul309 multiply 900000000000000000 900000000   -> 810000000000000000000000000
dqmul310 multiply 900000000000000000 9000000000   -> 8100000000000000000000000000
dqmul311 multiply 900000000000000000 90000000000   -> 81000000000000000000000000000
dqmul312 multiply 900000000000000000 900000000000   -> 810000000000000000000000000000
dqmul313 multiply 900000000000000000 9000000000000   -> 8100000000000000000000000000000
dqmul314 multiply 900000000000000000 90000000000000   -> 81000000000000000000000000000000
dqmul315 multiply 900000000000000000 900000000000000   -> 810000000000000000000000000000000
dqmul316 multiply 900000000000000000 9000000000000000   -> 8100000000000000000000000000000000
dqmul317 multiply 9000000000000000000 9000000000000000   -> 8.100000000000000000000000000000000E+34  Rounded
dqmul318 multiply 90000000000000000000 9000000000000000   -> 8.100000000000000000000000000000000E+35  Rounded
dqmul319 multiply 900000000000000000000 9000000000000000   -> 8.100000000000000000000000000000000E+36  Rounded
dqmul320 multiply 9000000000000000000000 9000000000000000   -> 8.100000000000000000000000000000000E+37  Rounded
dqmul321 multiply 90000000000000000000000 9000000000000000   -> 8.100000000000000000000000000000000E+38  Rounded
dqmul322 multiply 900000000000000000000000 9000000000000000   -> 8.100000000000000000000000000000000E+39  Rounded
dqmul323 multiply 9000000000000000000000000 9000000000000000   -> 8.100000000000000000000000000000000E+40  Rounded

-- tryzeros cases
dqmul504  multiply  0E-4260 1000E-4260  -> 0E-6176 Clamped
dqmul505  multiply  100E+4260 0E+4260   -> 0E+6111 Clamped

-- mixed with zeros
dqmul541 multiply  0    -1     -> -0
dqmul542 multiply -0    -1     ->  0
dqmul543 multiply  0     1     ->  0
dqmul544 multiply -0     1     -> -0
dqmul545 multiply -1     0     -> -0
dqmul546 multiply -1    -0     ->  0
dqmul547 multiply  1     0     ->  0
dqmul548 multiply  1    -0     -> -0

dqmul551 multiply  0.0  -1     -> -0.0
dqmul552 multiply -0.0  -1     ->  0.0
dqmul553 multiply  0.0   1     ->  0.0
dqmul554 multiply -0.0   1     -> -0.0
dqmul555 multiply -1.0   0     -> -0.0
dqmul556 multiply -1.0  -0     ->  0.0
dqmul557 multiply  1.0   0     ->  0.0
dqmul558 multiply  1.0  -0     -> -0.0

dqmul561 multiply  0    -1.0   -> -0.0
dqmul562 multiply -0    -1.0   ->  0.0
dqmul563 multiply  0     1.0   ->  0.0
dqmul564 multiply -0     1.0   -> -0.0
dqmul565 multiply -1     0.0   -> -0.0
dqmul566 multiply -1    -0.0   ->  0.0
dqmul567 multiply  1     0.0   ->  0.0
dqmul568 multiply  1    -0.0   -> -0.0

dqmul571 multiply  0.0  -1.0   -> -0.00
dqmul572 multiply -0.0  -1.0   ->  0.00
dqmul573 multiply  0.0   1.0   ->  0.00
dqmul574 multiply -0.0   1.0   -> -0.00
dqmul575 multiply -1.0   0.0   -> -0.00
dqmul576 multiply -1.0  -0.0   ->  0.00
dqmul577 multiply  1.0   0.0   ->  0.00
dqmul578 multiply  1.0  -0.0   -> -0.00


-- Specials
dqmul580 multiply  Inf  -Inf   -> -Infinity
dqmul581 multiply  Inf  -1000  -> -Infinity
dqmul582 multiply  Inf  -1     -> -Infinity
dqmul583 multiply  Inf  -0     ->  NaN  Invalid_operation
dqmul584 multiply  Inf   0     ->  NaN  Invalid_operation
dqmul585 multiply  Inf   1     ->  Infinity
dqmul586 multiply  Inf   1000  ->  Infinity
dqmul587 multiply  Inf   Inf   ->  Infinity
dqmul588 multiply -1000  Inf   -> -Infinity
dqmul589 multiply -Inf   Inf   -> -Infinity
dqmul590 multiply -1     Inf   -> -Infinity
dqmul591 multiply -0     Inf   ->  NaN  Invalid_operation
dqmul592 multiply  0     Inf   ->  NaN  Invalid_operation
dqmul593 multiply  1     Inf   ->  Infinity
dqmul594 multiply  1000  Inf   ->  Infinity
dqmul595 multiply  Inf   Inf   ->  Infinity

dqmul600 multiply -Inf  -Inf   ->  Infinity
dqmul601 multiply -Inf  -1000  ->  Infinity
dqmul602 multiply -Inf  -1     ->  Infinity
dqmul603 multiply -Inf  -0     ->  NaN  Invalid_operation
dqmul604 multiply -Inf   0     ->  NaN  Invalid_operation
dqmul605 multiply -Inf   1     -> -Infinity
dqmul606 multiply -Inf   1000  -> -Infinity
dqmul607 multiply -Inf   Inf   -> -Infinity
dqmul608 multiply -1000  Inf   -> -Infinity
dqmul609 multiply -Inf  -Inf   ->  Infinity
dqmul610 multiply -1    -Inf   ->  Infinity
dqmul611 multiply -0    -Inf   ->  NaN  Invalid_operation
dqmul612 multiply  0    -Inf   ->  NaN  Invalid_operation
dqmul613 multiply  1    -Inf   -> -Infinity
dqmul614 multiply  1000 -Inf   -> -Infinity
dqmul615 multiply  Inf  -Inf   -> -Infinity

dqmul621 multiply  NaN -Inf    ->  NaN
dqmul622 multiply  NaN -1000   ->  NaN
dqmul623 multiply  NaN -1      ->  NaN
dqmul624 multiply  NaN -0      ->  NaN
dqmul625 multiply  NaN  0      ->  NaN
dqmul626 multiply  NaN  1      ->  NaN
dqmul627 multiply  NaN  1000   ->  NaN
dqmul628 multiply  NaN  Inf    ->  NaN
dqmul629 multiply  NaN  NaN    ->  NaN
dqmul630 multiply -Inf  NaN    ->  NaN
dqmul631 multiply -1000 NaN    ->  NaN
dqmul632 multiply -1    NaN    ->  NaN
dqmul633 multiply -0    NaN    ->  NaN
dqmul634 multiply  0    NaN    ->  NaN
dqmul635 multiply  1    NaN    ->  NaN
dqmul636 multiply  1000 NaN    ->  NaN
dqmul637 multiply  Inf  NaN    ->  NaN

dqmul641 multiply  sNaN -Inf   ->  NaN  Invalid_operation
dqmul642 multiply  sNaN -1000  ->  NaN  Invalid_operation
dqmul643 multiply  sNaN -1     ->  NaN  Invalid_operation
dqmul644 multiply  sNaN -0     ->  NaN  Invalid_operation
dqmul645 multiply  sNaN  0     ->  NaN  Invalid_operation
dqmul646 multiply  sNaN  1     ->  NaN  Invalid_operation
dqmul647 multiply  sNaN  1000  ->  NaN  Invalid_operation
dqmul648 multiply  sNaN  NaN   ->  NaN  Invalid_operation
dqmul649 multiply  sNaN sNaN   ->  NaN  Invalid_operation
dqmul650 multiply  NaN  sNaN   ->  NaN  Invalid_operation
dqmul651 multiply -Inf  sNaN   ->  NaN  Invalid_operation
dqmul652 multiply -1000 sNaN   ->  NaN  Invalid_operation
dqmul653 multiply -1    sNaN   ->  NaN  Invalid_operation
dqmul654 multiply -0    sNaN   ->  NaN  Invalid_operation
dqmul655 multiply  0    sNaN   ->  NaN  Invalid_operation
dqmul656 multiply  1    sNaN   ->  NaN  Invalid_operation
dqmul657 multiply  1000 sNaN   ->  NaN  Invalid_operation
dqmul658 multiply  Inf  sNaN   ->  NaN  Invalid_operation
dqmul659 multiply  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqmul661 multiply  NaN9 -Inf   ->  NaN9
dqmul662 multiply  NaN8  999   ->  NaN8
dqmul663 multiply  NaN71 Inf   ->  NaN71
dqmul664 multiply  NaN6  NaN5  ->  NaN6
dqmul665 multiply -Inf   NaN4  ->  NaN4
dqmul666 multiply -999   NaN33 ->  NaN33
dqmul667 multiply  Inf   NaN2  ->  NaN2

dqmul671 multiply  sNaN99 -Inf    ->  NaN99 Invalid_operation
dqmul672 multiply  sNaN98 -11     ->  NaN98 Invalid_operation
dqmul673 multiply  sNaN97  NaN    ->  NaN97 Invalid_operation
dqmul674 multiply  sNaN16 sNaN94  ->  NaN16 Invalid_operation
dqmul675 multiply  NaN95  sNaN93  ->  NaN93 Invalid_operation
dqmul676 multiply -Inf    sNaN92  ->  NaN92 Invalid_operation
dqmul677 multiply  088    sNaN91  ->  NaN91 Invalid_operation
dqmul678 multiply  Inf    sNaN90  ->  NaN90 Invalid_operation
dqmul679 multiply  NaN    sNaN89  ->  NaN89 Invalid_operation

dqmul681 multiply -NaN9 -Inf   -> -NaN9
dqmul682 multiply -NaN8  999   -> -NaN8
dqmul683 multiply -NaN71 Inf   -> -NaN71
dqmul684 multiply -NaN6 -NaN5  -> -NaN6
dqmul685 multiply -Inf  -NaN4  -> -NaN4
dqmul686 multiply -999  -NaN33 -> -NaN33
dqmul687 multiply  Inf  -NaN2  -> -NaN2

dqmul691 multiply -sNaN99 -Inf    -> -NaN99 Invalid_operation
dqmul692 multiply -sNaN98 -11     -> -NaN98 Invalid_operation
dqmul693 multiply -sNaN97  NaN    -> -NaN97 Invalid_operation
dqmul694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation
dqmul695 multiply -NaN95  -sNaN93 -> -NaN93 Invalid_operation
dqmul696 multiply -Inf    -sNaN92 -> -NaN92 Invalid_operation
dqmul697 multiply  088    -sNaN91 -> -NaN91 Invalid_operation
dqmul698 multiply  Inf    -sNaN90 -> -NaN90 Invalid_operation
dqmul699 multiply -NaN    -sNaN89 -> -NaN89 Invalid_operation

dqmul701 multiply -NaN  -Inf   -> -NaN
dqmul702 multiply -NaN   999   -> -NaN
dqmul703 multiply -NaN   Inf   -> -NaN
dqmul704 multiply -NaN  -NaN   -> -NaN
dqmul705 multiply -Inf  -NaN0  -> -NaN
dqmul706 multiply -999  -NaN   -> -NaN
dqmul707 multiply  Inf  -NaN   -> -NaN

dqmul711 multiply -sNaN   -Inf    -> -NaN Invalid_operation
dqmul712 multiply -sNaN   -11     -> -NaN Invalid_operation
dqmul713 multiply -sNaN00  NaN    -> -NaN Invalid_operation
dqmul714 multiply -sNaN   -sNaN   -> -NaN Invalid_operation
dqmul715 multiply -NaN    -sNaN   -> -NaN Invalid_operation
dqmul716 multiply -Inf    -sNaN   -> -NaN Invalid_operation
dqmul717 multiply  088    -sNaN   -> -NaN Invalid_operation
dqmul718 multiply  Inf    -sNaN   -> -NaN Invalid_operation
dqmul719 multiply -NaN    -sNaN   -> -NaN Invalid_operation

-- overflow and underflow tests .. note subnormal results
-- signs
dqmul751 multiply  1e+4277  1e+3311 ->  Infinity Overflow Inexact Rounded
dqmul752 multiply  1e+4277 -1e+3311 -> -Infinity Overflow Inexact Rounded
dqmul753 multiply -1e+4277  1e+3311 -> -Infinity Overflow Inexact Rounded
dqmul754 multiply -1e+4277 -1e+3311 ->  Infinity Overflow Inexact Rounded
dqmul755 multiply  1e-4277  1e-3311 ->  0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqmul756 multiply  1e-4277 -1e-3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqmul757 multiply -1e-4277  1e-3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqmul758 multiply -1e-4277 -1e-3311 ->  0E-6176 Underflow Subnormal Inexact Rounded Clamped

-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
dqmul760 multiply 1e-6069 1e-101 -> 1E-6170 Subnormal
dqmul761 multiply 1e-6069 1e-102 -> 1E-6171 Subnormal
dqmul762 multiply 1e-6069 1e-103 -> 1E-6172 Subnormal
dqmul763 multiply 1e-6069 1e-104 -> 1E-6173 Subnormal
dqmul764 multiply 1e-6069 1e-105 -> 1E-6174 Subnormal
dqmul765 multiply 1e-6069 1e-106 -> 1E-6175 Subnormal
dqmul766 multiply 1e-6069 1e-107 -> 1E-6176 Subnormal
dqmul767 multiply 1e-6069 1e-108 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqmul768 multiply 1e-6069 1e-109 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqmul769 multiply 1e-6069 1e-110 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-- [no equivalent of 'subnormal' for overflow]
dqmul770 multiply 1e+40 1e+6101 -> 1.000000000000000000000000000000E+6141 Clamped
dqmul771 multiply 1e+40 1e+6102 -> 1.0000000000000000000000000000000E+6142  Clamped
dqmul772 multiply 1e+40 1e+6103 -> 1.00000000000000000000000000000000E+6143  Clamped
dqmul773 multiply 1e+40 1e+6104 -> 1.000000000000000000000000000000000E+6144  Clamped
dqmul774 multiply 1e+40 1e+6105 -> Infinity Overflow Inexact Rounded
dqmul775 multiply 1e+40 1e+6106 -> Infinity Overflow Inexact Rounded
dqmul776 multiply 1e+40 1e+6107 -> Infinity Overflow Inexact Rounded
dqmul777 multiply 1e+40 1e+6108 -> Infinity Overflow Inexact Rounded
dqmul778 multiply 1e+40 1e+6109 -> Infinity Overflow Inexact Rounded
dqmul779 multiply 1e+40 1e+6110 -> Infinity Overflow Inexact Rounded

dqmul801 multiply  1.0000E-6172  1     -> 1.0000E-6172 Subnormal
dqmul802 multiply  1.000E-6172   1e-1  -> 1.000E-6173  Subnormal
dqmul803 multiply  1.00E-6172    1e-2  -> 1.00E-6174   Subnormal
dqmul804 multiply  1.0E-6172     1e-3  -> 1.0E-6175    Subnormal
dqmul805 multiply  1.0E-6172     1e-4  -> 1E-6176     Subnormal Rounded
dqmul806 multiply  1.3E-6172     1e-4  -> 1E-6176     Underflow Subnormal Inexact Rounded
dqmul807 multiply  1.5E-6172     1e-4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqmul808 multiply  1.7E-6172     1e-4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqmul809 multiply  2.3E-6172     1e-4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqmul810 multiply  2.5E-6172     1e-4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqmul811 multiply  2.7E-6172     1e-4  -> 3E-6176     Underflow Subnormal Inexact Rounded
dqmul812 multiply  1.49E-6172    1e-4  -> 1E-6176     Underflow Subnormal Inexact Rounded
dqmul813 multiply  1.50E-6172    1e-4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqmul814 multiply  1.51E-6172    1e-4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqmul815 multiply  2.49E-6172    1e-4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqmul816 multiply  2.50E-6172    1e-4  -> 2E-6176     Underflow Subnormal Inexact Rounded
dqmul817 multiply  2.51E-6172    1e-4  -> 3E-6176     Underflow Subnormal Inexact Rounded

dqmul818 multiply  1E-6172       1e-4  -> 1E-6176     Subnormal
dqmul819 multiply  3E-6172       1e-5  -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped
dqmul820 multiply  5E-6172       1e-5  -> 0E-6176     Underflow Subnormal Inexact Rounded Clamped
dqmul821 multiply  7E-6172       1e-5  -> 1E-6176     Underflow Subnormal Inexact Rounded
dqmul822 multiply  9E-6172       1e-5  -> 1E-6176     Underflow Subnormal Inexact Rounded
dqmul823 multiply  9.9E-6172     1e-5  -> 1E-6176     Underflow Subnormal Inexact Rounded

dqmul824 multiply  1E-6172      -1e-4  -> -1E-6176    Subnormal
dqmul825 multiply  3E-6172      -1e-5  -> -0E-6176    Underflow Subnormal Inexact Rounded Clamped
dqmul826 multiply -5E-6172       1e-5  -> -0E-6176    Underflow Subnormal Inexact Rounded Clamped
dqmul827 multiply  7E-6172      -1e-5  -> -1E-6176    Underflow Subnormal Inexact Rounded
dqmul828 multiply -9E-6172       1e-5  -> -1E-6176    Underflow Subnormal Inexact Rounded
dqmul829 multiply  9.9E-6172    -1e-5  -> -1E-6176    Underflow Subnormal Inexact Rounded
dqmul830 multiply  3.0E-6172    -1e-5  -> -0E-6176    Underflow Subnormal Inexact Rounded Clamped

dqmul831 multiply  1.0E-5977     1e-200 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqmul832 multiply  1.0E-5977     1e-199 -> 1E-6176    Subnormal Rounded
dqmul833 multiply  1.0E-5977     1e-198 -> 1.0E-6175    Subnormal
dqmul834 multiply  2.0E-5977     2e-198 -> 4.0E-6175    Subnormal
dqmul835 multiply  4.0E-5977     4e-198 -> 1.60E-6174   Subnormal
dqmul836 multiply 10.0E-5977    10e-198 -> 1.000E-6173  Subnormal
dqmul837 multiply 30.0E-5977    30e-198 -> 9.000E-6173  Subnormal
dqmul838 multiply 40.0E-5982    40e-166 -> 1.6000E-6145 Subnormal
dqmul839 multiply 40.0E-5982    40e-165 -> 1.6000E-6144 Subnormal
dqmul840 multiply 40.0E-5982    40e-164 -> 1.6000E-6143

-- Long operand overflow may be a different path
dqmul870 multiply 100  9.999E+6143     ->  Infinity Inexact Overflow Rounded
dqmul871 multiply 100 -9.999E+6143     -> -Infinity Inexact Overflow Rounded
dqmul872 multiply      9.999E+6143 100 ->  Infinity Inexact Overflow Rounded
dqmul873 multiply     -9.999E+6143 100 -> -Infinity Inexact Overflow Rounded

-- check for double-rounded subnormals
dqmul881 multiply  1.2347E-6133 1.2347E-40  ->  1.524E-6173 Inexact Rounded Subnormal Underflow
dqmul882 multiply  1.234E-6133 1.234E-40    ->  1.523E-6173 Inexact Rounded Subnormal Underflow
dqmul883 multiply  1.23E-6133  1.23E-40     ->  1.513E-6173 Inexact Rounded Subnormal Underflow
dqmul884 multiply  1.2E-6133   1.2E-40      ->  1.44E-6173  Subnormal
dqmul885 multiply  1.2E-6133   1.2E-41      ->  1.44E-6174  Subnormal
dqmul886 multiply  1.2E-6133   1.2E-42      ->  1.4E-6175   Subnormal Inexact Rounded Underflow
dqmul887 multiply  1.2E-6133   1.3E-42      ->  1.6E-6175   Subnormal Inexact Rounded Underflow
dqmul888 multiply  1.3E-6133   1.3E-42      ->  1.7E-6175   Subnormal Inexact Rounded Underflow
dqmul889 multiply  1.3E-6133   1.3E-43      ->    2E-6176   Subnormal Inexact Rounded Underflow
dqmul890 multiply  1.3E-6134   1.3E-43      ->    0E-6176   Clamped Subnormal Inexact Rounded Underflow

dqmul891 multiply  1.2345E-39    1.234E-6133 ->  1.5234E-6172 Inexact Rounded Subnormal Underflow
dqmul892 multiply  1.23456E-39   1.234E-6133 ->  1.5234E-6172 Inexact Rounded Subnormal Underflow
dqmul893 multiply  1.2345E-40   1.234E-6133 ->  1.523E-6173  Inexact Rounded Subnormal Underflow
dqmul894 multiply  1.23456E-40  1.234E-6133 ->  1.523E-6173  Inexact Rounded Subnormal Underflow
dqmul895 multiply  1.2345E-41   1.234E-6133 ->  1.52E-6174   Inexact Rounded Subnormal Underflow
dqmul896 multiply  1.23456E-41  1.234E-6133 ->  1.52E-6174   Inexact Rounded Subnormal Underflow

-- Now explore the case where we get a normal result with Underflow
-- prove operands are exact
dqmul906 multiply  9.999999999999999999999999999999999E-6143  1                       -> 9.999999999999999999999999999999999E-6143
dqmul907 multiply                       1  0.09999999999999999999999999999999999     -> 0.09999999999999999999999999999999999
-- the next rounds to Nmin
dqmul908 multiply  9.999999999999999999999999999999999E-6143  0.09999999999999999999999999999999999     -> 1.000000000000000000000000000000000E-6143 Underflow Inexact Subnormal Rounded

-- hugest
dqmul909 multiply 9999999999999999999999999999999999 9999999999999999999999999999999999 -> 9.999999999999999999999999999999998E+67 Inexact Rounded

-- Examples from SQL proposal (Krishna Kulkarni)
precision:   34
rounding:    half_up
maxExponent: 6144
minExponent: -6143
dqmul1001  multiply 130E-2  120E-2 -> 1.5600
dqmul1002  multiply 130E-2  12E-1  -> 1.560
dqmul1003  multiply 130E-2  1E0    -> 1.30
dqmul1004  multiply 1E2     1E4    -> 1E+6

-- Null tests
dqmul990 multiply 10  # -> NaN Invalid_operation
dqmul991 multiply  # 10 -> NaN Invalid_operation

Added test/dectest/dqNextMinus.decTest.





























































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
------------------------------------------------------------------------
-- dqNextMinus.decTest -- decQuad next that is less [754r nextdown]   --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

dqnextm001 nextminus  0.9999999999999999999999999999999995 ->   0.9999999999999999999999999999999994
dqnextm002 nextminus  0.9999999999999999999999999999999996 ->   0.9999999999999999999999999999999995
dqnextm003 nextminus  0.9999999999999999999999999999999997 ->   0.9999999999999999999999999999999996
dqnextm004 nextminus  0.9999999999999999999999999999999998 ->   0.9999999999999999999999999999999997
dqnextm005 nextminus  0.9999999999999999999999999999999999 ->   0.9999999999999999999999999999999998
dqnextm006 nextminus  1.000000000000000000000000000000000  ->   0.9999999999999999999999999999999999
dqnextm007 nextminus  1.0         ->   0.9999999999999999999999999999999999
dqnextm008 nextminus  1           ->   0.9999999999999999999999999999999999
dqnextm009 nextminus  1.000000000000000000000000000000001  ->   1.000000000000000000000000000000000
dqnextm010 nextminus  1.000000000000000000000000000000002  ->   1.000000000000000000000000000000001
dqnextm011 nextminus  1.000000000000000000000000000000003  ->   1.000000000000000000000000000000002
dqnextm012 nextminus  1.000000000000000000000000000000004  ->   1.000000000000000000000000000000003
dqnextm013 nextminus  1.000000000000000000000000000000005  ->   1.000000000000000000000000000000004
dqnextm014 nextminus  1.000000000000000000000000000000006  ->   1.000000000000000000000000000000005
dqnextm015 nextminus  1.000000000000000000000000000000007  ->   1.000000000000000000000000000000006
dqnextm016 nextminus  1.000000000000000000000000000000008  ->   1.000000000000000000000000000000007
dqnextm017 nextminus  1.000000000000000000000000000000009  ->   1.000000000000000000000000000000008
dqnextm018 nextminus  1.000000000000000000000000000000010  ->   1.000000000000000000000000000000009
dqnextm019 nextminus  1.000000000000000000000000000000011  ->   1.000000000000000000000000000000010
dqnextm020 nextminus  1.000000000000000000000000000000012  ->   1.000000000000000000000000000000011

dqnextm021 nextminus -0.9999999999999999999999999999999995 ->  -0.9999999999999999999999999999999996
dqnextm022 nextminus -0.9999999999999999999999999999999996 ->  -0.9999999999999999999999999999999997
dqnextm023 nextminus -0.9999999999999999999999999999999997 ->  -0.9999999999999999999999999999999998
dqnextm024 nextminus -0.9999999999999999999999999999999998 ->  -0.9999999999999999999999999999999999
dqnextm025 nextminus -0.9999999999999999999999999999999999 ->  -1.000000000000000000000000000000000
dqnextm026 nextminus -1.000000000000000000000000000000000  ->  -1.000000000000000000000000000000001
dqnextm027 nextminus -1.0         ->  -1.000000000000000000000000000000001
dqnextm028 nextminus -1           ->  -1.000000000000000000000000000000001
dqnextm029 nextminus -1.000000000000000000000000000000001  ->  -1.000000000000000000000000000000002
dqnextm030 nextminus -1.000000000000000000000000000000002  ->  -1.000000000000000000000000000000003
dqnextm031 nextminus -1.000000000000000000000000000000003  ->  -1.000000000000000000000000000000004
dqnextm032 nextminus -1.000000000000000000000000000000004  ->  -1.000000000000000000000000000000005
dqnextm033 nextminus -1.000000000000000000000000000000005  ->  -1.000000000000000000000000000000006
dqnextm034 nextminus -1.000000000000000000000000000000006  ->  -1.000000000000000000000000000000007
dqnextm035 nextminus -1.000000000000000000000000000000007  ->  -1.000000000000000000000000000000008
dqnextm036 nextminus -1.000000000000000000000000000000008  ->  -1.000000000000000000000000000000009
dqnextm037 nextminus -1.000000000000000000000000000000009  ->  -1.000000000000000000000000000000010
dqnextm038 nextminus -1.000000000000000000000000000000010  ->  -1.000000000000000000000000000000011
dqnextm039 nextminus -1.000000000000000000000000000000011  ->  -1.000000000000000000000000000000012

-- ultra-tiny inputs
dqnextm062 nextminus  1E-6176         ->   0E-6176
dqnextm065 nextminus -1E-6176         ->  -2E-6176

-- Zeros
dqnextm100 nextminus -0           -> -1E-6176
dqnextm101 nextminus  0           -> -1E-6176
dqnextm102 nextminus  0.00        -> -1E-6176
dqnextm103 nextminus -0.00        -> -1E-6176
dqnextm104 nextminus  0E-300      -> -1E-6176
dqnextm105 nextminus  0E+300      -> -1E-6176
dqnextm106 nextminus  0E+30000    -> -1E-6176
dqnextm107 nextminus -0E+30000    -> -1E-6176

-- specials
dqnextm150 nextminus   Inf    ->  9.999999999999999999999999999999999E+6144
dqnextm151 nextminus  -Inf    -> -Infinity
dqnextm152 nextminus   NaN    ->  NaN
dqnextm153 nextminus  sNaN    ->  NaN   Invalid_operation
dqnextm154 nextminus   NaN77  ->  NaN77
dqnextm155 nextminus  sNaN88  ->  NaN88 Invalid_operation
dqnextm156 nextminus  -NaN    -> -NaN
dqnextm157 nextminus -sNaN    -> -NaN   Invalid_operation
dqnextm158 nextminus  -NaN77  -> -NaN77
dqnextm159 nextminus -sNaN88  -> -NaN88 Invalid_operation

-- Nmax, Nmin, Ntiny, subnormals
dqnextm170 nextminus  9.999999999999999999999999999999999E+6144   -> 9.999999999999999999999999999999998E+6144
dqnextm171 nextminus  9.999999999999999999999999999999998E+6144   -> 9.999999999999999999999999999999997E+6144
dqnextm172 nextminus  1E-6143                   -> 9.99999999999999999999999999999999E-6144
dqnextm173 nextminus  1.000000000000000000000000000000000E-6143   -> 9.99999999999999999999999999999999E-6144
dqnextm174 nextminus  9E-6176                   -> 8E-6176
dqnextm175 nextminus  9.9E-6175                 -> 9.8E-6175
dqnextm176 nextminus  9.99999999999999999999999999999E-6147       -> 9.99999999999999999999999999998E-6147
dqnextm177 nextminus  9.99999999999999999999999999999999E-6144    -> 9.99999999999999999999999999999998E-6144
dqnextm178 nextminus  9.99999999999999999999999999999998E-6144    -> 9.99999999999999999999999999999997E-6144
dqnextm179 nextminus  9.99999999999999999999999999999997E-6144    -> 9.99999999999999999999999999999996E-6144
dqnextm180 nextminus  0E-6176                   -> -1E-6176
dqnextm181 nextminus  1E-6176                   -> 0E-6176
dqnextm182 nextminus  2E-6176                   -> 1E-6176

dqnextm183 nextminus  -0E-6176                  -> -1E-6176
dqnextm184 nextminus  -1E-6176                  -> -2E-6176
dqnextm185 nextminus  -2E-6176                  -> -3E-6176
dqnextm186 nextminus  -10E-6176                 -> -1.1E-6175
dqnextm187 nextminus  -100E-6176                -> -1.01E-6174
dqnextm188 nextminus  -100000E-6176             -> -1.00001E-6171
dqnextm189 nextminus  -1.00000000000000000000000000000E-6143      -> -1.000000000000000000000000000000001E-6143
dqnextm190 nextminus  -1.000000000000000000000000000000000E-6143  -> -1.000000000000000000000000000000001E-6143
dqnextm191 nextminus  -1E-6143                  -> -1.000000000000000000000000000000001E-6143
dqnextm192 nextminus  -9.999999999999999999999999999999998E+6144  -> -9.999999999999999999999999999999999E+6144
dqnextm193 nextminus  -9.999999999999999999999999999999999E+6144  -> -Infinity

-- Null tests
dqnextm900 nextminus  # -> NaN Invalid_operation

Added test/dectest/dqNextPlus.decTest.

























































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
------------------------------------------------------------------------
-- dqNextPlus.decTest -- decQuad next that is greater [754r nextup]   --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

dqnextp001 nextplus  0.9999999999999999999999999999999995 ->   0.9999999999999999999999999999999996
dqnextp002 nextplus  0.9999999999999999999999999999999996 ->   0.9999999999999999999999999999999997
dqnextp003 nextplus  0.9999999999999999999999999999999997 ->   0.9999999999999999999999999999999998
dqnextp004 nextplus  0.9999999999999999999999999999999998 ->   0.9999999999999999999999999999999999
dqnextp005 nextplus  0.9999999999999999999999999999999999 ->   1.000000000000000000000000000000000
dqnextp006 nextplus  1.000000000000000000000000000000000  ->   1.000000000000000000000000000000001
dqnextp007 nextplus  1.0         ->   1.000000000000000000000000000000001
dqnextp008 nextplus  1           ->   1.000000000000000000000000000000001
dqnextp009 nextplus  1.000000000000000000000000000000001  ->   1.000000000000000000000000000000002
dqnextp010 nextplus  1.000000000000000000000000000000002  ->   1.000000000000000000000000000000003
dqnextp011 nextplus  1.000000000000000000000000000000003  ->   1.000000000000000000000000000000004
dqnextp012 nextplus  1.000000000000000000000000000000004  ->   1.000000000000000000000000000000005
dqnextp013 nextplus  1.000000000000000000000000000000005  ->   1.000000000000000000000000000000006
dqnextp014 nextplus  1.000000000000000000000000000000006  ->   1.000000000000000000000000000000007
dqnextp015 nextplus  1.000000000000000000000000000000007  ->   1.000000000000000000000000000000008
dqnextp016 nextplus  1.000000000000000000000000000000008  ->   1.000000000000000000000000000000009
dqnextp017 nextplus  1.000000000000000000000000000000009  ->   1.000000000000000000000000000000010
dqnextp018 nextplus  1.000000000000000000000000000000010  ->   1.000000000000000000000000000000011
dqnextp019 nextplus  1.000000000000000000000000000000011  ->   1.000000000000000000000000000000012

dqnextp021 nextplus -0.9999999999999999999999999999999995 ->  -0.9999999999999999999999999999999994
dqnextp022 nextplus -0.9999999999999999999999999999999996 ->  -0.9999999999999999999999999999999995
dqnextp023 nextplus -0.9999999999999999999999999999999997 ->  -0.9999999999999999999999999999999996
dqnextp024 nextplus -0.9999999999999999999999999999999998 ->  -0.9999999999999999999999999999999997
dqnextp025 nextplus -0.9999999999999999999999999999999999 ->  -0.9999999999999999999999999999999998
dqnextp026 nextplus -1.000000000000000000000000000000000  ->  -0.9999999999999999999999999999999999
dqnextp027 nextplus -1.0         ->  -0.9999999999999999999999999999999999
dqnextp028 nextplus -1           ->  -0.9999999999999999999999999999999999
dqnextp029 nextplus -1.000000000000000000000000000000001  ->  -1.000000000000000000000000000000000
dqnextp030 nextplus -1.000000000000000000000000000000002  ->  -1.000000000000000000000000000000001
dqnextp031 nextplus -1.000000000000000000000000000000003  ->  -1.000000000000000000000000000000002
dqnextp032 nextplus -1.000000000000000000000000000000004  ->  -1.000000000000000000000000000000003
dqnextp033 nextplus -1.000000000000000000000000000000005  ->  -1.000000000000000000000000000000004
dqnextp034 nextplus -1.000000000000000000000000000000006  ->  -1.000000000000000000000000000000005
dqnextp035 nextplus -1.000000000000000000000000000000007  ->  -1.000000000000000000000000000000006
dqnextp036 nextplus -1.000000000000000000000000000000008  ->  -1.000000000000000000000000000000007
dqnextp037 nextplus -1.000000000000000000000000000000009  ->  -1.000000000000000000000000000000008
dqnextp038 nextplus -1.000000000000000000000000000000010  ->  -1.000000000000000000000000000000009
dqnextp039 nextplus -1.000000000000000000000000000000011  ->  -1.000000000000000000000000000000010
dqnextp040 nextplus -1.000000000000000000000000000000012  ->  -1.000000000000000000000000000000011

-- Zeros
dqnextp100 nextplus  0           ->  1E-6176
dqnextp101 nextplus  0.00        ->  1E-6176
dqnextp102 nextplus  0E-300      ->  1E-6176
dqnextp103 nextplus  0E+300      ->  1E-6176
dqnextp104 nextplus  0E+30000    ->  1E-6176
dqnextp105 nextplus -0           ->  1E-6176
dqnextp106 nextplus -0.00        ->  1E-6176
dqnextp107 nextplus -0E-300      ->  1E-6176
dqnextp108 nextplus -0E+300      ->  1E-6176
dqnextp109 nextplus -0E+30000    ->  1E-6176

-- specials
dqnextp150 nextplus   Inf    ->  Infinity
dqnextp151 nextplus  -Inf    -> -9.999999999999999999999999999999999E+6144
dqnextp152 nextplus   NaN    ->  NaN
dqnextp153 nextplus  sNaN    ->  NaN   Invalid_operation
dqnextp154 nextplus   NaN77  ->  NaN77
dqnextp155 nextplus  sNaN88  ->  NaN88 Invalid_operation
dqnextp156 nextplus  -NaN    -> -NaN
dqnextp157 nextplus -sNaN    -> -NaN   Invalid_operation
dqnextp158 nextplus  -NaN77  -> -NaN77
dqnextp159 nextplus -sNaN88  -> -NaN88 Invalid_operation

-- Nmax, Nmin, Ntiny, subnormals
dqnextp170 nextplus  -9.999999999999999999999999999999999E+6144  -> -9.999999999999999999999999999999998E+6144
dqnextp171 nextplus  -9.999999999999999999999999999999998E+6144  -> -9.999999999999999999999999999999997E+6144
dqnextp172 nextplus  -1E-6143                  -> -9.99999999999999999999999999999999E-6144
dqnextp173 nextplus  -1.000000000000000E-6143  -> -9.99999999999999999999999999999999E-6144
dqnextp174 nextplus  -9E-6176                  -> -8E-6176
dqnextp175 nextplus  -9.9E-6175                -> -9.8E-6175
dqnextp176 nextplus  -9.99999999999999999999999999999E-6147      -> -9.99999999999999999999999999998E-6147
dqnextp177 nextplus  -9.99999999999999999999999999999999E-6144   -> -9.99999999999999999999999999999998E-6144
dqnextp178 nextplus  -9.99999999999999999999999999999998E-6144   -> -9.99999999999999999999999999999997E-6144
dqnextp179 nextplus  -9.99999999999999999999999999999997E-6144   -> -9.99999999999999999999999999999996E-6144
dqnextp180 nextplus  -0E-6176                  ->  1E-6176
dqnextp181 nextplus  -1E-6176                  -> -0E-6176
dqnextp182 nextplus  -2E-6176                  -> -1E-6176

dqnextp183 nextplus   0E-6176                  ->  1E-6176
dqnextp184 nextplus   1E-6176                  ->  2E-6176
dqnextp185 nextplus   2E-6176                  ->  3E-6176
dqnextp186 nextplus   10E-6176                 ->  1.1E-6175
dqnextp187 nextplus   100E-6176                ->  1.01E-6174
dqnextp188 nextplus   100000E-6176             ->  1.00001E-6171
dqnextp189 nextplus   1.00000000000000000000000000000E-6143      ->  1.000000000000000000000000000000001E-6143
dqnextp190 nextplus   1.000000000000000000000000000000000E-6143  ->  1.000000000000000000000000000000001E-6143
dqnextp191 nextplus   1E-6143                  ->  1.000000000000000000000000000000001E-6143
dqnextp192 nextplus   9.999999999999999999999999999999998E+6144  ->  9.999999999999999999999999999999999E+6144
dqnextp193 nextplus   9.999999999999999999999999999999999E+6144  ->  Infinity

-- Null tests
dqnextp900 nextplus  # -> NaN Invalid_operation

Added test/dectest/dqNextToward.decTest.















































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
------------------------------------------------------------------------
-- dqNextToward.decTest -- decQuad next toward rhs [754r nextafter]   --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even


-- Sanity check with a scattering of numerics
dqnextt001 nexttoward   10    10   ->  10
dqnextt002 nexttoward  -10   -10   -> -10
dqnextt003 nexttoward   1     10   ->  1.000000000000000000000000000000001
dqnextt004 nexttoward   1    -10   ->  0.9999999999999999999999999999999999
dqnextt005 nexttoward  -1     10   -> -0.9999999999999999999999999999999999
dqnextt006 nexttoward  -1    -10   -> -1.000000000000000000000000000000001
dqnextt007 nexttoward   0     10   ->  1E-6176       Underflow Subnormal Inexact Rounded
dqnextt008 nexttoward   0    -10   -> -1E-6176       Underflow Subnormal Inexact Rounded
dqnextt009 nexttoward   9.999999999999999999999999999999999E+6144 +Infinity ->  Infinity Overflow Inexact Rounded
dqnextt010 nexttoward  -9.999999999999999999999999999999999E+6144 -Infinity -> -Infinity Overflow Inexact Rounded
dqnextt011 nexttoward       9.999999999999999999999999999999999  10  ->  10.00000000000000000000000000000000
dqnextt012 nexttoward   10  9.999999999999999999999999999999999      ->  9.999999999999999999999999999999999
dqnextt013 nexttoward      -9.999999999999999999999999999999999 -10  -> -10.00000000000000000000000000000000
dqnextt014 nexttoward  -10 -9.999999999999999999999999999999999      -> -9.999999999999999999999999999999999
dqnextt015 nexttoward       9.999999999999999999999999999999998  10  ->  9.999999999999999999999999999999999
dqnextt016 nexttoward   10  9.999999999999999999999999999999998      ->  9.999999999999999999999999999999999
dqnextt017 nexttoward      -9.999999999999999999999999999999998 -10  -> -9.999999999999999999999999999999999
dqnextt018 nexttoward  -10 -9.999999999999999999999999999999998      -> -9.999999999999999999999999999999999

------- lhs=rhs
-- finites
dqnextt101 nexttoward          7       7 ->  7
dqnextt102 nexttoward         -7      -7 -> -7
dqnextt103 nexttoward         75      75 ->  75
dqnextt104 nexttoward        -75     -75 -> -75
dqnextt105 nexttoward       7.50     7.5 ->  7.50
dqnextt106 nexttoward      -7.50   -7.50 -> -7.50
dqnextt107 nexttoward       7.500 7.5000 ->  7.500
dqnextt108 nexttoward      -7.500   -7.5 -> -7.500

-- zeros
dqnextt111 nexttoward          0       0 ->  0
dqnextt112 nexttoward         -0      -0 -> -0
dqnextt113 nexttoward       0E+4       0 ->  0E+4
dqnextt114 nexttoward      -0E+4      -0 -> -0E+4
dqnextt115 nexttoward     0.00000000000   0.000000000000 ->  0E-11
dqnextt116 nexttoward    -0.00000000000  -0.00           -> -0E-11
dqnextt117 nexttoward      0E-141      0 ->  0E-141
dqnextt118 nexttoward     -0E-141   -000 -> -0E-141

-- full coefficients, alternating bits
dqnextt121 nexttoward   268268268    268268268 ->   268268268
dqnextt122 nexttoward  -268268268   -268268268 ->  -268268268
dqnextt123 nexttoward   134134134    134134134 ->   134134134
dqnextt124 nexttoward  -134134134   -134134134 ->  -134134134

-- Nmax, Nmin, Ntiny
dqnextt131 nexttoward  9.999999999999999999999999999999999E+6144  9.999999999999999999999999999999999E+6144   ->   9.999999999999999999999999999999999E+6144
dqnextt132 nexttoward  1E-6143           1E-6143            ->   1E-6143
dqnextt133 nexttoward  1.000000000000000000000000000000000E-6143  1.000000000000000000000000000000000E-6143   ->   1.000000000000000000000000000000000E-6143
dqnextt134 nexttoward  1E-6176           1E-6176            ->   1E-6176

dqnextt135 nexttoward  -1E-6176          -1E-6176           ->  -1E-6176
dqnextt136 nexttoward  -1.000000000000000000000000000000000E-6143 -1.000000000000000000000000000000000E-6143  ->  -1.000000000000000000000000000000000E-6143
dqnextt137 nexttoward  -1E-6143          -1E-6143           ->  -1E-6143
dqnextt138 nexttoward  -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144  ->  -9.999999999999999999999999999999999E+6144

------- lhs<rhs
dqnextt201 nexttoward  0.9999999999999999999999999999999995 Infinity ->   0.9999999999999999999999999999999996
dqnextt202 nexttoward  0.9999999999999999999999999999999996 Infinity ->   0.9999999999999999999999999999999997
dqnextt203 nexttoward  0.9999999999999999999999999999999997 Infinity ->   0.9999999999999999999999999999999998
dqnextt204 nexttoward  0.9999999999999999999999999999999998 Infinity ->   0.9999999999999999999999999999999999
dqnextt205 nexttoward  0.9999999999999999999999999999999999 Infinity ->   1.000000000000000000000000000000000
dqnextt206 nexttoward  1.000000000000000000000000000000000  Infinity ->   1.000000000000000000000000000000001
dqnextt207 nexttoward  1.0         Infinity ->   1.000000000000000000000000000000001
dqnextt208 nexttoward  1           Infinity ->   1.000000000000000000000000000000001
dqnextt209 nexttoward  1.000000000000000000000000000000001  Infinity ->   1.000000000000000000000000000000002
dqnextt210 nexttoward  1.000000000000000000000000000000002  Infinity ->   1.000000000000000000000000000000003
dqnextt211 nexttoward  1.000000000000000000000000000000003  Infinity ->   1.000000000000000000000000000000004
dqnextt212 nexttoward  1.000000000000000000000000000000004  Infinity ->   1.000000000000000000000000000000005
dqnextt213 nexttoward  1.000000000000000000000000000000005  Infinity ->   1.000000000000000000000000000000006
dqnextt214 nexttoward  1.000000000000000000000000000000006  Infinity ->   1.000000000000000000000000000000007
dqnextt215 nexttoward  1.000000000000000000000000000000007  Infinity ->   1.000000000000000000000000000000008
dqnextt216 nexttoward  1.000000000000000000000000000000008  Infinity ->   1.000000000000000000000000000000009
dqnextt217 nexttoward  1.000000000000000000000000000000009  Infinity ->   1.000000000000000000000000000000010
dqnextt218 nexttoward  1.000000000000000000000000000000010  Infinity ->   1.000000000000000000000000000000011
dqnextt219 nexttoward  1.000000000000000000000000000000011  Infinity ->   1.000000000000000000000000000000012

dqnextt221 nexttoward -0.9999999999999999999999999999999995 Infinity ->  -0.9999999999999999999999999999999994
dqnextt222 nexttoward -0.9999999999999999999999999999999996 Infinity -> -0.9999999999999999999999999999999995
dqnextt223 nexttoward -0.9999999999999999999999999999999997 Infinity ->  -0.9999999999999999999999999999999996
dqnextt224 nexttoward -0.9999999999999999999999999999999998 Infinity ->  -0.9999999999999999999999999999999997
dqnextt225 nexttoward -0.9999999999999999999999999999999999 Infinity ->  -0.9999999999999999999999999999999998
dqnextt226 nexttoward -1.000000000000000000000000000000000  Infinity ->  -0.9999999999999999999999999999999999
dqnextt227 nexttoward -1.0         Infinity ->  -0.9999999999999999999999999999999999
dqnextt228 nexttoward -1           Infinity ->  -0.9999999999999999999999999999999999
dqnextt229 nexttoward -1.000000000000000000000000000000001  Infinity ->  -1.000000000000000000000000000000000
dqnextt230 nexttoward -1.000000000000000000000000000000002  Infinity ->  -1.000000000000000000000000000000001
dqnextt231 nexttoward -1.000000000000000000000000000000003  Infinity ->  -1.000000000000000000000000000000002
dqnextt232 nexttoward -1.000000000000000000000000000000004  Infinity ->  -1.000000000000000000000000000000003
dqnextt233 nexttoward -1.000000000000000000000000000000005  Infinity ->  -1.000000000000000000000000000000004
dqnextt234 nexttoward -1.000000000000000000000000000000006  Infinity ->  -1.000000000000000000000000000000005
dqnextt235 nexttoward -1.000000000000000000000000000000007  Infinity ->  -1.000000000000000000000000000000006
dqnextt236 nexttoward -1.000000000000000000000000000000008  Infinity ->  -1.000000000000000000000000000000007
dqnextt237 nexttoward -1.000000000000000000000000000000009  Infinity ->  -1.000000000000000000000000000000008
dqnextt238 nexttoward -1.000000000000000000000000000000010  Infinity ->  -1.000000000000000000000000000000009
dqnextt239 nexttoward -1.000000000000000000000000000000011  Infinity ->  -1.000000000000000000000000000000010
dqnextt240 nexttoward -1.000000000000000000000000000000012  Infinity ->  -1.000000000000000000000000000000011

-- Zeros
dqnextt300 nexttoward  0           Infinity ->  1E-6176              Underflow Subnormal Inexact Rounded
dqnextt301 nexttoward  0.00        Infinity ->  1E-6176              Underflow Subnormal Inexact Rounded
dqnextt302 nexttoward  0E-300      Infinity ->  1E-6176              Underflow Subnormal Inexact Rounded
dqnextt303 nexttoward  0E+300      Infinity ->  1E-6176              Underflow Subnormal Inexact Rounded
dqnextt304 nexttoward  0E+30000    Infinity ->  1E-6176              Underflow Subnormal Inexact Rounded
dqnextt305 nexttoward -0           Infinity ->  1E-6176              Underflow Subnormal Inexact Rounded
dqnextt306 nexttoward -0.00        Infinity ->  1E-6176              Underflow Subnormal Inexact Rounded
dqnextt307 nexttoward -0E-300      Infinity ->  1E-6176              Underflow Subnormal Inexact Rounded
dqnextt308 nexttoward -0E+300      Infinity ->  1E-6176              Underflow Subnormal Inexact Rounded
dqnextt309 nexttoward -0E+30000    Infinity ->  1E-6176              Underflow Subnormal Inexact Rounded

-- specials
dqnextt350 nexttoward   Inf    Infinity ->  Infinity
dqnextt351 nexttoward  -Inf    Infinity -> -9.999999999999999999999999999999999E+6144
dqnextt352 nexttoward   NaN    Infinity ->  NaN
dqnextt353 nexttoward  sNaN    Infinity ->  NaN   Invalid_operation
dqnextt354 nexttoward   NaN77  Infinity ->  NaN77
dqnextt355 nexttoward  sNaN88  Infinity ->  NaN88 Invalid_operation
dqnextt356 nexttoward  -NaN    Infinity -> -NaN
dqnextt357 nexttoward -sNaN    Infinity -> -NaN   Invalid_operation
dqnextt358 nexttoward  -NaN77  Infinity -> -NaN77
dqnextt359 nexttoward -sNaN88  Infinity -> -NaN88 Invalid_operation

-- Nmax, Nmin, Ntiny, subnormals
dqnextt370 nexttoward  -9.999999999999999999999999999999999E+6144  Infinity  -> -9.999999999999999999999999999999998E+6144
dqnextt371 nexttoward  -9.999999999999999999999999999999998E+6144  Infinity  -> -9.999999999999999999999999999999997E+6144
dqnextt372 nexttoward  -1E-6143                  Infinity  -> -9.99999999999999999999999999999999E-6144  Underflow Subnormal Inexact Rounded
dqnextt373 nexttoward  -1.000000000000000E-6143  Infinity  -> -9.99999999999999999999999999999999E-6144  Underflow Subnormal Inexact Rounded
dqnextt374 nexttoward  -9E-6176                  Infinity  -> -8E-6176                 Underflow Subnormal Inexact Rounded
dqnextt375 nexttoward  -9.9E-6175                Infinity  -> -9.8E-6175               Underflow Subnormal Inexact Rounded
dqnextt376 nexttoward  -9.99999999999999999999999999999E-6147      Infinity  -> -9.99999999999999999999999999998E-6147     Underflow Subnormal Inexact Rounded
dqnextt377 nexttoward  -9.99999999999999999999999999999999E-6144   Infinity  -> -9.99999999999999999999999999999998E-6144  Underflow Subnormal Inexact Rounded
dqnextt378 nexttoward  -9.99999999999999999999999999999998E-6144   Infinity  -> -9.99999999999999999999999999999997E-6144  Underflow Subnormal Inexact Rounded
dqnextt379 nexttoward  -9.99999999999999999999999999999997E-6144   Infinity  -> -9.99999999999999999999999999999996E-6144  Underflow Subnormal Inexact Rounded
dqnextt380 nexttoward  -0E-6176                  Infinity  ->  1E-6176                 Underflow Subnormal Inexact Rounded
dqnextt381 nexttoward  -1E-6176                  Infinity  -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqnextt382 nexttoward  -2E-6176                  Infinity  -> -1E-6176                 Underflow Subnormal Inexact Rounded

dqnextt383 nexttoward   0E-6176                  Infinity  ->  1E-6176                 Underflow Subnormal Inexact Rounded
dqnextt384 nexttoward   1E-6176                  Infinity  ->  2E-6176                 Underflow Subnormal Inexact Rounded
dqnextt385 nexttoward   2E-6176                  Infinity  ->  3E-6176                 Underflow Subnormal Inexact Rounded
dqnextt386 nexttoward   10E-6176                 Infinity  ->  1.1E-6175               Underflow Subnormal Inexact Rounded
dqnextt387 nexttoward   100E-6176                Infinity  ->  1.01E-6174              Underflow Subnormal Inexact Rounded
dqnextt388 nexttoward   100000E-6176             Infinity  ->  1.00001E-6171           Underflow Subnormal Inexact Rounded
dqnextt389 nexttoward   1.00000000000000000000000000000E-6143      Infinity  ->  1.000000000000000000000000000000001E-6143
dqnextt390 nexttoward   1.000000000000000000000000000000000E-6143  Infinity  ->  1.000000000000000000000000000000001E-6143
dqnextt391 nexttoward   1E-6143                  Infinity  ->  1.000000000000000000000000000000001E-6143
dqnextt392 nexttoward   9.999999999999999999999999999999997E+6144  Infinity  ->  9.999999999999999999999999999999998E+6144
dqnextt393 nexttoward   9.999999999999999999999999999999998E+6144  Infinity  ->  9.999999999999999999999999999999999E+6144
dqnextt394 nexttoward   9.999999999999999999999999999999999E+6144  Infinity  ->  Infinity               Overflow Inexact Rounded

------- lhs>rhs
dqnextt401 nexttoward  0.9999999999999999999999999999999995  -Infinity ->   0.9999999999999999999999999999999994
dqnextt402 nexttoward  0.9999999999999999999999999999999996  -Infinity ->   0.9999999999999999999999999999999995
dqnextt403 nexttoward  0.9999999999999999999999999999999997  -Infinity ->   0.9999999999999999999999999999999996
dqnextt404 nexttoward  0.9999999999999999999999999999999998  -Infinity ->   0.9999999999999999999999999999999997
dqnextt405 nexttoward  0.9999999999999999999999999999999999  -Infinity ->   0.9999999999999999999999999999999998
dqnextt406 nexttoward  1.000000000000000000000000000000000   -Infinity ->   0.9999999999999999999999999999999999
dqnextt407 nexttoward  1.0          -Infinity ->   0.9999999999999999999999999999999999
dqnextt408 nexttoward  1            -Infinity ->   0.9999999999999999999999999999999999
dqnextt409 nexttoward  1.000000000000000000000000000000001   -Infinity ->   1.000000000000000000000000000000000
dqnextt410 nexttoward  1.000000000000000000000000000000002   -Infinity ->   1.000000000000000000000000000000001
dqnextt411 nexttoward  1.000000000000000000000000000000003   -Infinity ->   1.000000000000000000000000000000002
dqnextt412 nexttoward  1.000000000000000000000000000000004   -Infinity ->   1.000000000000000000000000000000003
dqnextt413 nexttoward  1.000000000000000000000000000000005   -Infinity ->   1.000000000000000000000000000000004
dqnextt414 nexttoward  1.000000000000000000000000000000006   -Infinity ->   1.000000000000000000000000000000005
dqnextt415 nexttoward  1.000000000000000000000000000000007   -Infinity ->   1.000000000000000000000000000000006
dqnextt416 nexttoward  1.000000000000000000000000000000008   -Infinity ->   1.000000000000000000000000000000007
dqnextt417 nexttoward  1.000000000000000000000000000000009   -Infinity ->   1.000000000000000000000000000000008
dqnextt418 nexttoward  1.000000000000000000000000000000010   -Infinity ->   1.000000000000000000000000000000009
dqnextt419 nexttoward  1.000000000000000000000000000000011   -Infinity ->   1.000000000000000000000000000000010
dqnextt420 nexttoward  1.000000000000000000000000000000012   -Infinity ->   1.000000000000000000000000000000011

dqnextt421 nexttoward -0.9999999999999999999999999999999995  -Infinity ->  -0.9999999999999999999999999999999996
dqnextt422 nexttoward -0.9999999999999999999999999999999996  -Infinity ->  -0.9999999999999999999999999999999997
dqnextt423 nexttoward -0.9999999999999999999999999999999997  -Infinity ->  -0.9999999999999999999999999999999998
dqnextt424 nexttoward -0.9999999999999999999999999999999998  -Infinity ->  -0.9999999999999999999999999999999999
dqnextt425 nexttoward -0.9999999999999999999999999999999999  -Infinity ->  -1.000000000000000000000000000000000
dqnextt426 nexttoward -1.000000000000000000000000000000000   -Infinity ->  -1.000000000000000000000000000000001
dqnextt427 nexttoward -1.0          -Infinity ->  -1.000000000000000000000000000000001
dqnextt428 nexttoward -1            -Infinity ->  -1.000000000000000000000000000000001
dqnextt429 nexttoward -1.000000000000000000000000000000001   -Infinity ->  -1.000000000000000000000000000000002
dqnextt430 nexttoward -1.000000000000000000000000000000002   -Infinity ->  -1.000000000000000000000000000000003
dqnextt431 nexttoward -1.000000000000000000000000000000003   -Infinity ->  -1.000000000000000000000000000000004
dqnextt432 nexttoward -1.000000000000000000000000000000004   -Infinity ->  -1.000000000000000000000000000000005
dqnextt433 nexttoward -1.000000000000000000000000000000005   -Infinity ->  -1.000000000000000000000000000000006
dqnextt434 nexttoward -1.000000000000000000000000000000006   -Infinity ->  -1.000000000000000000000000000000007
dqnextt435 nexttoward -1.000000000000000000000000000000007   -Infinity ->  -1.000000000000000000000000000000008
dqnextt436 nexttoward -1.000000000000000000000000000000008   -Infinity ->  -1.000000000000000000000000000000009
dqnextt437 nexttoward -1.000000000000000000000000000000009   -Infinity ->  -1.000000000000000000000000000000010
dqnextt438 nexttoward -1.000000000000000000000000000000010   -Infinity ->  -1.000000000000000000000000000000011
dqnextt439 nexttoward -1.000000000000000000000000000000011   -Infinity ->  -1.000000000000000000000000000000012

-- Zeros
dqnextt500 nexttoward -0            -Infinity -> -1E-6176         Underflow Subnormal Inexact Rounded
dqnextt501 nexttoward  0            -Infinity -> -1E-6176         Underflow Subnormal Inexact Rounded
dqnextt502 nexttoward  0.00         -Infinity -> -1E-6176         Underflow Subnormal Inexact Rounded
dqnextt503 nexttoward -0.00         -Infinity -> -1E-6176         Underflow Subnormal Inexact Rounded
dqnextt504 nexttoward  0E-300       -Infinity -> -1E-6176         Underflow Subnormal Inexact Rounded
dqnextt505 nexttoward  0E+300       -Infinity -> -1E-6176         Underflow Subnormal Inexact Rounded
dqnextt506 nexttoward  0E+30000     -Infinity -> -1E-6176         Underflow Subnormal Inexact Rounded
dqnextt507 nexttoward -0E+30000     -Infinity -> -1E-6176         Underflow Subnormal Inexact Rounded

-- specials
dqnextt550 nexttoward   Inf     -Infinity ->  9.999999999999999999999999999999999E+6144
dqnextt551 nexttoward  -Inf     -Infinity -> -Infinity
dqnextt552 nexttoward   NaN     -Infinity ->  NaN
dqnextt553 nexttoward  sNaN     -Infinity ->  NaN   Invalid_operation
dqnextt554 nexttoward   NaN77   -Infinity ->  NaN77
dqnextt555 nexttoward  sNaN88   -Infinity ->  NaN88 Invalid_operation
dqnextt556 nexttoward  -NaN     -Infinity -> -NaN
dqnextt557 nexttoward -sNaN     -Infinity -> -NaN   Invalid_operation
dqnextt558 nexttoward  -NaN77   -Infinity -> -NaN77
dqnextt559 nexttoward -sNaN88   -Infinity -> -NaN88 Invalid_operation

-- Nmax, Nmin, Ntiny, subnormals
dqnextt670 nexttoward  9.999999999999999999999999999999999E+6144   -Infinity  -> 9.999999999999999999999999999999998E+6144
dqnextt671 nexttoward  9.999999999999999999999999999999998E+6144   -Infinity  -> 9.999999999999999999999999999999997E+6144
dqnextt672 nexttoward  1E-6143                   -Infinity  -> 9.99999999999999999999999999999999E-6144   Underflow Subnormal  Inexact Rounded
dqnextt673 nexttoward  1.000000000000000000000000000000000E-6143   -Infinity  -> 9.99999999999999999999999999999999E-6144   Underflow Subnormal  Inexact Rounded
dqnextt674 nexttoward  9E-6176                   -Infinity  -> 8E-6176                  Underflow Subnormal  Inexact Rounded
dqnextt675 nexttoward  9.9E-6175                 -Infinity  -> 9.8E-6175                Underflow Subnormal  Inexact Rounded
dqnextt676 nexttoward  9.99999999999999999999999999999E-6147       -Infinity  -> 9.99999999999999999999999999998E-6147      Underflow Subnormal  Inexact Rounded
dqnextt677 nexttoward  9.99999999999999999999999999999999E-6144    -Infinity  -> 9.99999999999999999999999999999998E-6144   Underflow Subnormal  Inexact Rounded
dqnextt678 nexttoward  9.99999999999999999999999999999998E-6144    -Infinity  -> 9.99999999999999999999999999999997E-6144   Underflow Subnormal  Inexact Rounded
dqnextt679 nexttoward  9.99999999999999999999999999999997E-6144    -Infinity  -> 9.99999999999999999999999999999996E-6144   Underflow Subnormal  Inexact Rounded
dqnextt680 nexttoward  0E-6176                   -Infinity  -> -1E-6176                 Underflow Subnormal  Inexact Rounded
dqnextt681 nexttoward  1E-6176                   -Infinity  -> 0E-6176                  Underflow Subnormal  Inexact Rounded Clamped
dqnextt682 nexttoward  2E-6176                   -Infinity  -> 1E-6176                  Underflow Subnormal  Inexact Rounded

dqnextt683 nexttoward  -0E-6176                  -Infinity  -> -1E-6176                 Underflow Subnormal  Inexact Rounded
dqnextt684 nexttoward  -1E-6176                  -Infinity  -> -2E-6176                 Underflow Subnormal  Inexact Rounded
dqnextt685 nexttoward  -2E-6176                  -Infinity  -> -3E-6176                 Underflow Subnormal  Inexact Rounded
dqnextt686 nexttoward  -10E-6176                 -Infinity  -> -1.1E-6175               Underflow Subnormal  Inexact Rounded
dqnextt687 nexttoward  -100E-6176                -Infinity  -> -1.01E-6174              Underflow Subnormal  Inexact Rounded
dqnextt688 nexttoward  -100000E-6176             -Infinity  -> -1.00001E-6171           Underflow Subnormal  Inexact Rounded
dqnextt689 nexttoward  -1.00000000000000000000000000000E-6143      -Infinity  -> -1.000000000000000000000000000000001E-6143
dqnextt690 nexttoward  -1.000000000000000000000000000000000E-6143  -Infinity  -> -1.000000000000000000000000000000001E-6143
dqnextt691 nexttoward  -1E-6143                  -Infinity  -> -1.000000000000000000000000000000001E-6143
dqnextt692 nexttoward  -9.999999999999999999999999999999998E+6144  -Infinity  -> -9.999999999999999999999999999999999E+6144
dqnextt693 nexttoward  -9.999999999999999999999999999999999E+6144  -Infinity  -> -Infinity               Overflow Inexact Rounded

------- Specials
dqnextt780 nexttoward -Inf  -Inf   -> -Infinity
dqnextt781 nexttoward -Inf  -1000  -> -9.999999999999999999999999999999999E+6144
dqnextt782 nexttoward -Inf  -1     -> -9.999999999999999999999999999999999E+6144
dqnextt783 nexttoward -Inf  -0     -> -9.999999999999999999999999999999999E+6144
dqnextt784 nexttoward -Inf   0     -> -9.999999999999999999999999999999999E+6144
dqnextt785 nexttoward -Inf   1     -> -9.999999999999999999999999999999999E+6144
dqnextt786 nexttoward -Inf   1000  -> -9.999999999999999999999999999999999E+6144
dqnextt787 nexttoward -1000 -Inf   -> -1000.000000000000000000000000000001
dqnextt788 nexttoward -Inf  -Inf   -> -Infinity
dqnextt789 nexttoward -1    -Inf   -> -1.000000000000000000000000000000001
dqnextt790 nexttoward -0    -Inf   -> -1E-6176           Underflow Subnormal Inexact Rounded
dqnextt791 nexttoward  0    -Inf   -> -1E-6176           Underflow Subnormal Inexact Rounded
dqnextt792 nexttoward  1    -Inf   ->  0.9999999999999999999999999999999999
dqnextt793 nexttoward  1000 -Inf   ->  999.9999999999999999999999999999999
dqnextt794 nexttoward  Inf  -Inf   ->  9.999999999999999999999999999999999E+6144

dqnextt800 nexttoward  Inf  -Inf   ->  9.999999999999999999999999999999999E+6144
dqnextt801 nexttoward  Inf  -1000  ->  9.999999999999999999999999999999999E+6144
dqnextt802 nexttoward  Inf  -1     ->  9.999999999999999999999999999999999E+6144
dqnextt803 nexttoward  Inf  -0     ->  9.999999999999999999999999999999999E+6144
dqnextt804 nexttoward  Inf   0     ->  9.999999999999999999999999999999999E+6144
dqnextt805 nexttoward  Inf   1     ->  9.999999999999999999999999999999999E+6144
dqnextt806 nexttoward  Inf   1000  ->  9.999999999999999999999999999999999E+6144
dqnextt807 nexttoward  Inf   Inf   ->  Infinity
dqnextt808 nexttoward -1000  Inf   -> -999.9999999999999999999999999999999
dqnextt809 nexttoward -Inf   Inf   -> -9.999999999999999999999999999999999E+6144
dqnextt810 nexttoward -1     Inf   -> -0.9999999999999999999999999999999999
dqnextt811 nexttoward -0     Inf   ->  1E-6176           Underflow Subnormal Inexact Rounded
dqnextt812 nexttoward  0     Inf   ->  1E-6176           Underflow Subnormal Inexact Rounded
dqnextt813 nexttoward  1     Inf   ->  1.000000000000000000000000000000001
dqnextt814 nexttoward  1000  Inf   ->  1000.000000000000000000000000000001
dqnextt815 nexttoward  Inf   Inf   ->  Infinity

dqnextt821 nexttoward  NaN -Inf    ->  NaN
dqnextt822 nexttoward  NaN -1000   ->  NaN
dqnextt823 nexttoward  NaN -1      ->  NaN
dqnextt824 nexttoward  NaN -0      ->  NaN
dqnextt825 nexttoward  NaN  0      ->  NaN
dqnextt826 nexttoward  NaN  1      ->  NaN
dqnextt827 nexttoward  NaN  1000   ->  NaN
dqnextt828 nexttoward  NaN  Inf    ->  NaN
dqnextt829 nexttoward  NaN  NaN    ->  NaN
dqnextt830 nexttoward -Inf  NaN    ->  NaN
dqnextt831 nexttoward -1000 NaN    ->  NaN
dqnextt832 nexttoward -1    NaN    ->  NaN
dqnextt833 nexttoward -0    NaN    ->  NaN
dqnextt834 nexttoward  0    NaN    ->  NaN
dqnextt835 nexttoward  1    NaN    ->  NaN
dqnextt836 nexttoward  1000 NaN    ->  NaN
dqnextt837 nexttoward  Inf  NaN    ->  NaN

dqnextt841 nexttoward  sNaN -Inf   ->  NaN  Invalid_operation
dqnextt842 nexttoward  sNaN -1000  ->  NaN  Invalid_operation
dqnextt843 nexttoward  sNaN -1     ->  NaN  Invalid_operation
dqnextt844 nexttoward  sNaN -0     ->  NaN  Invalid_operation
dqnextt845 nexttoward  sNaN  0     ->  NaN  Invalid_operation
dqnextt846 nexttoward  sNaN  1     ->  NaN  Invalid_operation
dqnextt847 nexttoward  sNaN  1000  ->  NaN  Invalid_operation
dqnextt848 nexttoward  sNaN  NaN   ->  NaN  Invalid_operation
dqnextt849 nexttoward  sNaN sNaN   ->  NaN  Invalid_operation
dqnextt850 nexttoward  NaN  sNaN   ->  NaN  Invalid_operation
dqnextt851 nexttoward -Inf  sNaN   ->  NaN  Invalid_operation
dqnextt852 nexttoward -1000 sNaN   ->  NaN  Invalid_operation
dqnextt853 nexttoward -1    sNaN   ->  NaN  Invalid_operation
dqnextt854 nexttoward -0    sNaN   ->  NaN  Invalid_operation
dqnextt855 nexttoward  0    sNaN   ->  NaN  Invalid_operation
dqnextt856 nexttoward  1    sNaN   ->  NaN  Invalid_operation
dqnextt857 nexttoward  1000 sNaN   ->  NaN  Invalid_operation
dqnextt858 nexttoward  Inf  sNaN   ->  NaN  Invalid_operation
dqnextt859 nexttoward  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqnextt861 nexttoward  NaN1   -Inf    ->  NaN1
dqnextt862 nexttoward +NaN2   -1000   ->  NaN2
dqnextt863 nexttoward  NaN3    1000   ->  NaN3
dqnextt864 nexttoward  NaN4    Inf    ->  NaN4
dqnextt865 nexttoward  NaN5   +NaN6   ->  NaN5
dqnextt866 nexttoward -Inf     NaN7   ->  NaN7
dqnextt867 nexttoward -1000    NaN8   ->  NaN8
dqnextt868 nexttoward  1000    NaN9   ->  NaN9
dqnextt869 nexttoward  Inf    +NaN10  ->  NaN10
dqnextt871 nexttoward  sNaN11  -Inf   ->  NaN11  Invalid_operation
dqnextt872 nexttoward  sNaN12  -1000  ->  NaN12  Invalid_operation
dqnextt873 nexttoward  sNaN13   1000  ->  NaN13  Invalid_operation
dqnextt874 nexttoward  sNaN14   NaN17 ->  NaN14  Invalid_operation
dqnextt875 nexttoward  sNaN15  sNaN18 ->  NaN15  Invalid_operation
dqnextt876 nexttoward  NaN16   sNaN19 ->  NaN19  Invalid_operation
dqnextt877 nexttoward -Inf    +sNaN20 ->  NaN20  Invalid_operation
dqnextt878 nexttoward -1000    sNaN21 ->  NaN21  Invalid_operation
dqnextt879 nexttoward  1000    sNaN22 ->  NaN22  Invalid_operation
dqnextt880 nexttoward  Inf     sNaN23 ->  NaN23  Invalid_operation
dqnextt881 nexttoward +NaN25  +sNaN24 ->  NaN24  Invalid_operation
dqnextt882 nexttoward -NaN26    NaN28 -> -NaN26
dqnextt883 nexttoward -sNaN27  sNaN29 -> -NaN27  Invalid_operation
dqnextt884 nexttoward  1000    -NaN30 -> -NaN30
dqnextt885 nexttoward  1000   -sNaN31 -> -NaN31  Invalid_operation

-- Null tests
dqnextt900 nexttoward 1  # -> NaN Invalid_operation
dqnextt901 nexttoward #  1 -> NaN Invalid_operation

Added test/dectest/dqOr.decTest.



































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
------------------------------------------------------------------------
-- dqOr.decTest -- digitwise logical OR for decQuads                  --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Sanity check (truth table)
dqor001 or             0    0 ->    0
dqor002 or             0    1 ->    1
dqor003 or             1    0 ->    1
dqor004 or             1    1 ->    1
dqor005 or          1100 1010 -> 1110
-- and at msd and msd-1
dqor006 or 0000000000000000000000000000000000 0000000000000000000000000000000000 ->           0
dqor007 or 0000000000000000000000000000000000 1000000000000000000000000000000000 ->   1000000000000000000000000000000000
dqor008 or 1000000000000000000000000000000000 0000000000000000000000000000000000 ->   1000000000000000000000000000000000
dqor009 or 1000000000000000000000000000000000 1000000000000000000000000000000000 ->   1000000000000000000000000000000000
dqor010 or 0000000000000000000000000000000000 0000000000000000000000000000000000 ->           0
dqor011 or 0000000000000000000000000000000000 0100000000000000000000000000000000 ->    100000000000000000000000000000000
dqor012 or 0100000000000000000000000000000000 0000000000000000000000000000000000 ->    100000000000000000000000000000000
dqor013 or 0100000000000000000000000000000000 0100000000000000000000000000000000 ->    100000000000000000000000000000000

-- Various lengths
dqor601 or 0111111111111111111111111111111111 1111111111111111111111111111111110  -> 1111111111111111111111111111111111
dqor602 or 1011111111111111111111111111111111 1111111111111111111111111111111101  -> 1111111111111111111111111111111111
dqor603 or 1101111111111111111111111111111111 1111111111111111111111111111111011  -> 1111111111111111111111111111111111
dqor604 or 1110111111111111111111111111111111 1111111111111111111111111111110111  -> 1111111111111111111111111111111111
dqor605 or 1111011111111111111111111111111111 1111111111111111111111111111101111  -> 1111111111111111111111111111111111
dqor606 or 1111101111111111111111111111111111 1111111111111111111111111111011111  -> 1111111111111111111111111111111111
dqor607 or 1111110111111111111111111111111111 1111111111111111111111111110111111  -> 1111111111111111111111111111111111
dqor608 or 1111111011111111111111111111111111 1111111111111111111111111101111111  -> 1111111111111111111111111111111111
dqor609 or 1111111101111111111111111111111111 1111111111111111111111111011111111  -> 1111111111111111111111111111111111
dqor610 or 1111111110111111111111111111111111 1111111111111111111111110111111111  -> 1111111111111111111111111111111111
dqor611 or 1111111111011111111111111111111111 1111111111111111111111101111111111  -> 1111111111111111111111111111111111
dqor612 or 1111111111101111111111111111111111 1111111111111111111111011111111111  -> 1111111111111111111111111111111111
dqor613 or 1111111111110111111111111111111111 1111111111111111111110111111111111  -> 1111111111111111111111111111111111
dqor614 or 1111111111111011111111111111111111 1111111111111111111101111111111111  -> 1111111111111111111111111111111111
dqor615 or 1111111111111101111111111111111111 1111111111111111111011111111111111  -> 1111111111111111111111111111111111
dqor616 or 1111111111111110111111111111111111 1111111111111111110111111111111111  -> 1111111111111111111111111111111111
dqor617 or 1111111111111111011111111111111111 1111111111111111101111111111111111  -> 1111111111111111111111111111111111
dqor618 or 1111111111111111101111111111111111 1111111111111111011111111111111111  -> 1111111111111111111111111111111111
dqor619 or 1111111111111111110111111111111111 1111111111111110111111111111111111  -> 1111111111111111111111111111111111
dqor620 or 1111111111111111111011111111111111 1111111111111101111111111111111111  -> 1111111111111111111111111111111111
dqor621 or 1111111111111111111101111111111111 1111111111111011111111111111111111  -> 1111111111111111111111111111111111
dqor622 or 1111111111111111111110111111111111 1111111111110111111111111111111111  -> 1111111111111111111111111111111111
dqor623 or 1111111111111111111111011111111111 1111111111101111111111111111111111  -> 1111111111111111111111111111111111
dqor624 or 1111111111111111111111101111111111 1111111111011111111111111111111111  -> 1111111111111111111111111111111111
dqor625 or 1111111111111111111111110111111111 1111111110111111111111111111111111  -> 1111111111111111111111111111111111
dqor626 or 1111111111111111111111111011111111 1111111101111111111111111111111111  -> 1111111111111111111111111111111111
dqor627 or 1111111111111111111111111101111111 1111111011111111111111111111111111  -> 1111111111111111111111111111111111
dqor628 or 1111111111111111111111111110111111 1111110111111111111111111111111111  -> 1111111111111111111111111111111111
dqor629 or 1111111111111111111111111111011111 1111101111111111111111111111111111  -> 1111111111111111111111111111111111
dqor630 or 1111111111111111111111111111101111 1111011111111111111111111111111111  -> 1111111111111111111111111111111111
dqor631 or 1111111111111111111111111111110111 1110111111111111111111111111111111  -> 1111111111111111111111111111111111
dqor632 or 1111111111111111111111111111111011 1101111111111111111111111111111111  -> 1111111111111111111111111111111111
dqor633 or 1111111111111111111111111111111101 1011111111111111111111111111111111  -> 1111111111111111111111111111111111
dqor634 or 1111111111111111111111111111111110 0111111111111111111111111111111111  -> 1111111111111111111111111111111111

dqor641 or 1111111111111111111111111111111110 0111111111111111111111111111111111  -> 1111111111111111111111111111111111
dqor642 or 1111111111111111111111111111111101 1011111111111111111111111111111111  -> 1111111111111111111111111111111111
dqor643 or 1111111111111111111111111111111011 1101111111111111111111111111111111  -> 1111111111111111111111111111111111
dqor644 or 1111111111111111111111111111110111 1110111111111111111111111111111111  -> 1111111111111111111111111111111111
dqor645 or 1111111111111111111111111111101111 1111011111111111111111111111111111  -> 1111111111111111111111111111111111
dqor646 or 1111111111111111111111111111011111 1111101111111111111111111111111111  -> 1111111111111111111111111111111111
dqor647 or 1111111111111111111111111110111111 1111110111111111111111111111111111  -> 1111111111111111111111111111111111
dqor648 or 1111111111111111111111111101111111 1111111011111111111111111111111111  -> 1111111111111111111111111111111111
dqor649 or 1111111111111111111111111011111111 1111111101111111111111111111111111  -> 1111111111111111111111111111111111
dqor650 or 1111111111111111111111110111111111 1111111110111111111111111111111111  -> 1111111111111111111111111111111111
dqor651 or 1111111111111111111111101111111111 1111111111011111111111111111111111  -> 1111111111111111111111111111111111
dqor652 or 1111111111111111111111011111111111 1111111111101111111111111111111111  -> 1111111111111111111111111111111111
dqor653 or 1111111111111111111110111111111111 1111111111110111111111111111111111  -> 1111111111111111111111111111111111
dqor654 or 1111111111111111111101111111111111 1111111111111011111111111111111111  -> 1111111111111111111111111111111111
dqor655 or 1111111111111111111011111111111111 1111111111111101111111111111111111  -> 1111111111111111111111111111111111
dqor656 or 1111111111111111110111111111111111 1111111111111110111111111111111111  -> 1111111111111111111111111111111111
dqor657 or 1010101010101010101010101010101010 1010101010101010001010101010101010  -> 1010101010101010101010101010101010
dqor658 or 1111111111111111011111111111111111 1111111111111111101111111111111111  -> 1111111111111111111111111111111111
dqor659 or 1111111111111110111111111111111111 1111111111111111110111111111111111  -> 1111111111111111111111111111111111
dqor660 or 1111111111111101111111111111111111 1111111111111111111011111111111111  -> 1111111111111111111111111111111111
dqor661 or 1111111111111011111111111111111111 1111111111111111111101111111111111  -> 1111111111111111111111111111111111
dqor662 or 1111111111110111111111111111111111 1111111111111111111110111111111111  -> 1111111111111111111111111111111111
dqor663 or 1111111111101111111111111111111111 1111111111111111111111011111111111  -> 1111111111111111111111111111111111
dqor664 or 1111111111011111111111111111111111 1111111111111111111111101111111111  -> 1111111111111111111111111111111111
dqor665 or 1111111110111111111111111111111111 1111111111111111111111110111111111  -> 1111111111111111111111111111111111
dqor666 or 0101010101010101010101010101010101 0101010101010101010101010001010101  ->  101010101010101010101010101010101
dqor667 or 1111111011111111111111111111111111 1111111111111111111111111101111111  -> 1111111111111111111111111111111111
dqor668 or 1111110111111111111111111111111111 1111111111111111111111111110111111  -> 1111111111111111111111111111111111
dqor669 or 1111101111111111111111111111111111 1111111111111111111111111111011111  -> 1111111111111111111111111111111111
dqor670 or 1111011111111111111111111111111111 1111111111111111111111111111101111  -> 1111111111111111111111111111111111
dqor671 or 1110111111111111111111111111111111 1111111111111111111111111111110111  -> 1111111111111111111111111111111111
dqor672 or 1101111111111111111111111111111111 1111111111111111111111111111111011  -> 1111111111111111111111111111111111
dqor673 or 1011111111111111111111111111111111 1111111111111111111111111111111101  -> 1111111111111111111111111111111111
dqor674 or 0111111111111111111111111111111111 1111111111111111111111111111111110  -> 1111111111111111111111111111111111
dqor675 or 0111111111111111111111111111111110 1111111111111111111111111111111110  -> 1111111111111111111111111111111110
dqor676 or 1111111111111111111111111111111110 1111111111111111111111111111111110  -> 1111111111111111111111111111111110

dqor681 or 0111111111111111111111111111111111 0111111111011111111111111111111110  ->  111111111111111111111111111111111
dqor682 or 1011111111111111111111111111111111 1011111110101111111111111111111101  -> 1011111111111111111111111111111111
dqor683 or 1101111111111111111111111111111111 1101111101110111111111111111111011  -> 1101111111111111111111111111111111
dqor684 or 1110111111111111111111111111111111 1110111011111011111111111111110111  -> 1110111111111111111111111111111111
dqor685 or 1111011111111111111111111111111111 1111010111111101111111111111101111  -> 1111011111111111111111111111111111
dqor686 or 1111101111111111111111111111111111 1111101111111110111111111111011111  -> 1111101111111111111111111111111111
dqor687 or 1111110111111111111111111111111111 1111010111111111011111111110111111  -> 1111110111111111111111111111111111
dqor688 or 1111111011111111111111111111111111 1110111011111111101111111101111111  -> 1111111011111111111111111111111111
dqor689 or 1111111101111111111111111111111111 1101111101111111110111111011111111  -> 1111111101111111111111111111111111
dqor690 or 1111111110111111111111111111111111 1011111110111111111011110111111110  -> 1111111110111111111111111111111111
dqor691 or 1111111111011111111111111111111111 0111111111011111111101101111111101  -> 1111111111011111111111111111111111
dqor692 or 1111111111101111111111111111111111 1111111111101111111110011111111011  -> 1111111111101111111111111111111111
dqor693 or 1111111111110111111111111111111111 1111111111110111111110011111110111  -> 1111111111110111111111111111111111
dqor694 or 1111111111111011111111111111111111 1111111111111011111101101111101111  -> 1111111111111011111111111111111111
dqor695 or 1111111111111101111111111111111111 1111111111111101111011110111011111  -> 1111111111111101111111111111111111
dqor696 or 1111111111111110111111111111111111 1111111111111110110111111010111111  -> 1111111111111110111111111111111111
dqor697 or 1111111111111111011111111111111111 1111111111111111001111111101111111  -> 1111111111111111011111111111111111
dqor698 or 1111111111111111101111111111111111 1111111111111111001111111010111111  -> 1111111111111111101111111111111111
dqor699 or 1111111111111111110111111111111111 1111111111111110110111110111011111  -> 1111111111111111110111111111111111
dqor700 or 1111111111111111111011111111111111 1111111111111101111011101111101111  -> 1111111111111111111011111111111111
dqor701 or 1111111111111111111101111111111111 1111111111111011111101011111110111  -> 1111111111111111111101111111111111
dqor702 or 1111111111111111111110111111111111 1111111111110111111110111111111011  -> 1111111111111111111110111111111111
dqor703 or 1111111111111111111111011111111111 1111111111101111111101011111111101  -> 1111111111111111111111011111111111
dqor704 or 1111111111111111111111101111111111 1111111111011111111011101111111110  -> 1111111111111111111111101111111111
dqor705 or 1111111111111111111111110111111111 0111111110111111110111110111111111  -> 1111111111111111111111110111111111
dqor706 or 1111111111111111111111111011111111 1011111101111111101111111011111111  -> 1111111111111111111111111011111111
dqor707 or 1111111111111111111111111101111111 1101111011111111011111111101111111  -> 1111111111111111111111111101111111
dqor708 or 1111111111111111111111111110111111 1110110111111110111111111110111111  -> 1111111111111111111111111110111111
dqor709 or 1111111111111111111111111111011111 1111001111111101111111111111011111  -> 1111111111111111111111111111011111
dqor710 or 1111111111111111111111111111101111 1111001111111011111111111111101111  -> 1111111111111111111111111111101111
dqor711 or 1111111111111111111111111111110111 1110110111110111111111111111110111  -> 1111111111111111111111111111110111
dqor712 or 1111111111111111111111111111111011 1101111011101111111111111111111011  -> 1111111111111111111111111111111011
dqor713 or 1111111111111111111111111111111101 1011111101011111111111111111111101  -> 1111111111111111111111111111111101
dqor714 or 1111111111111111111111111111111110 0111111110111111111111111111111110  -> 1111111111111111111111111111111110



--         1234567890123456     1234567890123456 1234567890123456
dqor020 or 1111111111111111     1111111111111111  ->  1111111111111111
dqor021 or  111111111111111      111111111111111  ->   111111111111111
dqor022 or   11111111111111       11111111111111  ->    11111111111111
dqor023 or    1111111111111        1111111111111  ->     1111111111111
dqor024 or     111111111111         111111111111  ->      111111111111
dqor025 or      11111111111          11111111111  ->       11111111111
dqor026 or       1111111111           1111111111  ->        1111111111
dqor027 or        111111111            111111111  ->         111111111
dqor028 or         11111111             11111111  ->          11111111
dqor029 or          1111111              1111111  ->           1111111
dqor030 or           111111               111111  ->            111111
dqor031 or            11111                11111  ->             11111
dqor032 or             1111                 1111  ->              1111
dqor033 or              111                  111  ->               111
dqor034 or               11                   11  ->                11
dqor035 or                1                    1  ->                 1
dqor036 or                0                    0  ->                 0

dqor042 or  111111110000000     1111111110000000  ->  1111111110000000
dqor043 or   11111110000000     1000000100000000  ->  1011111110000000
dqor044 or    1111110000000     1000001000000000  ->  1001111110000000
dqor045 or     111110000000     1000010000000000  ->  1000111110000000
dqor046 or      11110000000     1000100000000000  ->  1000111110000000
dqor047 or       1110000000     1001000000000000  ->  1001001110000000
dqor048 or        110000000     1010000000000000  ->  1010000110000000
dqor049 or         10000000     1100000000000000  ->  1100000010000000

dqor090 or 011111111  111101111  ->  111111111
dqor091 or 101111111  111101111  ->  111111111
dqor092 or 110111111  111101111  ->  111111111
dqor093 or 111011111  111101111  ->  111111111
dqor094 or 111101111  111101111  ->  111101111
dqor095 or 111110111  111101111  ->  111111111
dqor096 or 111111011  111101111  ->  111111111
dqor097 or 111111101  111101111  ->  111111111
dqor098 or 111111110  111101111  ->  111111111

dqor100 or 111101111  011111111  ->  111111111
dqor101 or 111101111  101111111  ->  111111111
dqor102 or 111101111  110111111  ->  111111111
dqor103 or 111101111  111011111  ->  111111111
dqor104 or 111101111  111101111  ->  111101111
dqor105 or 111101111  111110111  ->  111111111
dqor106 or 111101111  111111011  ->  111111111
dqor107 or 111101111  111111101  ->  111111111
dqor108 or 111101111  111111110  ->  111111111

-- non-0/1 should not be accepted, nor should signs
dqor220 or 111111112  111111111  ->  NaN Invalid_operation
dqor221 or 333333333  333333333  ->  NaN Invalid_operation
dqor222 or 555555555  555555555  ->  NaN Invalid_operation
dqor223 or 777777777  777777777  ->  NaN Invalid_operation
dqor224 or 999999999  999999999  ->  NaN Invalid_operation
dqor225 or 222222222  999999999  ->  NaN Invalid_operation
dqor226 or 444444444  999999999  ->  NaN Invalid_operation
dqor227 or 666666666  999999999  ->  NaN Invalid_operation
dqor228 or 888888888  999999999  ->  NaN Invalid_operation
dqor229 or 999999999  222222222  ->  NaN Invalid_operation
dqor230 or 999999999  444444444  ->  NaN Invalid_operation
dqor231 or 999999999  666666666  ->  NaN Invalid_operation
dqor232 or 999999999  888888888  ->  NaN Invalid_operation
-- a few randoms
dqor240 or  567468689 -934981942 ->  NaN Invalid_operation
dqor241 or  567367689  934981942 ->  NaN Invalid_operation
dqor242 or -631917772 -706014634 ->  NaN Invalid_operation
dqor243 or -756253257  138579234 ->  NaN Invalid_operation
dqor244 or  835590149  567435400 ->  NaN Invalid_operation
-- test MSD
dqor250 or  2000000111000111000111000000000000 1000000111000111000111000000000000 ->  NaN Invalid_operation
dqor251 or  7000000111000111000111000000000000 1000000111000111000111000000000000 ->  NaN Invalid_operation
dqor252 or  8000000111000111000111000000000000 1000000111000111000111000000000000 ->  NaN Invalid_operation
dqor253 or  9000000111000111000111000000000000 1000000111000111000111000000000000 ->  NaN Invalid_operation
dqor254 or  2000000111000111000111000000000000 0000000111000111000111000000000000 ->  NaN Invalid_operation
dqor255 or  7000000111000111000111000000000000 0000000111000111000111000000000000 ->  NaN Invalid_operation
dqor256 or  8000000111000111000111000000000000 0000000111000111000111000000000000 ->  NaN Invalid_operation
dqor257 or  9000000111000111000111000000000000 0000000111000111000111000000000000 ->  NaN Invalid_operation
dqor258 or  1000000111000111000111000000000000 2000000111000111000111000000000000 ->  NaN Invalid_operation
dqor259 or  1000000111000111000111000000000000 7000000111000111000111000000000000 ->  NaN Invalid_operation
dqor260 or  1000000111000111000111000000000000 8000000111000111000111000000000000 ->  NaN Invalid_operation
dqor261 or  1000000111000111000111000000000000 9000000111000111000111000000000000 ->  NaN Invalid_operation
dqor262 or  0000000111000111000111000000000000 2000000111000111000111000000000000 ->  NaN Invalid_operation
dqor263 or  0000000111000111000111000000000000 7000000111000111000111000000000000 ->  NaN Invalid_operation
dqor264 or  0000000111000111000111000000000000 8000000111000111000111000000000000 ->  NaN Invalid_operation
dqor265 or  0000000111000111000111000000000000 9000000111000111000111000000000000 ->  NaN Invalid_operation
-- test MSD-1
dqor270 or  0200000111000111000111001000000000 1000000111000111000111100000000010 ->  NaN Invalid_operation
dqor271 or  0700000111000111000111000100000000 1000000111000111000111010000000100 ->  NaN Invalid_operation
dqor272 or  0800000111000111000111000010000000 1000000111000111000111001000001000 ->  NaN Invalid_operation
dqor273 or  0900000111000111000111000001000000 1000000111000111000111000100010000 ->  NaN Invalid_operation
dqor274 or  1000000111000111000111000000100000 0200000111000111000111000010100000 ->  NaN Invalid_operation
dqor275 or  1000000111000111000111000000010000 0700000111000111000111000001000000 ->  NaN Invalid_operation
dqor276 or  1000000111000111000111000000001000 0800000111000111000111000010100000 ->  NaN Invalid_operation
dqor277 or  1000000111000111000111000000000100 0900000111000111000111000000010000 ->  NaN Invalid_operation
-- test LSD
dqor280 or  0010000111000111000111000000000002 1000000111000111000111000100000001 ->  NaN Invalid_operation
dqor281 or  0001000111000111000111000000000007 1000000111000111000111001000000011 ->  NaN Invalid_operation
dqor282 or  0000000111000111000111100000000008 1000000111000111000111010000000001 ->  NaN Invalid_operation
dqor283 or  0000000111000111000111010000000009 1000000111000111000111100000000001 ->  NaN Invalid_operation
dqor284 or  1000000111000111000111001000000000 0001000111000111000111000000000002 ->  NaN Invalid_operation
dqor285 or  1000000111000111000111000100000000 0010000111000111000111000000000007 ->  NaN Invalid_operation
dqor286 or  1000000111000111000111000010000000 0100000111000111000111000000000008 ->  NaN Invalid_operation
dqor287 or  1000000111000111000111000001000000 1000000111000111000111000000000009 ->  NaN Invalid_operation
-- test Middie
dqor288 or  0010000111000111000111000020000000 1000000111000111000111001000000000 ->  NaN Invalid_operation
dqor289 or  0001000111000111000111000070000001 1000000111000111000111000100000000 ->  NaN Invalid_operation
dqor290 or  0000000111000111000111100080000010 1000000111000111000111000010000000 ->  NaN Invalid_operation
dqor291 or  0000000111000111000111010090000100 1000000111000111000111000001000000 ->  NaN Invalid_operation
dqor292 or  1000000111000111000111001000001000 0000000111000111000111000020100000 ->  NaN Invalid_operation
dqor293 or  1000000111000111000111000100010000 0000000111000111000111000070010000 ->  NaN Invalid_operation
dqor294 or  1000000111000111000111000010100000 0000000111000111000111000080001000 ->  NaN Invalid_operation
dqor295 or  1000000111000111000111000001000000 0000000111000111000111000090000100 ->  NaN Invalid_operation
-- signs
dqor296 or -1000000111000111000111000001000000 -0000001110001110001110010000000100 ->  NaN Invalid_operation
dqor297 or -1000000111000111000111000001000000  0000001110001110001110000010000100 ->  NaN Invalid_operation
dqor298 or  1000000111000111000111000001000000 -0000001110001110001110001000000100 ->  NaN Invalid_operation
dqor299 or  1000000111000111000111000001000000  0000001110001110001110000011000100 ->  1000001111001111001111000011000100

-- Nmax, Nmin, Ntiny-like
dqor331 or  2   9.99999999E+1999    -> NaN Invalid_operation
dqor332 or  3   1E-1999             -> NaN Invalid_operation
dqor333 or  4   1.00000000E-1999    -> NaN Invalid_operation
dqor334 or  5   1E-1009             -> NaN Invalid_operation
dqor335 or  6   -1E-1009            -> NaN Invalid_operation
dqor336 or  7   -1.00000000E-1999   -> NaN Invalid_operation
dqor337 or  8   -1E-1999            -> NaN Invalid_operation
dqor338 or  9   -9.99999999E+1999   -> NaN Invalid_operation
dqor341 or  9.99999999E+2999    -18 -> NaN Invalid_operation
dqor342 or  1E-2999              01 -> NaN Invalid_operation
dqor343 or  1.00000000E-2999    -18 -> NaN Invalid_operation
dqor344 or  1E-1009              18 -> NaN Invalid_operation
dqor345 or  -1E-1009            -10 -> NaN Invalid_operation
dqor346 or  -1.00000000E-2999    18 -> NaN Invalid_operation
dqor347 or  -1E-2999             10 -> NaN Invalid_operation
dqor348 or  -9.99999999E+2999   -18 -> NaN Invalid_operation

-- A few other non-integers
dqor361 or  1.0                  1  -> NaN Invalid_operation
dqor362 or  1E+1                 1  -> NaN Invalid_operation
dqor363 or  0.0                  1  -> NaN Invalid_operation
dqor364 or  0E+1                 1  -> NaN Invalid_operation
dqor365 or  9.9                  1  -> NaN Invalid_operation
dqor366 or  9E+1                 1  -> NaN Invalid_operation
dqor371 or  0 1.0                   -> NaN Invalid_operation
dqor372 or  0 1E+1                  -> NaN Invalid_operation
dqor373 or  0 0.0                   -> NaN Invalid_operation
dqor374 or  0 0E+1                  -> NaN Invalid_operation
dqor375 or  0 9.9                   -> NaN Invalid_operation
dqor376 or  0 9E+1                  -> NaN Invalid_operation

-- All Specials are in error
dqor780 or -Inf  -Inf   -> NaN Invalid_operation
dqor781 or -Inf  -1000  -> NaN Invalid_operation
dqor782 or -Inf  -1     -> NaN Invalid_operation
dqor783 or -Inf  -0     -> NaN Invalid_operation
dqor784 or -Inf   0     -> NaN Invalid_operation
dqor785 or -Inf   1     -> NaN Invalid_operation
dqor786 or -Inf   1000  -> NaN Invalid_operation
dqor787 or -1000 -Inf   -> NaN Invalid_operation
dqor788 or -Inf  -Inf   -> NaN Invalid_operation
dqor789 or -1    -Inf   -> NaN Invalid_operation
dqor790 or -0    -Inf   -> NaN Invalid_operation
dqor791 or  0    -Inf   -> NaN Invalid_operation
dqor792 or  1    -Inf   -> NaN Invalid_operation
dqor793 or  1000 -Inf   -> NaN Invalid_operation
dqor794 or  Inf  -Inf   -> NaN Invalid_operation

dqor800 or  Inf  -Inf   -> NaN Invalid_operation
dqor801 or  Inf  -1000  -> NaN Invalid_operation
dqor802 or  Inf  -1     -> NaN Invalid_operation
dqor803 or  Inf  -0     -> NaN Invalid_operation
dqor804 or  Inf   0     -> NaN Invalid_operation
dqor805 or  Inf   1     -> NaN Invalid_operation
dqor806 or  Inf   1000  -> NaN Invalid_operation
dqor807 or  Inf   Inf   -> NaN Invalid_operation
dqor808 or -1000  Inf   -> NaN Invalid_operation
dqor809 or -Inf   Inf   -> NaN Invalid_operation
dqor810 or -1     Inf   -> NaN Invalid_operation
dqor811 or -0     Inf   -> NaN Invalid_operation
dqor812 or  0     Inf   -> NaN Invalid_operation
dqor813 or  1     Inf   -> NaN Invalid_operation
dqor814 or  1000  Inf   -> NaN Invalid_operation
dqor815 or  Inf   Inf   -> NaN Invalid_operation

dqor821 or  NaN -Inf    -> NaN Invalid_operation
dqor822 or  NaN -1000   -> NaN Invalid_operation
dqor823 or  NaN -1      -> NaN Invalid_operation
dqor824 or  NaN -0      -> NaN Invalid_operation
dqor825 or  NaN  0      -> NaN Invalid_operation
dqor826 or  NaN  1      -> NaN Invalid_operation
dqor827 or  NaN  1000   -> NaN Invalid_operation
dqor828 or  NaN  Inf    -> NaN Invalid_operation
dqor829 or  NaN  NaN    -> NaN Invalid_operation
dqor830 or -Inf  NaN    -> NaN Invalid_operation
dqor831 or -1000 NaN    -> NaN Invalid_operation
dqor832 or -1    NaN    -> NaN Invalid_operation
dqor833 or -0    NaN    -> NaN Invalid_operation
dqor834 or  0    NaN    -> NaN Invalid_operation
dqor835 or  1    NaN    -> NaN Invalid_operation
dqor836 or  1000 NaN    -> NaN Invalid_operation
dqor837 or  Inf  NaN    -> NaN Invalid_operation

dqor841 or  sNaN -Inf   ->  NaN  Invalid_operation
dqor842 or  sNaN -1000  ->  NaN  Invalid_operation
dqor843 or  sNaN -1     ->  NaN  Invalid_operation
dqor844 or  sNaN -0     ->  NaN  Invalid_operation
dqor845 or  sNaN  0     ->  NaN  Invalid_operation
dqor846 or  sNaN  1     ->  NaN  Invalid_operation
dqor847 or  sNaN  1000  ->  NaN  Invalid_operation
dqor848 or  sNaN  NaN   ->  NaN  Invalid_operation
dqor849 or  sNaN sNaN   ->  NaN  Invalid_operation
dqor850 or  NaN  sNaN   ->  NaN  Invalid_operation
dqor851 or -Inf  sNaN   ->  NaN  Invalid_operation
dqor852 or -1000 sNaN   ->  NaN  Invalid_operation
dqor853 or -1    sNaN   ->  NaN  Invalid_operation
dqor854 or -0    sNaN   ->  NaN  Invalid_operation
dqor855 or  0    sNaN   ->  NaN  Invalid_operation
dqor856 or  1    sNaN   ->  NaN  Invalid_operation
dqor857 or  1000 sNaN   ->  NaN  Invalid_operation
dqor858 or  Inf  sNaN   ->  NaN  Invalid_operation
dqor859 or  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqor861 or  NaN1   -Inf    -> NaN Invalid_operation
dqor862 or +NaN2   -1000   -> NaN Invalid_operation
dqor863 or  NaN3    1000   -> NaN Invalid_operation
dqor864 or  NaN4    Inf    -> NaN Invalid_operation
dqor865 or  NaN5   +NaN6   -> NaN Invalid_operation
dqor866 or -Inf     NaN7   -> NaN Invalid_operation
dqor867 or -1000    NaN8   -> NaN Invalid_operation
dqor868 or  1000    NaN9   -> NaN Invalid_operation
dqor869 or  Inf    +NaN10  -> NaN Invalid_operation
dqor871 or  sNaN11  -Inf   -> NaN Invalid_operation
dqor872 or  sNaN12  -1000  -> NaN Invalid_operation
dqor873 or  sNaN13   1000  -> NaN Invalid_operation
dqor874 or  sNaN14   NaN17 -> NaN Invalid_operation
dqor875 or  sNaN15  sNaN18 -> NaN Invalid_operation
dqor876 or  NaN16   sNaN19 -> NaN Invalid_operation
dqor877 or -Inf    +sNaN20 -> NaN Invalid_operation
dqor878 or -1000    sNaN21 -> NaN Invalid_operation
dqor879 or  1000    sNaN22 -> NaN Invalid_operation
dqor880 or  Inf     sNaN23 -> NaN Invalid_operation
dqor881 or +NaN25  +sNaN24 -> NaN Invalid_operation
dqor882 or -NaN26    NaN28 -> NaN Invalid_operation
dqor883 or -sNaN27  sNaN29 -> NaN Invalid_operation
dqor884 or  1000    -NaN30 -> NaN Invalid_operation
dqor885 or  1000   -sNaN31 -> NaN Invalid_operation

Added test/dectest/dqPlus.decTest.

















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
------------------------------------------------------------------------
-- dqPlus.decTest -- decQuad 0+x                                      --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Sanity check
dqpls001 plus       +7.50  -> 7.50

-- Infinities
dqpls011 plus  Infinity    -> Infinity
dqpls012 plus  -Infinity   -> -Infinity

-- NaNs, 0 payload
ddqls021 plus         NaN  -> NaN
ddqls022 plus        -NaN  -> -NaN
ddqls023 plus        sNaN  -> NaN  Invalid_operation
ddqls024 plus       -sNaN  -> -NaN Invalid_operation

-- NaNs, non-0 payload
ddqls031 plus       NaN13  -> NaN13
ddqls032 plus      -NaN13  -> -NaN13
ddqls033 plus      sNaN13  -> NaN13   Invalid_operation
ddqls034 plus     -sNaN13  -> -NaN13  Invalid_operation
ddqls035 plus       NaN70  -> NaN70
ddqls036 plus      -NaN70  -> -NaN70
ddqls037 plus      sNaN101 -> NaN101  Invalid_operation
ddqls038 plus     -sNaN101 -> -NaN101 Invalid_operation

-- finites
dqpls101 plus          7   -> 7
dqpls102 plus         -7   -> -7
dqpls103 plus         75   -> 75
dqpls104 plus        -75   -> -75
dqpls105 plus       7.50   -> 7.50
dqpls106 plus      -7.50   -> -7.50
dqpls107 plus       7.500  -> 7.500
dqpls108 plus      -7.500  -> -7.500

-- zeros
dqpls111 plus          0   -> 0
dqpls112 plus         -0   -> 0
dqpls113 plus       0E+4   -> 0E+4
dqpls114 plus      -0E+4   -> 0E+4
dqpls115 plus     0.0000   -> 0.0000
dqpls116 plus    -0.0000   -> 0.0000
dqpls117 plus      0E-141  -> 0E-141
dqpls118 plus     -0E-141  -> 0E-141

-- full coefficients, alternating bits
dqpls121 plus   2682682682682682682682682682682682    ->  2682682682682682682682682682682682
dqpls122 plus  -2682682682682682682682682682682682    -> -2682682682682682682682682682682682
dqpls123 plus   1341341341341341341341341341341341    ->  1341341341341341341341341341341341
dqpls124 plus  -1341341341341341341341341341341341    -> -1341341341341341341341341341341341

-- Nmax, Nmin, Ntiny
dqpls131 plus  9.999999999999999999999999999999999E+6144   ->  9.999999999999999999999999999999999E+6144
dqpls132 plus  1E-6143                                     ->  1E-6143
dqpls133 plus  1.000000000000000000000000000000000E-6143   ->  1.000000000000000000000000000000000E-6143
dqpls134 plus  1E-6176                                     ->  1E-6176 Subnormal

dqpls135 plus  -1E-6176                                    -> -1E-6176 Subnormal
dqpls136 plus  -1.000000000000000000000000000000000E-6143  -> -1.000000000000000000000000000000000E-6143
dqpls137 plus  -1E-6143                                    -> -1E-6143
dqpls138 plus  -9.999999999999999999999999999999999E+6144  -> -9.999999999999999999999999999999999E+6144

Added test/dectest/dqQuantize.decTest.















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
------------------------------------------------------------------------
-- dqQuantize.decTest -- decQuad quantize operation                   --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Most of the tests here assume a "regular pattern", where the
-- sign and coefficient are +1.
-- 2004.03.15 Underflow for quantize is suppressed
-- 2005.06.08 More extensive tests for 'does not fit'
-- [Forked from quantize.decTest 2006.11.25]

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks
dqqua001 quantize 0       1e0   -> 0
dqqua002 quantize 1       1e0   -> 1
dqqua003 quantize 0.1    1e+2   -> 0E+2 Inexact Rounded
dqqua005 quantize 0.1    1e+1   -> 0E+1 Inexact Rounded
dqqua006 quantize 0.1     1e0   -> 0 Inexact Rounded
dqqua007 quantize 0.1    1e-1   -> 0.1
dqqua008 quantize 0.1    1e-2   -> 0.10
dqqua009 quantize 0.1    1e-3   -> 0.100
dqqua010 quantize 0.9    1e+2   -> 0E+2 Inexact Rounded
dqqua011 quantize 0.9    1e+1   -> 0E+1 Inexact Rounded
dqqua012 quantize 0.9    1e+0   -> 1 Inexact Rounded
dqqua013 quantize 0.9    1e-1   -> 0.9
dqqua014 quantize 0.9    1e-2   -> 0.90
dqqua015 quantize 0.9    1e-3   -> 0.900
-- negatives
dqqua021 quantize -0      1e0   -> -0
dqqua022 quantize -1      1e0   -> -1
dqqua023 quantize -0.1   1e+2   -> -0E+2 Inexact Rounded
dqqua025 quantize -0.1   1e+1   -> -0E+1 Inexact Rounded
dqqua026 quantize -0.1    1e0   -> -0 Inexact Rounded
dqqua027 quantize -0.1   1e-1   -> -0.1
dqqua028 quantize -0.1   1e-2   -> -0.10
dqqua029 quantize -0.1   1e-3   -> -0.100
dqqua030 quantize -0.9   1e+2   -> -0E+2 Inexact Rounded
dqqua031 quantize -0.9   1e+1   -> -0E+1 Inexact Rounded
dqqua032 quantize -0.9   1e+0   -> -1 Inexact Rounded
dqqua033 quantize -0.9   1e-1   -> -0.9
dqqua034 quantize -0.9   1e-2   -> -0.90
dqqua035 quantize -0.9   1e-3   -> -0.900
dqqua036 quantize -0.5   1e+2   -> -0E+2 Inexact Rounded
dqqua037 quantize -0.5   1e+1   -> -0E+1 Inexact Rounded
dqqua038 quantize -0.5   1e+0   -> -0 Inexact Rounded
dqqua039 quantize -0.5   1e-1   -> -0.5
dqqua040 quantize -0.5   1e-2   -> -0.50
dqqua041 quantize -0.5   1e-3   -> -0.500
dqqua042 quantize -0.9   1e+2   -> -0E+2 Inexact Rounded
dqqua043 quantize -0.9   1e+1   -> -0E+1 Inexact Rounded
dqqua044 quantize -0.9   1e+0   -> -1 Inexact Rounded
dqqua045 quantize -0.9   1e-1   -> -0.9
dqqua046 quantize -0.9   1e-2   -> -0.90
dqqua047 quantize -0.9   1e-3   -> -0.900

-- examples from Specification
dqqua060 quantize 2.17   0.001  -> 2.170
dqqua061 quantize 2.17   0.01   -> 2.17
dqqua062 quantize 2.17   0.1    -> 2.2 Inexact Rounded
dqqua063 quantize 2.17   1e+0   -> 2 Inexact Rounded
dqqua064 quantize 2.17   1e+1   -> 0E+1 Inexact Rounded
dqqua065 quantize -Inf    Inf   -> -Infinity
dqqua066 quantize 2       Inf   -> NaN Invalid_operation
dqqua067 quantize -0.1    1     -> -0 Inexact Rounded
dqqua068 quantize -0      1e+5     -> -0E+5
dqqua069 quantize +123451234567899876543216789012345.6 1e-2 -> NaN Invalid_operation
dqqua070 quantize -987651234567899876543214335236450.6 1e-2 -> NaN Invalid_operation
dqqua071 quantize 217    1e-1   -> 217.0
dqqua072 quantize 217    1e+0   -> 217
dqqua073 quantize 217    1e+1   -> 2.2E+2 Inexact Rounded
dqqua074 quantize 217    1e+2   -> 2E+2 Inexact Rounded

-- general tests ..
dqqua089 quantize 12     1e+4   -> 0E+4 Inexact Rounded
dqqua090 quantize 12     1e+3   -> 0E+3 Inexact Rounded
dqqua091 quantize 12     1e+2   -> 0E+2 Inexact Rounded
dqqua092 quantize 12     1e+1   -> 1E+1 Inexact Rounded
dqqua093 quantize 1.2345 1e-2   -> 1.23 Inexact Rounded
dqqua094 quantize 1.2355 1e-2   -> 1.24 Inexact Rounded
dqqua095 quantize 1.2345 1e-6   -> 1.234500
dqqua096 quantize 9.9999 1e-2   -> 10.00 Inexact Rounded
dqqua097 quantize 0.0001 1e-2   -> 0.00 Inexact Rounded
dqqua098 quantize 0.001  1e-2   -> 0.00 Inexact Rounded
dqqua099 quantize 0.009  1e-2   -> 0.01 Inexact Rounded
dqqua100 quantize 92     1e+2   -> 1E+2 Inexact Rounded

dqqua101 quantize -1      1e0   ->  -1
dqqua102 quantize -1     1e-1   ->  -1.0
dqqua103 quantize -1     1e-2   ->  -1.00
dqqua104 quantize  0      1e0   ->  0
dqqua105 quantize  0     1e-1   ->  0.0
dqqua106 quantize  0     1e-2   ->  0.00
dqqua107 quantize  0.00   1e0   ->  0
dqqua108 quantize  0     1e+1   ->  0E+1
dqqua109 quantize  0     1e+2   ->  0E+2
dqqua110 quantize +1      1e0   ->  1
dqqua111 quantize +1     1e-1   ->  1.0
dqqua112 quantize +1     1e-2   ->  1.00

dqqua120 quantize   1.04  1e-3 ->  1.040
dqqua121 quantize   1.04  1e-2 ->  1.04
dqqua122 quantize   1.04  1e-1 ->  1.0 Inexact Rounded
dqqua123 quantize   1.04   1e0 ->  1 Inexact Rounded
dqqua124 quantize   1.05  1e-3 ->  1.050
dqqua125 quantize   1.05  1e-2 ->  1.05
dqqua126 quantize   1.05  1e-1 ->  1.0 Inexact Rounded
dqqua131 quantize   1.05   1e0 ->  1 Inexact Rounded
dqqua132 quantize   1.06  1e-3 ->  1.060
dqqua133 quantize   1.06  1e-2 ->  1.06
dqqua134 quantize   1.06  1e-1 ->  1.1 Inexact Rounded
dqqua135 quantize   1.06   1e0 ->  1 Inexact Rounded

dqqua140 quantize   -10    1e-2  ->  -10.00
dqqua141 quantize   +1     1e-2  ->  1.00
dqqua142 quantize   +10    1e-2  ->  10.00
dqqua143 quantize   1E+37  1e-2  ->  NaN Invalid_operation
dqqua144 quantize   1E-37  1e-2  ->  0.00 Inexact Rounded
dqqua145 quantize   1E-3   1e-2  ->  0.00 Inexact Rounded
dqqua146 quantize   1E-2   1e-2  ->  0.01
dqqua147 quantize   1E-1   1e-2  ->  0.10
dqqua148 quantize   0E-37  1e-2  ->  0.00

dqqua150 quantize   1.0600 1e-5 ->  1.06000
dqqua151 quantize   1.0600 1e-4 ->  1.0600
dqqua152 quantize   1.0600 1e-3 ->  1.060 Rounded
dqqua153 quantize   1.0600 1e-2 ->  1.06 Rounded
dqqua154 quantize   1.0600 1e-1 ->  1.1 Inexact Rounded
dqqua155 quantize   1.0600  1e0 ->  1 Inexact Rounded

-- a couple where rounding was different in base tests
rounding:    half_up
dqqua157 quantize -0.5   1e+0   -> -1 Inexact Rounded
dqqua158 quantize   1.05  1e-1 ->  1.1 Inexact Rounded
dqqua159 quantize   1.06   1e0 ->  1 Inexact Rounded
rounding:    half_even

-- base tests with non-1 coefficients
dqqua161 quantize 0      -9e0   -> 0
dqqua162 quantize 1      -7e0   -> 1
dqqua163 quantize 0.1   -1e+2   -> 0E+2 Inexact Rounded
dqqua165 quantize 0.1    0e+1   -> 0E+1 Inexact Rounded
dqqua166 quantize 0.1     2e0   -> 0 Inexact Rounded
dqqua167 quantize 0.1    3e-1   -> 0.1
dqqua168 quantize 0.1   44e-2   -> 0.10
dqqua169 quantize 0.1  555e-3   -> 0.100
dqqua170 quantize 0.9 6666e+2   -> 0E+2 Inexact Rounded
dqqua171 quantize 0.9 -777e+1   -> 0E+1 Inexact Rounded
dqqua172 quantize 0.9  -88e+0   -> 1 Inexact Rounded
dqqua173 quantize 0.9   -9e-1   -> 0.9
dqqua174 quantize 0.9    0e-2   -> 0.90
dqqua175 quantize 0.9  1.1e-3   -> 0.9000
-- negatives
dqqua181 quantize -0    1.1e0   -> -0.0
dqqua182 quantize -1     -1e0   -> -1
dqqua183 quantize -0.1  11e+2   -> -0E+2 Inexact Rounded
dqqua185 quantize -0.1 111e+1   -> -0E+1 Inexact Rounded
dqqua186 quantize -0.1   71e0   -> -0 Inexact Rounded
dqqua187 quantize -0.1 -91e-1   -> -0.1
dqqua188 quantize -0.1 -.1e-2   -> -0.100
dqqua189 quantize -0.1  -1e-3   -> -0.100
dqqua190 quantize -0.9   0e+2   -> -0E+2 Inexact Rounded
dqqua191 quantize -0.9  -0e+1   -> -0E+1 Inexact Rounded
dqqua192 quantize -0.9 -10e+0   -> -1 Inexact Rounded
dqqua193 quantize -0.9 100e-1   -> -0.9
dqqua194 quantize -0.9 999e-2   -> -0.90

-- +ve exponents ..
dqqua201 quantize   -1   1e+0 ->  -1
dqqua202 quantize   -1   1e+1 ->  -0E+1 Inexact Rounded
dqqua203 quantize   -1   1e+2 ->  -0E+2 Inexact Rounded
dqqua204 quantize    0   1e+0 ->  0
dqqua205 quantize    0   1e+1 ->  0E+1
dqqua206 quantize    0   1e+2 ->  0E+2
dqqua207 quantize   +1   1e+0 ->  1
dqqua208 quantize   +1   1e+1 ->  0E+1 Inexact Rounded
dqqua209 quantize   +1   1e+2 ->  0E+2 Inexact Rounded

dqqua220 quantize   1.04 1e+3 ->  0E+3 Inexact Rounded
dqqua221 quantize   1.04 1e+2 ->  0E+2 Inexact Rounded
dqqua222 quantize   1.04 1e+1 ->  0E+1 Inexact Rounded
dqqua223 quantize   1.04 1e+0 ->  1 Inexact Rounded
dqqua224 quantize   1.05 1e+3 ->  0E+3 Inexact Rounded
dqqua225 quantize   1.05 1e+2 ->  0E+2 Inexact Rounded
dqqua226 quantize   1.05 1e+1 ->  0E+1 Inexact Rounded
dqqua227 quantize   1.05 1e+0 ->  1 Inexact Rounded
dqqua228 quantize   1.05 1e+3 ->  0E+3 Inexact Rounded
dqqua229 quantize   1.05 1e+2 ->  0E+2 Inexact Rounded
dqqua230 quantize   1.05 1e+1 ->  0E+1 Inexact Rounded
dqqua231 quantize   1.05 1e+0 ->  1 Inexact Rounded
dqqua232 quantize   1.06 1e+3 ->  0E+3 Inexact Rounded
dqqua233 quantize   1.06 1e+2 ->  0E+2 Inexact Rounded
dqqua234 quantize   1.06 1e+1 ->  0E+1 Inexact Rounded
dqqua235 quantize   1.06 1e+0 ->  1 Inexact Rounded

dqqua240 quantize   -10   1e+1  ->  -1E+1 Rounded
dqqua241 quantize   +1    1e+1  ->  0E+1 Inexact Rounded
dqqua242 quantize   +10   1e+1  ->  1E+1 Rounded
dqqua243 quantize   1E+1  1e+1  ->  1E+1          -- underneath this is E+1
dqqua244 quantize   1E+2  1e+1  ->  1.0E+2        -- underneath this is E+1
dqqua245 quantize   1E+3  1e+1  ->  1.00E+3       -- underneath this is E+1
dqqua246 quantize   1E+4  1e+1  ->  1.000E+4      -- underneath this is E+1
dqqua247 quantize   1E+5  1e+1  ->  1.0000E+5     -- underneath this is E+1
dqqua248 quantize   1E+6  1e+1  ->  1.00000E+6    -- underneath this is E+1
dqqua249 quantize   1E+7  1e+1  ->  1.000000E+7   -- underneath this is E+1
dqqua250 quantize   1E+8  1e+1  ->  1.0000000E+8  -- underneath this is E+1
dqqua251 quantize   1E+9  1e+1  ->  1.00000000E+9 -- underneath this is E+1
-- next one tries to add 9 zeros
dqqua252 quantize   1E+37 1e+1  ->  NaN Invalid_operation
dqqua253 quantize   1E-37 1e+1  ->  0E+1 Inexact Rounded
dqqua254 quantize   1E-2  1e+1  ->  0E+1 Inexact Rounded
dqqua255 quantize   0E-37 1e+1  ->  0E+1
dqqua256 quantize  -0E-37 1e+1  -> -0E+1
dqqua257 quantize  -0E-1  1e+1  -> -0E+1
dqqua258 quantize  -0     1e+1  -> -0E+1
dqqua259 quantize  -0E+1  1e+1  -> -0E+1

dqqua260 quantize   -10   1e+2  ->  -0E+2 Inexact Rounded
dqqua261 quantize   +1    1e+2  ->  0E+2 Inexact Rounded
dqqua262 quantize   +10   1e+2  ->  0E+2 Inexact Rounded
dqqua263 quantize   1E+1  1e+2  ->  0E+2 Inexact Rounded
dqqua264 quantize   1E+2  1e+2  ->  1E+2
dqqua265 quantize   1E+3  1e+2  ->  1.0E+3
dqqua266 quantize   1E+4  1e+2  ->  1.00E+4
dqqua267 quantize   1E+5  1e+2  ->  1.000E+5
dqqua268 quantize   1E+6  1e+2  ->  1.0000E+6
dqqua269 quantize   1E+7  1e+2  ->  1.00000E+7
dqqua270 quantize   1E+8  1e+2  ->  1.000000E+8
dqqua271 quantize   1E+9  1e+2  ->  1.0000000E+9
dqqua272 quantize   1E+10 1e+2  ->  1.00000000E+10
dqqua273 quantize   1E-10 1e+2  ->  0E+2 Inexact Rounded
dqqua274 quantize   1E-2  1e+2  ->  0E+2 Inexact Rounded
dqqua275 quantize   0E-10 1e+2  ->  0E+2

dqqua280 quantize   -10   1e+3  ->  -0E+3 Inexact Rounded
dqqua281 quantize   +1    1e+3  ->  0E+3 Inexact Rounded
dqqua282 quantize   +10   1e+3  ->  0E+3 Inexact Rounded
dqqua283 quantize   1E+1  1e+3  ->  0E+3 Inexact Rounded
dqqua284 quantize   1E+2  1e+3  ->  0E+3 Inexact Rounded
dqqua285 quantize   1E+3  1e+3  ->  1E+3
dqqua286 quantize   1E+4  1e+3  ->  1.0E+4
dqqua287 quantize   1E+5  1e+3  ->  1.00E+5
dqqua288 quantize   1E+6  1e+3  ->  1.000E+6
dqqua289 quantize   1E+7  1e+3  ->  1.0000E+7
dqqua290 quantize   1E+8  1e+3  ->  1.00000E+8
dqqua291 quantize   1E+9  1e+3  ->  1.000000E+9
dqqua292 quantize   1E+10 1e+3  ->  1.0000000E+10
dqqua293 quantize   1E-10 1e+3  ->  0E+3 Inexact Rounded
dqqua294 quantize   1E-2  1e+3  ->  0E+3 Inexact Rounded
dqqua295 quantize   0E-10 1e+3  ->  0E+3

-- round up from below [sign wrong in JIT compiler once]
dqqua300 quantize   0.0078 1e-5 ->  0.00780
dqqua301 quantize   0.0078 1e-4 ->  0.0078
dqqua302 quantize   0.0078 1e-3 ->  0.008 Inexact Rounded
dqqua303 quantize   0.0078 1e-2 ->  0.01 Inexact Rounded
dqqua304 quantize   0.0078 1e-1 ->  0.0 Inexact Rounded
dqqua305 quantize   0.0078  1e0 ->  0 Inexact Rounded
dqqua306 quantize   0.0078 1e+1 ->  0E+1 Inexact Rounded
dqqua307 quantize   0.0078 1e+2 ->  0E+2 Inexact Rounded

dqqua310 quantize  -0.0078 1e-5 -> -0.00780
dqqua311 quantize  -0.0078 1e-4 -> -0.0078
dqqua312 quantize  -0.0078 1e-3 -> -0.008 Inexact Rounded
dqqua313 quantize  -0.0078 1e-2 -> -0.01 Inexact Rounded
dqqua314 quantize  -0.0078 1e-1 -> -0.0 Inexact Rounded
dqqua315 quantize  -0.0078  1e0 -> -0 Inexact Rounded
dqqua316 quantize  -0.0078 1e+1 -> -0E+1 Inexact Rounded
dqqua317 quantize  -0.0078 1e+2 -> -0E+2 Inexact Rounded

dqqua320 quantize   0.078 1e-5 ->  0.07800
dqqua321 quantize   0.078 1e-4 ->  0.0780
dqqua322 quantize   0.078 1e-3 ->  0.078
dqqua323 quantize   0.078 1e-2 ->  0.08 Inexact Rounded
dqqua324 quantize   0.078 1e-1 ->  0.1 Inexact Rounded
dqqua325 quantize   0.078  1e0 ->  0 Inexact Rounded
dqqua326 quantize   0.078 1e+1 ->  0E+1 Inexact Rounded
dqqua327 quantize   0.078 1e+2 ->  0E+2 Inexact Rounded

dqqua330 quantize  -0.078 1e-5 -> -0.07800
dqqua331 quantize  -0.078 1e-4 -> -0.0780
dqqua332 quantize  -0.078 1e-3 -> -0.078
dqqua333 quantize  -0.078 1e-2 -> -0.08 Inexact Rounded
dqqua334 quantize  -0.078 1e-1 -> -0.1 Inexact Rounded
dqqua335 quantize  -0.078  1e0 -> -0 Inexact Rounded
dqqua336 quantize  -0.078 1e+1 -> -0E+1 Inexact Rounded
dqqua337 quantize  -0.078 1e+2 -> -0E+2 Inexact Rounded

dqqua340 quantize   0.78 1e-5 ->  0.78000
dqqua341 quantize   0.78 1e-4 ->  0.7800
dqqua342 quantize   0.78 1e-3 ->  0.780
dqqua343 quantize   0.78 1e-2 ->  0.78
dqqua344 quantize   0.78 1e-1 ->  0.8 Inexact Rounded
dqqua345 quantize   0.78  1e0 ->  1 Inexact Rounded
dqqua346 quantize   0.78 1e+1 ->  0E+1 Inexact Rounded
dqqua347 quantize   0.78 1e+2 ->  0E+2 Inexact Rounded

dqqua350 quantize  -0.78 1e-5 -> -0.78000
dqqua351 quantize  -0.78 1e-4 -> -0.7800
dqqua352 quantize  -0.78 1e-3 -> -0.780
dqqua353 quantize  -0.78 1e-2 -> -0.78
dqqua354 quantize  -0.78 1e-1 -> -0.8 Inexact Rounded
dqqua355 quantize  -0.78  1e0 -> -1 Inexact Rounded
dqqua356 quantize  -0.78 1e+1 -> -0E+1 Inexact Rounded
dqqua357 quantize  -0.78 1e+2 -> -0E+2 Inexact Rounded

dqqua360 quantize   7.8 1e-5 ->  7.80000
dqqua361 quantize   7.8 1e-4 ->  7.8000
dqqua362 quantize   7.8 1e-3 ->  7.800
dqqua363 quantize   7.8 1e-2 ->  7.80
dqqua364 quantize   7.8 1e-1 ->  7.8
dqqua365 quantize   7.8  1e0 ->  8 Inexact Rounded
dqqua366 quantize   7.8 1e+1 ->  1E+1 Inexact Rounded
dqqua367 quantize   7.8 1e+2 ->  0E+2 Inexact Rounded
dqqua368 quantize   7.8 1e+3 ->  0E+3 Inexact Rounded

dqqua370 quantize  -7.8 1e-5 -> -7.80000
dqqua371 quantize  -7.8 1e-4 -> -7.8000
dqqua372 quantize  -7.8 1e-3 -> -7.800
dqqua373 quantize  -7.8 1e-2 -> -7.80
dqqua374 quantize  -7.8 1e-1 -> -7.8
dqqua375 quantize  -7.8  1e0 -> -8 Inexact Rounded
dqqua376 quantize  -7.8 1e+1 -> -1E+1 Inexact Rounded
dqqua377 quantize  -7.8 1e+2 -> -0E+2 Inexact Rounded
dqqua378 quantize  -7.8 1e+3 -> -0E+3 Inexact Rounded

-- some individuals
dqqua380 quantize   1122334455667788991234567352364.506 1e-2 -> 1122334455667788991234567352364.51 Inexact Rounded
dqqua381 quantize   11223344556677889912345673523645.06 1e-2 -> 11223344556677889912345673523645.06
dqqua382 quantize   112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
dqqua383 quantize   1122334455667788991234567352364506  1e-2 -> NaN Invalid_operation
dqqua384 quantize  -1122334455667788991234567352364.506 1e-2 -> -1122334455667788991234567352364.51 Inexact Rounded
dqqua385 quantize  -11223344556677889912345673523645.06 1e-2 -> -11223344556677889912345673523645.06
dqqua386 quantize  -112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
dqqua387 quantize  -1122334455667788991234567352364506  1e-2 -> NaN Invalid_operation

rounding: down
dqqua389 quantize   112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
-- ? should that one instead have been:
-- dqqua389 quantize   112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
rounding: half_up

-- and a few more from e-mail discussions
dqqua391 quantize  11223344556677889912345678912.34567  1e-3 -> 11223344556677889912345678912.346   Inexact Rounded
dqqua392 quantize  112233445566778899123456789123.4567  1e-3 -> 112233445566778899123456789123.457  Inexact Rounded
dqqua393 quantize  1122334455667788991234567891234567.  1e-3 -> NaN Invalid_operation

-- some 9999 round-up cases
dqqua400 quantize   9.999        1e-5  ->  9.99900
dqqua401 quantize   9.999        1e-4  ->  9.9990
dqqua402 quantize   9.999        1e-3  ->  9.999
dqqua403 quantize   9.999        1e-2  -> 10.00     Inexact Rounded
dqqua404 quantize   9.999        1e-1  -> 10.0      Inexact Rounded
dqqua405 quantize   9.999         1e0  -> 10        Inexact Rounded
dqqua406 quantize   9.999         1e1  -> 1E+1      Inexact Rounded
dqqua407 quantize   9.999         1e2  -> 0E+2      Inexact Rounded

dqqua410 quantize   0.999        1e-5  ->  0.99900
dqqua411 quantize   0.999        1e-4  ->  0.9990
dqqua412 quantize   0.999        1e-3  ->  0.999
dqqua413 quantize   0.999        1e-2  ->  1.00     Inexact Rounded
dqqua414 quantize   0.999        1e-1  ->  1.0      Inexact Rounded
dqqua415 quantize   0.999         1e0  ->  1        Inexact Rounded
dqqua416 quantize   0.999         1e1  -> 0E+1      Inexact Rounded

dqqua420 quantize   0.0999       1e-5  ->  0.09990
dqqua421 quantize   0.0999       1e-4  ->  0.0999
dqqua422 quantize   0.0999       1e-3  ->  0.100    Inexact Rounded
dqqua423 quantize   0.0999       1e-2  ->  0.10     Inexact Rounded
dqqua424 quantize   0.0999       1e-1  ->  0.1      Inexact Rounded
dqqua425 quantize   0.0999        1e0  ->  0        Inexact Rounded
dqqua426 quantize   0.0999        1e1  -> 0E+1      Inexact Rounded

dqqua430 quantize   0.00999      1e-5  ->  0.00999
dqqua431 quantize   0.00999      1e-4  ->  0.0100   Inexact Rounded
dqqua432 quantize   0.00999      1e-3  ->  0.010    Inexact Rounded
dqqua433 quantize   0.00999      1e-2  ->  0.01     Inexact Rounded
dqqua434 quantize   0.00999      1e-1  ->  0.0      Inexact Rounded
dqqua435 quantize   0.00999       1e0  ->  0        Inexact Rounded
dqqua436 quantize   0.00999       1e1  -> 0E+1      Inexact Rounded

dqqua440 quantize   0.000999     1e-5  ->  0.00100  Inexact Rounded
dqqua441 quantize   0.000999     1e-4  ->  0.0010   Inexact Rounded
dqqua442 quantize   0.000999     1e-3  ->  0.001    Inexact Rounded
dqqua443 quantize   0.000999     1e-2  ->  0.00     Inexact Rounded
dqqua444 quantize   0.000999     1e-1  ->  0.0      Inexact Rounded
dqqua445 quantize   0.000999      1e0  ->  0        Inexact Rounded
dqqua446 quantize   0.000999      1e1  -> 0E+1      Inexact Rounded

dqqua1001 quantize  0.000        0.001 ->  0.000
dqqua1002 quantize  0.001        0.001 ->  0.001
dqqua1003 quantize  0.0012       0.001 ->  0.001     Inexact Rounded
dqqua1004 quantize  0.0018       0.001 ->  0.002     Inexact Rounded
dqqua1005 quantize  0.501        0.001 ->  0.501
dqqua1006 quantize  0.5012       0.001 ->  0.501     Inexact Rounded
dqqua1007 quantize  0.5018       0.001 ->  0.502     Inexact Rounded
dqqua1008 quantize  0.999        0.001 ->  0.999

dqqua481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
dqqua482 quantize 1234567800  1e+1 -> 1.23456780E+9 Rounded
dqqua483 quantize 1234567890  1e+1 -> 1.23456789E+9 Rounded
dqqua484 quantize 1234567891  1e+1 -> 1.23456789E+9 Inexact Rounded
dqqua485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
dqqua486 quantize 1234567896  1e+1 -> 1.23456790E+9 Inexact Rounded
-- a potential double-round
dqqua487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
dqqua488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded

dqqua491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
dqqua492 quantize 1234567800  1e+1 -> 1.23456780E+9 Rounded
dqqua493 quantize 1234567890  1e+1 -> 1.23456789E+9 Rounded
dqqua494 quantize 1234567891  1e+1 -> 1.23456789E+9 Inexact Rounded
dqqua495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
dqqua496 quantize 1234567896  1e+1 -> 1.23456790E+9 Inexact Rounded
dqqua497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
dqqua498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded

-- Zeros
dqqua500 quantize   0     1e1 ->  0E+1
dqqua501 quantize   0     1e0 ->  0
dqqua502 quantize   0    1e-1 ->  0.0
dqqua503 quantize   0.0  1e-1 ->  0.0
dqqua504 quantize   0.0   1e0 ->  0
dqqua505 quantize   0.0  1e+1 ->  0E+1
dqqua506 quantize   0E+1 1e-1 ->  0.0
dqqua507 quantize   0E+1  1e0 ->  0
dqqua508 quantize   0E+1 1e+1 ->  0E+1
dqqua509 quantize  -0     1e1 -> -0E+1
dqqua510 quantize  -0     1e0 -> -0
dqqua511 quantize  -0    1e-1 -> -0.0
dqqua512 quantize  -0.0  1e-1 -> -0.0
dqqua513 quantize  -0.0   1e0 -> -0
dqqua514 quantize  -0.0  1e+1 -> -0E+1
dqqua515 quantize  -0E+1 1e-1 -> -0.0
dqqua516 quantize  -0E+1  1e0 -> -0
dqqua517 quantize  -0E+1 1e+1 -> -0E+1

-- Suspicious RHS values
dqqua520 quantize   1.234    1e359 -> 0E+359 Inexact Rounded
dqqua521 quantize 123.456    1e359 -> 0E+359 Inexact Rounded
dqqua522 quantize   1.234    1e359 -> 0E+359 Inexact Rounded
dqqua523 quantize 123.456    1e359 -> 0E+359 Inexact Rounded
-- next four are "won't fit" overfl
dqqua526 quantize   1.234   1e-299 -> NaN Invalid_operation
dqqua527 quantize 123.456   1e-299 -> NaN Invalid_operation
dqqua528 quantize   1.234   1e-299 -> NaN Invalid_operation
dqqua529 quantize 123.456   1e-299 -> NaN Invalid_operation

dqqua532 quantize   1.234E+299    1e299 -> 1E+299    Inexact Rounded
dqqua533 quantize   1.234E+298    1e299 -> 0E+299    Inexact Rounded
dqqua534 quantize   1.234         1e299 -> 0E+299    Inexact Rounded
dqqua537 quantize   0            1e-299 -> 0E-299
-- next two are "won't fit" overflows
dqqua538 quantize   1.234        1e-299 -> NaN Invalid_operation
dqqua539 quantize   1.234        1e-300 -> NaN Invalid_operation
-- [more below]

-- Specials
dqqua580 quantize  Inf    -Inf   ->  Infinity
dqqua581 quantize  Inf  1e-299   ->  NaN  Invalid_operation
dqqua582 quantize  Inf  1e-1     ->  NaN  Invalid_operation
dqqua583 quantize  Inf   1e0     ->  NaN  Invalid_operation
dqqua584 quantize  Inf   1e1     ->  NaN  Invalid_operation
dqqua585 quantize  Inf   1e299   ->  NaN  Invalid_operation
dqqua586 quantize  Inf     Inf   ->  Infinity
dqqua587 quantize -1000    Inf   ->  NaN  Invalid_operation
dqqua588 quantize -Inf     Inf   ->  -Infinity
dqqua589 quantize -1       Inf   ->  NaN  Invalid_operation
dqqua590 quantize  0       Inf   ->  NaN  Invalid_operation
dqqua591 quantize  1       Inf   ->  NaN  Invalid_operation
dqqua592 quantize  1000    Inf   ->  NaN  Invalid_operation
dqqua593 quantize  Inf     Inf   ->  Infinity
dqqua594 quantize  Inf  1e-0     ->  NaN  Invalid_operation
dqqua595 quantize -0       Inf   ->  NaN  Invalid_operation

dqqua600 quantize -Inf    -Inf   ->  -Infinity
dqqua601 quantize -Inf  1e-299   ->  NaN  Invalid_operation
dqqua602 quantize -Inf  1e-1     ->  NaN  Invalid_operation
dqqua603 quantize -Inf   1e0     ->  NaN  Invalid_operation
dqqua604 quantize -Inf   1e1     ->  NaN  Invalid_operation
dqqua605 quantize -Inf   1e299   ->  NaN  Invalid_operation
dqqua606 quantize -Inf     Inf   ->  -Infinity
dqqua607 quantize -1000    Inf   ->  NaN  Invalid_operation
dqqua608 quantize -Inf    -Inf   ->  -Infinity
dqqua609 quantize -1      -Inf   ->  NaN  Invalid_operation
dqqua610 quantize  0      -Inf   ->  NaN  Invalid_operation
dqqua611 quantize  1      -Inf   ->  NaN  Invalid_operation
dqqua612 quantize  1000   -Inf   ->  NaN  Invalid_operation
dqqua613 quantize  Inf    -Inf   ->  Infinity
dqqua614 quantize -Inf  1e-0     ->  NaN  Invalid_operation
dqqua615 quantize -0      -Inf   ->  NaN  Invalid_operation

dqqua621 quantize  NaN   -Inf    ->  NaN
dqqua622 quantize  NaN 1e-299    ->  NaN
dqqua623 quantize  NaN 1e-1      ->  NaN
dqqua624 quantize  NaN  1e0      ->  NaN
dqqua625 quantize  NaN  1e1      ->  NaN
dqqua626 quantize  NaN  1e299    ->  NaN
dqqua627 quantize  NaN    Inf    ->  NaN
dqqua628 quantize  NaN    NaN    ->  NaN
dqqua629 quantize -Inf    NaN    ->  NaN
dqqua630 quantize -1000   NaN    ->  NaN
dqqua631 quantize -1      NaN    ->  NaN
dqqua632 quantize  0      NaN    ->  NaN
dqqua633 quantize  1      NaN    ->  NaN
dqqua634 quantize  1000   NaN    ->  NaN
dqqua635 quantize  Inf    NaN    ->  NaN
dqqua636 quantize  NaN 1e-0      ->  NaN
dqqua637 quantize -0      NaN    ->  NaN

dqqua641 quantize  sNaN   -Inf   ->  NaN  Invalid_operation
dqqua642 quantize  sNaN 1e-299   ->  NaN  Invalid_operation
dqqua643 quantize  sNaN 1e-1     ->  NaN  Invalid_operation
dqqua644 quantize  sNaN  1e0     ->  NaN  Invalid_operation
dqqua645 quantize  sNaN  1e1     ->  NaN  Invalid_operation
dqqua646 quantize  sNaN  1e299   ->  NaN  Invalid_operation
dqqua647 quantize  sNaN    NaN   ->  NaN  Invalid_operation
dqqua648 quantize  sNaN   sNaN   ->  NaN  Invalid_operation
dqqua649 quantize  NaN    sNaN   ->  NaN  Invalid_operation
dqqua650 quantize -Inf    sNaN   ->  NaN  Invalid_operation
dqqua651 quantize -1000   sNaN   ->  NaN  Invalid_operation
dqqua652 quantize -1      sNaN   ->  NaN  Invalid_operation
dqqua653 quantize  0      sNaN   ->  NaN  Invalid_operation
dqqua654 quantize  1      sNaN   ->  NaN  Invalid_operation
dqqua655 quantize  1000   sNaN   ->  NaN  Invalid_operation
dqqua656 quantize  Inf    sNaN   ->  NaN  Invalid_operation
dqqua657 quantize  NaN    sNaN   ->  NaN  Invalid_operation
dqqua658 quantize  sNaN 1e-0     ->  NaN  Invalid_operation
dqqua659 quantize -0      sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqqua661 quantize  NaN9 -Inf   ->  NaN9
dqqua662 quantize  NaN8  919   ->  NaN8
dqqua663 quantize  NaN71 Inf   ->  NaN71
dqqua664 quantize  NaN6  NaN5  ->  NaN6
dqqua665 quantize -Inf   NaN4  ->  NaN4
dqqua666 quantize -919   NaN31 ->  NaN31
dqqua667 quantize  Inf   NaN2  ->  NaN2

dqqua671 quantize  sNaN99 -Inf    ->  NaN99 Invalid_operation
dqqua672 quantize  sNaN98 -11     ->  NaN98 Invalid_operation
dqqua673 quantize  sNaN97  NaN    ->  NaN97 Invalid_operation
dqqua674 quantize  sNaN16 sNaN94  ->  NaN16 Invalid_operation
dqqua675 quantize  NaN95  sNaN93  ->  NaN93 Invalid_operation
dqqua676 quantize -Inf    sNaN92  ->  NaN92 Invalid_operation
dqqua677 quantize  088    sNaN91  ->  NaN91 Invalid_operation
dqqua678 quantize  Inf    sNaN90  ->  NaN90 Invalid_operation
dqqua679 quantize  NaN    sNaN88  ->  NaN88 Invalid_operation

dqqua681 quantize -NaN9 -Inf   -> -NaN9
dqqua682 quantize -NaN8  919   -> -NaN8
dqqua683 quantize -NaN71 Inf   -> -NaN71
dqqua684 quantize -NaN6 -NaN5  -> -NaN6
dqqua685 quantize -Inf  -NaN4  -> -NaN4
dqqua686 quantize -919  -NaN31 -> -NaN31
dqqua687 quantize  Inf  -NaN2  -> -NaN2

dqqua691 quantize -sNaN99 -Inf    -> -NaN99 Invalid_operation
dqqua692 quantize -sNaN98 -11     -> -NaN98 Invalid_operation
dqqua693 quantize -sNaN97  NaN    -> -NaN97 Invalid_operation
dqqua694 quantize -sNaN16 sNaN94  -> -NaN16 Invalid_operation
dqqua695 quantize -NaN95 -sNaN93  -> -NaN93 Invalid_operation
dqqua696 quantize -Inf   -sNaN92  -> -NaN92 Invalid_operation
dqqua697 quantize  088   -sNaN91  -> -NaN91 Invalid_operation
dqqua698 quantize  Inf   -sNaN90  -> -NaN90 Invalid_operation
dqqua699 quantize  NaN   -sNaN88  -> -NaN88 Invalid_operation

-- subnormals and underflow
dqqua710 quantize  1.00E-6143    1e-6143  ->   1E-6143    Rounded
dqqua711 quantize  0.1E-6143    2e-6144  ->   1E-6144   Subnormal
dqqua712 quantize  0.10E-6143   3e-6144  ->   1E-6144   Subnormal Rounded
dqqua713 quantize  0.100E-6143  4e-6144  ->   1E-6144   Subnormal Rounded
dqqua714 quantize  0.01E-6143   5e-6145  ->   1E-6145   Subnormal
-- next is rounded to Emin
dqqua715 quantize  0.999E-6143   1e-6143  ->   1E-6143    Inexact Rounded
dqqua716 quantize  0.099E-6143 10e-6144  ->   1E-6144   Inexact Rounded Subnormal

dqqua717 quantize  0.009E-6143  1e-6145  ->   1E-6145   Inexact Rounded Subnormal
dqqua718 quantize  0.001E-6143  1e-6145  ->   0E-6145   Inexact Rounded
dqqua719 quantize  0.0009E-6143 1e-6145  ->   0E-6145   Inexact Rounded
dqqua720 quantize  0.0001E-6143 1e-6145  ->   0E-6145   Inexact Rounded

dqqua730 quantize -1.00E-6143   1e-6143  ->  -1E-6143     Rounded
dqqua731 quantize -0.1E-6143    1e-6143  ->  -0E-6143     Rounded Inexact
dqqua732 quantize -0.10E-6143   1e-6143  ->  -0E-6143     Rounded Inexact
dqqua733 quantize -0.100E-6143  1e-6143  ->  -0E-6143     Rounded Inexact
dqqua734 quantize -0.01E-6143   1e-6143  ->  -0E-6143     Inexact Rounded
-- next is rounded to Emin
dqqua735 quantize -0.999E-6143 90e-6143  ->  -1E-6143     Inexact Rounded
dqqua736 quantize -0.099E-6143 -1e-6143  ->  -0E-6143     Inexact Rounded
dqqua737 quantize -0.009E-6143 -1e-6143  ->  -0E-6143     Inexact Rounded
dqqua738 quantize -0.001E-6143 -0e-6143  ->  -0E-6143     Inexact Rounded
dqqua739 quantize -0.0001E-6143 0e-6143  ->  -0E-6143     Inexact Rounded

dqqua740 quantize -1.00E-6143   1e-6144 ->  -1.0E-6143   Rounded
dqqua741 quantize -0.1E-6143    1e-6144 ->  -1E-6144    Subnormal
dqqua742 quantize -0.10E-6143   1e-6144 ->  -1E-6144    Subnormal Rounded
dqqua743 quantize -0.100E-6143  1e-6144 ->  -1E-6144    Subnormal Rounded
dqqua744 quantize -0.01E-6143   1e-6144 ->  -0E-6144    Inexact Rounded
-- next is rounded to Emin
dqqua745 quantize -0.999E-6143  1e-6144 ->  -1.0E-6143   Inexact Rounded
dqqua746 quantize -0.099E-6143  1e-6144 ->  -1E-6144    Inexact Rounded Subnormal
dqqua747 quantize -0.009E-6143  1e-6144 ->  -0E-6144    Inexact Rounded
dqqua748 quantize -0.001E-6143  1e-6144 ->  -0E-6144    Inexact Rounded
dqqua749 quantize -0.0001E-6143 1e-6144 ->  -0E-6144    Inexact Rounded

dqqua750 quantize -1.00E-6143   1e-6145 ->  -1.00E-6143
dqqua751 quantize -0.1E-6143    1e-6145 ->  -1.0E-6144  Subnormal
dqqua752 quantize -0.10E-6143   1e-6145 ->  -1.0E-6144  Subnormal
dqqua753 quantize -0.100E-6143  1e-6145 ->  -1.0E-6144  Subnormal Rounded
dqqua754 quantize -0.01E-6143   1e-6145 ->  -1E-6145    Subnormal
-- next is rounded to Emin
dqqua755 quantize -0.999E-6143  1e-6145 ->  -1.00E-6143  Inexact Rounded
dqqua756 quantize -0.099E-6143  1e-6145 ->  -1.0E-6144  Inexact Rounded Subnormal
dqqua757 quantize -0.009E-6143  1e-6145 ->  -1E-6145    Inexact Rounded Subnormal
dqqua758 quantize -0.001E-6143  1e-6145 ->  -0E-6145    Inexact Rounded
dqqua759 quantize -0.0001E-6143 1e-6145 ->  -0E-6145    Inexact Rounded

dqqua760 quantize -1.00E-6143   1e-6146 ->  -1.000E-6143
dqqua761 quantize -0.1E-6143    1e-6146 ->  -1.00E-6144  Subnormal
dqqua762 quantize -0.10E-6143   1e-6146 ->  -1.00E-6144  Subnormal
dqqua763 quantize -0.100E-6143  1e-6146 ->  -1.00E-6144  Subnormal
dqqua764 quantize -0.01E-6143   1e-6146 ->  -1.0E-6145   Subnormal
dqqua765 quantize -0.999E-6143  1e-6146 ->  -9.99E-6144  Subnormal
dqqua766 quantize -0.099E-6143  1e-6146 ->  -9.9E-6145   Subnormal
dqqua767 quantize -0.009E-6143  1e-6146 ->  -9E-6146     Subnormal
dqqua768 quantize -0.001E-6143  1e-6146 ->  -1E-6146     Subnormal
dqqua769 quantize -0.0001E-6143 1e-6146 ->  -0E-6146     Inexact Rounded

-- More from Fung Lee
dqqua1021 quantize  8.666666666666000E+6144  1.000000000000000E+6144 ->  8.666666666666000000000000000000000E+6144  Clamped
dqqua1022 quantize -8.666666666666000E+6144  1.000000000000000E+6144 -> -8.666666666666000000000000000000000E+6144  Clamped
dqqua1027 quantize 8.666666666666000E+323  1E+31    -> NaN Invalid_operation
dqqua1030 quantize 8.66666666E+3           1E+3     -> 9E+3 Inexact Rounded

-- Int and uInt32 edge values for testing conversions
dqqua1040 quantize -2147483646     0 -> -2147483646
dqqua1041 quantize -2147483647     0 -> -2147483647
dqqua1042 quantize -2147483648     0 -> -2147483648
dqqua1043 quantize -2147483649     0 -> -2147483649
dqqua1044 quantize  2147483646     0 ->  2147483646
dqqua1045 quantize  2147483647     0 ->  2147483647
dqqua1046 quantize  2147483648     0 ->  2147483648
dqqua1047 quantize  2147483649     0 ->  2147483649
dqqua1048 quantize  4294967294     0 ->  4294967294
dqqua1049 quantize  4294967295     0 ->  4294967295
dqqua1050 quantize  4294967296     0 ->  4294967296
dqqua1051 quantize  4294967297     0 ->  4294967297

-- Rounding swathe
rounding: half_even
dqqua1100 quantize  1.2300    1.00    ->  1.23  Rounded
dqqua1101 quantize  1.2301    1.00    ->  1.23  Inexact Rounded
dqqua1102 quantize  1.2310    1.00    ->  1.23  Inexact Rounded
dqqua1103 quantize  1.2350    1.00    ->  1.24  Inexact Rounded
dqqua1104 quantize  1.2351    1.00    ->  1.24  Inexact Rounded
dqqua1105 quantize  1.2450    1.00    ->  1.24  Inexact Rounded
dqqua1106 quantize  1.2451    1.00    ->  1.25  Inexact Rounded
dqqua1107 quantize  1.2360    1.00    ->  1.24  Inexact Rounded
dqqua1108 quantize  1.2370    1.00    ->  1.24  Inexact Rounded
dqqua1109 quantize  1.2399    1.00    ->  1.24  Inexact Rounded

rounding: half_up
dqqua1200 quantize  1.2300    1.00    ->  1.23  Rounded
dqqua1201 quantize  1.2301    1.00    ->  1.23  Inexact Rounded
dqqua1202 quantize  1.2310    1.00    ->  1.23  Inexact Rounded
dqqua1203 quantize  1.2350    1.00    ->  1.24  Inexact Rounded
dqqua1204 quantize  1.2351    1.00    ->  1.24  Inexact Rounded
dqqua1205 quantize  1.2450    1.00    ->  1.25  Inexact Rounded
dqqua1206 quantize  1.2451    1.00    ->  1.25  Inexact Rounded
dqqua1207 quantize  1.2360    1.00    ->  1.24  Inexact Rounded
dqqua1208 quantize  1.2370    1.00    ->  1.24  Inexact Rounded
dqqua1209 quantize  1.2399    1.00    ->  1.24  Inexact Rounded

rounding: half_down
dqqua1300 quantize  1.2300    1.00    ->  1.23  Rounded
dqqua1301 quantize  1.2301    1.00    ->  1.23  Inexact Rounded
dqqua1302 quantize  1.2310    1.00    ->  1.23  Inexact Rounded
dqqua1303 quantize  1.2350    1.00    ->  1.23  Inexact Rounded
dqqua1304 quantize  1.2351    1.00    ->  1.24  Inexact Rounded
dqqua1305 quantize  1.2450    1.00    ->  1.24  Inexact Rounded
dqqua1306 quantize  1.2451    1.00    ->  1.25  Inexact Rounded
dqqua1307 quantize  1.2360    1.00    ->  1.24  Inexact Rounded
dqqua1308 quantize  1.2370    1.00    ->  1.24  Inexact Rounded
dqqua1309 quantize  1.2399    1.00    ->  1.24  Inexact Rounded

rounding: up
dqqua1400 quantize  1.2300    1.00    ->  1.23  Rounded
dqqua1401 quantize  1.2301    1.00    ->  1.24  Inexact Rounded
dqqua1402 quantize  1.2310    1.00    ->  1.24  Inexact Rounded
dqqua1403 quantize  1.2350    1.00    ->  1.24  Inexact Rounded
dqqua1404 quantize  1.2351    1.00    ->  1.24  Inexact Rounded
dqqua1405 quantize  1.2450    1.00    ->  1.25  Inexact Rounded
dqqua1406 quantize  1.2451    1.00    ->  1.25  Inexact Rounded
dqqua1407 quantize  1.2360    1.00    ->  1.24  Inexact Rounded
dqqua1408 quantize  1.2370    1.00    ->  1.24  Inexact Rounded
dqqua1409 quantize  1.2399    1.00    ->  1.24  Inexact Rounded
dqqua1411 quantize -1.2399    1.00    -> -1.24  Inexact Rounded

rounding: down
dqqua1500 quantize  1.2300    1.00    ->  1.23  Rounded
dqqua1501 quantize  1.2301    1.00    ->  1.23  Inexact Rounded
dqqua1502 quantize  1.2310    1.00    ->  1.23  Inexact Rounded
dqqua1503 quantize  1.2350    1.00    ->  1.23  Inexact Rounded
dqqua1504 quantize  1.2351    1.00    ->  1.23  Inexact Rounded
dqqua1505 quantize  1.2450    1.00    ->  1.24  Inexact Rounded
dqqua1506 quantize  1.2451    1.00    ->  1.24  Inexact Rounded
dqqua1507 quantize  1.2360    1.00    ->  1.23  Inexact Rounded
dqqua1508 quantize  1.2370    1.00    ->  1.23  Inexact Rounded
dqqua1509 quantize  1.2399    1.00    ->  1.23  Inexact Rounded
dqqua1511 quantize -1.2399    1.00    -> -1.23  Inexact Rounded

rounding: ceiling
dqqua1600 quantize  1.2300    1.00    ->  1.23  Rounded
dqqua1601 quantize  1.2301    1.00    ->  1.24  Inexact Rounded
dqqua1602 quantize  1.2310    1.00    ->  1.24  Inexact Rounded
dqqua1603 quantize  1.2350    1.00    ->  1.24  Inexact Rounded
dqqua1604 quantize  1.2351    1.00    ->  1.24  Inexact Rounded
dqqua1605 quantize  1.2450    1.00    ->  1.25  Inexact Rounded
dqqua1606 quantize  1.2451    1.00    ->  1.25  Inexact Rounded
dqqua1607 quantize  1.2360    1.00    ->  1.24  Inexact Rounded
dqqua1608 quantize  1.2370    1.00    ->  1.24  Inexact Rounded
dqqua1609 quantize  1.2399    1.00    ->  1.24  Inexact Rounded
dqqua1611 quantize -1.2399    1.00    -> -1.23  Inexact Rounded

rounding: floor
dqqua1700 quantize  1.2300    1.00    ->  1.23  Rounded
dqqua1701 quantize  1.2301    1.00    ->  1.23  Inexact Rounded
dqqua1702 quantize  1.2310    1.00    ->  1.23  Inexact Rounded
dqqua1703 quantize  1.2350    1.00    ->  1.23  Inexact Rounded
dqqua1704 quantize  1.2351    1.00    ->  1.23  Inexact Rounded
dqqua1705 quantize  1.2450    1.00    ->  1.24  Inexact Rounded
dqqua1706 quantize  1.2451    1.00    ->  1.24  Inexact Rounded
dqqua1707 quantize  1.2360    1.00    ->  1.23  Inexact Rounded
dqqua1708 quantize  1.2370    1.00    ->  1.23  Inexact Rounded
dqqua1709 quantize  1.2399    1.00    ->  1.23  Inexact Rounded
dqqua1711 quantize -1.2399    1.00    -> -1.24  Inexact Rounded

rounding: 05up
dqqua1800 quantize  1.2000    1.00    ->  1.20  Rounded
dqqua1801 quantize  1.2001    1.00    ->  1.21  Inexact Rounded
dqqua1802 quantize  1.2010    1.00    ->  1.21  Inexact Rounded
dqqua1803 quantize  1.2050    1.00    ->  1.21  Inexact Rounded
dqqua1804 quantize  1.2051    1.00    ->  1.21  Inexact Rounded
dqqua1807 quantize  1.2060    1.00    ->  1.21  Inexact Rounded
dqqua1808 quantize  1.2070    1.00    ->  1.21  Inexact Rounded
dqqua1809 quantize  1.2099    1.00    ->  1.21  Inexact Rounded
dqqua1811 quantize -1.2099    1.00    -> -1.21  Inexact Rounded

dqqua1900 quantize  1.2100    1.00    ->  1.21  Rounded
dqqua1901 quantize  1.2101    1.00    ->  1.21  Inexact Rounded
dqqua1902 quantize  1.2110    1.00    ->  1.21  Inexact Rounded
dqqua1903 quantize  1.2150    1.00    ->  1.21  Inexact Rounded
dqqua1904 quantize  1.2151    1.00    ->  1.21  Inexact Rounded
dqqua1907 quantize  1.2160    1.00    ->  1.21  Inexact Rounded
dqqua1908 quantize  1.2170    1.00    ->  1.21  Inexact Rounded
dqqua1909 quantize  1.2199    1.00    ->  1.21  Inexact Rounded
dqqua1911 quantize -1.2199    1.00    -> -1.21  Inexact Rounded

dqqua2000 quantize  1.2400    1.00    ->  1.24  Rounded
dqqua2001 quantize  1.2401    1.00    ->  1.24  Inexact Rounded
dqqua2002 quantize  1.2410    1.00    ->  1.24  Inexact Rounded
dqqua2003 quantize  1.2450    1.00    ->  1.24  Inexact Rounded
dqqua2004 quantize  1.2451    1.00    ->  1.24  Inexact Rounded
dqqua2007 quantize  1.2460    1.00    ->  1.24  Inexact Rounded
dqqua2008 quantize  1.2470    1.00    ->  1.24  Inexact Rounded
dqqua2009 quantize  1.2499    1.00    ->  1.24  Inexact Rounded
dqqua2011 quantize -1.2499    1.00    -> -1.24  Inexact Rounded

dqqua2100 quantize  1.2500    1.00    ->  1.25  Rounded
dqqua2101 quantize  1.2501    1.00    ->  1.26  Inexact Rounded
dqqua2102 quantize  1.2510    1.00    ->  1.26  Inexact Rounded
dqqua2103 quantize  1.2550    1.00    ->  1.26  Inexact Rounded
dqqua2104 quantize  1.2551    1.00    ->  1.26  Inexact Rounded
dqqua2107 quantize  1.2560    1.00    ->  1.26  Inexact Rounded
dqqua2108 quantize  1.2570    1.00    ->  1.26  Inexact Rounded
dqqua2109 quantize  1.2599    1.00    ->  1.26  Inexact Rounded
dqqua2111 quantize -1.2599    1.00    -> -1.26  Inexact Rounded

dqqua2200 quantize  1.2600    1.00    ->  1.26  Rounded
dqqua2201 quantize  1.2601    1.00    ->  1.26  Inexact Rounded
dqqua2202 quantize  1.2610    1.00    ->  1.26  Inexact Rounded
dqqua2203 quantize  1.2650    1.00    ->  1.26  Inexact Rounded
dqqua2204 quantize  1.2651    1.00    ->  1.26  Inexact Rounded
dqqua2207 quantize  1.2660    1.00    ->  1.26  Inexact Rounded
dqqua2208 quantize  1.2670    1.00    ->  1.26  Inexact Rounded
dqqua2209 quantize  1.2699    1.00    ->  1.26  Inexact Rounded
dqqua2211 quantize -1.2699    1.00    -> -1.26  Inexact Rounded

dqqua2300 quantize  1.2900    1.00    ->  1.29  Rounded
dqqua2301 quantize  1.2901    1.00    ->  1.29  Inexact Rounded
dqqua2302 quantize  1.2910    1.00    ->  1.29  Inexact Rounded
dqqua2303 quantize  1.2950    1.00    ->  1.29  Inexact Rounded
dqqua2304 quantize  1.2951    1.00    ->  1.29  Inexact Rounded
dqqua2307 quantize  1.2960    1.00    ->  1.29  Inexact Rounded
dqqua2308 quantize  1.2970    1.00    ->  1.29  Inexact Rounded
dqqua2309 quantize  1.2999    1.00    ->  1.29  Inexact Rounded
dqqua2311 quantize -1.2999    1.00    -> -1.29  Inexact Rounded

-- Null tests
dqqua998 quantize 10    # -> NaN Invalid_operation
dqqua999 quantize  # 1e10 -> NaN Invalid_operation

Added test/dectest/dqReduce.decTest.















































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
------------------------------------------------------------------------
-- dqReduce.decTest -- remove trailing zeros from a decQuad           --
-- Copyright (c) IBM Corporation, 2003, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------

version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

dqred001 reduce '1'      -> '1'
dqred002 reduce '-1'     -> '-1'
dqred003 reduce '1.00'   -> '1'
dqred004 reduce '-1.00'  -> '-1'
dqred005 reduce '0'      -> '0'
dqred006 reduce '0.00'   -> '0'
dqred007 reduce '00.0'   -> '0'
dqred008 reduce '00.00'  -> '0'
dqred009 reduce '00'     -> '0'
dqred010 reduce '0E+1'   -> '0'
dqred011 reduce '0E+5'   -> '0'

dqred012 reduce '-2'     -> '-2'
dqred013 reduce '2'      -> '2'
dqred014 reduce '-2.00'  -> '-2'
dqred015 reduce '2.00'   -> '2'
dqred016 reduce '-0'     -> '-0'
dqred017 reduce '-0.00'  -> '-0'
dqred018 reduce '-00.0'  -> '-0'
dqred019 reduce '-00.00' -> '-0'
dqred020 reduce '-00'    -> '-0'
dqred021 reduce '-0E+5'   -> '-0'
dqred022 reduce '-0E+1'  -> '-0'

dqred030 reduce '+0.1'            -> '0.1'
dqred031 reduce '-0.1'            -> '-0.1'
dqred032 reduce '+0.01'           -> '0.01'
dqred033 reduce '-0.01'           -> '-0.01'
dqred034 reduce '+0.001'          -> '0.001'
dqred035 reduce '-0.001'          -> '-0.001'
dqred036 reduce '+0.000001'       -> '0.000001'
dqred037 reduce '-0.000001'       -> '-0.000001'
dqred038 reduce '+0.000000000001' -> '1E-12'
dqred039 reduce '-0.000000000001' -> '-1E-12'

dqred041 reduce 1.1        -> 1.1
dqred042 reduce 1.10       -> 1.1
dqred043 reduce 1.100      -> 1.1
dqred044 reduce 1.110      -> 1.11
dqred045 reduce -1.1       -> -1.1
dqred046 reduce -1.10      -> -1.1
dqred047 reduce -1.100     -> -1.1
dqred048 reduce -1.110     -> -1.11
dqred049 reduce 9.9        -> 9.9
dqred050 reduce 9.90       -> 9.9
dqred051 reduce 9.900      -> 9.9
dqred052 reduce 9.990      -> 9.99
dqred053 reduce -9.9       -> -9.9
dqred054 reduce -9.90      -> -9.9
dqred055 reduce -9.900     -> -9.9
dqred056 reduce -9.990     -> -9.99

-- some trailing fractional zeros with zeros in units
dqred060 reduce  10.0        -> 1E+1
dqred061 reduce  10.00       -> 1E+1
dqred062 reduce  100.0       -> 1E+2
dqred063 reduce  100.00      -> 1E+2
dqred064 reduce  1.1000E+3   -> 1.1E+3
dqred065 reduce  1.10000E+3  -> 1.1E+3
dqred066 reduce -10.0        -> -1E+1
dqred067 reduce -10.00       -> -1E+1
dqred068 reduce -100.0       -> -1E+2
dqred069 reduce -100.00      -> -1E+2
dqred070 reduce -1.1000E+3   -> -1.1E+3
dqred071 reduce -1.10000E+3  -> -1.1E+3

-- some insignificant trailing zeros with positive exponent
dqred080 reduce  10E+1       -> 1E+2
dqred081 reduce  100E+1      -> 1E+3
dqred082 reduce  1.0E+2      -> 1E+2
dqred083 reduce  1.0E+3      -> 1E+3
dqred084 reduce  1.1E+3      -> 1.1E+3
dqred085 reduce  1.00E+3     -> 1E+3
dqred086 reduce  1.10E+3     -> 1.1E+3
dqred087 reduce -10E+1       -> -1E+2
dqred088 reduce -100E+1      -> -1E+3
dqred089 reduce -1.0E+2      -> -1E+2
dqred090 reduce -1.0E+3      -> -1E+3
dqred091 reduce -1.1E+3      -> -1.1E+3
dqred092 reduce -1.00E+3     -> -1E+3
dqred093 reduce -1.10E+3     -> -1.1E+3

-- some significant trailing zeros, were we to be trimming
dqred100 reduce  11          -> 11
dqred101 reduce  10          -> 1E+1
dqred102 reduce  10.         -> 1E+1
dqred103 reduce  1.1E+1      -> 11
dqred104 reduce  1.0E+1      -> 1E+1
dqred105 reduce  1.10E+2     -> 1.1E+2
dqred106 reduce  1.00E+2     -> 1E+2
dqred107 reduce  1.100E+3    -> 1.1E+3
dqred108 reduce  1.000E+3    -> 1E+3
dqred109 reduce  1.000000E+6 -> 1E+6
dqred110 reduce -11          -> -11
dqred111 reduce -10          -> -1E+1
dqred112 reduce -10.         -> -1E+1
dqred113 reduce -1.1E+1      -> -11
dqred114 reduce -1.0E+1      -> -1E+1
dqred115 reduce -1.10E+2     -> -1.1E+2
dqred116 reduce -1.00E+2     -> -1E+2
dqred117 reduce -1.100E+3    -> -1.1E+3
dqred118 reduce -1.000E+3    -> -1E+3
dqred119 reduce -1.00000E+5  -> -1E+5
dqred120 reduce -1.000000E+6 -> -1E+6
dqred121 reduce -10.00000E+6 -> -1E+7
dqred122 reduce -100.0000E+6 -> -1E+8
dqred123 reduce -1000.000E+6 -> -1E+9
dqred124 reduce -10000.00E+6 -> -1E+10
dqred125 reduce -100000.0E+6 -> -1E+11
dqred126 reduce -1000000.E+6 -> -1E+12

-- examples from decArith
dqred140 reduce '2.1'     ->  '2.1'
dqred141 reduce '-2.0'    ->  '-2'
dqred142 reduce '1.200'   ->  '1.2'
dqred143 reduce '-120'    ->  '-1.2E+2'
dqred144 reduce '120.00'  ->  '1.2E+2'
dqred145 reduce '0.00'    ->  '0'

-- Nmax, Nmin, Ntiny
-- note origami effect on some of these
dqred151 reduce  9.999999999999999999999999999999999E+6144   -> 9.999999999999999999999999999999999E+6144
dqred152 reduce  9.999999999999999999999999000000000E+6140   -> 9.99999999999999999999999900000E+6140
dqred153 reduce  9.999999999999999999999999999990000E+6144   -> 9.999999999999999999999999999990000E+6144
dqred154 reduce  1E-6143                   -> 1E-6143
dqred155 reduce  1.000000000000000000000000000000000E-6143   -> 1E-6143
dqred156 reduce  2.000E-6173               -> 2E-6173   Subnormal
dqred157 reduce  1E-6176                   -> 1E-6176   Subnormal

dqred161 reduce  -1E-6176                  -> -1E-6176  Subnormal
dqred162 reduce  -2.000E-6173              -> -2E-6173  Subnormal
dqred163 reduce  -1.000000000000000000000000000000000E-6143  -> -1E-6143
dqred164 reduce  -1E-6143                  -> -1E-6143
dqred165 reduce  -9.999999999999999999999999000000000E+6140  -> -9.99999999999999999999999900000E+6140
dqred166 reduce  -9.999999999999999999999999999990000E+6144  -> -9.999999999999999999999999999990000E+6144
dqred167 reduce  -9.999999999999999999999999999999990E+6144  -> -9.999999999999999999999999999999990E+6144
dqred168 reduce  -9.999999999999999999999999999999999E+6144  -> -9.999999999999999999999999999999999E+6144
dqred169 reduce  -9.999999999999999999999999999999990E+6144  -> -9.999999999999999999999999999999990E+6144


-- specials (reduce does not affect payload)
dqred820 reduce 'Inf'    -> 'Infinity'
dqred821 reduce '-Inf'   -> '-Infinity'
dqred822 reduce   NaN    ->  NaN
dqred823 reduce  sNaN    ->  NaN    Invalid_operation
dqred824 reduce   NaN101 ->  NaN101
dqred825 reduce  sNaN010 ->  NaN10  Invalid_operation
dqred827 reduce  -NaN    -> -NaN
dqred828 reduce -sNaN    -> -NaN    Invalid_operation
dqred829 reduce  -NaN101 -> -NaN101
dqred830 reduce -sNaN010 -> -NaN10  Invalid_operation

-- Null test
dqred900 reduce  # -> NaN Invalid_operation

Added test/dectest/dqRemainder.decTest.

























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
------------------------------------------------------------------------
-- dqRemainder.decTest -- decQuad remainder                           --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks (as base, above)
dqrem001 remainder  1     1    ->  0
dqrem002 remainder  2     1    ->  0
dqrem003 remainder  1     2    ->  1
dqrem004 remainder  2     2    ->  0
dqrem005 remainder  0     1    ->  0
dqrem006 remainder  0     2    ->  0
dqrem007 remainder  1     3    ->  1
dqrem008 remainder  2     3    ->  2
dqrem009 remainder  3     3    ->  0

dqrem010 remainder  2.4   1    ->  0.4
dqrem011 remainder  2.4   -1   ->  0.4
dqrem012 remainder  -2.4  1    ->  -0.4
dqrem013 remainder  -2.4  -1   ->  -0.4
dqrem014 remainder  2.40  1    ->  0.40
dqrem015 remainder  2.400 1    ->  0.400
dqrem016 remainder  2.4   2    ->  0.4
dqrem017 remainder  2.400 2    ->  0.400
dqrem018 remainder  2.    2    ->  0
dqrem019 remainder  20    20   ->  0

dqrem020 remainder  187   187    ->  0
dqrem021 remainder  5     2      ->  1
dqrem022 remainder  5     2.0    ->  1.0
dqrem023 remainder  5     2.000  ->  1.000
dqrem024 remainder  5     0.200  ->  0.000
dqrem025 remainder  5     0.200  ->  0.000

dqrem030 remainder  1     2      ->  1
dqrem031 remainder  1     4      ->  1
dqrem032 remainder  1     8      ->  1

dqrem033 remainder  1     16     ->  1
dqrem034 remainder  1     32     ->  1
dqrem035 remainder  1     64     ->  1
dqrem040 remainder  1    -2      ->  1
dqrem041 remainder  1    -4      ->  1
dqrem042 remainder  1    -8      ->  1
dqrem043 remainder  1    -16     ->  1
dqrem044 remainder  1    -32     ->  1
dqrem045 remainder  1    -64     ->  1
dqrem050 remainder -1     2      ->  -1
dqrem051 remainder -1     4      ->  -1
dqrem052 remainder -1     8      ->  -1
dqrem053 remainder -1     16     ->  -1
dqrem054 remainder -1     32     ->  -1
dqrem055 remainder -1     64     ->  -1
dqrem060 remainder -1    -2      ->  -1
dqrem061 remainder -1    -4      ->  -1
dqrem062 remainder -1    -8      ->  -1
dqrem063 remainder -1    -16     ->  -1
dqrem064 remainder -1    -32     ->  -1
dqrem065 remainder -1    -64     ->  -1

dqrem066 remainder  999999999     1  -> 0
dqrem067 remainder  999999999.4   1  -> 0.4
dqrem068 remainder  999999999.5   1  -> 0.5
dqrem069 remainder  999999999.9   1  -> 0.9
dqrem070 remainder  999999999.999 1  -> 0.999
dqrem071 remainder  999999.999999 1  -> 0.999999
dqrem072 remainder  9             1  -> 0

dqrem080 remainder  0.            1  -> 0
dqrem081 remainder  .0            1  -> 0.0
dqrem082 remainder  0.00          1  -> 0.00
dqrem083 remainder  0.00E+9       1  -> 0
dqrem084 remainder  0.00E+3       1  -> 0
dqrem085 remainder  0.00E+2       1  -> 0
dqrem086 remainder  0.00E+1       1  -> 0.0
dqrem087 remainder  0.00E+0       1  -> 0.00
dqrem088 remainder  0.00E-0       1  -> 0.00
dqrem089 remainder  0.00E-1       1  -> 0.000
dqrem090 remainder  0.00E-2       1  -> 0.0000
dqrem091 remainder  0.00E-3       1  -> 0.00000
dqrem092 remainder  0.00E-4       1  -> 0.000000
dqrem093 remainder  0.00E-5       1  -> 0E-7
dqrem094 remainder  0.00E-6       1  -> 0E-8
dqrem095 remainder  0.0000E-50    1  -> 0E-54

-- Various flavours of remainder by 0
dqrem101 remainder  0       0   -> NaN Division_undefined
dqrem102 remainder  0      -0   -> NaN Division_undefined
dqrem103 remainder -0       0   -> NaN Division_undefined
dqrem104 remainder -0      -0   -> NaN Division_undefined
dqrem105 remainder  0.0E5   0   -> NaN Division_undefined
dqrem106 remainder  0.000   0   -> NaN Division_undefined
-- [Some think this next group should be Division_by_zero exception, but
-- IEEE 854 is explicit that it is Invalid operation .. for
-- remainder-near, anyway]
dqrem107 remainder  0.0001  0   -> NaN Invalid_operation
dqrem108 remainder  0.01    0   -> NaN Invalid_operation
dqrem109 remainder  0.1     0   -> NaN Invalid_operation
dqrem110 remainder  1       0   -> NaN Invalid_operation
dqrem111 remainder  1       0.0 -> NaN Invalid_operation
dqrem112 remainder 10       0.0 -> NaN Invalid_operation
dqrem113 remainder 1E+100   0.0 -> NaN Invalid_operation
dqrem114 remainder 1E+380   0   -> NaN Invalid_operation
dqrem115 remainder  0.0001 -0   -> NaN Invalid_operation
dqrem116 remainder  0.01   -0   -> NaN Invalid_operation
dqrem119 remainder  0.1    -0   -> NaN Invalid_operation
dqrem120 remainder  1      -0   -> NaN Invalid_operation
dqrem121 remainder  1      -0.0 -> NaN Invalid_operation
dqrem122 remainder 10      -0.0 -> NaN Invalid_operation
dqrem123 remainder 1E+100  -0.0 -> NaN Invalid_operation
dqrem124 remainder 1E+384  -0   -> NaN Invalid_operation
-- and zeros on left
dqrem130 remainder  0      1   ->  0
dqrem131 remainder  0     -1   ->  0
dqrem132 remainder  0.0    1   ->  0.0
dqrem133 remainder  0.0   -1   ->  0.0
dqrem134 remainder -0      1   -> -0
dqrem135 remainder -0     -1   -> -0
dqrem136 remainder -0.0    1   -> -0.0
dqrem137 remainder -0.0   -1   -> -0.0

-- 0.5ers
dqrem143 remainder   0.5  2     ->  0.5
dqrem144 remainder   0.5  2.1   ->  0.5
dqrem145 remainder   0.5  2.01  ->  0.50
dqrem146 remainder   0.5  2.001 ->  0.500
dqrem147 remainder   0.50 2     ->  0.50
dqrem148 remainder   0.50 2.01  ->  0.50
dqrem149 remainder   0.50 2.001 ->  0.500

-- steadies
dqrem150 remainder  1  1   -> 0
dqrem151 remainder  1  2   -> 1
dqrem152 remainder  1  3   -> 1
dqrem153 remainder  1  4   -> 1
dqrem154 remainder  1  5   -> 1
dqrem155 remainder  1  6   -> 1
dqrem156 remainder  1  7   -> 1
dqrem157 remainder  1  8   -> 1
dqrem158 remainder  1  9   -> 1
dqrem159 remainder  1  10  -> 1
dqrem160 remainder  1  1   -> 0
dqrem161 remainder  2  1   -> 0
dqrem162 remainder  3  1   -> 0
dqrem163 remainder  4  1   -> 0
dqrem164 remainder  5  1   -> 0
dqrem165 remainder  6  1   -> 0
dqrem166 remainder  7  1   -> 0
dqrem167 remainder  8  1   -> 0
dqrem168 remainder  9  1   -> 0
dqrem169 remainder  10 1   -> 0

-- some differences from remainderNear
dqrem171 remainder   0.4  1.020 ->  0.400
dqrem172 remainder   0.50 1.020 ->  0.500
dqrem173 remainder   0.51 1.020 ->  0.510
dqrem174 remainder   0.52 1.020 ->  0.520
dqrem175 remainder   0.6  1.020 ->  0.600

-- More flavours of remainder by 0
dqrem201 remainder  0      0   -> NaN Division_undefined
dqrem202 remainder  0.0E5  0   -> NaN Division_undefined
dqrem203 remainder  0.000  0   -> NaN Division_undefined
dqrem204 remainder  0.0001 0   -> NaN Invalid_operation
dqrem205 remainder  0.01   0   -> NaN Invalid_operation
dqrem206 remainder  0.1    0   -> NaN Invalid_operation
dqrem207 remainder  1      0   -> NaN Invalid_operation
dqrem208 remainder  1      0.0 -> NaN Invalid_operation
dqrem209 remainder 10      0.0 -> NaN Invalid_operation
dqrem210 remainder 1E+100  0.0 -> NaN Invalid_operation
dqrem211 remainder 1E+380  0   -> NaN Invalid_operation

-- some differences from remainderNear
dqrem231 remainder  -0.4  1.020 -> -0.400
dqrem232 remainder  -0.50 1.020 -> -0.500
dqrem233 remainder  -0.51 1.020 -> -0.510
dqrem234 remainder  -0.52 1.020 -> -0.520
dqrem235 remainder  -0.6  1.020 -> -0.600

-- high Xs
dqrem240 remainder  1E+2  1.00  ->  0.00

-- dqrem3xx are from DiagBigDecimal
dqrem301 remainder   1    3     ->  1
dqrem302 remainder   5    5     ->  0
dqrem303 remainder   13   10    ->  3
dqrem304 remainder   13   50    ->  13
dqrem305 remainder   13   100   ->  13
dqrem306 remainder   13   1000  ->  13
dqrem307 remainder   .13    1   ->  0.13
dqrem308 remainder   0.133  1   ->  0.133
dqrem309 remainder   0.1033 1   ->  0.1033
dqrem310 remainder   1.033  1   ->  0.033
dqrem311 remainder   10.33  1   ->  0.33
dqrem312 remainder   10.33 10   ->  0.33
dqrem313 remainder   103.3  1   ->  0.3
dqrem314 remainder   133   10   ->  3
dqrem315 remainder   1033  10   ->  3
dqrem316 remainder   1033  50   ->  33
dqrem317 remainder   101.0  3   ->  2.0
dqrem318 remainder   102.0  3   ->  0.0
dqrem319 remainder   103.0  3   ->  1.0
dqrem320 remainder   2.40   1   ->  0.40
dqrem321 remainder   2.400  1   ->  0.400
dqrem322 remainder   2.4    1   ->  0.4
dqrem323 remainder   2.4    2   ->  0.4
dqrem324 remainder   2.400  2   ->  0.400
dqrem325 remainder   1   0.3    ->  0.1
dqrem326 remainder   1   0.30   ->  0.10
dqrem327 remainder   1   0.300  ->  0.100
dqrem328 remainder   1   0.3000 ->  0.1000
dqrem329 remainder   1.0    0.3 ->  0.1
dqrem330 remainder   1.00   0.3 ->  0.10
dqrem331 remainder   1.000  0.3 ->  0.100
dqrem332 remainder   1.0000 0.3 ->  0.1000
dqrem333 remainder   0.5  2     ->  0.5
dqrem334 remainder   0.5  2.1   ->  0.5
dqrem335 remainder   0.5  2.01  ->  0.50
dqrem336 remainder   0.5  2.001 ->  0.500
dqrem337 remainder   0.50 2     ->  0.50
dqrem338 remainder   0.50 2.01  ->  0.50
dqrem339 remainder   0.50 2.001 ->  0.500

dqrem340 remainder   0.5   0.5000001    ->  0.5000000
dqrem341 remainder   0.5   0.50000001    ->  0.50000000
dqrem342 remainder   0.5   0.500000001    ->  0.500000000
dqrem343 remainder   0.5   0.5000000001    ->  0.5000000000
dqrem344 remainder   0.5   0.50000000001    ->  0.50000000000
dqrem345 remainder   0.5   0.4999999    ->  1E-7
dqrem346 remainder   0.5   0.49999999    ->  1E-8
dqrem347 remainder   0.5   0.499999999    ->  1E-9
dqrem348 remainder   0.5   0.4999999999    ->  1E-10
dqrem349 remainder   0.5   0.49999999999    ->  1E-11
dqrem350 remainder   0.5   0.499999999999    ->  1E-12

dqrem351 remainder   0.03  7  ->  0.03
dqrem352 remainder   5   2    ->  1
dqrem353 remainder   4.1   2    ->  0.1
dqrem354 remainder   4.01   2    ->  0.01
dqrem355 remainder   4.001   2    ->  0.001
dqrem356 remainder   4.0001   2    ->  0.0001
dqrem357 remainder   4.00001   2    ->  0.00001
dqrem358 remainder   4.000001   2    ->  0.000001
dqrem359 remainder   4.0000001   2    ->  1E-7

dqrem360 remainder   1.2   0.7345 ->  0.4655
dqrem361 remainder   0.8   12     ->  0.8
dqrem362 remainder   0.8   0.2    ->  0.0
dqrem363 remainder   0.8   0.3    ->  0.2
dqrem364 remainder   0.800   12   ->  0.800
dqrem365 remainder   0.800   1.7  ->  0.800
dqrem366 remainder   2.400   2    ->  0.400

dqrem371 remainder   2.400  2        ->  0.400

dqrem381 remainder 12345  1         ->  0
dqrem382 remainder 12345  1.0001    ->  0.7657
dqrem383 remainder 12345  1.001     ->  0.668
dqrem384 remainder 12345  1.01      ->  0.78
dqrem385 remainder 12345  1.1       ->  0.8
dqrem386 remainder 12355  4         ->  3
dqrem387 remainder 12345  4         ->  1
dqrem388 remainder 12355  4.0001    ->  2.6912
dqrem389 remainder 12345  4.0001    ->  0.6914
dqrem390 remainder 12345  4.9       ->  1.9
dqrem391 remainder 12345  4.99      ->  4.73
dqrem392 remainder 12345  4.999     ->  2.469
dqrem393 remainder 12345  4.9999    ->  0.2469
dqrem394 remainder 12345  5         ->  0
dqrem395 remainder 12345  5.0001    ->  4.7532
dqrem396 remainder 12345  5.001     ->  2.532
dqrem397 remainder 12345  5.01      ->  0.36
dqrem398 remainder 12345  5.1       ->  3.0

-- the nasty division-by-1 cases
dqrem401 remainder   0.5         1   ->  0.5
dqrem402 remainder   0.55        1   ->  0.55
dqrem403 remainder   0.555       1   ->  0.555
dqrem404 remainder   0.5555      1   ->  0.5555
dqrem405 remainder   0.55555     1   ->  0.55555
dqrem406 remainder   0.555555    1   ->  0.555555
dqrem407 remainder   0.5555555   1   ->  0.5555555
dqrem408 remainder   0.55555555  1   ->  0.55555555
dqrem409 remainder   0.555555555 1   ->  0.555555555

-- folddowns
dqrem421 remainder   1E+6144        1  ->   NaN Division_impossible
dqrem422 remainder   1E+6144  1E+6143  ->   0E+6111 Clamped
dqrem423 remainder   1E+6144  2E+6143  ->   0E+6111 Clamped
dqrem424 remainder   1E+6144  3E+6143  ->   1.00000000000000000000000000000000E+6143 Clamped
dqrem425 remainder   1E+6144  4E+6143  ->   2.00000000000000000000000000000000E+6143 Clamped
dqrem426 remainder   1E+6144  5E+6143  ->   0E+6111 Clamped
dqrem427 remainder   1E+6144  6E+6143  ->   4.00000000000000000000000000000000E+6143 Clamped
dqrem428 remainder   1E+6144  7E+6143  ->   3.00000000000000000000000000000000E+6143 Clamped
dqrem429 remainder   1E+6144  8E+6143  ->   2.00000000000000000000000000000000E+6143 Clamped
dqrem430 remainder   1E+6144  9E+6143  ->   1.00000000000000000000000000000000E+6143 Clamped
-- tinies
dqrem431 remainder   1E-6175  1E-6176  ->   0E-6176
dqrem432 remainder   1E-6175  2E-6176  ->   0E-6176
dqrem433 remainder   1E-6175  3E-6176  ->   1E-6176 Subnormal
dqrem434 remainder   1E-6175  4E-6176  ->   2E-6176 Subnormal
dqrem435 remainder   1E-6175  5E-6176  ->   0E-6176
dqrem436 remainder   1E-6175  6E-6176  ->   4E-6176 Subnormal
dqrem437 remainder   1E-6175  7E-6176  ->   3E-6176 Subnormal
dqrem438 remainder   1E-6175  8E-6176  ->   2E-6176 Subnormal
dqrem439 remainder   1E-6175  9E-6176  ->   1E-6176 Subnormal
dqrem440 remainder   1E-6175 10E-6176  ->   0E-6176
dqrem441 remainder   1E-6175 11E-6176  -> 1.0E-6175 Subnormal
dqrem442 remainder 100E-6175 11E-6176  -> 1.0E-6175 Subnormal
dqrem443 remainder 100E-6175 20E-6176  ->   0E-6176
dqrem444 remainder 100E-6175 21E-6176  -> 1.3E-6175 Subnormal
dqrem445 remainder 100E-6175 30E-6176  -> 1.0E-6175 Subnormal


-- Specials
dqrem680 remainder  Inf  -Inf   ->  NaN Invalid_operation
dqrem681 remainder  Inf  -1000  ->  NaN Invalid_operation
dqrem682 remainder  Inf  -1     ->  NaN Invalid_operation
dqrem683 remainder  Inf   0     ->  NaN Invalid_operation
dqrem684 remainder  Inf  -0     ->  NaN Invalid_operation
dqrem685 remainder  Inf   1     ->  NaN Invalid_operation
dqrem686 remainder  Inf   1000  ->  NaN Invalid_operation
dqrem687 remainder  Inf   Inf   ->  NaN Invalid_operation
dqrem688 remainder -1000  Inf   -> -1000
dqrem689 remainder -Inf   Inf   ->  NaN Invalid_operation
dqrem691 remainder -1     Inf   -> -1
dqrem692 remainder  0     Inf   ->  0
dqrem693 remainder -0     Inf   -> -0
dqrem694 remainder  1     Inf   ->  1
dqrem695 remainder  1000  Inf   ->  1000
dqrem696 remainder  Inf   Inf   ->  NaN Invalid_operation

dqrem700 remainder -Inf  -Inf   ->  NaN Invalid_operation
dqrem701 remainder -Inf  -1000  ->  NaN Invalid_operation
dqrem702 remainder -Inf  -1     ->  NaN Invalid_operation
dqrem703 remainder -Inf  -0     ->  NaN Invalid_operation
dqrem704 remainder -Inf   0     ->  NaN Invalid_operation
dqrem705 remainder -Inf   1     ->  NaN Invalid_operation
dqrem706 remainder -Inf   1000  ->  NaN Invalid_operation
dqrem707 remainder -Inf   Inf   ->  NaN Invalid_operation
dqrem708 remainder -Inf  -Inf   ->  NaN Invalid_operation
dqrem709 remainder -1000  Inf   -> -1000
dqrem710 remainder -1    -Inf   -> -1
dqrem711 remainder -0    -Inf   -> -0
dqrem712 remainder  0    -Inf   ->  0
dqrem713 remainder  1    -Inf   ->  1
dqrem714 remainder  1000 -Inf   ->  1000
dqrem715 remainder  Inf  -Inf   ->  NaN Invalid_operation

dqrem721 remainder  NaN -Inf    ->  NaN
dqrem722 remainder  NaN -1000   ->  NaN
dqrem723 remainder  NaN -1      ->  NaN
dqrem724 remainder  NaN -0      ->  NaN
dqrem725 remainder -NaN  0      -> -NaN
dqrem726 remainder  NaN  1      ->  NaN
dqrem727 remainder  NaN  1000   ->  NaN
dqrem728 remainder  NaN  Inf    ->  NaN
dqrem729 remainder  NaN -NaN    ->  NaN
dqrem730 remainder -Inf  NaN    ->  NaN
dqrem731 remainder -1000 NaN    ->  NaN
dqrem732 remainder -1    NaN    ->  NaN
dqrem733 remainder -0   -NaN    -> -NaN
dqrem734 remainder  0    NaN    ->  NaN
dqrem735 remainder  1   -NaN    -> -NaN
dqrem736 remainder  1000 NaN    ->  NaN
dqrem737 remainder  Inf  NaN    ->  NaN

dqrem741 remainder  sNaN -Inf   ->  NaN  Invalid_operation
dqrem742 remainder  sNaN -1000  ->  NaN  Invalid_operation
dqrem743 remainder -sNaN -1     -> -NaN  Invalid_operation
dqrem744 remainder  sNaN -0     ->  NaN  Invalid_operation
dqrem745 remainder  sNaN  0     ->  NaN  Invalid_operation
dqrem746 remainder  sNaN  1     ->  NaN  Invalid_operation
dqrem747 remainder  sNaN  1000  ->  NaN  Invalid_operation
dqrem749 remainder  sNaN  NaN   ->  NaN  Invalid_operation
dqrem750 remainder  sNaN sNaN   ->  NaN  Invalid_operation
dqrem751 remainder  NaN  sNaN   ->  NaN  Invalid_operation
dqrem752 remainder -Inf  sNaN   ->  NaN  Invalid_operation
dqrem753 remainder -1000 sNaN   ->  NaN  Invalid_operation
dqrem754 remainder -1    sNaN   ->  NaN  Invalid_operation
dqrem755 remainder -0    sNaN   ->  NaN  Invalid_operation
dqrem756 remainder  0    sNaN   ->  NaN  Invalid_operation
dqrem757 remainder  1    sNaN   ->  NaN  Invalid_operation
dqrem758 remainder  1000 sNaN   ->  NaN  Invalid_operation
dqrem759 remainder  Inf -sNaN   -> -NaN  Invalid_operation

-- propaging NaNs
dqrem760 remainder  NaN1   NaN7   ->  NaN1
dqrem761 remainder sNaN2   NaN8   ->  NaN2 Invalid_operation
dqrem762 remainder  NaN3  sNaN9   ->  NaN9 Invalid_operation
dqrem763 remainder sNaN4  sNaN10  ->  NaN4 Invalid_operation
dqrem764 remainder    15   NaN11  ->  NaN11
dqrem765 remainder  NaN6   NaN12  ->  NaN6
dqrem766 remainder  Inf    NaN13  ->  NaN13
dqrem767 remainder  NaN14  -Inf   ->  NaN14
dqrem768 remainder    0    NaN15  ->  NaN15
dqrem769 remainder  NaN16   -0    ->  NaN16

-- edge cases of impossible
dqrem770  remainder  1234568888888887777777777890123456  10    ->  6
dqrem771  remainder  1234568888888887777777777890123456   1    ->  0
dqrem772  remainder  1234568888888887777777777890123456   0.1  ->  NaN Division_impossible
dqrem773  remainder  1234568888888887777777777890123456   0.01 ->  NaN Division_impossible

-- long operand checks
dqrem801 remainder 12345678000 100 -> 0
dqrem802 remainder 1 12345678000   -> 1
dqrem803 remainder 1234567800  10  -> 0
dqrem804 remainder 1 1234567800    -> 1
dqrem805 remainder 1234567890  10  -> 0
dqrem806 remainder 1 1234567890    -> 1
dqrem807 remainder 1234567891  10  -> 1
dqrem808 remainder 1 1234567891    -> 1
dqrem809 remainder 12345678901 100 -> 1
dqrem810 remainder 1 12345678901   -> 1
dqrem811 remainder 1234567896  10  -> 6
dqrem812 remainder 1 1234567896    -> 1

dqrem821 remainder 12345678000 100 -> 0
dqrem822 remainder 1 12345678000   -> 1
dqrem823 remainder 1234567800  10  -> 0
dqrem824 remainder 1 1234567800    -> 1
dqrem825 remainder 1234567890  10  -> 0
dqrem826 remainder 1 1234567890    -> 1
dqrem827 remainder 1234567891  10  -> 1
dqrem828 remainder 1 1234567891    -> 1
dqrem829 remainder 12345678901 100 -> 1
dqrem830 remainder 1 12345678901   -> 1
dqrem831 remainder 1234567896  10  -> 6
dqrem832 remainder 1 1234567896    -> 1

-- from divideint
dqrem840 remainder  100000000.0   1  ->  0.0
dqrem841 remainder  100000000.4   1  ->  0.4
dqrem842 remainder  100000000.5   1  ->  0.5
dqrem843 remainder  100000000.9   1  ->  0.9
dqrem844 remainder  100000000.999 1  ->  0.999
dqrem850 remainder  100000003     5  ->  3
dqrem851 remainder  10000003      5  ->  3
dqrem852 remainder  1000003       5  ->  3
dqrem853 remainder  100003        5  ->  3
dqrem854 remainder  10003         5  ->  3
dqrem855 remainder  1003          5  ->  3
dqrem856 remainder  103           5  ->  3
dqrem857 remainder  13            5  ->  3
dqrem858 remainder  1             5  ->  1

-- Vladimir's cases         1234567890123456
dqrem860 remainder 123.0e1 1000000000000000  -> 1230
dqrem861 remainder 1230    1000000000000000  -> 1230
dqrem862 remainder 12.3e2  1000000000000000  -> 1230
dqrem863 remainder 1.23e3  1000000000000000  -> 1230
dqrem864 remainder 123e1   1000000000000000  -> 1230
dqrem870 remainder 123e1    1000000000000000 -> 1230
dqrem871 remainder 123e1     100000000000000 -> 1230
dqrem872 remainder 123e1      10000000000000 -> 1230
dqrem873 remainder 123e1       1000000000000 -> 1230
dqrem874 remainder 123e1        100000000000 -> 1230
dqrem875 remainder 123e1         10000000000 -> 1230
dqrem876 remainder 123e1          1000000000 -> 1230
dqrem877 remainder 123e1           100000000 -> 1230
dqrem878 remainder 1230            100000000 -> 1230
dqrem879 remainder 123e1            10000000 -> 1230
dqrem880 remainder 123e1             1000000 -> 1230
dqrem881 remainder 123e1              100000 -> 1230
dqrem882 remainder 123e1               10000 -> 1230
dqrem883 remainder 123e1                1000 ->  230
dqrem884 remainder 123e1                 100 ->   30
dqrem885 remainder 123e1                  10 ->    0
dqrem886 remainder 123e1                   1 ->    0

dqrem890 remainder 123e1    2000000000000000 -> 1230
dqrem891 remainder 123e1     200000000000000 -> 1230
dqrem892 remainder 123e1      20000000000000 -> 1230
dqrem893 remainder 123e1       2000000000000 -> 1230
dqrem894 remainder 123e1        200000000000 -> 1230
dqrem895 remainder 123e1         20000000000 -> 1230
dqrem896 remainder 123e1          2000000000 -> 1230
dqrem897 remainder 123e1           200000000 -> 1230
dqrem899 remainder 123e1            20000000 -> 1230
dqrem900 remainder 123e1             2000000 -> 1230
dqrem901 remainder 123e1              200000 -> 1230
dqrem902 remainder 123e1               20000 -> 1230
dqrem903 remainder 123e1                2000 -> 1230
dqrem904 remainder 123e1                 200 ->   30
dqrem905 remainder 123e1                  20 ->   10
dqrem906 remainder 123e1                   2 ->    0

dqrem910 remainder 123e1    5000000000000000 -> 1230
dqrem911 remainder 123e1     500000000000000 -> 1230
dqrem912 remainder 123e1      50000000000000 -> 1230
dqrem913 remainder 123e1       5000000000000 -> 1230
dqrem914 remainder 123e1        500000000000 -> 1230
dqrem915 remainder 123e1         50000000000 -> 1230
dqrem916 remainder 123e1          5000000000 -> 1230
dqrem917 remainder 123e1           500000000 -> 1230
dqrem919 remainder 123e1            50000000 -> 1230
dqrem920 remainder 123e1             5000000 -> 1230
dqrem921 remainder 123e1              500000 -> 1230
dqrem922 remainder 123e1               50000 -> 1230
dqrem923 remainder 123e1                5000 -> 1230
dqrem924 remainder 123e1                 500 ->  230
dqrem925 remainder 123e1                  50 ->   30
dqrem926 remainder 123e1                   5 ->    0

dqrem930 remainder 123e1    9000000000000000 -> 1230
dqrem931 remainder 123e1     900000000000000 -> 1230
dqrem932 remainder 123e1      90000000000000 -> 1230
dqrem933 remainder 123e1       9000000000000 -> 1230
dqrem934 remainder 123e1        900000000000 -> 1230
dqrem935 remainder 123e1         90000000000 -> 1230
dqrem936 remainder 123e1          9000000000 -> 1230
dqrem937 remainder 123e1           900000000 -> 1230
dqrem939 remainder 123e1            90000000 -> 1230
dqrem940 remainder 123e1             9000000 -> 1230
dqrem941 remainder 123e1              900000 -> 1230
dqrem942 remainder 123e1               90000 -> 1230
dqrem943 remainder 123e1                9000 -> 1230
dqrem944 remainder 123e1                 900 ->  330
dqrem945 remainder 123e1                  90 ->   60
dqrem946 remainder 123e1                   9 ->    6

dqrem950 remainder 123e1   1000000000000000 -> 1230
dqrem961 remainder 123e1   2999999999999999 -> 1230
dqrem962 remainder 123e1   3999999999999999 -> 1230
dqrem963 remainder 123e1   4999999999999999 -> 1230
dqrem964 remainder 123e1   5999999999999999 -> 1230
dqrem965 remainder 123e1   6999999999999999 -> 1230
dqrem966 remainder 123e1   7999999999999999 -> 1230
dqrem967 remainder 123e1   8999999999999999 -> 1230
dqrem968 remainder 123e1   9999999999999999 -> 1230
dqrem969 remainder 123e1   9876543210987654 -> 1230

dqrem980 remainder 123e1 1000E299 -> 1.23E+3  -- 123E+1 internally

-- overflow and underflow tests [from divide]
dqrem1051 remainder  1e+277  1e-311 ->  NaN Division_impossible
dqrem1052 remainder  1e+277 -1e-311 ->  NaN Division_impossible
dqrem1053 remainder -1e+277  1e-311 ->  NaN Division_impossible
dqrem1054 remainder -1e+277 -1e-311 ->  NaN Division_impossible
dqrem1055 remainder  1e-277  1e+311 ->  1E-277
dqrem1056 remainder  1e-277 -1e+311 ->  1E-277
dqrem1057 remainder -1e-277  1e+311 -> -1E-277
dqrem1058 remainder -1e-277 -1e+311 -> -1E-277

-- Null tests
dqrem1000 remainder 10  # -> NaN Invalid_operation
dqrem1001 remainder  # 10 -> NaN Invalid_operation

Added test/dectest/dqRemainderNear.decTest.























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
------------------------------------------------------------------------
-- dqRemainderNear.decTest -- decQuad remainder-near                  --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- sanity checks (as base, above)
dqrmn001 remaindernear  1     1    ->  0
dqrmn002 remaindernear  2     1    ->  0
dqrmn003 remaindernear  1     2    ->  1
dqrmn004 remaindernear  2     2    ->  0
dqrmn005 remaindernear  0     1    ->  0
dqrmn006 remaindernear  0     2    ->  0
dqrmn007 remaindernear  1     3    ->  1
dqrmn008 remaindernear  2     3    -> -1
dqrmn009 remaindernear  3     3    ->  0

dqrmn010 remaindernear  2.4   1    ->  0.4
dqrmn011 remaindernear  2.4   -1   ->  0.4
dqrmn012 remaindernear  -2.4  1    ->  -0.4
dqrmn013 remaindernear  -2.4  -1   ->  -0.4
dqrmn014 remaindernear  2.40  1    ->  0.40
dqrmn015 remaindernear  2.400 1    ->  0.400
dqrmn016 remaindernear  2.4   2    ->  0.4
dqrmn017 remaindernear  2.400 2    ->  0.400
dqrmn018 remaindernear  2.    2    ->  0
dqrmn019 remaindernear  20    20   ->  0

dqrmn020 remaindernear  187   187    ->  0
dqrmn021 remaindernear  5     2      ->  1
dqrmn022 remaindernear  5     2.0    ->  1.0
dqrmn023 remaindernear  5     2.000  ->  1.000
dqrmn024 remaindernear  5     0.200  ->  0.000
dqrmn025 remaindernear  5     0.200  ->  0.000

dqrmn030 remaindernear  1     2      ->  1
dqrmn031 remaindernear  1     4      ->  1
dqrmn032 remaindernear  1     8      ->  1

dqrmn033 remaindernear  1     16     ->  1
dqrmn034 remaindernear  1     32     ->  1
dqrmn035 remaindernear  1     64     ->  1
dqrmn040 remaindernear  1    -2      ->  1
dqrmn041 remaindernear  1    -4      ->  1
dqrmn042 remaindernear  1    -8      ->  1
dqrmn043 remaindernear  1    -16     ->  1
dqrmn044 remaindernear  1    -32     ->  1
dqrmn045 remaindernear  1    -64     ->  1
dqrmn050 remaindernear -1     2      ->  -1
dqrmn051 remaindernear -1     4      ->  -1
dqrmn052 remaindernear -1     8      ->  -1
dqrmn053 remaindernear -1     16     ->  -1
dqrmn054 remaindernear -1     32     ->  -1
dqrmn055 remaindernear -1     64     ->  -1
dqrmn060 remaindernear -1    -2      ->  -1
dqrmn061 remaindernear -1    -4      ->  -1
dqrmn062 remaindernear -1    -8      ->  -1
dqrmn063 remaindernear -1    -16     ->  -1
dqrmn064 remaindernear -1    -32     ->  -1
dqrmn065 remaindernear -1    -64     ->  -1

dqrmn066 remaindernear          9.9   1  -> -0.1
dqrmn067 remaindernear         99.7   1  -> -0.3
dqrmn068 remaindernear  999999999     1  -> 0
dqrmn069 remaindernear  999999999.4   1  -> 0.4
dqrmn070 remaindernear  999999999.5   1  -> -0.5
dqrmn071 remaindernear  999999999.9   1  -> -0.1
dqrmn072 remaindernear  999999999.999 1  -> -0.001
dqrmn073 remaindernear  999999.999999 1  -> -0.000001
dqrmn074 remaindernear  9             1  -> 0
dqrmn075 remaindernear  9999999999999999 1  -> 0
dqrmn076 remaindernear  9999999999999999 2  -> -1
dqrmn077 remaindernear  9999999999999999 3  -> 0
dqrmn078 remaindernear  9999999999999999 4  -> -1

dqrmn080 remaindernear  0.            1  -> 0
dqrmn081 remaindernear  .0            1  -> 0.0
dqrmn082 remaindernear  0.00          1  -> 0.00
dqrmn083 remaindernear  0.00E+9       1  -> 0
dqrmn084 remaindernear  0.00E+3       1  -> 0
dqrmn085 remaindernear  0.00E+2       1  -> 0
dqrmn086 remaindernear  0.00E+1       1  -> 0.0
dqrmn087 remaindernear  0.00E+0       1  -> 0.00
dqrmn088 remaindernear  0.00E-0       1  -> 0.00
dqrmn089 remaindernear  0.00E-1       1  -> 0.000
dqrmn090 remaindernear  0.00E-2       1  -> 0.0000
dqrmn091 remaindernear  0.00E-3       1  -> 0.00000
dqrmn092 remaindernear  0.00E-4       1  -> 0.000000
dqrmn093 remaindernear  0.00E-5       1  -> 0E-7
dqrmn094 remaindernear  0.00E-6       1  -> 0E-8
dqrmn095 remaindernear  0.0000E-50    1  -> 0E-54

-- Various flavours of remaindernear by 0
dqrmn101 remaindernear  0       0   -> NaN Division_undefined
dqrmn102 remaindernear  0      -0   -> NaN Division_undefined
dqrmn103 remaindernear -0       0   -> NaN Division_undefined
dqrmn104 remaindernear -0      -0   -> NaN Division_undefined
dqrmn105 remaindernear  0.0E5   0   -> NaN Division_undefined
dqrmn106 remaindernear  0.000   0   -> NaN Division_undefined
-- [Some think this next group should be Division_by_zero exception, but
-- IEEE 854 is explicit that it is Invalid operation .. for
-- remainder-near, anyway]
dqrmn107 remaindernear  0.0001  0   -> NaN Invalid_operation
dqrmn108 remaindernear  0.01    0   -> NaN Invalid_operation
dqrmn109 remaindernear  0.1     0   -> NaN Invalid_operation
dqrmn110 remaindernear  1       0   -> NaN Invalid_operation
dqrmn111 remaindernear  1       0.0 -> NaN Invalid_operation
dqrmn112 remaindernear 10       0.0 -> NaN Invalid_operation
dqrmn113 remaindernear 1E+100   0.0 -> NaN Invalid_operation
dqrmn114 remaindernear 1E+380   0   -> NaN Invalid_operation
dqrmn115 remaindernear  0.0001 -0   -> NaN Invalid_operation
dqrmn116 remaindernear  0.01   -0   -> NaN Invalid_operation
dqrmn119 remaindernear  0.1    -0   -> NaN Invalid_operation
dqrmn120 remaindernear  1      -0   -> NaN Invalid_operation
dqrmn121 remaindernear  1      -0.0 -> NaN Invalid_operation
dqrmn122 remaindernear 10      -0.0 -> NaN Invalid_operation
dqrmn123 remaindernear 1E+100  -0.0 -> NaN Invalid_operation
dqrmn124 remaindernear 1E+384  -0   -> NaN Invalid_operation
-- and zeros on left
dqrmn130 remaindernear  0      1   ->  0
dqrmn131 remaindernear  0     -1   ->  0
dqrmn132 remaindernear  0.0    1   ->  0.0
dqrmn133 remaindernear  0.0   -1   ->  0.0
dqrmn134 remaindernear -0      1   -> -0
dqrmn135 remaindernear -0     -1   -> -0
dqrmn136 remaindernear -0.0    1   -> -0.0
dqrmn137 remaindernear -0.0   -1   -> -0.0

-- 0.5ers
dqrmn143 remaindernear   0.5  2     ->  0.5
dqrmn144 remaindernear   0.5  2.1   ->  0.5
dqrmn145 remaindernear   0.5  2.01  ->  0.50
dqrmn146 remaindernear   0.5  2.001 ->  0.500
dqrmn147 remaindernear   0.50 2     ->  0.50
dqrmn148 remaindernear   0.50 2.01  ->  0.50
dqrmn149 remaindernear   0.50 2.001 ->  0.500

-- steadies
dqrmn150 remaindernear  1  1   -> 0
dqrmn151 remaindernear  1  2   -> 1
dqrmn152 remaindernear  1  3   -> 1
dqrmn153 remaindernear  1  4   -> 1
dqrmn154 remaindernear  1  5   -> 1
dqrmn155 remaindernear  1  6   -> 1
dqrmn156 remaindernear  1  7   -> 1
dqrmn157 remaindernear  1  8   -> 1
dqrmn158 remaindernear  1  9   -> 1
dqrmn159 remaindernear  1  10  -> 1
dqrmn160 remaindernear  1  1   -> 0
dqrmn161 remaindernear  2  1   -> 0
dqrmn162 remaindernear  3  1   -> 0
dqrmn163 remaindernear  4  1   -> 0
dqrmn164 remaindernear  5  1   -> 0
dqrmn165 remaindernear  6  1   -> 0
dqrmn166 remaindernear  7  1   -> 0
dqrmn167 remaindernear  8  1   -> 0
dqrmn168 remaindernear  9  1   -> 0
dqrmn169 remaindernear  10 1   -> 0

-- some differences from remainder
dqrmn171 remaindernear   0.4  1.020 ->  0.400
dqrmn172 remaindernear   0.50 1.020 ->  0.500
dqrmn173 remaindernear   0.51 1.020 ->  0.510
dqrmn174 remaindernear   0.52 1.020 -> -0.500
dqrmn175 remaindernear   0.6  1.020 -> -0.420

-- More flavours of remaindernear by 0
dqrmn201 remaindernear  0      0   -> NaN Division_undefined
dqrmn202 remaindernear  0.0E5  0   -> NaN Division_undefined
dqrmn203 remaindernear  0.000  0   -> NaN Division_undefined
dqrmn204 remaindernear  0.0001 0   -> NaN Invalid_operation
dqrmn205 remaindernear  0.01   0   -> NaN Invalid_operation
dqrmn206 remaindernear  0.1    0   -> NaN Invalid_operation
dqrmn207 remaindernear  1      0   -> NaN Invalid_operation
dqrmn208 remaindernear  1      0.0 -> NaN Invalid_operation
dqrmn209 remaindernear 10      0.0 -> NaN Invalid_operation
dqrmn210 remaindernear 1E+100  0.0 -> NaN Invalid_operation
dqrmn211 remaindernear 1E+380  0   -> NaN Invalid_operation

-- tests from the extended specification
dqrmn221 remaindernear 2.1     3   -> -0.9
dqrmn222 remaindernear  10     6   -> -2
dqrmn223 remaindernear  10     3   ->  1
dqrmn224 remaindernear -10     3   -> -1
dqrmn225 remaindernear  10.2   1   -> 0.2
dqrmn226 remaindernear  10     0.3 -> 0.1
dqrmn227 remaindernear   3.6   1.3 -> -0.3

-- some differences from remainder
dqrmn231 remaindernear  -0.4  1.020 -> -0.400
dqrmn232 remaindernear  -0.50 1.020 -> -0.500
dqrmn233 remaindernear  -0.51 1.020 -> -0.510
dqrmn234 remaindernear  -0.52 1.020 ->  0.500
dqrmn235 remaindernear  -0.6  1.020 ->  0.420

-- high Xs
dqrmn240 remaindernear  1E+2  1.00  ->  0.00

-- dqrmn3xx are from DiagBigDecimal
dqrmn301 remaindernear   1    3     ->  1
dqrmn302 remaindernear   5    5     ->  0
dqrmn303 remaindernear   13   10    ->  3
dqrmn304 remaindernear   13   50    ->  13
dqrmn305 remaindernear   13   100   ->  13
dqrmn306 remaindernear   13   1000  ->  13
dqrmn307 remaindernear   .13    1   ->  0.13
dqrmn308 remaindernear   0.133  1   ->  0.133
dqrmn309 remaindernear   0.1033 1   ->  0.1033
dqrmn310 remaindernear   1.033  1   ->  0.033
dqrmn311 remaindernear   10.33  1   ->  0.33
dqrmn312 remaindernear   10.33 10   ->  0.33
dqrmn313 remaindernear   103.3  1   ->  0.3
dqrmn314 remaindernear   133   10   ->  3
dqrmn315 remaindernear   1033  10   ->  3
dqrmn316 remaindernear   1033  50   -> -17
dqrmn317 remaindernear   101.0  3   -> -1.0
dqrmn318 remaindernear   102.0  3   ->  0.0
dqrmn319 remaindernear   103.0  3   ->  1.0
dqrmn320 remaindernear   2.40   1   ->  0.40
dqrmn321 remaindernear   2.400  1   ->  0.400
dqrmn322 remaindernear   2.4    1   ->  0.4
dqrmn323 remaindernear   2.4    2   ->  0.4
dqrmn324 remaindernear   2.400  2   ->  0.400
dqrmn325 remaindernear   1   0.3    ->  0.1
dqrmn326 remaindernear   1   0.30   ->  0.10
dqrmn327 remaindernear   1   0.300  ->  0.100
dqrmn328 remaindernear   1   0.3000 ->  0.1000
dqrmn329 remaindernear   1.0    0.3 ->  0.1
dqrmn330 remaindernear   1.00   0.3 ->  0.10
dqrmn331 remaindernear   1.000  0.3 ->  0.100
dqrmn332 remaindernear   1.0000 0.3 ->  0.1000
dqrmn333 remaindernear   0.5  2     ->  0.5
dqrmn334 remaindernear   0.5  2.1   ->  0.5
dqrmn335 remaindernear   0.5  2.01  ->  0.50
dqrmn336 remaindernear   0.5  2.001 ->  0.500
dqrmn337 remaindernear   0.50 2     ->  0.50
dqrmn338 remaindernear   0.50 2.01  ->  0.50
dqrmn339 remaindernear   0.50 2.001 ->  0.500

dqrmn340 remaindernear   0.5   0.5000001    ->  -1E-7
dqrmn341 remaindernear   0.5   0.50000001    ->  -1E-8
dqrmn342 remaindernear   0.5   0.500000001    ->  -1E-9
dqrmn343 remaindernear   0.5   0.5000000001    ->  -1E-10
dqrmn344 remaindernear   0.5   0.50000000001    ->  -1E-11
dqrmn345 remaindernear   0.5   0.4999999    ->  1E-7
dqrmn346 remaindernear   0.5   0.49999999    ->  1E-8
dqrmn347 remaindernear   0.5   0.499999999    ->  1E-9
dqrmn348 remaindernear   0.5   0.4999999999    ->  1E-10
dqrmn349 remaindernear   0.5   0.49999999999    ->  1E-11
dqrmn350 remaindernear   0.5   0.499999999999    ->  1E-12

dqrmn351 remaindernear   0.03  7  ->  0.03
dqrmn352 remaindernear   5   2    ->  1
dqrmn353 remaindernear   4.1   2    ->  0.1
dqrmn354 remaindernear   4.01   2    ->  0.01
dqrmn355 remaindernear   4.001   2    ->  0.001
dqrmn356 remaindernear   4.0001   2    ->  0.0001
dqrmn357 remaindernear   4.00001   2    ->  0.00001
dqrmn358 remaindernear   4.000001   2    ->  0.000001
dqrmn359 remaindernear   4.0000001   2    ->  1E-7

dqrmn360 remaindernear   1.2   0.7345 -> -0.2690
dqrmn361 remaindernear   0.8   12     ->  0.8
dqrmn362 remaindernear   0.8   0.2    ->  0.0
dqrmn363 remaindernear   0.8   0.3    -> -0.1
dqrmn364 remaindernear   0.800   12   ->  0.800
dqrmn365 remaindernear   0.800   1.7  ->  0.800
dqrmn366 remaindernear   2.400   2    ->  0.400

-- round to even
dqrmn371 remaindernear   121     2    ->  1
dqrmn372 remaindernear   122     2    ->  0
dqrmn373 remaindernear   123     2    -> -1
dqrmn374 remaindernear   124     2    ->  0
dqrmn375 remaindernear   125     2    ->  1
dqrmn376 remaindernear   126     2    ->  0
dqrmn377 remaindernear   127     2    -> -1

dqrmn381 remaindernear 12345  1         ->  0
dqrmn382 remaindernear 12345  1.0001    -> -0.2344
dqrmn383 remaindernear 12345  1.001     -> -0.333
dqrmn384 remaindernear 12345  1.01      -> -0.23
dqrmn385 remaindernear 12345  1.1       -> -0.3
dqrmn386 remaindernear 12355  4         -> -1
dqrmn387 remaindernear 12345  4         ->  1
dqrmn388 remaindernear 12355  4.0001    -> -1.3089
dqrmn389 remaindernear 12345  4.0001    ->  0.6914
dqrmn390 remaindernear 12345  4.9       ->  1.9
dqrmn391 remaindernear 12345  4.99      -> -0.26
dqrmn392 remaindernear 12345  4.999     ->  2.469
dqrmn393 remaindernear 12345  4.9999    ->  0.2469
dqrmn394 remaindernear 12345  5         ->  0
dqrmn395 remaindernear 12345  5.0001    -> -0.2469
dqrmn396 remaindernear 12345  5.001     -> -2.469
dqrmn397 remaindernear 12345  5.01      ->  0.36
dqrmn398 remaindernear 12345  5.1       -> -2.1

-- the nasty division-by-1 cases
dqrmn401 remaindernear   0.4         1   ->  0.4
dqrmn402 remaindernear   0.45        1   ->  0.45
dqrmn403 remaindernear   0.455       1   ->  0.455
dqrmn404 remaindernear   0.4555      1   ->  0.4555
dqrmn405 remaindernear   0.45555     1   ->  0.45555
dqrmn406 remaindernear   0.455555    1   ->  0.455555
dqrmn407 remaindernear   0.4555555   1   ->  0.4555555
dqrmn408 remaindernear   0.45555555  1   ->  0.45555555
dqrmn409 remaindernear   0.455555555 1   ->  0.455555555
-- with spill... [412 exercises sticktab loop]
dqrmn411 remaindernear   0.5         1   ->  0.5
dqrmn412 remaindernear   0.55        1   -> -0.45
dqrmn413 remaindernear   0.555       1   -> -0.445
dqrmn414 remaindernear   0.5555      1   -> -0.4445
dqrmn415 remaindernear   0.55555     1   -> -0.44445
dqrmn416 remaindernear   0.555555    1   -> -0.444445
dqrmn417 remaindernear   0.5555555   1   -> -0.4444445
dqrmn418 remaindernear   0.55555555  1   -> -0.44444445
dqrmn419 remaindernear   0.555555555 1   -> -0.444444445

-- folddowns
dqrmn421 remaindernear   1E+6144        1  ->   NaN Division_impossible
dqrmn422 remaindernear   1E+6144  1E+6143  ->   0E+6111 Clamped
dqrmn423 remaindernear   1E+6144  2E+6143  ->   0E+6111 Clamped
dqrmn424 remaindernear   1E+6144  3E+6143  ->   1.00000000000000000000000000000000E+6143 Clamped
dqrmn425 remaindernear   1E+6144  4E+6143  ->   2.00000000000000000000000000000000E+6143 Clamped
dqrmn426 remaindernear   1E+6144  5E+6143  ->   0E+6111 Clamped
dqrmn427 remaindernear   1E+6144  6E+6143  ->  -2.00000000000000000000000000000000E+6143 Clamped
dqrmn428 remaindernear   1E+6144  7E+6143  ->   3.00000000000000000000000000000000E+6143 Clamped
dqrmn429 remaindernear   1E+6144  8E+6143  ->   2.00000000000000000000000000000000E+6143 Clamped
dqrmn430 remaindernear   1E+6144  9E+6143  ->   1.00000000000000000000000000000000E+6143 Clamped
-- tinies
dqrmn431 remaindernear   1E-6175  1E-6176  ->   0E-6176
dqrmn432 remaindernear   1E-6175  2E-6176  ->   0E-6176
dqrmn433 remaindernear   1E-6175  3E-6176  ->   1E-6176 Subnormal
dqrmn434 remaindernear   1E-6175  4E-6176  ->   2E-6176 Subnormal
dqrmn435 remaindernear   1E-6175  5E-6176  ->   0E-6176
dqrmn436 remaindernear   1E-6175  6E-6176  ->  -2E-6176 Subnormal
dqrmn437 remaindernear   1E-6175  7E-6176  ->   3E-6176 Subnormal
dqrmn438 remaindernear   1E-6175  8E-6176  ->   2E-6176 Subnormal
dqrmn439 remaindernear   1E-6175  9E-6176  ->   1E-6176 Subnormal
dqrmn440 remaindernear   1E-6175 10E-6176  ->   0E-6176
dqrmn441 remaindernear   1E-6175 11E-6176  ->  -1E-6176 Subnormal
dqrmn442 remaindernear 100E-6175 11E-6176  ->  -1E-6176 Subnormal
dqrmn443 remaindernear 100E-6175 20E-6176  ->   0E-6176
dqrmn444 remaindernear 100E-6175 21E-6176  ->  -8E-6176 Subnormal
dqrmn445 remaindernear 100E-6175 30E-6176  -> 1.0E-6175 Subnormal

-- Specials
dqrmn680 remaindernear  Inf  -Inf   ->  NaN Invalid_operation
dqrmn681 remaindernear  Inf  -1000  ->  NaN Invalid_operation
dqrmn682 remaindernear  Inf  -1     ->  NaN Invalid_operation
dqrmn683 remaindernear  Inf   0     ->  NaN Invalid_operation
dqrmn684 remaindernear  Inf  -0     ->  NaN Invalid_operation
dqrmn685 remaindernear  Inf   1     ->  NaN Invalid_operation
dqrmn686 remaindernear  Inf   1000  ->  NaN Invalid_operation
dqrmn687 remaindernear  Inf   Inf   ->  NaN Invalid_operation
dqrmn688 remaindernear -1000  Inf   -> -1000
dqrmn689 remaindernear -Inf   Inf   ->  NaN Invalid_operation
dqrmn691 remaindernear -1     Inf   -> -1
dqrmn692 remaindernear  0     Inf   ->  0
dqrmn693 remaindernear -0     Inf   -> -0
dqrmn694 remaindernear  1     Inf   ->  1
dqrmn695 remaindernear  1000  Inf   ->  1000
dqrmn696 remaindernear  Inf   Inf   ->  NaN Invalid_operation

dqrmn700 remaindernear -Inf  -Inf   ->  NaN Invalid_operation
dqrmn701 remaindernear -Inf  -1000  ->  NaN Invalid_operation
dqrmn702 remaindernear -Inf  -1     ->  NaN Invalid_operation
dqrmn703 remaindernear -Inf  -0     ->  NaN Invalid_operation
dqrmn704 remaindernear -Inf   0     ->  NaN Invalid_operation
dqrmn705 remaindernear -Inf   1     ->  NaN Invalid_operation
dqrmn706 remaindernear -Inf   1000  ->  NaN Invalid_operation
dqrmn707 remaindernear -Inf   Inf   ->  NaN Invalid_operation
dqrmn708 remaindernear -Inf  -Inf   ->  NaN Invalid_operation
dqrmn709 remaindernear -1000  Inf   -> -1000
dqrmn710 remaindernear -1    -Inf   -> -1
dqrmn711 remaindernear -0    -Inf   -> -0
dqrmn712 remaindernear  0    -Inf   ->  0
dqrmn713 remaindernear  1    -Inf   ->  1
dqrmn714 remaindernear  1000 -Inf   ->  1000
dqrmn715 remaindernear  Inf  -Inf   ->  NaN Invalid_operation

dqrmn721 remaindernear  NaN -Inf    ->  NaN
dqrmn722 remaindernear  NaN -1000   ->  NaN
dqrmn723 remaindernear  NaN -1      ->  NaN
dqrmn724 remaindernear  NaN -0      ->  NaN
dqrmn725 remaindernear -NaN  0      -> -NaN
dqrmn726 remaindernear  NaN  1      ->  NaN
dqrmn727 remaindernear  NaN  1000   ->  NaN
dqrmn728 remaindernear  NaN  Inf    ->  NaN
dqrmn729 remaindernear  NaN -NaN    ->  NaN
dqrmn730 remaindernear -Inf  NaN    ->  NaN
dqrmn731 remaindernear -1000 NaN    ->  NaN
dqrmn732 remaindernear -1    NaN    ->  NaN
dqrmn733 remaindernear -0   -NaN    -> -NaN
dqrmn734 remaindernear  0    NaN    ->  NaN
dqrmn735 remaindernear  1   -NaN    -> -NaN
dqrmn736 remaindernear  1000 NaN    ->  NaN
dqrmn737 remaindernear  Inf  NaN    ->  NaN

dqrmn741 remaindernear  sNaN -Inf   ->  NaN  Invalid_operation
dqrmn742 remaindernear  sNaN -1000  ->  NaN  Invalid_operation
dqrmn743 remaindernear -sNaN -1     -> -NaN  Invalid_operation
dqrmn744 remaindernear  sNaN -0     ->  NaN  Invalid_operation
dqrmn745 remaindernear  sNaN  0     ->  NaN  Invalid_operation
dqrmn746 remaindernear  sNaN  1     ->  NaN  Invalid_operation
dqrmn747 remaindernear  sNaN  1000  ->  NaN  Invalid_operation
dqrmn749 remaindernear  sNaN  NaN   ->  NaN  Invalid_operation
dqrmn750 remaindernear  sNaN sNaN   ->  NaN  Invalid_operation
dqrmn751 remaindernear  NaN  sNaN   ->  NaN  Invalid_operation
dqrmn752 remaindernear -Inf  sNaN   ->  NaN  Invalid_operation
dqrmn753 remaindernear -1000 sNaN   ->  NaN  Invalid_operation
dqrmn754 remaindernear -1    sNaN   ->  NaN  Invalid_operation
dqrmn755 remaindernear -0    sNaN   ->  NaN  Invalid_operation
dqrmn756 remaindernear  0    sNaN   ->  NaN  Invalid_operation
dqrmn757 remaindernear  1    sNaN   ->  NaN  Invalid_operation
dqrmn758 remaindernear  1000 sNaN   ->  NaN  Invalid_operation
dqrmn759 remaindernear  Inf -sNaN   -> -NaN  Invalid_operation

-- propaging NaNs
dqrmn760 remaindernear  NaN1   NaN7   ->  NaN1
dqrmn761 remaindernear sNaN2   NaN8   ->  NaN2 Invalid_operation
dqrmn762 remaindernear  NaN3  sNaN9   ->  NaN9 Invalid_operation
dqrmn763 remaindernear sNaN4  sNaN10  ->  NaN4 Invalid_operation
dqrmn764 remaindernear    15   NaN11  ->  NaN11
dqrmn765 remaindernear  NaN6   NaN12  ->  NaN6
dqrmn766 remaindernear  Inf    NaN13  ->  NaN13
dqrmn767 remaindernear  NaN14  -Inf   ->  NaN14
dqrmn768 remaindernear    0    NaN15  ->  NaN15
dqrmn769 remaindernear  NaN16   -0    ->  NaN16

-- edge cases of impossible
dqrmn770  remaindernear  1234500000000000000000067890123456  10    -> -4
dqrmn771  remaindernear  1234500000000000000000067890123456   1    ->  0
dqrmn772  remaindernear  1234500000000000000000067890123456   0.1  ->  NaN Division_impossible
dqrmn773  remaindernear  1234500000000000000000067890123456   0.01 ->  NaN Division_impossible

-- long operand checks
dqrmn801 remaindernear 12345678000 100 -> 0
dqrmn802 remaindernear 1 12345678000   -> 1
dqrmn803 remaindernear 1234567800  10  -> 0
dqrmn804 remaindernear 1 1234567800    -> 1
dqrmn805 remaindernear 1234567890  10  -> 0
dqrmn806 remaindernear 1 1234567890    -> 1
dqrmn807 remaindernear 1234567891  10  -> 1
dqrmn808 remaindernear 1 1234567891    -> 1
dqrmn809 remaindernear 12345678901 100 -> 1
dqrmn810 remaindernear 1 12345678901   -> 1
dqrmn811 remaindernear 1234567896  10  -> -4
dqrmn812 remaindernear 1 1234567896    -> 1

dqrmn821 remaindernear 12345678000 100 -> 0
dqrmn822 remaindernear 1 12345678000   -> 1
dqrmn823 remaindernear 1234567800  10  -> 0
dqrmn824 remaindernear 1 1234567800    -> 1
dqrmn825 remaindernear 1234567890  10  -> 0
dqrmn826 remaindernear 1 1234567890    -> 1
dqrmn827 remaindernear 1234567891  10  -> 1
dqrmn828 remaindernear 1 1234567891    -> 1
dqrmn829 remaindernear 12345678901 100 -> 1
dqrmn830 remaindernear 1 12345678901   -> 1
dqrmn831 remaindernear 1234567896  10  -> -4
dqrmn832 remaindernear 1 1234567896    -> 1

-- from divideint
dqrmn840 remaindernear  100000000.0   1  ->  0.0
dqrmn841 remaindernear  100000000.4   1  ->  0.4
dqrmn842 remaindernear  100000000.5   1  ->  0.5
dqrmn843 remaindernear  100000000.9   1  -> -0.1
dqrmn844 remaindernear  100000000.999 1  -> -0.001
dqrmn850 remaindernear  100000003     5  -> -2
dqrmn851 remaindernear  10000003      5  -> -2
dqrmn852 remaindernear  1000003       5  -> -2
dqrmn853 remaindernear  100003        5  -> -2
dqrmn854 remaindernear  10003         5  -> -2
dqrmn855 remaindernear  1003          5  -> -2
dqrmn856 remaindernear  103           5  -> -2
dqrmn857 remaindernear  13            5  -> -2
dqrmn858 remaindernear  1             5  ->  1

-- Vladimir's cases         1234567890123456
dqrmn860 remaindernear 123.0e1 1000000000000000  -> 1230
dqrmn861 remaindernear 1230    1000000000000000  -> 1230
dqrmn862 remaindernear 12.3e2  1000000000000000  -> 1230
dqrmn863 remaindernear 1.23e3  1000000000000000  -> 1230
dqrmn864 remaindernear 123e1   1000000000000000  -> 1230
dqrmn870 remaindernear 123e1    1000000000000000 -> 1230
dqrmn871 remaindernear 123e1     100000000000000 -> 1230
dqrmn872 remaindernear 123e1      10000000000000 -> 1230
dqrmn873 remaindernear 123e1       1000000000000 -> 1230
dqrmn874 remaindernear 123e1        100000000000 -> 1230
dqrmn875 remaindernear 123e1         10000000000 -> 1230
dqrmn876 remaindernear 123e1          1000000000 -> 1230
dqrmn877 remaindernear 123e1           100000000 -> 1230
dqrmn878 remaindernear 1230            100000000 -> 1230
dqrmn879 remaindernear 123e1            10000000 -> 1230
dqrmn880 remaindernear 123e1             1000000 -> 1230
dqrmn881 remaindernear 123e1              100000 -> 1230
dqrmn882 remaindernear 123e1               10000 -> 1230
dqrmn883 remaindernear 123e1                1000 ->  230
dqrmn884 remaindernear 123e1                 100 ->   30
dqrmn885 remaindernear 123e1                  10 ->    0
dqrmn886 remaindernear 123e1                   1 ->    0

dqrmn890 remaindernear 123e1    2000000000000000 -> 1230
dqrmn891 remaindernear 123e1     200000000000000 -> 1230
dqrmn892 remaindernear 123e1      20000000000000 -> 1230
dqrmn893 remaindernear 123e1       2000000000000 -> 1230
dqrmn894 remaindernear 123e1        200000000000 -> 1230
dqrmn895 remaindernear 123e1         20000000000 -> 1230
dqrmn896 remaindernear 123e1          2000000000 -> 1230
dqrmn897 remaindernear 123e1           200000000 -> 1230
dqrmn899 remaindernear 123e1            20000000 -> 1230
dqrmn900 remaindernear 123e1             2000000 -> 1230
dqrmn901 remaindernear 123e1              200000 -> 1230
dqrmn902 remaindernear 123e1               20000 -> 1230
dqrmn903 remaindernear 123e1                2000 -> -770
dqrmn904 remaindernear 123e1                 200 ->   30
dqrmn905 remaindernear 123e1                  20 ->  -10
dqrmn906 remaindernear 123e1                   2 ->    0

dqrmn910 remaindernear 123e1    5000000000000000 -> 1230
dqrmn911 remaindernear 123e1     500000000000000 -> 1230
dqrmn912 remaindernear 123e1      50000000000000 -> 1230
dqrmn913 remaindernear 123e1       5000000000000 -> 1230
dqrmn914 remaindernear 123e1        500000000000 -> 1230
dqrmn915 remaindernear 123e1         50000000000 -> 1230
dqrmn916 remaindernear 123e1          5000000000 -> 1230
dqrmn917 remaindernear 123e1           500000000 -> 1230
dqrmn919 remaindernear 123e1            50000000 -> 1230
dqrmn920 remaindernear 123e1             5000000 -> 1230
dqrmn921 remaindernear 123e1              500000 -> 1230
dqrmn922 remaindernear 123e1               50000 -> 1230
dqrmn923 remaindernear 123e1                5000 -> 1230
dqrmn924 remaindernear 123e1                 500 ->  230
dqrmn925 remaindernear 123e1                  50 ->  -20
dqrmn926 remaindernear 123e1                   5 ->    0

dqrmn930 remaindernear 123e1    9000000000000000 -> 1230
dqrmn931 remaindernear 123e1     900000000000000 -> 1230
dqrmn932 remaindernear 123e1      90000000000000 -> 1230
dqrmn933 remaindernear 123e1       9000000000000 -> 1230
dqrmn934 remaindernear 123e1        900000000000 -> 1230
dqrmn935 remaindernear 123e1         90000000000 -> 1230
dqrmn936 remaindernear 123e1          9000000000 -> 1230
dqrmn937 remaindernear 123e1           900000000 -> 1230
dqrmn939 remaindernear 123e1            90000000 -> 1230
dqrmn940 remaindernear 123e1             9000000 -> 1230
dqrmn941 remaindernear 123e1              900000 -> 1230
dqrmn942 remaindernear 123e1               90000 -> 1230
dqrmn943 remaindernear 123e1                9000 -> 1230
dqrmn944 remaindernear 123e1                 900 ->  330
dqrmn945 remaindernear 123e1                  90 ->  -30
dqrmn946 remaindernear 123e1                   9 ->   -3

dqrmn950 remaindernear 123e1   1000000000000000 -> 1230
dqrmn961 remaindernear 123e1   2999999999999999 -> 1230
dqrmn962 remaindernear 123e1   3999999999999999 -> 1230
dqrmn963 remaindernear 123e1   4999999999999999 -> 1230
dqrmn964 remaindernear 123e1   5999999999999999 -> 1230
dqrmn965 remaindernear 123e1   6999999999999999 -> 1230
dqrmn966 remaindernear 123e1   7999999999999999 -> 1230
dqrmn967 remaindernear 123e1   8999999999999999 -> 1230
dqrmn968 remaindernear 123e1   9999999999999999 -> 1230
dqrmn969 remaindernear 123e1   9876543210987654 -> 1230

dqrmn980 remaindernear 123e1 1000E299 -> 1.23E+3  -- 123E+1 internally

-- overflow and underflow tests [from divide]
dqrmn1051 remaindernear  1e+277  1e-311 ->  NaN Division_impossible
dqrmn1052 remaindernear  1e+277 -1e-311 ->  NaN Division_impossible
dqrmn1053 remaindernear -1e+277  1e-311 ->  NaN Division_impossible
dqrmn1054 remaindernear -1e+277 -1e-311 ->  NaN Division_impossible
dqrmn1055 remaindernear  1e-277  1e+311 ->  1E-277
dqrmn1056 remaindernear  1e-277 -1e+311 ->  1E-277
dqrmn1057 remaindernear -1e-277  1e+311 -> -1E-277
dqrmn1058 remaindernear -1e-277 -1e+311 -> -1E-277

-- Null tests
dqrmn1000 remaindernear 10  # -> NaN Invalid_operation
dqrmn1001 remaindernear  # 10 -> NaN Invalid_operation

Added test/dectest/dqRotate.decTest.





















































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
------------------------------------------------------------------------
-- dqRotate.decTest -- rotate decQuad coefficient left or right       --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Sanity check
dqrot001 rotate                                   0    0  ->  0
dqrot002 rotate                                   0    2  ->  0
dqrot003 rotate                                   1    2  ->  100
dqrot004 rotate                                   1   33  ->  1000000000000000000000000000000000
dqrot005 rotate                                   1   34  ->  1
dqrot006 rotate                                   1   -1  ->  1000000000000000000000000000000000
dqrot007 rotate                                   0   -2  ->  0
dqrot008 rotate  1234567890123456789012345678901234   -1  ->  4123456789012345678901234567890123
dqrot009 rotate  1234567890123456789012345678901234   -33 ->  2345678901234567890123456789012341
dqrot010 rotate  1234567890123456789012345678901234   -34 ->  1234567890123456789012345678901234
dqrot011 rotate  9934567890123456789012345678901234   -33 ->  9345678901234567890123456789012349
dqrot012 rotate  9934567890123456789012345678901234   -34 ->  9934567890123456789012345678901234

-- rhs must be an integer
dqrot015 rotate        1    1.5    -> NaN Invalid_operation
dqrot016 rotate        1    1.0    -> NaN Invalid_operation
dqrot017 rotate        1    0.1    -> NaN Invalid_operation
dqrot018 rotate        1    0.0    -> NaN Invalid_operation
dqrot019 rotate        1    1E+1   -> NaN Invalid_operation
dqrot020 rotate        1    1E+99  -> NaN Invalid_operation
dqrot021 rotate        1    Inf    -> NaN Invalid_operation
dqrot022 rotate        1    -Inf   -> NaN Invalid_operation
-- and |rhs| <= precision
dqrot025 rotate        1    -1000  -> NaN Invalid_operation
dqrot026 rotate        1    -35    -> NaN Invalid_operation
dqrot027 rotate        1     35    -> NaN Invalid_operation
dqrot028 rotate        1     1000  -> NaN Invalid_operation

-- full pattern
dqrot030 rotate  1234567890123456789012345678901234         -34  -> 1234567890123456789012345678901234
dqrot031 rotate  1234567890123456789012345678901234         -33  -> 2345678901234567890123456789012341
dqrot032 rotate  1234567890123456789012345678901234         -32  -> 3456789012345678901234567890123412
dqrot033 rotate  1234567890123456789012345678901234         -31  -> 4567890123456789012345678901234123
dqrot034 rotate  1234567890123456789012345678901234         -30  -> 5678901234567890123456789012341234
dqrot035 rotate  1234567890123456789012345678901234         -29  -> 6789012345678901234567890123412345
dqrot036 rotate  1234567890123456789012345678901234         -28  -> 7890123456789012345678901234123456
dqrot037 rotate  1234567890123456789012345678901234         -27  -> 8901234567890123456789012341234567
dqrot038 rotate  1234567890123456789012345678901234         -26  -> 9012345678901234567890123412345678
dqrot039 rotate  1234567890123456789012345678901234         -25  ->  123456789012345678901234123456789
dqrot040 rotate  1234567890123456789012345678901234         -24  -> 1234567890123456789012341234567890
dqrot041 rotate  1234567890123456789012345678901234         -23  -> 2345678901234567890123412345678901
dqrot042 rotate  1234567890123456789012345678901234         -22  -> 3456789012345678901234123456789012
dqrot043 rotate  1234567890123456789012345678901234         -21  -> 4567890123456789012341234567890123
dqrot044 rotate  1234567890123456789012345678901234         -20  -> 5678901234567890123412345678901234
dqrot045 rotate  1234567890123456789012345678901234         -19  -> 6789012345678901234123456789012345
dqrot047 rotate  1234567890123456789012345678901234         -18  -> 7890123456789012341234567890123456
dqrot048 rotate  1234567890123456789012345678901234         -17  -> 8901234567890123412345678901234567
dqrot049 rotate  1234567890123456789012345678901234         -16  -> 9012345678901234123456789012345678
dqrot050 rotate  1234567890123456789012345678901234         -15  ->  123456789012341234567890123456789
dqrot051 rotate  1234567890123456789012345678901234         -14  -> 1234567890123412345678901234567890
dqrot052 rotate  1234567890123456789012345678901234         -13  -> 2345678901234123456789012345678901
dqrot053 rotate  1234567890123456789012345678901234         -12  -> 3456789012341234567890123456789012
dqrot054 rotate  1234567890123456789012345678901234         -11  -> 4567890123412345678901234567890123
dqrot055 rotate  1234567890123456789012345678901234         -10  -> 5678901234123456789012345678901234
dqrot056 rotate  1234567890123456789012345678901234         -9   -> 6789012341234567890123456789012345
dqrot057 rotate  1234567890123456789012345678901234         -8   -> 7890123412345678901234567890123456
dqrot058 rotate  1234567890123456789012345678901234         -7   -> 8901234123456789012345678901234567
dqrot059 rotate  1234567890123456789012345678901234         -6   -> 9012341234567890123456789012345678
dqrot060 rotate  1234567890123456789012345678901234         -5   ->  123412345678901234567890123456789
dqrot061 rotate  1234567890123456789012345678901234         -4   -> 1234123456789012345678901234567890
dqrot062 rotate  1234567890123456789012345678901234         -3   -> 2341234567890123456789012345678901
dqrot063 rotate  1234567890123456789012345678901234         -2   -> 3412345678901234567890123456789012
dqrot064 rotate  1234567890123456789012345678901234         -1   -> 4123456789012345678901234567890123
dqrot065 rotate  1234567890123456789012345678901234         -0   -> 1234567890123456789012345678901234

dqrot066 rotate  1234567890123456789012345678901234         +0   -> 1234567890123456789012345678901234
dqrot067 rotate  1234567890123456789012345678901234         +1   -> 2345678901234567890123456789012341
dqrot068 rotate  1234567890123456789012345678901234         +2   -> 3456789012345678901234567890123412
dqrot069 rotate  1234567890123456789012345678901234         +3   -> 4567890123456789012345678901234123
dqrot070 rotate  1234567890123456789012345678901234         +4   -> 5678901234567890123456789012341234
dqrot071 rotate  1234567890123456789012345678901234         +5   -> 6789012345678901234567890123412345
dqrot072 rotate  1234567890123456789012345678901234         +6   -> 7890123456789012345678901234123456
dqrot073 rotate  1234567890123456789012345678901234         +7   -> 8901234567890123456789012341234567
dqrot074 rotate  1234567890123456789012345678901234         +8   -> 9012345678901234567890123412345678
dqrot075 rotate  1234567890123456789012345678901234         +9   ->  123456789012345678901234123456789
dqrot076 rotate  1234567890123456789012345678901234         +10  -> 1234567890123456789012341234567890
dqrot077 rotate  1234567890123456789012345678901234         +11  -> 2345678901234567890123412345678901
dqrot078 rotate  1234567890123456789012345678901234         +12  -> 3456789012345678901234123456789012
dqrot079 rotate  1234567890123456789012345678901234         +13  -> 4567890123456789012341234567890123
dqrot080 rotate  1234567890123456789012345678901234         +14  -> 5678901234567890123412345678901234
dqrot081 rotate  1234567890123456789012345678901234         +15  -> 6789012345678901234123456789012345
dqrot082 rotate  1234567890123456789012345678901234         +16  -> 7890123456789012341234567890123456
dqrot083 rotate  1234567890123456789012345678901234         +17  -> 8901234567890123412345678901234567
dqrot084 rotate  1234567890123456789012345678901234         +18  -> 9012345678901234123456789012345678
dqrot085 rotate  1234567890123456789012345678901234         +19  ->  123456789012341234567890123456789
dqrot086 rotate  1234567890123456789012345678901234         +20  -> 1234567890123412345678901234567890
dqrot087 rotate  1234567890123456789012345678901234         +21  -> 2345678901234123456789012345678901
dqrot088 rotate  1234567890123456789012345678901234         +22  -> 3456789012341234567890123456789012
dqrot089 rotate  1234567890123456789012345678901234         +23  -> 4567890123412345678901234567890123
dqrot090 rotate  1234567890123456789012345678901234         +24  -> 5678901234123456789012345678901234
dqrot091 rotate  1234567890123456789012345678901234         +25  -> 6789012341234567890123456789012345
dqrot092 rotate  1234567890123456789012345678901234         +26  -> 7890123412345678901234567890123456
dqrot093 rotate  1234567890123456789012345678901234         +27  -> 8901234123456789012345678901234567
dqrot094 rotate  1234567890123456789012345678901234         +28  -> 9012341234567890123456789012345678
dqrot095 rotate  1234567890123456789012345678901234         +29  ->  123412345678901234567890123456789
dqrot096 rotate  1234567890123456789012345678901234         +30  -> 1234123456789012345678901234567890
dqrot097 rotate  1234567890123456789012345678901234         +31  -> 2341234567890123456789012345678901
dqrot098 rotate  1234567890123456789012345678901234         +32  -> 3412345678901234567890123456789012
dqrot099 rotate  1234567890123456789012345678901234         +33  -> 4123456789012345678901234567890123
dqrot100 rotate  1234567890123456789012345678901234         +34  -> 1234567890123456789012345678901234

-- zeros
dqrot270 rotate  0E-10              +29   ->   0E-10
dqrot271 rotate  0E-10              -29   ->   0E-10
dqrot272 rotate  0.000              +29   ->   0.000
dqrot273 rotate  0.000              -29   ->   0.000
dqrot274 rotate  0E+10              +29   ->   0E+10
dqrot275 rotate  0E+10              -29   ->   0E+10
dqrot276 rotate -0E-10              +29   ->  -0E-10
dqrot277 rotate -0E-10              -29   ->  -0E-10
dqrot278 rotate -0.000              +29   ->  -0.000
dqrot279 rotate -0.000              -29   ->  -0.000
dqrot280 rotate -0E+10              +29   ->  -0E+10
dqrot281 rotate -0E+10              -29   ->  -0E+10

-- Nmax, Nmin, Ntiny
dqrot141 rotate  9.999999999999999999999999999999999E+6144     -1  -> 9.999999999999999999999999999999999E+6144
dqrot142 rotate  9.999999999999999999999999999999999E+6144     -33 -> 9.999999999999999999999999999999999E+6144
dqrot143 rotate  9.999999999999999999999999999999999E+6144      1  -> 9.999999999999999999999999999999999E+6144
dqrot144 rotate  9.999999999999999999999999999999999E+6144      33 -> 9.999999999999999999999999999999999E+6144
dqrot145 rotate  1E-6143                                       -1  -> 1.000000000000000000000000000000000E-6110
dqrot146 rotate  1E-6143                                       -33 -> 1.0E-6142
dqrot147 rotate  1E-6143                                        1  -> 1.0E-6142
dqrot148 rotate  1E-6143                                        33 -> 1.000000000000000000000000000000000E-6110
dqrot151 rotate  1.000000000000000000000000000000000E-6143     -1  -> 1.00000000000000000000000000000000E-6144
dqrot152 rotate  1.000000000000000000000000000000000E-6143     -33 -> 1E-6176
dqrot153 rotate  1.000000000000000000000000000000000E-6143      1  -> 1E-6176
dqrot154 rotate  1.000000000000000000000000000000000E-6143      33 -> 1.00000000000000000000000000000000E-6144
dqrot155 rotate  9.000000000000000000000000000000000E-6143     -1  -> 9.00000000000000000000000000000000E-6144
dqrot156 rotate  9.000000000000000000000000000000000E-6143     -33 -> 9E-6176
dqrot157 rotate  9.000000000000000000000000000000000E-6143      1  -> 9E-6176
dqrot158 rotate  9.000000000000000000000000000000000E-6143      33 -> 9.00000000000000000000000000000000E-6144
dqrot160 rotate  1E-6176                                       -1  -> 1.000000000000000000000000000000000E-6143
dqrot161 rotate  1E-6176                                       -33 -> 1.0E-6175
dqrot162 rotate  1E-6176                                        1  -> 1.0E-6175
dqrot163 rotate  1E-6176                                        33 -> 1.000000000000000000000000000000000E-6143
--  negatives
dqrot171 rotate -9.999999999999999999999999999999999E+6144     -1  -> -9.999999999999999999999999999999999E+6144
dqrot172 rotate -9.999999999999999999999999999999999E+6144     -33 -> -9.999999999999999999999999999999999E+6144
dqrot173 rotate -9.999999999999999999999999999999999E+6144      1  -> -9.999999999999999999999999999999999E+6144
dqrot174 rotate -9.999999999999999999999999999999999E+6144      33 -> -9.999999999999999999999999999999999E+6144
dqrot175 rotate -1E-6143                                       -1  -> -1.000000000000000000000000000000000E-6110
dqrot176 rotate -1E-6143                                       -33 -> -1.0E-6142
dqrot177 rotate -1E-6143                                        1  -> -1.0E-6142
dqrot178 rotate -1E-6143                                        33 -> -1.000000000000000000000000000000000E-6110
dqrot181 rotate -1.000000000000000000000000000000000E-6143     -1  -> -1.00000000000000000000000000000000E-6144
dqrot182 rotate -1.000000000000000000000000000000000E-6143     -33 -> -1E-6176
dqrot183 rotate -1.000000000000000000000000000000000E-6143      1  -> -1E-6176
dqrot184 rotate -1.000000000000000000000000000000000E-6143      33 -> -1.00000000000000000000000000000000E-6144
dqrot185 rotate -9.000000000000000000000000000000000E-6143     -1  -> -9.00000000000000000000000000000000E-6144
dqrot186 rotate -9.000000000000000000000000000000000E-6143     -33 -> -9E-6176
dqrot187 rotate -9.000000000000000000000000000000000E-6143      1  -> -9E-6176
dqrot188 rotate -9.000000000000000000000000000000000E-6143      33 -> -9.00000000000000000000000000000000E-6144
dqrot190 rotate -1E-6176                                       -1  -> -1.000000000000000000000000000000000E-6143
dqrot191 rotate -1E-6176                                       -33 -> -1.0E-6175
dqrot192 rotate -1E-6176                                        1  -> -1.0E-6175
dqrot193 rotate -1E-6176                                        33 -> -1.000000000000000000000000000000000E-6143

-- more negatives (of sanities)
dqrot201 rotate                                  -0    0  -> -0
dqrot202 rotate                                  -0    2  -> -0
dqrot203 rotate                                  -1    2  -> -100
dqrot204 rotate                                  -1   33  -> -1000000000000000000000000000000000
dqrot205 rotate                                  -1   34  -> -1
dqrot206 rotate                                  -1   -1  -> -1000000000000000000000000000000000
dqrot207 rotate                                  -0   -2  -> -0
dqrot208 rotate -1234567890123456789012345678901234   -1  -> -4123456789012345678901234567890123
dqrot209 rotate -1234567890123456789012345678901234   -33 -> -2345678901234567890123456789012341
dqrot210 rotate -1234567890123456789012345678901234   -34 -> -1234567890123456789012345678901234
dqrot211 rotate -9934567890123456789012345678901234   -33 -> -9345678901234567890123456789012349
dqrot212 rotate -9934567890123456789012345678901234   -34 -> -9934567890123456789012345678901234


-- Specials; NaNs are handled as usual
dqrot781 rotate -Inf  -8     -> -Infinity
dqrot782 rotate -Inf  -1     -> -Infinity
dqrot783 rotate -Inf  -0     -> -Infinity
dqrot784 rotate -Inf   0     -> -Infinity
dqrot785 rotate -Inf   1     -> -Infinity
dqrot786 rotate -Inf   8     -> -Infinity
dqrot787 rotate -1000 -Inf   -> NaN Invalid_operation
dqrot788 rotate -Inf  -Inf   -> NaN Invalid_operation
dqrot789 rotate -1    -Inf   -> NaN Invalid_operation
dqrot790 rotate -0    -Inf   -> NaN Invalid_operation
dqrot791 rotate  0    -Inf   -> NaN Invalid_operation
dqrot792 rotate  1    -Inf   -> NaN Invalid_operation
dqrot793 rotate  1000 -Inf   -> NaN Invalid_operation
dqrot794 rotate  Inf  -Inf   -> NaN Invalid_operation

dqrot800 rotate  Inf  -Inf   -> NaN Invalid_operation
dqrot801 rotate  Inf  -8     -> Infinity
dqrot802 rotate  Inf  -1     -> Infinity
dqrot803 rotate  Inf  -0     -> Infinity
dqrot804 rotate  Inf   0     -> Infinity
dqrot805 rotate  Inf   1     -> Infinity
dqrot806 rotate  Inf   8     -> Infinity
dqrot807 rotate  Inf   Inf   -> NaN Invalid_operation
dqrot808 rotate -1000  Inf   -> NaN Invalid_operation
dqrot809 rotate -Inf   Inf   -> NaN Invalid_operation
dqrot810 rotate -1     Inf   -> NaN Invalid_operation
dqrot811 rotate -0     Inf   -> NaN Invalid_operation
dqrot812 rotate  0     Inf   -> NaN Invalid_operation
dqrot813 rotate  1     Inf   -> NaN Invalid_operation
dqrot814 rotate  1000  Inf   -> NaN Invalid_operation
dqrot815 rotate  Inf   Inf   -> NaN Invalid_operation

dqrot821 rotate  NaN -Inf    ->  NaN
dqrot822 rotate  NaN -1000   ->  NaN
dqrot823 rotate  NaN -1      ->  NaN
dqrot824 rotate  NaN -0      ->  NaN
dqrot825 rotate  NaN  0      ->  NaN
dqrot826 rotate  NaN  1      ->  NaN
dqrot827 rotate  NaN  1000   ->  NaN
dqrot828 rotate  NaN  Inf    ->  NaN
dqrot829 rotate  NaN  NaN    ->  NaN
dqrot830 rotate -Inf  NaN    ->  NaN
dqrot831 rotate -1000 NaN    ->  NaN
dqrot832 rotate -1    NaN    ->  NaN
dqrot833 rotate -0    NaN    ->  NaN
dqrot834 rotate  0    NaN    ->  NaN
dqrot835 rotate  1    NaN    ->  NaN
dqrot836 rotate  1000 NaN    ->  NaN
dqrot837 rotate  Inf  NaN    ->  NaN

dqrot841 rotate  sNaN -Inf   ->  NaN  Invalid_operation
dqrot842 rotate  sNaN -1000  ->  NaN  Invalid_operation
dqrot843 rotate  sNaN -1     ->  NaN  Invalid_operation
dqrot844 rotate  sNaN -0     ->  NaN  Invalid_operation
dqrot845 rotate  sNaN  0     ->  NaN  Invalid_operation
dqrot846 rotate  sNaN  1     ->  NaN  Invalid_operation
dqrot847 rotate  sNaN  1000  ->  NaN  Invalid_operation
dqrot848 rotate  sNaN  NaN   ->  NaN  Invalid_operation
dqrot849 rotate  sNaN sNaN   ->  NaN  Invalid_operation
dqrot850 rotate  NaN  sNaN   ->  NaN  Invalid_operation
dqrot851 rotate -Inf  sNaN   ->  NaN  Invalid_operation
dqrot852 rotate -1000 sNaN   ->  NaN  Invalid_operation
dqrot853 rotate -1    sNaN   ->  NaN  Invalid_operation
dqrot854 rotate -0    sNaN   ->  NaN  Invalid_operation
dqrot855 rotate  0    sNaN   ->  NaN  Invalid_operation
dqrot856 rotate  1    sNaN   ->  NaN  Invalid_operation
dqrot857 rotate  1000 sNaN   ->  NaN  Invalid_operation
dqrot858 rotate  Inf  sNaN   ->  NaN  Invalid_operation
dqrot859 rotate  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqrot861 rotate  NaN1   -Inf    ->  NaN1
dqrot862 rotate +NaN2   -1000   ->  NaN2
dqrot863 rotate  NaN3    1000   ->  NaN3
dqrot864 rotate  NaN4    Inf    ->  NaN4
dqrot865 rotate  NaN5   +NaN6   ->  NaN5
dqrot866 rotate -Inf     NaN7   ->  NaN7
dqrot867 rotate -1000    NaN8   ->  NaN8
dqrot868 rotate  1000    NaN9   ->  NaN9
dqrot869 rotate  Inf    +NaN10  ->  NaN10
dqrot871 rotate  sNaN11  -Inf   ->  NaN11  Invalid_operation
dqrot872 rotate  sNaN12  -1000  ->  NaN12  Invalid_operation
dqrot873 rotate  sNaN13   1000  ->  NaN13  Invalid_operation
dqrot874 rotate  sNaN14   NaN17 ->  NaN14  Invalid_operation
dqrot875 rotate  sNaN15  sNaN18 ->  NaN15  Invalid_operation
dqrot876 rotate  NaN16   sNaN19 ->  NaN19  Invalid_operation
dqrot877 rotate -Inf    +sNaN20 ->  NaN20  Invalid_operation
dqrot878 rotate -1000    sNaN21 ->  NaN21  Invalid_operation
dqrot879 rotate  1000    sNaN22 ->  NaN22  Invalid_operation
dqrot880 rotate  Inf     sNaN23 ->  NaN23  Invalid_operation
dqrot881 rotate +NaN25  +sNaN24 ->  NaN24  Invalid_operation
dqrot882 rotate -NaN26    NaN28 -> -NaN26
dqrot883 rotate -sNaN27  sNaN29 -> -NaN27  Invalid_operation
dqrot884 rotate  1000    -NaN30 -> -NaN30
dqrot885 rotate  1000   -sNaN31 -> -NaN31  Invalid_operation

Added test/dectest/dqSameQuantum.decTest.











































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
------------------------------------------------------------------------
-- dqSameQuantum.decTest -- check decQuad quantums match              --
-- Copyright (c) IBM Corporation, 2001, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- All operands and results are decQuads.
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

dqsamq001 samequantum  0      0      ->  1
dqsamq002 samequantum  0      1      ->  1
dqsamq003 samequantum  1      0      ->  1
dqsamq004 samequantum  1      1      ->  1

dqsamq011 samequantum  10     1E+1   -> 0
dqsamq012 samequantum  10E+1  10E+1  -> 1
dqsamq013 samequantum  100    10E+1  -> 0
dqsamq014 samequantum  100    1E+2   -> 0
dqsamq015 samequantum  0.1    1E-2   -> 0
dqsamq016 samequantum  0.1    1E-1   -> 1
dqsamq017 samequantum  0.1    1E-0   -> 0
dqsamq018 samequantum  999    999    -> 1
dqsamq019 samequantum  999E-1 99.9   -> 1
dqsamq020 samequantum  111E-1 22.2   -> 1
dqsamq021 samequantum  111E-1 1234.2 -> 1

-- zeros
dqsamq030 samequantum  0.0    1.1    -> 1
dqsamq031 samequantum  0.0    1.11   -> 0
dqsamq032 samequantum  0.0    0      -> 0
dqsamq033 samequantum  0.0    0.0    -> 1
dqsamq034 samequantum  0.0    0.00   -> 0
dqsamq035 samequantum  0E+1   0E+0   -> 0
dqsamq036 samequantum  0E+1   0E+1   -> 1
dqsamq037 samequantum  0E+1   0E+2   -> 0
dqsamq038 samequantum  0E-17  0E-16  -> 0
dqsamq039 samequantum  0E-17  0E-17  -> 1
dqsamq040 samequantum  0E-17  0E-18  -> 0
dqsamq041 samequantum  0E-17  0.0E-15 -> 0
dqsamq042 samequantum  0E-17  0.0E-16 -> 1
dqsamq043 samequantum  0E-17  0.0E-17 -> 0
dqsamq044 samequantum -0E-17  0.0E-16 -> 1
dqsamq045 samequantum  0E-17 -0.0E-17 -> 0
dqsamq046 samequantum  0E-17 -0.0E-16 -> 1
dqsamq047 samequantum -0E-17  0.0E-17 -> 0
dqsamq048 samequantum -0E-17 -0.0E-16 -> 1
dqsamq049 samequantum -0E-17 -0.0E-17 -> 0

-- Nmax, Nmin, Ntiny
dqsamq051 samequantum  9.99999999999999999999999999999999E+6144    9.99999999999999999999999999999999E+6144  -> 1
dqsamq052 samequantum  1E-6143             1E-6143           -> 1
dqsamq053 samequantum  1.00000000000000000000000000000000E-6143    1.00000000000000000000000000000000E-6143  -> 1
dqsamq054 samequantum  1E-6176             1E-6176           -> 1
dqsamq055 samequantum  9.99999999999999999999999999999999E+6144    9.99999999999999999999999999999999E+6144  -> 1
dqsamq056 samequantum  1E-6143             1E-6143           -> 1
dqsamq057 samequantum  1.00000000000000000000000000000000E-6143    1.00000000000000000000000000000000E-6143  -> 1
dqsamq058 samequantum  1E-6176             1E-6176           -> 1

dqsamq061 samequantum  -1E-6176            -1E-6176          -> 1
dqsamq062 samequantum  -1.00000000000000000000000000000000E-6143   -1.00000000000000000000000000000000E-6143 -> 1
dqsamq063 samequantum  -1E-6143            -1E-6143          -> 1
dqsamq064 samequantum  -9.99999999999999999999999999999999E+6144   -9.99999999999999999999999999999999E+6144 -> 1
dqsamq065 samequantum  -1E-6176            -1E-6176          -> 1
dqsamq066 samequantum  -1.00000000000000000000000000000000E-6143   -1.00000000000000000000000000000000E-6143 -> 1
dqsamq067 samequantum  -1E-6143            -1E-6143          -> 1
dqsamq068 samequantum  -9.99999999999999999999999999999999E+6144   -9.99999999999999999999999999999999E+6144 -> 1

dqsamq071 samequantum  -4E-6176            -1E-6176          -> 1
dqsamq072 samequantum  -4.00000000000000000000000000000000E-6143   -1.00000000000000000000000000004000E-6143 -> 1
dqsamq073 samequantum  -4E-6143            -1E-6143          -> 1
dqsamq074 samequantum  -4.99999999999999999999999999999999E+6144   -9.99949999999999999999999999999999E+6144 -> 1
dqsamq075 samequantum  -4E-6176            -1E-6176          -> 1
dqsamq076 samequantum  -4.00000000000000000000000000000000E-6143   -1.00400000000000000000000000000000E-6143 -> 1
dqsamq077 samequantum  -4E-6143            -1E-6143          -> 1
dqsamq078 samequantum  -4.99999999999999999999999999999999E+6144   -9.94999999999999999999999999999999E+6144 -> 1

dqsamq081 samequantum  -4E-1006           -1E-6176          -> 0
dqsamq082 samequantum  -4.00000000000000000000000000000000E-6143   -1.00004000000000000000000000000000E-6136 -> 0
dqsamq083 samequantum  -4E-6140           -1E-6143          -> 0
dqsamq084 samequantum  -4.99999999999999999999999999999999E+6144   -9.99949999999999999999999999999999E+6136 -> 0
dqsamq085 samequantum  -4E-1006           -1E-6176          -> 0
dqsamq086 samequantum  -4.00000000000000000000000000000000E-6143   -1.00400000000000000000000000000000E-6136 -> 0
dqsamq087 samequantum  -4E-6133           -1E-6143          -> 0
dqsamq088 samequantum  -4.99999999999999999999999999999999E+6144   -9.94999999999999999999999999999999E+6136 -> 0

-- specials & combinations
dqsamq0110 samequantum  -Inf    -Inf   -> 1
dqsamq0111 samequantum  -Inf     Inf   -> 1
dqsamq0112 samequantum  -Inf     NaN   -> 0
dqsamq0113 samequantum  -Inf    -7E+3  -> 0
dqsamq0114 samequantum  -Inf    -7     -> 0
dqsamq0115 samequantum  -Inf    -7E-3  -> 0
dqsamq0116 samequantum  -Inf    -0E-3  -> 0
dqsamq0117 samequantum  -Inf    -0     -> 0
dqsamq0118 samequantum  -Inf    -0E+3  -> 0
dqsamq0119 samequantum  -Inf     0E-3  -> 0
dqsamq0120 samequantum  -Inf     0     -> 0
dqsamq0121 samequantum  -Inf     0E+3  -> 0
dqsamq0122 samequantum  -Inf     7E-3  -> 0
dqsamq0123 samequantum  -Inf     7     -> 0
dqsamq0124 samequantum  -Inf     7E+3  -> 0
dqsamq0125 samequantum  -Inf     sNaN  -> 0

dqsamq0210 samequantum   Inf    -Inf   -> 1
dqsamq0211 samequantum   Inf     Inf   -> 1
dqsamq0212 samequantum   Inf     NaN   -> 0
dqsamq0213 samequantum   Inf    -7E+3  -> 0
dqsamq0214 samequantum   Inf    -7     -> 0
dqsamq0215 samequantum   Inf    -7E-3  -> 0
dqsamq0216 samequantum   Inf    -0E-3  -> 0
dqsamq0217 samequantum   Inf    -0     -> 0
dqsamq0218 samequantum   Inf    -0E+3  -> 0
dqsamq0219 samequantum   Inf     0E-3  -> 0
dqsamq0220 samequantum   Inf     0     -> 0
dqsamq0221 samequantum   Inf     0E+3  -> 0
dqsamq0222 samequantum   Inf     7E-3  -> 0
dqsamq0223 samequantum   Inf     7     -> 0
dqsamq0224 samequantum   Inf     7E+3  -> 0
dqsamq0225 samequantum   Inf     sNaN  -> 0

dqsamq0310 samequantum   NaN    -Inf   -> 0
dqsamq0311 samequantum   NaN     Inf   -> 0
dqsamq0312 samequantum   NaN     NaN   -> 1
dqsamq0313 samequantum   NaN    -7E+3  -> 0
dqsamq0314 samequantum   NaN    -7     -> 0
dqsamq0315 samequantum   NaN    -7E-3  -> 0
dqsamq0316 samequantum   NaN    -0E-3  -> 0
dqsamq0317 samequantum   NaN    -0     -> 0
dqsamq0318 samequantum   NaN    -0E+3  -> 0
dqsamq0319 samequantum   NaN     0E-3  -> 0
dqsamq0320 samequantum   NaN     0     -> 0
dqsamq0321 samequantum   NaN     0E+3  -> 0
dqsamq0322 samequantum   NaN     7E-3  -> 0
dqsamq0323 samequantum   NaN     7     -> 0
dqsamq0324 samequantum   NaN     7E+3  -> 0
dqsamq0325 samequantum   NaN     sNaN  -> 1

dqsamq0410 samequantum  -7E+3    -Inf   -> 0
dqsamq0411 samequantum  -7E+3     Inf   -> 0
dqsamq0412 samequantum  -7E+3     NaN   -> 0
dqsamq0413 samequantum  -7E+3    -7E+3  -> 1
dqsamq0414 samequantum  -7E+3    -7     -> 0
dqsamq0415 samequantum  -7E+3    -7E-3  -> 0
dqsamq0416 samequantum  -7E+3    -0E-3  -> 0
dqsamq0417 samequantum  -7E+3    -0     -> 0
dqsamq0418 samequantum  -7E+3    -0E+3  -> 1
dqsamq0419 samequantum  -7E+3     0E-3  -> 0
dqsamq0420 samequantum  -7E+3     0     -> 0
dqsamq0421 samequantum  -7E+3     0E+3  -> 1
dqsamq0422 samequantum  -7E+3     7E-3  -> 0
dqsamq0423 samequantum  -7E+3     7     -> 0
dqsamq0424 samequantum  -7E+3     7E+3  -> 1
dqsamq0425 samequantum  -7E+3     sNaN  -> 0

dqsamq0510 samequantum  -7      -Inf   -> 0
dqsamq0511 samequantum  -7       Inf   -> 0
dqsamq0512 samequantum  -7       NaN   -> 0
dqsamq0513 samequantum  -7      -7E+3  -> 0
dqsamq0514 samequantum  -7      -7     -> 1
dqsamq0515 samequantum  -7      -7E-3  -> 0
dqsamq0516 samequantum  -7      -0E-3  -> 0
dqsamq0517 samequantum  -7      -0     -> 1
dqsamq0518 samequantum  -7      -0E+3  -> 0
dqsamq0519 samequantum  -7       0E-3  -> 0
dqsamq0520 samequantum  -7       0     -> 1
dqsamq0521 samequantum  -7       0E+3  -> 0
dqsamq0522 samequantum  -7       7E-3  -> 0
dqsamq0523 samequantum  -7       7     -> 1
dqsamq0524 samequantum  -7       7E+3  -> 0
dqsamq0525 samequantum  -7       sNaN  -> 0

dqsamq0610 samequantum  -7E-3    -Inf   -> 0
dqsamq0611 samequantum  -7E-3     Inf   -> 0
dqsamq0612 samequantum  -7E-3     NaN   -> 0
dqsamq0613 samequantum  -7E-3    -7E+3  -> 0
dqsamq0614 samequantum  -7E-3    -7     -> 0
dqsamq0615 samequantum  -7E-3    -7E-3  -> 1
dqsamq0616 samequantum  -7E-3    -0E-3  -> 1
dqsamq0617 samequantum  -7E-3    -0     -> 0
dqsamq0618 samequantum  -7E-3    -0E+3  -> 0
dqsamq0619 samequantum  -7E-3     0E-3  -> 1
dqsamq0620 samequantum  -7E-3     0     -> 0
dqsamq0621 samequantum  -7E-3     0E+3  -> 0
dqsamq0622 samequantum  -7E-3     7E-3  -> 1
dqsamq0623 samequantum  -7E-3     7     -> 0
dqsamq0624 samequantum  -7E-3     7E+3  -> 0
dqsamq0625 samequantum  -7E-3     sNaN  -> 0

dqsamq0710 samequantum  -0E-3    -Inf   -> 0
dqsamq0711 samequantum  -0E-3     Inf   -> 0
dqsamq0712 samequantum  -0E-3     NaN   -> 0
dqsamq0713 samequantum  -0E-3    -7E+3  -> 0
dqsamq0714 samequantum  -0E-3    -7     -> 0
dqsamq0715 samequantum  -0E-3    -7E-3  -> 1
dqsamq0716 samequantum  -0E-3    -0E-3  -> 1
dqsamq0717 samequantum  -0E-3    -0     -> 0
dqsamq0718 samequantum  -0E-3    -0E+3  -> 0
dqsamq0719 samequantum  -0E-3     0E-3  -> 1
dqsamq0720 samequantum  -0E-3     0     -> 0
dqsamq0721 samequantum  -0E-3     0E+3  -> 0
dqsamq0722 samequantum  -0E-3     7E-3  -> 1
dqsamq0723 samequantum  -0E-3     7     -> 0
dqsamq0724 samequantum  -0E-3     7E+3  -> 0
dqsamq0725 samequantum  -0E-3     sNaN  -> 0

dqsamq0810 samequantum  -0      -Inf   -> 0
dqsamq0811 samequantum  -0       Inf   -> 0
dqsamq0812 samequantum  -0       NaN   -> 0
dqsamq0813 samequantum  -0      -7E+3  -> 0
dqsamq0814 samequantum  -0      -7     -> 1
dqsamq0815 samequantum  -0      -7E-3  -> 0
dqsamq0816 samequantum  -0      -0E-3  -> 0
dqsamq0817 samequantum  -0      -0     -> 1
dqsamq0818 samequantum  -0      -0E+3  -> 0
dqsamq0819 samequantum  -0       0E-3  -> 0
dqsamq0820 samequantum  -0       0     -> 1
dqsamq0821 samequantum  -0       0E+3  -> 0
dqsamq0822 samequantum  -0       7E-3  -> 0
dqsamq0823 samequantum  -0       7     -> 1
dqsamq0824 samequantum  -0       7E+3  -> 0
dqsamq0825 samequantum  -0       sNaN  -> 0

dqsamq0910 samequantum  -0E+3    -Inf   -> 0
dqsamq0911 samequantum  -0E+3     Inf   -> 0
dqsamq0912 samequantum  -0E+3     NaN   -> 0
dqsamq0913 samequantum  -0E+3    -7E+3  -> 1
dqsamq0914 samequantum  -0E+3    -7     -> 0
dqsamq0915 samequantum  -0E+3    -7E-3  -> 0
dqsamq0916 samequantum  -0E+3    -0E-3  -> 0
dqsamq0917 samequantum  -0E+3    -0     -> 0
dqsamq0918 samequantum  -0E+3    -0E+3  -> 1
dqsamq0919 samequantum  -0E+3     0E-3  -> 0
dqsamq0920 samequantum  -0E+3     0     -> 0
dqsamq0921 samequantum  -0E+3     0E+3  -> 1
dqsamq0922 samequantum  -0E+3     7E-3  -> 0
dqsamq0923 samequantum  -0E+3     7     -> 0
dqsamq0924 samequantum  -0E+3     7E+3  -> 1
dqsamq0925 samequantum  -0E+3     sNaN  -> 0

dqsamq1110 samequantum  0E-3    -Inf   -> 0
dqsamq1111 samequantum  0E-3     Inf   -> 0
dqsamq1112 samequantum  0E-3     NaN   -> 0
dqsamq1113 samequantum  0E-3    -7E+3  -> 0
dqsamq1114 samequantum  0E-3    -7     -> 0
dqsamq1115 samequantum  0E-3    -7E-3  -> 1
dqsamq1116 samequantum  0E-3    -0E-3  -> 1
dqsamq1117 samequantum  0E-3    -0     -> 0
dqsamq1118 samequantum  0E-3    -0E+3  -> 0
dqsamq1119 samequantum  0E-3     0E-3  -> 1
dqsamq1120 samequantum  0E-3     0     -> 0
dqsamq1121 samequantum  0E-3     0E+3  -> 0
dqsamq1122 samequantum  0E-3     7E-3  -> 1
dqsamq1123 samequantum  0E-3     7     -> 0
dqsamq1124 samequantum  0E-3     7E+3  -> 0
dqsamq1125 samequantum  0E-3     sNaN  -> 0

dqsamq1210 samequantum  0       -Inf   -> 0
dqsamq1211 samequantum  0        Inf   -> 0
dqsamq1212 samequantum  0        NaN   -> 0
dqsamq1213 samequantum  0       -7E+3  -> 0
dqsamq1214 samequantum  0       -7     -> 1
dqsamq1215 samequantum  0       -7E-3  -> 0
dqsamq1216 samequantum  0       -0E-3  -> 0
dqsamq1217 samequantum  0       -0     -> 1
dqsamq1218 samequantum  0       -0E+3  -> 0
dqsamq1219 samequantum  0        0E-3  -> 0
dqsamq1220 samequantum  0        0     -> 1
dqsamq1221 samequantum  0        0E+3  -> 0
dqsamq1222 samequantum  0        7E-3  -> 0
dqsamq1223 samequantum  0        7     -> 1
dqsamq1224 samequantum  0        7E+3  -> 0
dqsamq1225 samequantum  0        sNaN  -> 0

dqsamq1310 samequantum  0E+3    -Inf   -> 0
dqsamq1311 samequantum  0E+3     Inf   -> 0
dqsamq1312 samequantum  0E+3     NaN   -> 0
dqsamq1313 samequantum  0E+3    -7E+3  -> 1
dqsamq1314 samequantum  0E+3    -7     -> 0
dqsamq1315 samequantum  0E+3    -7E-3  -> 0
dqsamq1316 samequantum  0E+3    -0E-3  -> 0
dqsamq1317 samequantum  0E+3    -0     -> 0
dqsamq1318 samequantum  0E+3    -0E+3  -> 1
dqsamq1319 samequantum  0E+3     0E-3  -> 0
dqsamq1320 samequantum  0E+3     0     -> 0
dqsamq1321 samequantum  0E+3     0E+3  -> 1
dqsamq1322 samequantum  0E+3     7E-3  -> 0
dqsamq1323 samequantum  0E+3     7     -> 0
dqsamq1324 samequantum  0E+3     7E+3  -> 1
dqsamq1325 samequantum  0E+3     sNaN  -> 0

dqsamq1410 samequantum  7E-3    -Inf   -> 0
dqsamq1411 samequantum  7E-3     Inf   -> 0
dqsamq1412 samequantum  7E-3     NaN   -> 0
dqsamq1413 samequantum  7E-3    -7E+3  -> 0
dqsamq1414 samequantum  7E-3    -7     -> 0
dqsamq1415 samequantum  7E-3    -7E-3  -> 1
dqsamq1416 samequantum  7E-3    -0E-3  -> 1
dqsamq1417 samequantum  7E-3    -0     -> 0
dqsamq1418 samequantum  7E-3    -0E+3  -> 0
dqsamq1419 samequantum  7E-3     0E-3  -> 1
dqsamq1420 samequantum  7E-3     0     -> 0
dqsamq1421 samequantum  7E-3     0E+3  -> 0
dqsamq1422 samequantum  7E-3     7E-3  -> 1
dqsamq1423 samequantum  7E-3     7     -> 0
dqsamq1424 samequantum  7E-3     7E+3  -> 0
dqsamq1425 samequantum  7E-3     sNaN  -> 0

dqsamq1510 samequantum  7      -Inf   -> 0
dqsamq1511 samequantum  7       Inf   -> 0
dqsamq1512 samequantum  7       NaN   -> 0
dqsamq1513 samequantum  7      -7E+3  -> 0
dqsamq1514 samequantum  7      -7     -> 1
dqsamq1515 samequantum  7      -7E-3  -> 0
dqsamq1516 samequantum  7      -0E-3  -> 0
dqsamq1517 samequantum  7      -0     -> 1
dqsamq1518 samequantum  7      -0E+3  -> 0
dqsamq1519 samequantum  7       0E-3  -> 0
dqsamq1520 samequantum  7       0     -> 1
dqsamq1521 samequantum  7       0E+3  -> 0
dqsamq1522 samequantum  7       7E-3  -> 0
dqsamq1523 samequantum  7       7     -> 1
dqsamq1524 samequantum  7       7E+3  -> 0
dqsamq1525 samequantum  7       sNaN  -> 0

dqsamq1610 samequantum  7E+3    -Inf   -> 0
dqsamq1611 samequantum  7E+3     Inf   -> 0
dqsamq1612 samequantum  7E+3     NaN   -> 0
dqsamq1613 samequantum  7E+3    -7E+3  -> 1
dqsamq1614 samequantum  7E+3    -7     -> 0
dqsamq1615 samequantum  7E+3    -7E-3  -> 0
dqsamq1616 samequantum  7E+3    -0E-3  -> 0
dqsamq1617 samequantum  7E+3    -0     -> 0
dqsamq1618 samequantum  7E+3    -0E+3  -> 1
dqsamq1619 samequantum  7E+3     0E-3  -> 0
dqsamq1620 samequantum  7E+3     0     -> 0
dqsamq1621 samequantum  7E+3     0E+3  -> 1
dqsamq1622 samequantum  7E+3     7E-3  -> 0
dqsamq1623 samequantum  7E+3     7     -> 0
dqsamq1624 samequantum  7E+3     7E+3  -> 1
dqsamq1625 samequantum  7E+3     sNaN  -> 0

dqsamq1710 samequantum  sNaN    -Inf   -> 0
dqsamq1711 samequantum  sNaN     Inf   -> 0
dqsamq1712 samequantum  sNaN     NaN   -> 1
dqsamq1713 samequantum  sNaN    -7E+3  -> 0
dqsamq1714 samequantum  sNaN    -7     -> 0
dqsamq1715 samequantum  sNaN    -7E-3  -> 0
dqsamq1716 samequantum  sNaN    -0E-3  -> 0
dqsamq1717 samequantum  sNaN    -0     -> 0
dqsamq1718 samequantum  sNaN    -0E+3  -> 0
dqsamq1719 samequantum  sNaN     0E-3  -> 0
dqsamq1720 samequantum  sNaN     0     -> 0
dqsamq1721 samequantum  sNaN     0E+3  -> 0
dqsamq1722 samequantum  sNaN     7E-3  -> 0
dqsamq1723 samequantum  sNaN     7     -> 0
dqsamq1724 samequantum  sNaN     7E+3  -> 0
dqsamq1725 samequantum  sNaN     sNaN  -> 1
-- noisy NaNs
dqsamq1730 samequantum  sNaN3    sNaN3 -> 1
dqsamq1731 samequantum  sNaN3    sNaN4 -> 1
dqsamq1732 samequantum   NaN3     NaN3 -> 1
dqsamq1733 samequantum   NaN3     NaN4 -> 1
dqsamq1734 samequantum  sNaN3     3    -> 0
dqsamq1735 samequantum   NaN3     3    -> 0
dqsamq1736 samequantum      4    sNaN4 -> 0
dqsamq1737 samequantum      3     NaN3 -> 0
dqsamq1738 samequantum    Inf    sNaN4 -> 0
dqsamq1739 samequantum   -Inf     NaN3 -> 0

Added test/dectest/dqScaleB.decTest.









































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
------------------------------------------------------------------------
-- dqScalebB.decTest -- scale a decQuad by powers of 10               --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Max |rhs| is 2*(6144+34) = 12356

-- Sanity checks
dqscb001 scaleb       7.50   10 -> 7.50E+10
dqscb002 scaleb       7.50    3 -> 7.50E+3
dqscb003 scaleb       7.50    2 -> 750
dqscb004 scaleb       7.50    1 -> 75.0
dqscb005 scaleb       7.50    0 -> 7.50
dqscb006 scaleb       7.50   -1 -> 0.750
dqscb007 scaleb       7.50   -2 -> 0.0750
dqscb008 scaleb       7.50  -10 -> 7.50E-10
dqscb009 scaleb      -7.50    3 -> -7.50E+3
dqscb010 scaleb      -7.50    2 -> -750
dqscb011 scaleb      -7.50    1 -> -75.0
dqscb012 scaleb      -7.50    0 -> -7.50
dqscb013 scaleb      -7.50   -1 -> -0.750

-- Infinities
dqscb014 scaleb  Infinity   1 -> Infinity
dqscb015 scaleb  -Infinity  2 -> -Infinity
dqscb016 scaleb  Infinity  -1 -> Infinity
dqscb017 scaleb  -Infinity -2 -> -Infinity

-- Next two are somewhat undefined in 754r; treat as non-integer
dqscb018 scaleb  10  Infinity -> NaN Invalid_operation
dqscb019 scaleb  10 -Infinity -> NaN Invalid_operation

-- NaNs are undefined in 754r; assume usual processing
-- NaNs, 0 payload
dqscb021 scaleb         NaN  1 -> NaN
dqscb022 scaleb        -NaN -1 -> -NaN
dqscb023 scaleb        sNaN  1 -> NaN Invalid_operation
dqscb024 scaleb       -sNaN  1 -> -NaN Invalid_operation
dqscb025 scaleb    4    NaN    -> NaN
dqscb026 scaleb -Inf   -NaN    -> -NaN
dqscb027 scaleb    4   sNaN    -> NaN Invalid_operation
dqscb028 scaleb  Inf  -sNaN    -> -NaN Invalid_operation

-- non-integer RHS
dqscb030 scaleb  1.23    1    ->  12.3
dqscb031 scaleb  1.23    1.00 ->  NaN Invalid_operation
dqscb032 scaleb  1.23    1.1  ->  NaN Invalid_operation
dqscb033 scaleb  1.23    1.01 ->  NaN Invalid_operation
dqscb034 scaleb  1.23    0.01 ->  NaN Invalid_operation
dqscb035 scaleb  1.23    0.11 ->  NaN Invalid_operation
dqscb036 scaleb  1.23    0.999999999 ->  NaN Invalid_operation
dqscb037 scaleb  1.23   -1    ->  0.123
dqscb0614 scaleb  1.23   -1.00 ->  NaN Invalid_operation
dqscb039 scaleb  1.23   -1.1  ->  NaN Invalid_operation
dqscb040 scaleb  1.23   -1.01 ->  NaN Invalid_operation
dqscb041 scaleb  1.23   -0.01 ->  NaN Invalid_operation
dqscb042 scaleb  1.23   -0.11 ->  NaN Invalid_operation
dqscb043 scaleb  1.23   -0.999999999 ->  NaN Invalid_operation
dqscb044 scaleb  1.23    0.1         ->  NaN Invalid_operation
dqscb045 scaleb  1.23    1E+1        ->  NaN Invalid_operation
dqscb046 scaleb  1.23    1.1234E+6   ->  NaN Invalid_operation
dqscb047 scaleb  1.23    1.123E+4    ->  NaN Invalid_operation

-- out-of range RHS
dqscb120 scaleb  1.23    12355       ->  Infinity Overflow Inexact Rounded
dqscb121 scaleb  1.23    12356       ->  Infinity Overflow Inexact Rounded
dqscb122 scaleb  1.23    12357       ->  NaN Invalid_operation
dqscb123 scaleb  1.23    12358       ->  NaN Invalid_operation
dqscb124 scaleb  1.23   -12355       ->  0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqscb125 scaleb  1.23   -12356       ->  0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqscb126 scaleb  1.23   -12357       ->  NaN Invalid_operation
dqscb127 scaleb  1.23   -12358       ->  NaN Invalid_operation

-- NaNs, non-0 payload
-- propagating NaNs
dqscb861 scaleb  NaN01   -Inf     ->  NaN1
dqscb862 scaleb -NaN02   -1000    -> -NaN2
dqscb863 scaleb  NaN03    1000    ->  NaN3
dqscb864 scaleb  NaN04    Inf     ->  NaN4
dqscb865 scaleb  NaN05    NaN61   ->  NaN5
dqscb866 scaleb -Inf     -NaN71   -> -NaN71
dqscb867 scaleb -1000     NaN81   ->  NaN81
dqscb868 scaleb  1000     NaN91   ->  NaN91
dqscb869 scaleb  Inf      NaN101  ->  NaN101
dqscb871 scaleb  sNaN011  -Inf    ->  NaN11  Invalid_operation
dqscb872 scaleb  sNaN012  -1000   ->  NaN12  Invalid_operation
dqscb873 scaleb -sNaN013   1000   -> -NaN13  Invalid_operation
dqscb874 scaleb  sNaN014   NaN171 ->  NaN14  Invalid_operation
dqscb875 scaleb  sNaN015  sNaN181 ->  NaN15  Invalid_operation
dqscb876 scaleb  NaN016   sNaN191 ->  NaN191 Invalid_operation
dqscb877 scaleb -Inf      sNaN201 ->  NaN201 Invalid_operation
dqscb878 scaleb -1000     sNaN211 ->  NaN211 Invalid_operation
dqscb879 scaleb  1000    -sNaN221 -> -NaN221 Invalid_operation
dqscb880 scaleb  Inf      sNaN231 ->  NaN231 Invalid_operation
dqscb881 scaleb  NaN025   sNaN241 ->  NaN241 Invalid_operation

-- finites
dqscb051 scaleb          7   -2  -> 0.07
dqscb052 scaleb         -7   -2  -> -0.07
dqscb053 scaleb         75   -2  -> 0.75
dqscb054 scaleb        -75   -2  -> -0.75
dqscb055 scaleb       7.50   -2  -> 0.0750
dqscb056 scaleb      -7.50   -2  -> -0.0750
dqscb057 scaleb       7.500  -2  -> 0.07500
dqscb058 scaleb      -7.500  -2  -> -0.07500
dqscb061 scaleb          7   -1  -> 0.7
dqscb062 scaleb         -7   -1  -> -0.7
dqscb063 scaleb         75   -1  -> 7.5
dqscb064 scaleb        -75   -1  -> -7.5
dqscb065 scaleb       7.50   -1  -> 0.750
dqscb066 scaleb      -7.50   -1  -> -0.750
dqscb067 scaleb       7.500  -1  -> 0.7500
dqscb068 scaleb      -7.500  -1  -> -0.7500
dqscb071 scaleb          7    0  -> 7
dqscb072 scaleb         -7    0  -> -7
dqscb073 scaleb         75    0  -> 75
dqscb074 scaleb        -75    0  -> -75
dqscb075 scaleb       7.50    0  -> 7.50
dqscb076 scaleb      -7.50    0  -> -7.50
dqscb077 scaleb       7.500   0  -> 7.500
dqscb078 scaleb      -7.500   0  -> -7.500
dqscb081 scaleb          7    1  -> 7E+1
dqscb082 scaleb         -7    1  -> -7E+1
dqscb083 scaleb         75    1  -> 7.5E+2
dqscb084 scaleb        -75    1  -> -7.5E+2
dqscb085 scaleb       7.50    1  -> 75.0
dqscb086 scaleb      -7.50    1  -> -75.0
dqscb087 scaleb       7.500   1  -> 75.00
dqscb088 scaleb      -7.500   1  -> -75.00
dqscb091 scaleb          7    2  -> 7E+2
dqscb092 scaleb         -7    2  -> -7E+2
dqscb093 scaleb         75    2  -> 7.5E+3
dqscb094 scaleb        -75    2  -> -7.5E+3
dqscb095 scaleb       7.50    2  -> 750
dqscb096 scaleb      -7.50    2  -> -750
dqscb097 scaleb       7.500   2  -> 750.0
dqscb098 scaleb      -7.500   2  -> -750.0

-- zeros
dqscb111 scaleb          0  1 -> 0E+1
dqscb112 scaleb         -0  2 -> -0E+2
dqscb113 scaleb       0E+4  3 -> 0E+7
dqscb114 scaleb      -0E+4  4 -> -0E+8
dqscb115 scaleb     0.0000  5 -> 0E+1
dqscb116 scaleb    -0.0000  6 -> -0E+2
dqscb117 scaleb      0E-141 7 -> 0E-134
dqscb118 scaleb     -0E-141 8 -> -0E-133

-- Nmax, Nmin, Ntiny
dqscb132 scaleb  9.999999999999999999999999999999999E+6144  +6144 -> Infinity    Overflow Inexact Rounded
dqscb133 scaleb  9.999999999999999999999999999999999E+6144  +10 -> Infinity     Overflow Inexact Rounded
dqscb134 scaleb  9.999999999999999999999999999999999E+6144  +1  -> Infinity     Overflow Inexact Rounded
dqscb135 scaleb  9.999999999999999999999999999999999E+6144   0  -> 9.999999999999999999999999999999999E+6144
dqscb136 scaleb  9.999999999999999999999999999999999E+6144  -1  -> 9.999999999999999999999999999999999E+6143
dqscb137 scaleb  1E-6143           +1  -> 1E-6142
dqscb1614 scaleb  1E-6143           -0  -> 1E-6143
dqscb139 scaleb  1E-6143           -1  -> 1E-6144          Subnormal
dqscb140 scaleb  1.000000000000000000000000000000000E-6143  +1  -> 1.000000000000000000000000000000000E-6142
dqscb141 scaleb  1.000000000000000000000000000000000E-6143   0  -> 1.000000000000000000000000000000000E-6143
dqscb142 scaleb  1.000000000000000000000000000000000E-6143  -1  -> 1.00000000000000000000000000000000E-6144 Subnormal Rounded
dqscb143 scaleb  1E-6176          +1  -> 1E-6175         Subnormal
dqscb144 scaleb  1E-6176          -0  -> 1E-6176         Subnormal
dqscb145 scaleb  1E-6176          -1  -> 0E-6176         Underflow Subnormal Inexact Rounded Clamped

dqscb150 scaleb  -1E-6176         +1  -> -1E-6175        Subnormal
dqscb151 scaleb  -1E-6176         -0  -> -1E-6176        Subnormal
dqscb152 scaleb  -1E-6176         -1  -> -0E-6176        Underflow Subnormal Inexact Rounded Clamped
dqscb153 scaleb  -1.000000000000000000000000000000000E-6143 +1  -> -1.000000000000000000000000000000000E-6142
dqscb154 scaleb  -1.000000000000000000000000000000000E-6143 +0  -> -1.000000000000000000000000000000000E-6143
dqscb155 scaleb  -1.000000000000000000000000000000000E-6143 -1  -> -1.00000000000000000000000000000000E-6144 Subnormal Rounded
dqscb156 scaleb  -1E-6143          +1  -> -1E-6142
dqscb157 scaleb  -1E-6143          -0  -> -1E-6143
dqscb158 scaleb  -1E-6143          -1  -> -1E-6144          Subnormal
dqscb159 scaleb  -9.999999999999999999999999999999999E+6144 +1  -> -Infinity        Overflow Inexact Rounded
dqscb160 scaleb  -9.999999999999999999999999999999999E+6144 +0  -> -9.999999999999999999999999999999999E+6144
dqscb161 scaleb  -9.999999999999999999999999999999999E+6144 -1  -> -9.999999999999999999999999999999999E+6143
dqscb162 scaleb  -9E+6144          +1  -> -Infinity        Overflow Inexact Rounded
dqscb163 scaleb  -1E+6144          +1  -> -Infinity        Overflow Inexact Rounded

-- some Origami
-- (these check that overflow is being done correctly)
dqscb171 scaleb   1000E+6109  +1 -> 1.000E+6113
dqscb172 scaleb   1000E+6110  +1 -> 1.000E+6114
dqscb173 scaleb   1000E+6111  +1 -> 1.0000E+6115                    Clamped
dqscb174 scaleb   1000E+6112  +1 -> 1.00000E+6116                   Clamped
dqscb175 scaleb   1000E+6113  +1 -> 1.000000E+6117                  Clamped
dqscb176 scaleb   1000E+6114  +1 -> 1.0000000E+6118                 Clamped
dqscb177 scaleb   1000E+6131  +1 -> 1.000000000000000000000000E+6135                Clamped
dqscb178 scaleb   1000E+6132  +1 -> 1.0000000000000000000000000E+6136               Clamped
dqscb179 scaleb   1000E+6133  +1 -> 1.00000000000000000000000000E+6137              Clamped
dqscb180 scaleb   1000E+6134  +1 -> 1.000000000000000000000000000E+6138             Clamped
dqscb181 scaleb   1000E+6135  +1 -> 1.0000000000000000000000000000E+6139            Clamped
dqscb182 scaleb   1000E+6136  +1 -> 1.00000000000000000000000000000E+6140           Clamped
dqscb183 scaleb   1000E+6137  +1 -> 1.000000000000000000000000000000E+6141          Clamped
dqscb184 scaleb   1000E+6138  +1 -> 1.0000000000000000000000000000000E+6142         Clamped
dqscb185 scaleb   1000E+6139  +1 -> 1.00000000000000000000000000000000E+6143        Clamped
dqscb186 scaleb   1000E+6140  +1 -> 1.000000000000000000000000000000000E+6144       Clamped
dqscb187 scaleb   1000E+6141  +1 -> Infinity    Overflow Inexact Rounded

-- and a few more subnormal truncations
-- (these check that underflow is being done correctly)
dqscb221 scaleb  1.000000000000000000000000000000000E-6143   0  -> 1.000000000000000000000000000000000E-6143
dqscb222 scaleb  1.000000000000000000000000000000000E-6143  -1  -> 1.00000000000000000000000000000000E-6144 Subnormal Rounded
dqscb223 scaleb  1.000000000000000000000000000000000E-6143  -2  -> 1.0000000000000000000000000000000E-6145 Subnormal Rounded
dqscb224 scaleb  1.000000000000000000000000000000000E-6143  -3  -> 1.000000000000000000000000000000E-6146 Subnormal Rounded
dqscb225 scaleb  1.000000000000000000000000000000000E-6143  -4  -> 1.00000000000000000000000000000E-6147 Subnormal Rounded
dqscb226 scaleb  1.000000000000000000000000000000000E-6143  -5  -> 1.0000000000000000000000000000E-6148 Subnormal Rounded
dqscb227 scaleb  1.000000000000000000000000000000000E-6143  -6  -> 1.000000000000000000000000000E-6149 Subnormal Rounded
dqscb228 scaleb  1.000000000000000000000000000000000E-6143  -7  -> 1.00000000000000000000000000E-6150 Subnormal Rounded
dqscb229 scaleb  1.000000000000000000000000000000000E-6143  -8  -> 1.0000000000000000000000000E-6151 Subnormal Rounded
dqscb230 scaleb  1.000000000000000000000000000000000E-6143  -9  -> 1.000000000000000000000000E-6152 Subnormal Rounded
dqscb231 scaleb  1.000000000000000000000000000000000E-6143  -10 -> 1.00000000000000000000000E-6153 Subnormal Rounded
dqscb232 scaleb  1.000000000000000000000000000000000E-6143  -11 -> 1.0000000000000000000000E-6154 Subnormal Rounded
dqscb233 scaleb  1.000000000000000000000000000000000E-6143  -12 -> 1.000000000000000000000E-6155 Subnormal Rounded
dqscb234 scaleb  1.000000000000000000000000000000000E-6143  -13 -> 1.00000000000000000000E-6156 Subnormal Rounded
dqscb235 scaleb  1.000000000000000000000000000000000E-6143  -14 -> 1.0000000000000000000E-6157 Subnormal Rounded
dqscb236 scaleb  1.000000000000000000000000000000000E-6143  -15 -> 1.000000000000000000E-6158 Subnormal Rounded
dqscb237 scaleb  1.000000000000000000000000000000000E-6143  -16 -> 1.00000000000000000E-6159 Subnormal Rounded
dqscb238 scaleb  1.000000000000000000000000000000000E-6143  -17 -> 1.0000000000000000E-6160 Subnormal Rounded
dqscb239 scaleb  1.000000000000000000000000000000000E-6143  -18 -> 1.000000000000000E-6161 Subnormal Rounded
dqscb202 scaleb  1.000000000000000000000000000000000E-6143  -19 -> 1.00000000000000E-6162 Subnormal Rounded
dqscb203 scaleb  1.000000000000000000000000000000000E-6143  -20 -> 1.0000000000000E-6163 Subnormal Rounded
dqscb204 scaleb  1.000000000000000000000000000000000E-6143  -21 -> 1.000000000000E-6164 Subnormal Rounded
dqscb205 scaleb  1.000000000000000000000000000000000E-6143  -22 -> 1.00000000000E-6165 Subnormal Rounded
dqscb206 scaleb  1.000000000000000000000000000000000E-6143  -23 -> 1.0000000000E-6166 Subnormal Rounded
dqscb207 scaleb  1.000000000000000000000000000000000E-6143  -24 -> 1.000000000E-6167 Subnormal Rounded
dqscb208 scaleb  1.000000000000000000000000000000000E-6143  -25 -> 1.00000000E-6168 Subnormal Rounded
dqscb209 scaleb  1.000000000000000000000000000000000E-6143  -26 -> 1.0000000E-6169 Subnormal Rounded
dqscb210 scaleb  1.000000000000000000000000000000000E-6143  -27 -> 1.000000E-6170 Subnormal Rounded
dqscb211 scaleb  1.000000000000000000000000000000000E-6143  -28 -> 1.00000E-6171 Subnormal Rounded
dqscb212 scaleb  1.000000000000000000000000000000000E-6143  -29 -> 1.0000E-6172 Subnormal Rounded
dqscb213 scaleb  1.000000000000000000000000000000000E-6143  -30 -> 1.000E-6173 Subnormal Rounded
dqscb214 scaleb  1.000000000000000000000000000000000E-6143  -31 -> 1.00E-6174 Subnormal Rounded
dqscb215 scaleb  1.000000000000000000000000000000000E-6143  -32 -> 1.0E-6175 Subnormal Rounded
dqscb216 scaleb  1.000000000000000000000000000000000E-6143  -33 -> 1E-6176 Subnormal Rounded
dqscb217 scaleb  1.000000000000000000000000000000000E-6143  -34 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
dqscb218 scaleb  1.000000000000000000000000000000000E-6143  -35 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped

Added test/dectest/dqShift.decTest.





















































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
------------------------------------------------------------------------
-- dqShift.decTest -- shift decQuad coefficient left or right         --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Sanity check
dqshi001 shift                                   0    0  ->  0
dqshi002 shift                                   0    2  ->  0
dqshi003 shift                                   1    2  ->  100
dqshi004 shift                                   1   33  ->  1000000000000000000000000000000000
dqshi005 shift                                   1   34  ->  0
dqshi006 shift                                   1   -1  ->  0
dqshi007 shift                                   0   -2  ->  0
dqshi008 shift  1234567890123456789012345678901234   -1  ->  123456789012345678901234567890123
dqshi009 shift  1234567890123456789012345678901234   -33 ->  1
dqshi010 shift  1234567890123456789012345678901234   -34 ->  0
dqshi011 shift  9934567890123456789012345678901234   -33 ->  9
dqshi012 shift  9934567890123456789012345678901234   -34 ->  0

-- rhs must be an integer
dqshi015 shift        1    1.5    -> NaN Invalid_operation
dqshi016 shift        1    1.0    -> NaN Invalid_operation
dqshi017 shift        1    0.1    -> NaN Invalid_operation
dqshi018 shift        1    0.0    -> NaN Invalid_operation
dqshi019 shift        1    1E+1   -> NaN Invalid_operation
dqshi020 shift        1    1E+99  -> NaN Invalid_operation
dqshi021 shift        1    Inf    -> NaN Invalid_operation
dqshi022 shift        1    -Inf   -> NaN Invalid_operation
-- and |rhs| <= precision
dqshi025 shift        1    -1000  -> NaN Invalid_operation
dqshi026 shift        1    -35    -> NaN Invalid_operation
dqshi027 shift        1     35    -> NaN Invalid_operation
dqshi028 shift        1     1000  -> NaN Invalid_operation

-- full shifting pattern
dqshi030 shift  1234567890123456789012345678901234         -34  -> 0
dqshi031 shift  1234567890123456789012345678901234         -33  -> 1
dqshi032 shift  1234567890123456789012345678901234         -32  -> 12
dqshi033 shift  1234567890123456789012345678901234         -31  -> 123
dqshi034 shift  1234567890123456789012345678901234         -30  -> 1234
dqshi035 shift  1234567890123456789012345678901234         -29  -> 12345
dqshi036 shift  1234567890123456789012345678901234         -28  -> 123456
dqshi037 shift  1234567890123456789012345678901234         -27  -> 1234567
dqshi038 shift  1234567890123456789012345678901234         -26  -> 12345678
dqshi039 shift  1234567890123456789012345678901234         -25  -> 123456789
dqshi040 shift  1234567890123456789012345678901234         -24  -> 1234567890
dqshi041 shift  1234567890123456789012345678901234         -23  -> 12345678901
dqshi042 shift  1234567890123456789012345678901234         -22  -> 123456789012
dqshi043 shift  1234567890123456789012345678901234         -21  -> 1234567890123
dqshi044 shift  1234567890123456789012345678901234         -20  -> 12345678901234
dqshi045 shift  1234567890123456789012345678901234         -19  -> 123456789012345
dqshi047 shift  1234567890123456789012345678901234         -18  -> 1234567890123456
dqshi048 shift  1234567890123456789012345678901234         -17  -> 12345678901234567
dqshi049 shift  1234567890123456789012345678901234         -16  -> 123456789012345678
dqshi050 shift  1234567890123456789012345678901234         -15  -> 1234567890123456789
dqshi051 shift  1234567890123456789012345678901234         -14  -> 12345678901234567890
dqshi052 shift  1234567890123456789012345678901234         -13  -> 123456789012345678901
dqshi053 shift  1234567890123456789012345678901234         -12  -> 1234567890123456789012
dqshi054 shift  1234567890123456789012345678901234         -11  -> 12345678901234567890123
dqshi055 shift  1234567890123456789012345678901234         -10  -> 123456789012345678901234
dqshi056 shift  1234567890123456789012345678901234         -9   -> 1234567890123456789012345
dqshi057 shift  1234567890123456789012345678901234         -8   -> 12345678901234567890123456
dqshi058 shift  1234567890123456789012345678901234         -7   -> 123456789012345678901234567
dqshi059 shift  1234567890123456789012345678901234         -6   -> 1234567890123456789012345678
dqshi060 shift  1234567890123456789012345678901234         -5   -> 12345678901234567890123456789
dqshi061 shift  1234567890123456789012345678901234         -4   -> 123456789012345678901234567890
dqshi062 shift  1234567890123456789012345678901234         -3   -> 1234567890123456789012345678901
dqshi063 shift  1234567890123456789012345678901234         -2   -> 12345678901234567890123456789012
dqshi064 shift  1234567890123456789012345678901234         -1   -> 123456789012345678901234567890123
dqshi065 shift  1234567890123456789012345678901234         -0   -> 1234567890123456789012345678901234

dqshi066 shift  1234567890123456789012345678901234         +0   -> 1234567890123456789012345678901234
dqshi067 shift  1234567890123456789012345678901234         +1   -> 2345678901234567890123456789012340
dqshi068 shift  1234567890123456789012345678901234         +2   -> 3456789012345678901234567890123400
dqshi069 shift  1234567890123456789012345678901234         +3   -> 4567890123456789012345678901234000
dqshi070 shift  1234567890123456789012345678901234         +4   -> 5678901234567890123456789012340000
dqshi071 shift  1234567890123456789012345678901234         +5   -> 6789012345678901234567890123400000
dqshi072 shift  1234567890123456789012345678901234         +6   -> 7890123456789012345678901234000000
dqshi073 shift  1234567890123456789012345678901234         +7   -> 8901234567890123456789012340000000
dqshi074 shift  1234567890123456789012345678901234         +8   -> 9012345678901234567890123400000000
dqshi075 shift  1234567890123456789012345678901234         +9   ->  123456789012345678901234000000000
dqshi076 shift  1234567890123456789012345678901234         +10  -> 1234567890123456789012340000000000
dqshi077 shift  1234567890123456789012345678901234         +11  -> 2345678901234567890123400000000000
dqshi078 shift  1234567890123456789012345678901234         +12  -> 3456789012345678901234000000000000
dqshi079 shift  1234567890123456789012345678901234         +13  -> 4567890123456789012340000000000000
dqshi080 shift  1234567890123456789012345678901234         +14  -> 5678901234567890123400000000000000
dqshi081 shift  1234567890123456789012345678901234         +15  -> 6789012345678901234000000000000000
dqshi082 shift  1234567890123456789012345678901234         +16  -> 7890123456789012340000000000000000
dqshi083 shift  1234567890123456789012345678901234         +17  -> 8901234567890123400000000000000000
dqshi084 shift  1234567890123456789012345678901234         +18  -> 9012345678901234000000000000000000
dqshi085 shift  1234567890123456789012345678901234         +19  ->  123456789012340000000000000000000
dqshi086 shift  1234567890123456789012345678901234         +20  -> 1234567890123400000000000000000000
dqshi087 shift  1234567890123456789012345678901234         +21  -> 2345678901234000000000000000000000
dqshi088 shift  1234567890123456789012345678901234         +22  -> 3456789012340000000000000000000000
dqshi089 shift  1234567890123456789012345678901234         +23  -> 4567890123400000000000000000000000
dqshi090 shift  1234567890123456789012345678901234         +24  -> 5678901234000000000000000000000000
dqshi091 shift  1234567890123456789012345678901234         +25  -> 6789012340000000000000000000000000
dqshi092 shift  1234567890123456789012345678901234         +26  -> 7890123400000000000000000000000000
dqshi093 shift  1234567890123456789012345678901234         +27  -> 8901234000000000000000000000000000
dqshi094 shift  1234567890123456789012345678901234         +28  -> 9012340000000000000000000000000000
dqshi095 shift  1234567890123456789012345678901234         +29  ->  123400000000000000000000000000000
dqshi096 shift  1234567890123456789012345678901234         +30  -> 1234000000000000000000000000000000
dqshi097 shift  1234567890123456789012345678901234         +31  -> 2340000000000000000000000000000000
dqshi098 shift  1234567890123456789012345678901234         +32  -> 3400000000000000000000000000000000
dqshi099 shift  1234567890123456789012345678901234         +33  -> 4000000000000000000000000000000000
dqshi100 shift  1234567890123456789012345678901234         +34  -> 0

-- zeros
dqshi270 shift  0E-10              +29   ->   0E-10
dqshi271 shift  0E-10              -29   ->   0E-10
dqshi272 shift  0.000              +29   ->   0.000
dqshi273 shift  0.000              -29   ->   0.000
dqshi274 shift  0E+10              +29   ->   0E+10
dqshi275 shift  0E+10              -29   ->   0E+10
dqshi276 shift -0E-10              +29   ->  -0E-10
dqshi277 shift -0E-10              -29   ->  -0E-10
dqshi278 shift -0.000              +29   ->  -0.000
dqshi279 shift -0.000              -29   ->  -0.000
dqshi280 shift -0E+10              +29   ->  -0E+10
dqshi281 shift -0E+10              -29   ->  -0E+10

-- Nmax, Nmin, Ntiny
dqshi141 shift  9.999999999999999999999999999999999E+6144     -1  -> 9.99999999999999999999999999999999E+6143
dqshi142 shift  9.999999999999999999999999999999999E+6144     -33 -> 9E+6111
dqshi143 shift  9.999999999999999999999999999999999E+6144      1  -> 9.999999999999999999999999999999990E+6144
dqshi144 shift  9.999999999999999999999999999999999E+6144      33 -> 9.000000000000000000000000000000000E+6144
dqshi145 shift  1E-6143                                       -1  -> 0E-6143
dqshi146 shift  1E-6143                                       -33 -> 0E-6143
dqshi147 shift  1E-6143                                        1  -> 1.0E-6142
dqshi148 shift  1E-6143                                        33 -> 1.000000000000000000000000000000000E-6110
dqshi151 shift  1.000000000000000000000000000000000E-6143     -1  -> 1.00000000000000000000000000000000E-6144
dqshi152 shift  1.000000000000000000000000000000000E-6143     -33 -> 1E-6176
dqshi153 shift  1.000000000000000000000000000000000E-6143      1  -> 0E-6176
dqshi154 shift  1.000000000000000000000000000000000E-6143      33 -> 0E-6176
dqshi155 shift  9.000000000000000000000000000000000E-6143     -1  -> 9.00000000000000000000000000000000E-6144
dqshi156 shift  9.000000000000000000000000000000000E-6143     -33 -> 9E-6176
dqshi157 shift  9.000000000000000000000000000000000E-6143      1  -> 0E-6176
dqshi158 shift  9.000000000000000000000000000000000E-6143      33 -> 0E-6176
dqshi160 shift  1E-6176                                       -1  -> 0E-6176
dqshi161 shift  1E-6176                                       -33 -> 0E-6176
dqshi162 shift  1E-6176                                        1  -> 1.0E-6175
dqshi163 shift  1E-6176                                        33 -> 1.000000000000000000000000000000000E-6143
--  negatives
dqshi171 shift -9.999999999999999999999999999999999E+6144     -1  -> -9.99999999999999999999999999999999E+6143
dqshi172 shift -9.999999999999999999999999999999999E+6144     -33 -> -9E+6111
dqshi173 shift -9.999999999999999999999999999999999E+6144      1  -> -9.999999999999999999999999999999990E+6144
dqshi174 shift -9.999999999999999999999999999999999E+6144      33 -> -9.000000000000000000000000000000000E+6144
dqshi175 shift -1E-6143                                       -1  -> -0E-6143
dqshi176 shift -1E-6143                                       -33 -> -0E-6143
dqshi177 shift -1E-6143                                        1  -> -1.0E-6142
dqshi178 shift -1E-6143                                        33 -> -1.000000000000000000000000000000000E-6110
dqshi181 shift -1.000000000000000000000000000000000E-6143     -1  -> -1.00000000000000000000000000000000E-6144
dqshi182 shift -1.000000000000000000000000000000000E-6143     -33 -> -1E-6176
dqshi183 shift -1.000000000000000000000000000000000E-6143      1  -> -0E-6176
dqshi184 shift -1.000000000000000000000000000000000E-6143      33 -> -0E-6176
dqshi185 shift -9.000000000000000000000000000000000E-6143     -1  -> -9.00000000000000000000000000000000E-6144
dqshi186 shift -9.000000000000000000000000000000000E-6143     -33 -> -9E-6176
dqshi187 shift -9.000000000000000000000000000000000E-6143      1  -> -0E-6176
dqshi188 shift -9.000000000000000000000000000000000E-6143      33 -> -0E-6176
dqshi190 shift -1E-6176                                       -1  -> -0E-6176
dqshi191 shift -1E-6176                                       -33 -> -0E-6176
dqshi192 shift -1E-6176                                        1  -> -1.0E-6175
dqshi193 shift -1E-6176                                        33 -> -1.000000000000000000000000000000000E-6143

-- more negatives (of sanities)
dqshi201 shift                                  -0    0  -> -0
dqshi202 shift                                  -0    2  -> -0
dqshi203 shift                                  -1    2  -> -100
dqshi204 shift                                  -1   33  -> -1000000000000000000000000000000000
dqshi205 shift                                  -1   34  -> -0
dqshi206 shift                                  -1   -1  -> -0
dqshi207 shift                                  -0   -2  -> -0
dqshi208 shift -1234567890123456789012345678901234   -1  -> -123456789012345678901234567890123
dqshi209 shift -1234567890123456789012345678901234   -33 -> -1
dqshi210 shift -1234567890123456789012345678901234   -34 -> -0
dqshi211 shift -9934567890123456789012345678901234   -33 -> -9
dqshi212 shift -9934567890123456789012345678901234   -34 -> -0


-- Specials; NaNs are handled as usual
dqshi781 shift -Inf  -8     -> -Infinity
dqshi782 shift -Inf  -1     -> -Infinity
dqshi783 shift -Inf  -0     -> -Infinity
dqshi784 shift -Inf   0     -> -Infinity
dqshi785 shift -Inf   1     -> -Infinity
dqshi786 shift -Inf   8     -> -Infinity
dqshi787 shift -1000 -Inf   -> NaN Invalid_operation
dqshi788 shift -Inf  -Inf   -> NaN Invalid_operation
dqshi789 shift -1    -Inf   -> NaN Invalid_operation
dqshi790 shift -0    -Inf   -> NaN Invalid_operation
dqshi791 shift  0    -Inf   -> NaN Invalid_operation
dqshi792 shift  1    -Inf   -> NaN Invalid_operation
dqshi793 shift  1000 -Inf   -> NaN Invalid_operation
dqshi794 shift  Inf  -Inf   -> NaN Invalid_operation

dqshi800 shift  Inf  -Inf   -> NaN Invalid_operation
dqshi801 shift  Inf  -8     -> Infinity
dqshi802 shift  Inf  -1     -> Infinity
dqshi803 shift  Inf  -0     -> Infinity
dqshi804 shift  Inf   0     -> Infinity
dqshi805 shift  Inf   1     -> Infinity
dqshi806 shift  Inf   8     -> Infinity
dqshi807 shift  Inf   Inf   -> NaN Invalid_operation
dqshi808 shift -1000  Inf   -> NaN Invalid_operation
dqshi809 shift -Inf   Inf   -> NaN Invalid_operation
dqshi810 shift -1     Inf   -> NaN Invalid_operation
dqshi811 shift -0     Inf   -> NaN Invalid_operation
dqshi812 shift  0     Inf   -> NaN Invalid_operation
dqshi813 shift  1     Inf   -> NaN Invalid_operation
dqshi814 shift  1000  Inf   -> NaN Invalid_operation
dqshi815 shift  Inf   Inf   -> NaN Invalid_operation

dqshi821 shift  NaN -Inf    ->  NaN
dqshi822 shift  NaN -1000   ->  NaN
dqshi823 shift  NaN -1      ->  NaN
dqshi824 shift  NaN -0      ->  NaN
dqshi825 shift  NaN  0      ->  NaN
dqshi826 shift  NaN  1      ->  NaN
dqshi827 shift  NaN  1000   ->  NaN
dqshi828 shift  NaN  Inf    ->  NaN
dqshi829 shift  NaN  NaN    ->  NaN
dqshi830 shift -Inf  NaN    ->  NaN
dqshi831 shift -1000 NaN    ->  NaN
dqshi832 shift -1    NaN    ->  NaN
dqshi833 shift -0    NaN    ->  NaN
dqshi834 shift  0    NaN    ->  NaN
dqshi835 shift  1    NaN    ->  NaN
dqshi836 shift  1000 NaN    ->  NaN
dqshi837 shift  Inf  NaN    ->  NaN

dqshi841 shift  sNaN -Inf   ->  NaN  Invalid_operation
dqshi842 shift  sNaN -1000  ->  NaN  Invalid_operation
dqshi843 shift  sNaN -1     ->  NaN  Invalid_operation
dqshi844 shift  sNaN -0     ->  NaN  Invalid_operation
dqshi845 shift  sNaN  0     ->  NaN  Invalid_operation
dqshi846 shift  sNaN  1     ->  NaN  Invalid_operation
dqshi847 shift  sNaN  1000  ->  NaN  Invalid_operation
dqshi848 shift  sNaN  NaN   ->  NaN  Invalid_operation
dqshi849 shift  sNaN sNaN   ->  NaN  Invalid_operation
dqshi850 shift  NaN  sNaN   ->  NaN  Invalid_operation
dqshi851 shift -Inf  sNaN   ->  NaN  Invalid_operation
dqshi852 shift -1000 sNaN   ->  NaN  Invalid_operation
dqshi853 shift -1    sNaN   ->  NaN  Invalid_operation
dqshi854 shift -0    sNaN   ->  NaN  Invalid_operation
dqshi855 shift  0    sNaN   ->  NaN  Invalid_operation
dqshi856 shift  1    sNaN   ->  NaN  Invalid_operation
dqshi857 shift  1000 sNaN   ->  NaN  Invalid_operation
dqshi858 shift  Inf  sNaN   ->  NaN  Invalid_operation
dqshi859 shift  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqshi861 shift  NaN1   -Inf    ->  NaN1
dqshi862 shift +NaN2   -1000   ->  NaN2
dqshi863 shift  NaN3    1000   ->  NaN3
dqshi864 shift  NaN4    Inf    ->  NaN4
dqshi865 shift  NaN5   +NaN6   ->  NaN5
dqshi866 shift -Inf     NaN7   ->  NaN7
dqshi867 shift -1000    NaN8   ->  NaN8
dqshi868 shift  1000    NaN9   ->  NaN9
dqshi869 shift  Inf    +NaN10  ->  NaN10
dqshi871 shift  sNaN11  -Inf   ->  NaN11  Invalid_operation
dqshi872 shift  sNaN12  -1000  ->  NaN12  Invalid_operation
dqshi873 shift  sNaN13   1000  ->  NaN13  Invalid_operation
dqshi874 shift  sNaN14   NaN17 ->  NaN14  Invalid_operation
dqshi875 shift  sNaN15  sNaN18 ->  NaN15  Invalid_operation
dqshi876 shift  NaN16   sNaN19 ->  NaN19  Invalid_operation
dqshi877 shift -Inf    +sNaN20 ->  NaN20  Invalid_operation
dqshi878 shift -1000    sNaN21 ->  NaN21  Invalid_operation
dqshi879 shift  1000    sNaN22 ->  NaN22  Invalid_operation
dqshi880 shift  Inf     sNaN23 ->  NaN23  Invalid_operation
dqshi881 shift +NaN25  +sNaN24 ->  NaN24  Invalid_operation
dqshi882 shift -NaN26    NaN28 -> -NaN26
dqshi883 shift -sNaN27  sNaN29 -> -NaN27  Invalid_operation
dqshi884 shift  1000    -NaN30 -> -NaN30
dqshi885 shift  1000   -sNaN31 -> -NaN31  Invalid_operation

Added test/dectest/dqSubtract.decTest.























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
------------------------------------------------------------------------
-- dqSubtract.decTest -- decQuad subtraction                          --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests are for decQuads only; all arguments are
-- representable in a decQuad
extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- [first group are 'quick confidence check']
dqsub001 subtract  0   0  -> '0'
dqsub002 subtract  1   1  -> '0'
dqsub003 subtract  1   2  -> '-1'
dqsub004 subtract  2   1  -> '1'
dqsub005 subtract  2   2  -> '0'
dqsub006 subtract  3   2  -> '1'
dqsub007 subtract  2   3  -> '-1'

dqsub011 subtract -0   0  -> '-0'
dqsub012 subtract -1   1  -> '-2'
dqsub013 subtract -1   2  -> '-3'
dqsub014 subtract -2   1  -> '-3'
dqsub015 subtract -2   2  -> '-4'
dqsub016 subtract -3   2  -> '-5'
dqsub017 subtract -2   3  -> '-5'

dqsub021 subtract  0  -0  -> '0'
dqsub022 subtract  1  -1  -> '2'
dqsub023 subtract  1  -2  -> '3'
dqsub024 subtract  2  -1  -> '3'
dqsub025 subtract  2  -2  -> '4'
dqsub026 subtract  3  -2  -> '5'
dqsub027 subtract  2  -3  -> '5'

dqsub030 subtract  11  1  -> 10
dqsub031 subtract  10  1  ->  9
dqsub032 subtract  9   1  ->  8
dqsub033 subtract  1   1  ->  0
dqsub034 subtract  0   1  -> -1
dqsub035 subtract -1   1  -> -2
dqsub036 subtract -9   1  -> -10
dqsub037 subtract -10  1  -> -11
dqsub038 subtract -11  1  -> -12

dqsub040 subtract '5.75' '3.3'  -> '2.45'
dqsub041 subtract '5'    '-3'   -> '8'
dqsub042 subtract '-5'   '-3'   -> '-2'
dqsub043 subtract '-7'   '2.5'  -> '-9.5'
dqsub044 subtract '0.7'  '0.3'  -> '0.4'
dqsub045 subtract '1.3'  '0.3'  -> '1.0'
dqsub046 subtract '1.25' '1.25' -> '0.00'

dqsub050 subtract '1.23456789'    '1.00000000' -> '0.23456789'
dqsub051 subtract '1.23456789'    '1.00000089' -> '0.23456700'

dqsub060 subtract '70'    '10000e+34' -> '-1.000000000000000000000000000000000E+38' Inexact Rounded
dqsub061 subtract '700'    '10000e+34' -> '-1.000000000000000000000000000000000E+38' Inexact Rounded
dqsub062 subtract '7000'    '10000e+34' -> '-9.999999999999999999999999999999999E+37' Inexact Rounded
dqsub063 subtract '70000'    '10000e+34' -> '-9.999999999999999999999999999999993E+37' Rounded
dqsub064 subtract '700000'    '10000e+34' -> '-9.999999999999999999999999999999930E+37' Rounded
  -- symmetry:
dqsub065 subtract '10000e+34'    '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqsub066 subtract '10000e+34'    '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
dqsub067 subtract '10000e+34'    '7000' -> '9.999999999999999999999999999999999E+37' Inexact Rounded
dqsub068 subtract '10000e+34'    '70000' -> '9.999999999999999999999999999999993E+37' Rounded
dqsub069 subtract '10000e+34'    '700000' -> '9.999999999999999999999999999999930E+37' Rounded

  -- some of the next group are really constructor tests
dqsub090 subtract '00.0'    '0.0'  -> '0.0'
dqsub091 subtract '00.0'    '0.00' -> '0.00'
dqsub092 subtract '0.00'    '00.0' -> '0.00'
dqsub093 subtract '00.0'    '0.00' -> '0.00'
dqsub094 subtract '0.00'    '00.0' -> '0.00'
dqsub095 subtract '3'    '.3'   -> '2.7'
dqsub096 subtract '3.'   '.3'   -> '2.7'
dqsub097 subtract '3.0'  '.3'   -> '2.7'
dqsub098 subtract '3.00' '.3'   -> '2.70'
dqsub099 subtract '3'    '3'    -> '0'
dqsub100 subtract '3'    '+3'   -> '0'
dqsub101 subtract '3'    '-3'   -> '6'
dqsub102 subtract '3'    '0.3'  -> '2.7'
dqsub103 subtract '3.'   '0.3'  -> '2.7'
dqsub104 subtract '3.0'  '0.3'  -> '2.7'
dqsub105 subtract '3.00' '0.3'  -> '2.70'
dqsub106 subtract '3'    '3.0'  -> '0.0'
dqsub107 subtract '3'    '+3.0' -> '0.0'
dqsub108 subtract '3'    '-3.0' -> '6.0'

-- the above all from add; massaged and extended.  Now some new ones...
-- [particularly important for comparisons]
-- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7
-- with input rounding.
dqsub120 subtract  '10.23456784'    '10.23456789'  -> '-5E-8'
dqsub121 subtract  '10.23456785'    '10.23456789'  -> '-4E-8'
dqsub122 subtract  '10.23456786'    '10.23456789'  -> '-3E-8'
dqsub123 subtract  '10.23456787'    '10.23456789'  -> '-2E-8'
dqsub124 subtract  '10.23456788'    '10.23456789'  -> '-1E-8'
dqsub125 subtract  '10.23456789'    '10.23456789'  -> '0E-8'
dqsub126 subtract  '10.23456790'    '10.23456789'  -> '1E-8'
dqsub127 subtract  '10.23456791'    '10.23456789'  -> '2E-8'
dqsub128 subtract  '10.23456792'    '10.23456789'  -> '3E-8'
dqsub129 subtract  '10.23456793'    '10.23456789'  -> '4E-8'
dqsub130 subtract  '10.23456794'    '10.23456789'  -> '5E-8'
dqsub131 subtract  '10.23456781'    '10.23456786'  -> '-5E-8'
dqsub132 subtract  '10.23456782'    '10.23456786'  -> '-4E-8'
dqsub133 subtract  '10.23456783'    '10.23456786'  -> '-3E-8'
dqsub134 subtract  '10.23456784'    '10.23456786'  -> '-2E-8'
dqsub135 subtract  '10.23456785'    '10.23456786'  -> '-1E-8'
dqsub136 subtract  '10.23456786'    '10.23456786'  -> '0E-8'
dqsub137 subtract  '10.23456787'    '10.23456786'  -> '1E-8'
dqsub138 subtract  '10.23456788'    '10.23456786'  -> '2E-8'
dqsub139 subtract  '10.23456789'    '10.23456786'  -> '3E-8'
dqsub140 subtract  '10.23456790'    '10.23456786'  -> '4E-8'
dqsub141 subtract  '10.23456791'    '10.23456786'  -> '5E-8'
dqsub142 subtract  '1'              '0.999999999'  -> '1E-9'
dqsub143 subtract  '0.999999999'    '1'            -> '-1E-9'
dqsub144 subtract  '-10.23456780'   '-10.23456786' -> '6E-8'
dqsub145 subtract  '-10.23456790'   '-10.23456786' -> '-4E-8'
dqsub146 subtract  '-10.23456791'   '-10.23456786' -> '-5E-8'

-- additional scaled arithmetic tests [0.97 problem]
dqsub160 subtract '0'     '.1'      -> '-0.1'
dqsub161 subtract '00'    '.97983'  -> '-0.97983'
dqsub162 subtract '0'     '.9'      -> '-0.9'
dqsub163 subtract '0'     '0.102'   -> '-0.102'
dqsub164 subtract '0'     '.4'      -> '-0.4'
dqsub165 subtract '0'     '.307'    -> '-0.307'
dqsub166 subtract '0'     '.43822'  -> '-0.43822'
dqsub167 subtract '0'     '.911'    -> '-0.911'
dqsub168 subtract '.0'    '.02'     -> '-0.02'
dqsub169 subtract '00'    '.392'    -> '-0.392'
dqsub170 subtract '0'     '.26'     -> '-0.26'
dqsub171 subtract '0'     '0.51'    -> '-0.51'
dqsub172 subtract '0'     '.2234'   -> '-0.2234'
dqsub173 subtract '0'     '.2'      -> '-0.2'
dqsub174 subtract '.0'    '.0008'   -> '-0.0008'
-- 0. on left
dqsub180 subtract '0.0'     '-.1'      -> '0.1'
dqsub181 subtract '0.00'    '-.97983'  -> '0.97983'
dqsub182 subtract '0.0'     '-.9'      -> '0.9'
dqsub183 subtract '0.0'     '-0.102'   -> '0.102'
dqsub184 subtract '0.0'     '-.4'      -> '0.4'
dqsub185 subtract '0.0'     '-.307'    -> '0.307'
dqsub186 subtract '0.0'     '-.43822'  -> '0.43822'
dqsub187 subtract '0.0'     '-.911'    -> '0.911'
dqsub188 subtract '0.0'     '-.02'     -> '0.02'
dqsub189 subtract '0.00'    '-.392'    -> '0.392'
dqsub190 subtract '0.0'     '-.26'     -> '0.26'
dqsub191 subtract '0.0'     '-0.51'    -> '0.51'
dqsub192 subtract '0.0'     '-.2234'   -> '0.2234'
dqsub193 subtract '0.0'     '-.2'      -> '0.2'
dqsub194 subtract '0.0'     '-.0008'   -> '0.0008'
-- negatives of same
dqsub200 subtract '0'     '-.1'      -> '0.1'
dqsub201 subtract '00'    '-.97983'  -> '0.97983'
dqsub202 subtract '0'     '-.9'      -> '0.9'
dqsub203 subtract '0'     '-0.102'   -> '0.102'
dqsub204 subtract '0'     '-.4'      -> '0.4'
dqsub205 subtract '0'     '-.307'    -> '0.307'
dqsub206 subtract '0'     '-.43822'  -> '0.43822'
dqsub207 subtract '0'     '-.911'    -> '0.911'
dqsub208 subtract '.0'    '-.02'     -> '0.02'
dqsub209 subtract '00'    '-.392'    -> '0.392'
dqsub210 subtract '0'     '-.26'     -> '0.26'
dqsub211 subtract '0'     '-0.51'    -> '0.51'
dqsub212 subtract '0'     '-.2234'   -> '0.2234'
dqsub213 subtract '0'     '-.2'      -> '0.2'
dqsub214 subtract '.0'    '-.0008'   -> '0.0008'

-- more fixed, LHS swaps [really the same as testcases under add]
dqsub220 subtract '-56267E-12' 0  -> '-5.6267E-8'
dqsub221 subtract '-56267E-11' 0  -> '-5.6267E-7'
dqsub222 subtract '-56267E-10' 0  -> '-0.0000056267'
dqsub223 subtract '-56267E-9'  0  -> '-0.000056267'
dqsub224 subtract '-56267E-8'  0  -> '-0.00056267'
dqsub225 subtract '-56267E-7'  0  -> '-0.0056267'
dqsub226 subtract '-56267E-6'  0  -> '-0.056267'
dqsub227 subtract '-56267E-5'  0  -> '-0.56267'
dqsub228 subtract '-56267E-2'  0  -> '-562.67'
dqsub229 subtract '-56267E-1'  0  -> '-5626.7'
dqsub230 subtract '-56267E-0'  0  -> '-56267'
-- symmetry ...
dqsub240 subtract 0 '-56267E-12'  -> '5.6267E-8'
dqsub241 subtract 0 '-56267E-11'  -> '5.6267E-7'
dqsub242 subtract 0 '-56267E-10'  -> '0.0000056267'
dqsub243 subtract 0 '-56267E-9'   -> '0.000056267'
dqsub244 subtract 0 '-56267E-8'   -> '0.00056267'
dqsub245 subtract 0 '-56267E-7'   -> '0.0056267'
dqsub246 subtract 0 '-56267E-6'   -> '0.056267'
dqsub247 subtract 0 '-56267E-5'   -> '0.56267'
dqsub248 subtract 0 '-56267E-2'   -> '562.67'
dqsub249 subtract 0 '-56267E-1'   -> '5626.7'
dqsub250 subtract 0 '-56267E-0'   -> '56267'

-- now some more from the 'new' add
dqsub301 subtract '1.23456789'  '1.00000000' -> '0.23456789'
dqsub302 subtract '1.23456789'  '1.00000011' -> '0.23456778'

-- some carrying effects
dqsub321 subtract '0.9998'  '0.0000' -> '0.9998'
dqsub322 subtract '0.9998'  '0.0001' -> '0.9997'
dqsub323 subtract '0.9998'  '0.0002' -> '0.9996'
dqsub324 subtract '0.9998'  '0.0003' -> '0.9995'
dqsub325 subtract '0.9998'  '-0.0000' -> '0.9998'
dqsub326 subtract '0.9998'  '-0.0001' -> '0.9999'
dqsub327 subtract '0.9998'  '-0.0002' -> '1.0000'
dqsub328 subtract '0.9998'  '-0.0003' -> '1.0001'

-- internal boundaries
dqsub346 subtract '10000e+9'  '7'   -> '9999999999993'
dqsub347 subtract '10000e+9'  '70'   -> '9999999999930'
dqsub348 subtract '10000e+9'  '700'   -> '9999999999300'
dqsub349 subtract '10000e+9'  '7000'   -> '9999999993000'
dqsub350 subtract '10000e+9'  '70000'   -> '9999999930000'
dqsub351 subtract '10000e+9'  '700000'   -> '9999999300000'
dqsub352 subtract '7' '10000e+9'   -> '-9999999999993'
dqsub353 subtract '70' '10000e+9'   -> '-9999999999930'
dqsub354 subtract '700' '10000e+9'   -> '-9999999999300'
dqsub355 subtract '7000' '10000e+9'   -> '-9999999993000'
dqsub356 subtract '70000' '10000e+9'   -> '-9999999930000'
dqsub357 subtract '700000' '10000e+9'   -> '-9999999300000'

-- zero preservation
dqsub361 subtract 1 '0.0001' -> '0.9999'
dqsub362 subtract 1 '0.00001' -> '0.99999'
dqsub363 subtract 1 '0.000001' -> '0.999999'
dqsub364 subtract 1 '0.0000000000000000000000000000000001' -> '0.9999999999999999999999999999999999'
dqsub365 subtract 1 '0.00000000000000000000000000000000001' -> '1.000000000000000000000000000000000' Inexact Rounded
dqsub366 subtract 1 '0.000000000000000000000000000000000001' -> '1.000000000000000000000000000000000' Inexact Rounded

-- some funny zeros [in case of bad signum]
dqsub370 subtract 1  0  -> 1
dqsub371 subtract 1 0.  -> 1
dqsub372 subtract 1  .0 -> 1.0
dqsub373 subtract 1 0.0 -> 1.0
dqsub374 subtract  0  1 -> -1
dqsub375 subtract 0.  1 -> -1
dqsub376 subtract  .0 1 -> -1.0
dqsub377 subtract 0.0 1 -> -1.0

-- leading 0 digit before round
dqsub910 subtract -103519362 -51897955.3 -> -51621406.7
dqsub911 subtract 159579.444 89827.5229 -> 69751.9211

dqsub920 subtract 333.0000000000000000000000000123456 33.00000000000000000000000001234566 -> 299.9999999999999999999999999999999 Inexact Rounded
dqsub921 subtract 333.0000000000000000000000000123456 33.00000000000000000000000001234565 -> 300.0000000000000000000000000000000 Inexact Rounded
dqsub922 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234565 ->  99.99999999999999999999999999999995
dqsub923 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234564 ->  99.99999999999999999999999999999996
dqsub924 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234540 -> 100.0000000000000000000000000000002 Rounded
dqsub925 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234560 ->  90.00000000000000000000000000000000
dqsub926 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234561 ->  89.99999999999999999999999999999999
dqsub927 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234566 ->  89.99999999999999999999999999999994
dqsub928 subtract 101.0000000000000000000000000123456 91.00000000000000000000000001234566 ->   9.99999999999999999999999999999994
dqsub929 subtract 101.0000000000000000000000000123456 99.00000000000000000000000001234566 ->   1.99999999999999999999999999999994

-- more LHS swaps [were fixed]
dqsub390 subtract '-56267E-10'   0 ->  '-0.0000056267'
dqsub391 subtract '-56267E-6'    0 ->  '-0.056267'
dqsub392 subtract '-56267E-5'    0 ->  '-0.56267'
dqsub393 subtract '-56267E-4'    0 ->  '-5.6267'
dqsub394 subtract '-56267E-3'    0 ->  '-56.267'
dqsub395 subtract '-56267E-2'    0 ->  '-562.67'
dqsub396 subtract '-56267E-1'    0 ->  '-5626.7'
dqsub397 subtract '-56267E-0'    0 ->  '-56267'
dqsub398 subtract '-5E-10'       0 ->  '-5E-10'
dqsub399 subtract '-5E-7'        0 ->  '-5E-7'
dqsub400 subtract '-5E-6'        0 ->  '-0.000005'
dqsub401 subtract '-5E-5'        0 ->  '-0.00005'
dqsub402 subtract '-5E-4'        0 ->  '-0.0005'
dqsub403 subtract '-5E-1'        0 ->  '-0.5'
dqsub404 subtract '-5E0'         0 ->  '-5'
dqsub405 subtract '-5E1'         0 ->  '-50'
dqsub406 subtract '-5E5'         0 ->  '-500000'
dqsub407 subtract '-5E33'        0 ->  '-5000000000000000000000000000000000'
dqsub408 subtract '-5E34'        0 ->  '-5.000000000000000000000000000000000E+34'  Rounded
dqsub409 subtract '-5E35'        0 ->  '-5.000000000000000000000000000000000E+35'  Rounded
dqsub410 subtract '-5E36'        0 ->  '-5.000000000000000000000000000000000E+36'  Rounded
dqsub411 subtract '-5E100'       0 ->  '-5.000000000000000000000000000000000E+100' Rounded

-- more RHS swaps [were fixed]
dqsub420 subtract 0  '-56267E-10' ->  '0.0000056267'
dqsub421 subtract 0  '-56267E-6'  ->  '0.056267'
dqsub422 subtract 0  '-56267E-5'  ->  '0.56267'
dqsub423 subtract 0  '-56267E-4'  ->  '5.6267'
dqsub424 subtract 0  '-56267E-3'  ->  '56.267'
dqsub425 subtract 0  '-56267E-2'  ->  '562.67'
dqsub426 subtract 0  '-56267E-1'  ->  '5626.7'
dqsub427 subtract 0  '-56267E-0'  ->  '56267'
dqsub428 subtract 0  '-5E-10'     ->  '5E-10'
dqsub429 subtract 0  '-5E-7'      ->  '5E-7'
dqsub430 subtract 0  '-5E-6'      ->  '0.000005'
dqsub431 subtract 0  '-5E-5'      ->  '0.00005'
dqsub432 subtract 0  '-5E-4'      ->  '0.0005'
dqsub433 subtract 0  '-5E-1'      ->  '0.5'
dqsub434 subtract 0  '-5E0'       ->  '5'
dqsub435 subtract 0  '-5E1'       ->  '50'
dqsub436 subtract 0  '-5E5'       ->  '500000'
dqsub437 subtract 0  '-5E33'      ->  '5000000000000000000000000000000000'
dqsub438 subtract 0  '-5E34'      ->  '5.000000000000000000000000000000000E+34'   Rounded
dqsub439 subtract 0  '-5E35'      ->  '5.000000000000000000000000000000000E+35'   Rounded
dqsub440 subtract 0  '-5E36'      ->  '5.000000000000000000000000000000000E+36'   Rounded
dqsub441 subtract 0  '-5E100'     ->  '5.000000000000000000000000000000000E+100'  Rounded


-- try borderline precision, with carries, etc.
dqsub461 subtract '1E+16' '1'        -> '9999999999999999'
dqsub462 subtract '1E+12' '-1.111'   -> '1000000000001.111'
dqsub463 subtract '1.111'  '-1E+12'  -> '1000000000001.111'
dqsub464 subtract '-1'    '-1E+16'   -> '9999999999999999'
dqsub465 subtract '7E+15' '1'        -> '6999999999999999'
dqsub466 subtract '7E+12' '-1.111'   -> '7000000000001.111'
dqsub467 subtract '1.111'  '-7E+12'  -> '7000000000001.111'
dqsub468 subtract '-1'    '-7E+15'   -> '6999999999999999'

--                   1234567890123456       1234567890123456      1 23456789012345
dqsub470 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555563' -> '1.000000000000000000000000000000001' Inexact Rounded
dqsub471 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555562' -> '1.000000000000000000000000000000001' Inexact Rounded
dqsub472 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555561' -> '1.000000000000000000000000000000000' Inexact Rounded
dqsub473 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555560' -> '1.000000000000000000000000000000000' Inexact Rounded
dqsub474 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555559' -> '1.000000000000000000000000000000000' Inexact Rounded
dqsub475 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555558' -> '1.000000000000000000000000000000000' Inexact Rounded
dqsub476 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555557' -> '1.000000000000000000000000000000000' Inexact Rounded
dqsub477 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555556' -> '1.000000000000000000000000000000000' Rounded
dqsub478 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
dqsub479 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555554' -> '0.9999999999999999999999999999999998'
dqsub480 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555553' -> '0.9999999999999999999999999999999997'
dqsub481 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555552' -> '0.9999999999999999999999999999999996'
dqsub482 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555551' -> '0.9999999999999999999999999999999995'
dqsub483 subtract '0.4444444444444444444444444444444444'  '-0.5555555555555555555555555555555550' -> '0.9999999999999999999999999999999994'

-- and some more, including residue effects and different roundings
rounding: half_up
dqsub500 subtract '1231234555555555555555555567456789' 0             -> '1231234555555555555555555567456789'
dqsub501 subtract '1231234555555555555555555567456789' 0.000000001   -> '1231234555555555555555555567456789' Inexact Rounded
dqsub502 subtract '1231234555555555555555555567456789' 0.000001      -> '1231234555555555555555555567456789' Inexact Rounded
dqsub503 subtract '1231234555555555555555555567456789' 0.1           -> '1231234555555555555555555567456789' Inexact Rounded
dqsub504 subtract '1231234555555555555555555567456789' 0.4           -> '1231234555555555555555555567456789' Inexact Rounded
dqsub505 subtract '1231234555555555555555555567456789' 0.49          -> '1231234555555555555555555567456789' Inexact Rounded
dqsub506 subtract '1231234555555555555555555567456789' 0.499999      -> '1231234555555555555555555567456789' Inexact Rounded
dqsub507 subtract '1231234555555555555555555567456789' 0.499999999   -> '1231234555555555555555555567456789' Inexact Rounded
dqsub508 subtract '1231234555555555555555555567456789' 0.5           -> '1231234555555555555555555567456789' Inexact Rounded
dqsub509 subtract '1231234555555555555555555567456789' 0.500000001   -> '1231234555555555555555555567456788' Inexact Rounded
dqsub510 subtract '1231234555555555555555555567456789' 0.500001      -> '1231234555555555555555555567456788' Inexact Rounded
dqsub511 subtract '1231234555555555555555555567456789' 0.51          -> '1231234555555555555555555567456788' Inexact Rounded
dqsub512 subtract '1231234555555555555555555567456789' 0.6           -> '1231234555555555555555555567456788' Inexact Rounded
dqsub513 subtract '1231234555555555555555555567456789' 0.9           -> '1231234555555555555555555567456788' Inexact Rounded
dqsub514 subtract '1231234555555555555555555567456789' 0.99999       -> '1231234555555555555555555567456788' Inexact Rounded
dqsub515 subtract '1231234555555555555555555567456789' 0.999999999   -> '1231234555555555555555555567456788' Inexact Rounded
dqsub516 subtract '1231234555555555555555555567456789' 1             -> '1231234555555555555555555567456788'
dqsub517 subtract '1231234555555555555555555567456789' 1.000000001   -> '1231234555555555555555555567456788' Inexact Rounded
dqsub518 subtract '1231234555555555555555555567456789' 1.00001       -> '1231234555555555555555555567456788' Inexact Rounded
dqsub519 subtract '1231234555555555555555555567456789' 1.1           -> '1231234555555555555555555567456788' Inexact Rounded

rounding: half_even
dqsub520 subtract '1231234555555555555555555567456789' 0             -> '1231234555555555555555555567456789'
dqsub521 subtract '1231234555555555555555555567456789' 0.000000001   -> '1231234555555555555555555567456789' Inexact Rounded
dqsub522 subtract '1231234555555555555555555567456789' 0.000001      -> '1231234555555555555555555567456789' Inexact Rounded
dqsub523 subtract '1231234555555555555555555567456789' 0.1           -> '1231234555555555555555555567456789' Inexact Rounded
dqsub524 subtract '1231234555555555555555555567456789' 0.4           -> '1231234555555555555555555567456789' Inexact Rounded
dqsub525 subtract '1231234555555555555555555567456789' 0.49          -> '1231234555555555555555555567456789' Inexact Rounded
dqsub526 subtract '1231234555555555555555555567456789' 0.499999      -> '1231234555555555555555555567456789' Inexact Rounded
dqsub527 subtract '1231234555555555555555555567456789' 0.499999999   -> '1231234555555555555555555567456789' Inexact Rounded
dqsub528 subtract '1231234555555555555555555567456789' 0.5           -> '1231234555555555555555555567456788' Inexact Rounded
dqsub529 subtract '1231234555555555555555555567456789' 0.500000001   -> '1231234555555555555555555567456788' Inexact Rounded
dqsub530 subtract '1231234555555555555555555567456789' 0.500001      -> '1231234555555555555555555567456788' Inexact Rounded
dqsub531 subtract '1231234555555555555555555567456789' 0.51          -> '1231234555555555555555555567456788' Inexact Rounded
dqsub532 subtract '1231234555555555555555555567456789' 0.6           -> '1231234555555555555555555567456788' Inexact Rounded
dqsub533 subtract '1231234555555555555555555567456789' 0.9           -> '1231234555555555555555555567456788' Inexact Rounded
dqsub534 subtract '1231234555555555555555555567456789' 0.99999       -> '1231234555555555555555555567456788' Inexact Rounded
dqsub535 subtract '1231234555555555555555555567456789' 0.999999999   -> '1231234555555555555555555567456788' Inexact Rounded
dqsub536 subtract '1231234555555555555555555567456789' 1             -> '1231234555555555555555555567456788'
dqsub537 subtract '1231234555555555555555555567456789' 1.00000001    -> '1231234555555555555555555567456788' Inexact Rounded
dqsub538 subtract '1231234555555555555555555567456789' 1.00001       -> '1231234555555555555555555567456788' Inexact Rounded
dqsub539 subtract '1231234555555555555555555567456789' 1.1           -> '1231234555555555555555555567456788' Inexact Rounded
-- critical few with even bottom digit...
dqsub540 subtract '1231234555555555555555555567456788' 0.499999999   -> '1231234555555555555555555567456788' Inexact Rounded
dqsub541 subtract '1231234555555555555555555567456788' 0.5           -> '1231234555555555555555555567456788' Inexact Rounded
dqsub542 subtract '1231234555555555555555555567456788' 0.500000001   -> '1231234555555555555555555567456787' Inexact Rounded

rounding: down
dqsub550 subtract '1231234555555555555555555567456789' 0             -> '1231234555555555555555555567456789'
dqsub551 subtract '1231234555555555555555555567456789' 0.000000001   -> '1231234555555555555555555567456788' Inexact Rounded
dqsub552 subtract '1231234555555555555555555567456789' 0.000001      -> '1231234555555555555555555567456788' Inexact Rounded
dqsub553 subtract '1231234555555555555555555567456789' 0.1           -> '1231234555555555555555555567456788' Inexact Rounded
dqsub554 subtract '1231234555555555555555555567456789' 0.4           -> '1231234555555555555555555567456788' Inexact Rounded
dqsub555 subtract '1231234555555555555555555567456789' 0.49          -> '1231234555555555555555555567456788' Inexact Rounded
dqsub556 subtract '1231234555555555555555555567456789' 0.499999      -> '1231234555555555555555555567456788' Inexact Rounded
dqsub557 subtract '1231234555555555555555555567456789' 0.499999999   -> '1231234555555555555555555567456788' Inexact Rounded
dqsub558 subtract '1231234555555555555555555567456789' 0.5           -> '1231234555555555555555555567456788' Inexact Rounded
dqsub559 subtract '1231234555555555555555555567456789' 0.500000001   -> '1231234555555555555555555567456788' Inexact Rounded
dqsub560 subtract '1231234555555555555555555567456789' 0.500001      -> '1231234555555555555555555567456788' Inexact Rounded
dqsub561 subtract '1231234555555555555555555567456789' 0.51          -> '1231234555555555555555555567456788' Inexact Rounded
dqsub562 subtract '1231234555555555555555555567456789' 0.6           -> '1231234555555555555555555567456788' Inexact Rounded
dqsub563 subtract '1231234555555555555555555567456789' 0.9           -> '1231234555555555555555555567456788' Inexact Rounded
dqsub564 subtract '1231234555555555555555555567456789' 0.99999       -> '1231234555555555555555555567456788' Inexact Rounded
dqsub565 subtract '1231234555555555555555555567456789' 0.999999999   -> '1231234555555555555555555567456788' Inexact Rounded
dqsub566 subtract '1231234555555555555555555567456789' 1             -> '1231234555555555555555555567456788'
dqsub567 subtract '1231234555555555555555555567456789' 1.00000001    -> '1231234555555555555555555567456787' Inexact Rounded
dqsub568 subtract '1231234555555555555555555567456789' 1.00001       -> '1231234555555555555555555567456787' Inexact Rounded
dqsub569 subtract '1231234555555555555555555567456789' 1.1           -> '1231234555555555555555555567456787' Inexact Rounded

-- symmetry...
rounding: half_up
dqsub600 subtract 0             '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
dqsub601 subtract 0.000000001   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub602 subtract 0.000001      '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub603 subtract 0.1           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub604 subtract 0.4           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub605 subtract 0.49          '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub606 subtract 0.499999      '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub607 subtract 0.499999999   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub608 subtract 0.5           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub609 subtract 0.500000001   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub610 subtract 0.500001      '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub611 subtract 0.51          '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub612 subtract 0.6           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub613 subtract 0.9           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub614 subtract 0.99999       '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub615 subtract 0.999999999   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub616 subtract 1             '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
dqsub617 subtract 1.000000001   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub618 subtract 1.00001       '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub619 subtract 1.1           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded

rounding: half_even
dqsub620 subtract 0             '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
dqsub621 subtract 0.000000001   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub622 subtract 0.000001      '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub623 subtract 0.1           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub624 subtract 0.4           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub625 subtract 0.49          '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub626 subtract 0.499999      '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub627 subtract 0.499999999   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
dqsub628 subtract 0.5           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub629 subtract 0.500000001   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub630 subtract 0.500001      '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub631 subtract 0.51          '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub632 subtract 0.6           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub633 subtract 0.9           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub634 subtract 0.99999       '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub635 subtract 0.999999999   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub636 subtract 1             '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
dqsub637 subtract 1.00000001    '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub638 subtract 1.00001       '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub639 subtract 1.1           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-- critical few with even bottom digit...
dqsub640 subtract 0.499999999   '1231234555555555555555555567456788' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub641 subtract 0.5           '1231234555555555555555555567456788' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub642 subtract 0.500000001   '1231234555555555555555555567456788' -> '-1231234555555555555555555567456787' Inexact Rounded

rounding: down
dqsub650 subtract 0             '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
dqsub651 subtract 0.000000001   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub652 subtract 0.000001      '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub653 subtract 0.1           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub654 subtract 0.4           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub655 subtract 0.49          '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub656 subtract 0.499999      '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub657 subtract 0.499999999   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub658 subtract 0.5           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub659 subtract 0.500000001   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub660 subtract 0.500001      '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub661 subtract 0.51          '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub662 subtract 0.6           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub663 subtract 0.9           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub664 subtract 0.99999       '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub665 subtract 0.999999999   '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
dqsub666 subtract 1             '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
dqsub667 subtract 1.00000001    '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
dqsub668 subtract 1.00001       '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
dqsub669 subtract 1.1           '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded


-- lots of leading zeros in intermediate result, and showing effects of
-- input rounding would have affected the following
rounding: half_up
dqsub670 subtract '1234567456789' '1234567456788.1' -> 0.9
dqsub671 subtract '1234567456789' '1234567456788.9' -> 0.1
dqsub672 subtract '1234567456789' '1234567456789.1' -> -0.1
dqsub673 subtract '1234567456789' '1234567456789.5' -> -0.5
dqsub674 subtract '1234567456789' '1234567456789.9' -> -0.9

rounding: half_even
dqsub680 subtract '1234567456789' '1234567456788.1' -> 0.9
dqsub681 subtract '1234567456789' '1234567456788.9' -> 0.1
dqsub682 subtract '1234567456789' '1234567456789.1' -> -0.1
dqsub683 subtract '1234567456789' '1234567456789.5' -> -0.5
dqsub684 subtract '1234567456789' '1234567456789.9' -> -0.9

dqsub685 subtract '1234567456788' '1234567456787.1' -> 0.9
dqsub686 subtract '1234567456788' '1234567456787.9' -> 0.1
dqsub687 subtract '1234567456788' '1234567456788.1' -> -0.1
dqsub688 subtract '1234567456788' '1234567456788.5' -> -0.5
dqsub689 subtract '1234567456788' '1234567456788.9' -> -0.9

rounding: down
dqsub690 subtract '1234567456789' '1234567456788.1' -> 0.9
dqsub691 subtract '1234567456789' '1234567456788.9' -> 0.1
dqsub692 subtract '1234567456789' '1234567456789.1' -> -0.1
dqsub693 subtract '1234567456789' '1234567456789.5' -> -0.5
dqsub694 subtract '1234567456789' '1234567456789.9' -> -0.9

-- Specials
dqsub780 subtract -Inf   Inf   -> -Infinity
dqsub781 subtract -Inf   1000  -> -Infinity
dqsub782 subtract -Inf   1     -> -Infinity
dqsub783 subtract -Inf  -0     -> -Infinity
dqsub784 subtract -Inf  -1     -> -Infinity
dqsub785 subtract -Inf  -1000  -> -Infinity
dqsub787 subtract -1000  Inf   -> -Infinity
dqsub788 subtract -Inf   Inf   -> -Infinity
dqsub789 subtract -1     Inf   -> -Infinity
dqsub790 subtract  0     Inf   -> -Infinity
dqsub791 subtract  1     Inf   -> -Infinity
dqsub792 subtract  1000  Inf   -> -Infinity

dqsub800 subtract  Inf   Inf   ->  NaN  Invalid_operation
dqsub801 subtract  Inf   1000  ->  Infinity
dqsub802 subtract  Inf   1     ->  Infinity
dqsub803 subtract  Inf   0     ->  Infinity
dqsub804 subtract  Inf  -0     ->  Infinity
dqsub805 subtract  Inf  -1     ->  Infinity
dqsub806 subtract  Inf  -1000  ->  Infinity
dqsub807 subtract  Inf  -Inf   ->  Infinity
dqsub808 subtract -1000 -Inf   ->  Infinity
dqsub809 subtract -Inf  -Inf   ->  NaN  Invalid_operation
dqsub810 subtract -1    -Inf   ->  Infinity
dqsub811 subtract -0    -Inf   ->  Infinity
dqsub812 subtract  0    -Inf   ->  Infinity
dqsub813 subtract  1    -Inf   ->  Infinity
dqsub814 subtract  1000 -Inf   ->  Infinity
dqsub815 subtract  Inf  -Inf   ->  Infinity

dqsub821 subtract  NaN   Inf   ->  NaN
dqsub822 subtract -NaN   1000  -> -NaN
dqsub823 subtract  NaN   1     ->  NaN
dqsub824 subtract  NaN   0     ->  NaN
dqsub825 subtract  NaN  -0     ->  NaN
dqsub826 subtract  NaN  -1     ->  NaN
dqsub827 subtract  NaN  -1000  ->  NaN
dqsub828 subtract  NaN  -Inf   ->  NaN
dqsub829 subtract -NaN   NaN   -> -NaN
dqsub830 subtract -Inf   NaN   ->  NaN
dqsub831 subtract -1000  NaN   ->  NaN
dqsub832 subtract -1     NaN   ->  NaN
dqsub833 subtract -0     NaN   ->  NaN
dqsub834 subtract  0     NaN   ->  NaN
dqsub835 subtract  1     NaN   ->  NaN
dqsub836 subtract  1000 -NaN   -> -NaN
dqsub837 subtract  Inf   NaN   ->  NaN

dqsub841 subtract  sNaN  Inf   ->  NaN  Invalid_operation
dqsub842 subtract -sNaN  1000  -> -NaN  Invalid_operation
dqsub843 subtract  sNaN  1     ->  NaN  Invalid_operation
dqsub844 subtract  sNaN  0     ->  NaN  Invalid_operation
dqsub845 subtract  sNaN -0     ->  NaN  Invalid_operation
dqsub846 subtract  sNaN -1     ->  NaN  Invalid_operation
dqsub847 subtract  sNaN -1000  ->  NaN  Invalid_operation
dqsub848 subtract  sNaN  NaN   ->  NaN  Invalid_operation
dqsub849 subtract  sNaN sNaN   ->  NaN  Invalid_operation
dqsub850 subtract  NaN  sNaN   ->  NaN  Invalid_operation
dqsub851 subtract -Inf -sNaN   -> -NaN  Invalid_operation
dqsub852 subtract -1000 sNaN   ->  NaN  Invalid_operation
dqsub853 subtract -1    sNaN   ->  NaN  Invalid_operation
dqsub854 subtract -0    sNaN   ->  NaN  Invalid_operation
dqsub855 subtract  0    sNaN   ->  NaN  Invalid_operation
dqsub856 subtract  1    sNaN   ->  NaN  Invalid_operation
dqsub857 subtract  1000 sNaN   ->  NaN  Invalid_operation
dqsub858 subtract  Inf  sNaN   ->  NaN  Invalid_operation
dqsub859 subtract  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqsub861 subtract  NaN01   -Inf     ->  NaN1
dqsub862 subtract -NaN02   -1000    -> -NaN2
dqsub863 subtract  NaN03    1000    ->  NaN3
dqsub864 subtract  NaN04    Inf     ->  NaN4
dqsub865 subtract  NaN05    NaN61   ->  NaN5
dqsub866 subtract -Inf     -NaN71   -> -NaN71
dqsub867 subtract -1000     NaN81   ->  NaN81
dqsub868 subtract  1000     NaN91   ->  NaN91
dqsub869 subtract  Inf      NaN101  ->  NaN101
dqsub871 subtract  sNaN011  -Inf    ->  NaN11  Invalid_operation
dqsub872 subtract  sNaN012  -1000   ->  NaN12  Invalid_operation
dqsub873 subtract -sNaN013   1000   -> -NaN13  Invalid_operation
dqsub874 subtract  sNaN014   NaN171 ->  NaN14  Invalid_operation
dqsub875 subtract  sNaN015  sNaN181 ->  NaN15  Invalid_operation
dqsub876 subtract  NaN016   sNaN191 ->  NaN191 Invalid_operation
dqsub877 subtract -Inf      sNaN201 ->  NaN201 Invalid_operation
dqsub878 subtract -1000     sNaN211 ->  NaN211 Invalid_operation
dqsub879 subtract  1000    -sNaN221 -> -NaN221 Invalid_operation
dqsub880 subtract  Inf      sNaN231 ->  NaN231 Invalid_operation
dqsub881 subtract  NaN025   sNaN241 ->  NaN241 Invalid_operation

-- edge case spills
dqsub901 subtract  2.E-3  1.002  -> -1.000
dqsub902 subtract  2.0E-3  1.002  -> -1.0000
dqsub903 subtract  2.00E-3  1.0020  -> -1.00000
dqsub904 subtract  2.000E-3  1.00200  -> -1.000000
dqsub905 subtract  2.0000E-3  1.002000  -> -1.0000000
dqsub906 subtract  2.00000E-3  1.0020000  -> -1.00000000
dqsub907 subtract  2.000000E-3  1.00200000  -> -1.000000000
dqsub908 subtract  2.0000000E-3  1.002000000  -> -1.0000000000

-- subnormals and overflows covered under Add

-- Examples from SQL proposal (Krishna Kulkarni)
dqsub1125  subtract 130E-2  120E-2 -> 0.10
dqsub1126  subtract 130E-2  12E-1  -> 0.10
dqsub1127  subtract 130E-2  1E0    -> 0.30
dqsub1128  subtract 1E2     1E4    -> -9.9E+3

-- Null tests
dqsub9990 subtract 10  # -> NaN Invalid_operation
dqsub9991 subtract  # 10 -> NaN Invalid_operation

Added test/dectest/dqToIntegral.decTest.



































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
------------------------------------------------------------------------
-- dqToIntegral.decTest -- round Quad to integral value               --
-- Copyright (c) IBM Corporation, 2001, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests tests the extended specification 'round-to-integral
-- value-exact' operations (from IEEE 854, later modified in 754r).
-- All non-zero results are defined as being those from either copy or
-- quantize, so those are assumed to have been tested extensively
-- elsewhere; the tests here are for integrity, rounding mode, etc.
-- Also, it is assumed the test harness will use these tests for both
-- ToIntegralExact (which does set Inexact) and the fixed-name
-- functions (which do not set Inexact).

-- Note that decNumber implements an earlier definition of toIntegral
-- which never sets Inexact; the decTest operator for that is called
-- 'tointegral' instead of 'tointegralx'.

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

dqintx001 tointegralx      0     ->  0
dqintx002 tointegralx      0.0   ->  0
dqintx003 tointegralx      0.1   ->  0  Inexact Rounded
dqintx004 tointegralx      0.2   ->  0  Inexact Rounded
dqintx005 tointegralx      0.3   ->  0  Inexact Rounded
dqintx006 tointegralx      0.4   ->  0  Inexact Rounded
dqintx007 tointegralx      0.5   ->  0  Inexact Rounded
dqintx008 tointegralx      0.6   ->  1  Inexact Rounded
dqintx009 tointegralx      0.7   ->  1  Inexact Rounded
dqintx010 tointegralx      0.8   ->  1  Inexact Rounded
dqintx011 tointegralx      0.9   ->  1  Inexact Rounded
dqintx012 tointegralx      1     ->  1
dqintx013 tointegralx      1.0   ->  1  Rounded
dqintx014 tointegralx      1.1   ->  1  Inexact Rounded
dqintx015 tointegralx      1.2   ->  1  Inexact Rounded
dqintx016 tointegralx      1.3   ->  1  Inexact Rounded
dqintx017 tointegralx      1.4   ->  1  Inexact Rounded
dqintx018 tointegralx      1.5   ->  2  Inexact Rounded
dqintx019 tointegralx      1.6   ->  2  Inexact Rounded
dqintx020 tointegralx      1.7   ->  2  Inexact Rounded
dqintx021 tointegralx      1.8   ->  2  Inexact Rounded
dqintx022 tointegralx      1.9   ->  2  Inexact Rounded
-- negatives
dqintx031 tointegralx     -0     -> -0
dqintx032 tointegralx     -0.0   -> -0
dqintx033 tointegralx     -0.1   -> -0  Inexact Rounded
dqintx034 tointegralx     -0.2   -> -0  Inexact Rounded
dqintx035 tointegralx     -0.3   -> -0  Inexact Rounded
dqintx036 tointegralx     -0.4   -> -0  Inexact Rounded
dqintx037 tointegralx     -0.5   -> -0  Inexact Rounded
dqintx038 tointegralx     -0.6   -> -1  Inexact Rounded
dqintx039 tointegralx     -0.7   -> -1  Inexact Rounded
dqintx040 tointegralx     -0.8   -> -1  Inexact Rounded
dqintx041 tointegralx     -0.9   -> -1  Inexact Rounded
dqintx042 tointegralx     -1     -> -1
dqintx043 tointegralx     -1.0   -> -1  Rounded
dqintx044 tointegralx     -1.1   -> -1  Inexact Rounded
dqintx045 tointegralx     -1.2   -> -1  Inexact Rounded
dqintx046 tointegralx     -1.3   -> -1  Inexact Rounded
dqintx047 tointegralx     -1.4   -> -1  Inexact Rounded
dqintx048 tointegralx     -1.5   -> -2  Inexact Rounded
dqintx049 tointegralx     -1.6   -> -2  Inexact Rounded
dqintx050 tointegralx     -1.7   -> -2  Inexact Rounded
dqintx051 tointegralx     -1.8   -> -2  Inexact Rounded
dqintx052 tointegralx     -1.9   -> -2  Inexact Rounded
-- next two would be NaN using quantize(x, 0)
dqintx053 tointegralx    10E+60  -> 1.0E+61
dqintx054 tointegralx   -10E+60  -> -1.0E+61

-- numbers around precision
dqintx060 tointegralx '56267E-17'   -> '0'      Inexact Rounded
dqintx061 tointegralx '56267E-5'    -> '1'      Inexact Rounded
dqintx062 tointegralx '56267E-2'    -> '563'    Inexact Rounded
dqintx063 tointegralx '56267E-1'    -> '5627'   Inexact Rounded
dqintx065 tointegralx '56267E-0'    -> '56267'
dqintx066 tointegralx '56267E+0'    -> '56267'
dqintx067 tointegralx '56267E+1'    -> '5.6267E+5'
dqintx068 tointegralx '56267E+9'    -> '5.6267E+13'
dqintx069 tointegralx '56267E+10'   -> '5.6267E+14'
dqintx070 tointegralx '56267E+11'   -> '5.6267E+15'
dqintx071 tointegralx '56267E+12'   -> '5.6267E+16'
dqintx072 tointegralx '56267E+13'   -> '5.6267E+17'
dqintx073 tointegralx '1.23E+96'    -> '1.23E+96'
dqintx074 tointegralx '1.23E+6144'  -> #47ffd300000000000000000000000000 Clamped

dqintx080 tointegralx '-56267E-10'  -> '-0'      Inexact Rounded
dqintx081 tointegralx '-56267E-5'   -> '-1'      Inexact Rounded
dqintx082 tointegralx '-56267E-2'   -> '-563'    Inexact Rounded
dqintx083 tointegralx '-56267E-1'   -> '-5627'   Inexact Rounded
dqintx085 tointegralx '-56267E-0'   -> '-56267'
dqintx086 tointegralx '-56267E+0'   -> '-56267'
dqintx087 tointegralx '-56267E+1'   -> '-5.6267E+5'
dqintx088 tointegralx '-56267E+9'   -> '-5.6267E+13'
dqintx089 tointegralx '-56267E+10'  -> '-5.6267E+14'
dqintx090 tointegralx '-56267E+11'  -> '-5.6267E+15'
dqintx091 tointegralx '-56267E+12'  -> '-5.6267E+16'
dqintx092 tointegralx '-56267E+13'  -> '-5.6267E+17'
dqintx093 tointegralx '-1.23E+96'   -> '-1.23E+96'
dqintx094 tointegralx '-1.23E+6144' -> #c7ffd300000000000000000000000000 Clamped

-- subnormal inputs
dqintx100 tointegralx        1E-299 -> 0  Inexact Rounded
dqintx101 tointegralx      0.1E-299 -> 0  Inexact Rounded
dqintx102 tointegralx     0.01E-299 -> 0  Inexact Rounded
dqintx103 tointegralx        0E-299 -> 0

-- specials and zeros
dqintx120 tointegralx 'Inf'       ->  Infinity
dqintx121 tointegralx '-Inf'      -> -Infinity
dqintx122 tointegralx   NaN       ->  NaN
dqintx123 tointegralx  sNaN       ->  NaN  Invalid_operation
dqintx124 tointegralx     0       ->  0
dqintx125 tointegralx    -0       -> -0
dqintx126 tointegralx     0.000   ->  0
dqintx127 tointegralx     0.00    ->  0
dqintx128 tointegralx     0.0     ->  0
dqintx129 tointegralx     0       ->  0
dqintx130 tointegralx     0E-3    ->  0
dqintx131 tointegralx     0E-2    ->  0
dqintx132 tointegralx     0E-1    ->  0
dqintx133 tointegralx     0E-0    ->  0
dqintx134 tointegralx     0E+1    ->  0E+1
dqintx135 tointegralx     0E+2    ->  0E+2
dqintx136 tointegralx     0E+3    ->  0E+3
dqintx137 tointegralx     0E+4    ->  0E+4
dqintx138 tointegralx     0E+5    ->  0E+5
dqintx139 tointegralx    -0.000   -> -0
dqintx140 tointegralx    -0.00    -> -0
dqintx141 tointegralx    -0.0     -> -0
dqintx142 tointegralx    -0       -> -0
dqintx143 tointegralx    -0E-3    -> -0
dqintx144 tointegralx    -0E-2    -> -0
dqintx145 tointegralx    -0E-1    -> -0
dqintx146 tointegralx    -0E-0    -> -0
dqintx147 tointegralx    -0E+1    -> -0E+1
dqintx148 tointegralx    -0E+2    -> -0E+2
dqintx149 tointegralx    -0E+3    -> -0E+3
dqintx150 tointegralx    -0E+4    -> -0E+4
dqintx151 tointegralx    -0E+5    -> -0E+5
-- propagating NaNs
dqintx152 tointegralx   NaN808    ->  NaN808
dqintx153 tointegralx  sNaN080    ->  NaN80  Invalid_operation
dqintx154 tointegralx  -NaN808    -> -NaN808
dqintx155 tointegralx -sNaN080    -> -NaN80  Invalid_operation
dqintx156 tointegralx  -NaN       -> -NaN
dqintx157 tointegralx -sNaN       -> -NaN    Invalid_operation

-- examples
rounding:    half_up
dqintx200 tointegralx     2.1    -> 2            Inexact Rounded
dqintx201 tointegralx   100      -> 100
dqintx202 tointegralx   100.0    -> 100          Rounded
dqintx203 tointegralx   101.5    -> 102          Inexact Rounded
dqintx204 tointegralx  -101.5    -> -102         Inexact Rounded
dqintx205 tointegralx   10E+5    -> 1.0E+6
dqintx206 tointegralx  7.89E+77  -> 7.89E+77
dqintx207 tointegralx   -Inf     -> -Infinity


-- all rounding modes
rounding:    half_even
dqintx210 tointegralx     55.5   ->  56  Inexact Rounded
dqintx211 tointegralx     56.5   ->  56  Inexact Rounded
dqintx212 tointegralx     57.5   ->  58  Inexact Rounded
dqintx213 tointegralx    -55.5   -> -56  Inexact Rounded
dqintx214 tointegralx    -56.5   -> -56  Inexact Rounded
dqintx215 tointegralx    -57.5   -> -58  Inexact Rounded

rounding:    half_up

dqintx220 tointegralx     55.5   ->  56  Inexact Rounded
dqintx221 tointegralx     56.5   ->  57  Inexact Rounded
dqintx222 tointegralx     57.5   ->  58  Inexact Rounded
dqintx223 tointegralx    -55.5   -> -56  Inexact Rounded
dqintx224 tointegralx    -56.5   -> -57  Inexact Rounded
dqintx225 tointegralx    -57.5   -> -58  Inexact Rounded

rounding:    half_down

dqintx230 tointegralx     55.5   ->  55  Inexact Rounded
dqintx231 tointegralx     56.5   ->  56  Inexact Rounded
dqintx232 tointegralx     57.5   ->  57  Inexact Rounded
dqintx233 tointegralx    -55.5   -> -55  Inexact Rounded
dqintx234 tointegralx    -56.5   -> -56  Inexact Rounded
dqintx235 tointegralx    -57.5   -> -57  Inexact Rounded

rounding:    up

dqintx240 tointegralx     55.3   ->  56  Inexact Rounded
dqintx241 tointegralx     56.3   ->  57  Inexact Rounded
dqintx242 tointegralx     57.3   ->  58  Inexact Rounded
dqintx243 tointegralx    -55.3   -> -56  Inexact Rounded
dqintx244 tointegralx    -56.3   -> -57  Inexact Rounded
dqintx245 tointegralx    -57.3   -> -58  Inexact Rounded

rounding:    down

dqintx250 tointegralx     55.7   ->  55  Inexact Rounded
dqintx251 tointegralx     56.7   ->  56  Inexact Rounded
dqintx252 tointegralx     57.7   ->  57  Inexact Rounded
dqintx253 tointegralx    -55.7   -> -55  Inexact Rounded
dqintx254 tointegralx    -56.7   -> -56  Inexact Rounded
dqintx255 tointegralx    -57.7   -> -57  Inexact Rounded

rounding:    ceiling

dqintx260 tointegralx     55.3   ->  56  Inexact Rounded
dqintx261 tointegralx     56.3   ->  57  Inexact Rounded
dqintx262 tointegralx     57.3   ->  58  Inexact Rounded
dqintx263 tointegralx    -55.3   -> -55  Inexact Rounded
dqintx264 tointegralx    -56.3   -> -56  Inexact Rounded
dqintx265 tointegralx    -57.3   -> -57  Inexact Rounded

rounding:    floor

dqintx270 tointegralx     55.7   ->  55  Inexact Rounded
dqintx271 tointegralx     56.7   ->  56  Inexact Rounded
dqintx272 tointegralx     57.7   ->  57  Inexact Rounded
dqintx273 tointegralx    -55.7   -> -56  Inexact Rounded
dqintx274 tointegralx    -56.7   -> -57  Inexact Rounded
dqintx275 tointegralx    -57.7   -> -58  Inexact Rounded

-- Int and uInt32 edge values for testing conversions
dqintx300 tointegralx -2147483646  -> -2147483646
dqintx301 tointegralx -2147483647  -> -2147483647
dqintx302 tointegralx -2147483648  -> -2147483648
dqintx303 tointegralx -2147483649  -> -2147483649
dqintx304 tointegralx  2147483646  ->  2147483646
dqintx305 tointegralx  2147483647  ->  2147483647
dqintx306 tointegralx  2147483648  ->  2147483648
dqintx307 tointegralx  2147483649  ->  2147483649
dqintx308 tointegralx  4294967294  ->  4294967294
dqintx309 tointegralx  4294967295  ->  4294967295
dqintx310 tointegralx  4294967296  ->  4294967296
dqintx311 tointegralx  4294967297  ->  4294967297

Added test/dectest/dqXor.decTest.





















































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
------------------------------------------------------------------------
-- dqXor.decTest -- digitwise logical XOR for decQuads                --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
clamp:       1
precision:   34
maxExponent: 6144
minExponent: -6143
rounding:    half_even

-- Sanity check (truth table)
dqxor001 xor             0    0 ->    0
dqxor002 xor             0    1 ->    1
dqxor003 xor             1    0 ->    1
dqxor004 xor             1    1 ->    0
dqxor005 xor          1100 1010 ->  110
-- and at msd and msd-1
dqxor006 xor 0000000000000000000000000000000000 0000000000000000000000000000000000 ->           0
dqxor007 xor 0000000000000000000000000000000000 1000000000000000000000000000000000 ->   1000000000000000000000000000000000
dqxor008 xor 1000000000000000000000000000000000 0000000000000000000000000000000000 ->   1000000000000000000000000000000000
dqxor009 xor 1000000000000000000000000000000000 1000000000000000000000000000000000 ->           0
dqxor010 xor 0000000000000000000000000000000000 0000000000000000000000000000000000 ->           0
dqxor011 xor 0000000000000000000000000000000000 0100000000000000000000000000000000 ->    100000000000000000000000000000000
dqxor012 xor 0100000000000000000000000000000000 0000000000000000000000000000000000 ->    100000000000000000000000000000000
dqxor013 xor 0100000000000000000000000000000000 0100000000000000000000000000000000 ->           0

-- Various lengths
--           1234567890123456789012345678901234
dqxor601 xor 0111111111111111111111111111111111 1111111111111111111111111111111111  -> 1000000000000000000000000000000000
dqxor602 xor 1011111111111111111111111111111111 1111111111111111111111111111111111  ->  100000000000000000000000000000000
dqxor603 xor 1101111111111111111111111111111111 1111111111111111111111111111111111  ->   10000000000000000000000000000000
dqxor604 xor 1110111111111111111111111111111111 1111111111111111111111111111111111  ->    1000000000000000000000000000000
dqxor605 xor 1111011111111111111111111111111111 1111111111111111111111111111111111  ->     100000000000000000000000000000
dqxor606 xor 1111101111111111111111111111111111 1111111111111111111111111111111111  ->      10000000000000000000000000000
dqxor607 xor 1111110111111111111111111111111111 1111111111111111111111111111111111  ->       1000000000000000000000000000
dqxor608 xor 1111111011111111111111111111111111 1111111111111111111111111111111111  ->        100000000000000000000000000
dqxor609 xor 1111111101111111111111111111111111 1111111111111111111111111111111111  ->         10000000000000000000000000
dqxor610 xor 1111111110111111111111111111111111 1111111111111111111111111111111111  ->          1000000000000000000000000
dqxor611 xor 1111111111011111111111111111111111 1111111111111111111111111111111111  ->           100000000000000000000000
dqxor612 xor 1111111111101111111111111111111111 1111111111111111111111111111111111  ->            10000000000000000000000
dqxor613 xor 1111111111110111111111111111111111 1111111111111111111111111111111111  ->             1000000000000000000000
dqxor614 xor 1111111111111011111111111111111111 1111111111111111111111111111111111  ->              100000000000000000000
dqxor615 xor 1111111111111101111111111111111111 1111111111111111111111111111111111  ->               10000000000000000000
dqxor616 xor 1111111111111110111111111111111111 1111111111111111111111111111111111  ->                1000000000000000000
dqxor617 xor 1111111111111111011111111111111111 1111111111111111111111111111111111  ->                 100000000000000000
dqxor618 xor 1111111111111111101111111111111111 1111111111111111111111111111111111  ->                  10000000000000000
dqxor619 xor 1111111111111111110111111111111111 1111111111111111111111111111111111  ->                   1000000000000000
dqxor620 xor 1111111111111111111011111111111111 1111111111111111111111111111111111  ->                    100000000000000
dqxor621 xor 1111111111111111111101111111111111 1111111111111111111111111111111111  ->                     10000000000000
dqxor622 xor 1111111111111111111110111111111111 1111111111111111111111111111111111  ->                      1000000000000
dqxor623 xor 1111111111111111111111011111111111 1111111111111111111111111111111111  ->                       100000000000
dqxor624 xor 1111111111111111111111101111111111 1111111111111111111111111111111111  ->                        10000000000
dqxor625 xor 1111111111111111111111110111111111 1111111111111111111111111111111111  ->                         1000000000
dqxor626 xor 1111111111111111111111111011111111 1111111111111111111111111111111111  ->                          100000000
dqxor627 xor 1111111111111111111111111101111111 1111111111111111111111111111111111  ->                           10000000
dqxor628 xor 1111111111111111111111111110111111 1111111111111111111111111111111111  ->                            1000000
dqxor629 xor 1111111111111111111111111111011111 1111111111111111111111111111111111  ->                             100000
dqxor630 xor 1111111111111111111111111111101111 1111111111111111111111111111111111  ->                              10000
dqxor631 xor 1111111111111111111111111111110111 1111111111111111111111111111111111  ->                               1000
dqxor632 xor 1111111111111111111111111111111011 1111111111111111111111111111111111  ->                                100
dqxor633 xor 1111111111111111111111111111111101 1111111111111111111111111111111111  ->                                 10
dqxor634 xor 1111111111111111111111111111111110 1111111111111111111111111111111111  ->                                  1

dqxor641 xor 1111111111111111111111111111111111 0111111111111111111111111111111111  -> 1000000000000000000000000000000000
dqxor642 xor 1111111111111111111111111111111111 1011111111111111111111111111111111  ->  100000000000000000000000000000000
dqxor643 xor 1111111111111111111111111111111111 1101111111111111111111111111111111  ->   10000000000000000000000000000000
dqxor644 xor 1111111111111111111111111111111111 1110111111111111111111111111111111  ->    1000000000000000000000000000000
dqxor645 xor 1111111111111111111111111111111111 1111011111111111111111111111111111  ->     100000000000000000000000000000
dqxor646 xor 1111111111111111111111111111111111 1111101111111111111111111111111111  ->      10000000000000000000000000000
dqxor647 xor 1111111111111111111111111111111111 1111110111111111111111111111111111  ->       1000000000000000000000000000
dqxor648 xor 1111111111111111111111111111111111 1111111011111111111111111111111111  ->        100000000000000000000000000
dqxor649 xor 1111111111111111111111111111111111 1111111101111111111111111111111111  ->         10000000000000000000000000
dqxor650 xor 1111111111111111111111111111111111 1111111110111111111111111111111111  ->          1000000000000000000000000
dqxor651 xor 1111111111111111111111111111111111 1111111111011111111111111111111111  ->           100000000000000000000000
dqxor652 xor 1111111111111111111111111111111111 1111111111101111111111111111111111  ->            10000000000000000000000
dqxor653 xor 1111111111111111111111111111111111 1111111111110111111111111111111111  ->             1000000000000000000000
dqxor654 xor 1111111111111111111111111111111111 1111111111111011111111111111111111  ->              100000000000000000000
dqxor655 xor 1111111111111111111111111111111111 1111111111111101111111111111111111  ->               10000000000000000000
dqxor656 xor 1111111111111111111111111111111111 1111111111111110111111111111111111  ->                1000000000000000000
dqxor657 xor 1111111111111111111111111111111111 1111111111111111011111111111111111  ->                 100000000000000000
dqxor658 xor 1111111111111111111111111111111111 1111111111111111101111111111111111  ->                  10000000000000000
dqxor659 xor 1111111111111111111111111111111111 1111111111111111110111111111111111  ->                   1000000000000000
dqxor660 xor 1111111111111111111111111111111111 1111111111111111111011111111111111  ->                    100000000000000
dqxor661 xor 1111111111111111111111111111111111 1111111111111111111101111111111111  ->                     10000000000000
dqxor662 xor 1111111111111111111111111111111111 1111111111111111111110111111111111  ->                      1000000000000
dqxor663 xor 1111111111111111111111111111111111 1111111111111111111111011111111111  ->                       100000000000
dqxor664 xor 1111111111111111111111111111111111 1111111111111111111111101111111111  ->                        10000000000
dqxor665 xor 1111111111111111111111111111111111 1111111111111111111111110111111111  ->                         1000000000
dqxor666 xor 1111111111111111111111111111111111 1111111111111111111111111011111111  ->                          100000000
dqxor667 xor 1111111111111111111111111111111111 1111111111111111111111111101111111  ->                           10000000
dqxor668 xor 1111111111111111111111111111111111 1111111111111111111111111110111111  ->                            1000000
dqxor669 xor 1111111111111111111111111111111111 1111111111111111111111111111011111  ->                             100000
dqxor670 xor 1111111111111111111111111111111111 1111111111111111111111111111101111  ->                              10000
dqxor671 xor 1111111111111111111111111111111111 1111111111111111111111111111110111  ->                               1000
dqxor672 xor 1111111111111111111111111111111111 1111111111111111111111111111111011  ->                                100
dqxor673 xor 1111111111111111111111111111111111 1111111111111111111111111111111101  ->                                 10
dqxor674 xor 1111111111111111111111111111111111 1111111111111111111111111111111110  ->                                  1
dqxor675 xor 0111111111111111111111111111111111 1111111111111111111111111111111110  -> 1000000000000000000000000000000001
dqxor676 xor 1111111111111111111111111111111111 1111111111111111111111111111111110  ->                                  1


dqxor021 xor 1111111110000000     1111111110000000  ->  0
dqxor022 xor  111111110000000      111111110000000  ->  0
dqxor023 xor   11111110000000       11111110000000  ->  0
dqxor024 xor    1111110000000        1111110000000  ->  0
dqxor025 xor     111110000000         111110000000  ->  0
dqxor026 xor      11110000000          11110000000  ->  0
dqxor027 xor       1110000000           1110000000  ->  0
dqxor028 xor        110000000            110000000  ->  0
dqxor029 xor         10000000             10000000  ->  0
dqxor030 xor          1000000              1000000  ->  0
dqxor031 xor           100000               100000  ->  0
dqxor032 xor            10000                10000  ->  0
dqxor033 xor             1000                 1000  ->  0
dqxor034 xor              100                  100  ->  0
dqxor035 xor               10                   10  ->  0
dqxor036 xor                1                    1  ->  0

dqxor040 xor 111111111  111111111111  ->  111000000000
dqxor041 xor  11111111  111111111111  ->  111100000000
dqxor042 xor  11111111     111111111  ->  100000000
dqxor043 xor   1111111     100000010  ->  101111101
dqxor044 xor    111111     100000100  ->  100111011
dqxor045 xor     11111     100001000  ->  100010111
dqxor046 xor      1111     100010000  ->  100011111
dqxor047 xor       111     100100000  ->  100100111
dqxor048 xor        11     101000000  ->  101000011
dqxor049 xor         1     110000000  ->  110000001

dqxor050 xor 1111111111  1  ->  1111111110
dqxor051 xor  111111111  1  ->  111111110
dqxor052 xor   11111111  1  ->  11111110
dqxor053 xor    1111111  1  ->  1111110
dqxor054 xor     111111  1  ->  111110
dqxor055 xor      11111  1  ->  11110
dqxor056 xor       1111  1  ->  1110
dqxor057 xor        111  1  ->  110
dqxor058 xor         11  1  ->  10
dqxor059 xor          1  1  ->  0

dqxor060 xor 1111111111  0  ->  1111111111
dqxor061 xor  111111111  0  ->  111111111
dqxor062 xor   11111111  0  ->  11111111
dqxor063 xor    1111111  0  ->  1111111
dqxor064 xor     111111  0  ->  111111
dqxor065 xor      11111  0  ->  11111
dqxor066 xor       1111  0  ->  1111
dqxor067 xor        111  0  ->  111
dqxor068 xor         11  0  ->  11
dqxor069 xor          1  0  ->  1

dqxor070 xor 1  1111111111  ->  1111111110
dqxor071 xor 1   111111111  ->  111111110
dqxor072 xor 1    11111111  ->  11111110
dqxor073 xor 1     1111111  ->  1111110
dqxor074 xor 1      111111  ->  111110
dqxor075 xor 1       11111  ->  11110
dqxor076 xor 1        1111  ->  1110
dqxor077 xor 1         111  ->  110
dqxor078 xor 1          11  ->  10
dqxor079 xor 1           1  ->  0

dqxor080 xor 0  1111111111  ->  1111111111
dqxor081 xor 0   111111111  ->  111111111
dqxor082 xor 0    11111111  ->  11111111
dqxor083 xor 0     1111111  ->  1111111
dqxor084 xor 0      111111  ->  111111
dqxor085 xor 0       11111  ->  11111
dqxor086 xor 0        1111  ->  1111
dqxor087 xor 0         111  ->  111
dqxor088 xor 0          11  ->  11
dqxor089 xor 0           1  ->  1

dqxor090 xor 011111111  111101111  ->  100010000
dqxor091 xor 101111111  111101111  ->   10010000
dqxor092 xor 110111111  111101111  ->    1010000
dqxor093 xor 111011111  111101111  ->     110000
dqxor094 xor 111101111  111101111  ->          0
dqxor095 xor 111110111  111101111  ->      11000
dqxor096 xor 111111011  111101111  ->      10100
dqxor097 xor 111111101  111101111  ->      10010
dqxor098 xor 111111110  111101111  ->      10001

dqxor100 xor 111101111  011111111  ->  100010000
dqxor101 xor 111101111  101111111  ->   10010000
dqxor102 xor 111101111  110111111  ->    1010000
dqxor103 xor 111101111  111011111  ->     110000
dqxor104 xor 111101111  111101111  ->          0
dqxor105 xor 111101111  111110111  ->      11000
dqxor106 xor 111101111  111111011  ->      10100
dqxor107 xor 111101111  111111101  ->      10010
dqxor108 xor 111101111  111111110  ->      10001

-- non-0/1 should not be accepted, nor should signs
dqxor220 xor 111111112  111111111  ->  NaN Invalid_operation
dqxor221 xor 333333333  333333333  ->  NaN Invalid_operation
dqxor222 xor 555555555  555555555  ->  NaN Invalid_operation
dqxor223 xor 777777777  777777777  ->  NaN Invalid_operation
dqxor224 xor 999999999  999999999  ->  NaN Invalid_operation
dqxor225 xor 222222222  999999999  ->  NaN Invalid_operation
dqxor226 xor 444444444  999999999  ->  NaN Invalid_operation
dqxor227 xor 666666666  999999999  ->  NaN Invalid_operation
dqxor228 xor 888888888  999999999  ->  NaN Invalid_operation
dqxor229 xor 999999999  222222222  ->  NaN Invalid_operation
dqxor230 xor 999999999  444444444  ->  NaN Invalid_operation
dqxor231 xor 999999999  666666666  ->  NaN Invalid_operation
dqxor232 xor 999999999  888888888  ->  NaN Invalid_operation
-- a few randoms
dqxor240 xor  567468689 -934981942 ->  NaN Invalid_operation
dqxor241 xor  567367689  934981942 ->  NaN Invalid_operation
dqxor242 xor -631917772 -706014634 ->  NaN Invalid_operation
dqxor243 xor -756253257  138579234 ->  NaN Invalid_operation
dqxor244 xor  835590149  567435400 ->  NaN Invalid_operation
-- test MSD
dqxor250 xor  2000000111000111000111000000000000 1000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor251 xor  7000000111000111000111000000000000 1000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor252 xor  8000000111000111000111000000000000 1000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor253 xor  9000000111000111000111000000000000 1000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor254 xor  2000000111000111000111000000000000 0000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor255 xor  7000000111000111000111000000000000 0000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor256 xor  8000000111000111000111000000000000 0000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor257 xor  9000000111000111000111000000000000 0000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor258 xor  1000000111000111000111000000000000 2000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor259 xor  1000000111000111000111000000000000 7000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor260 xor  1000000111000111000111000000000000 8000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor261 xor  1000000111000111000111000000000000 9000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor262 xor  0000000111000111000111000000000000 2000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor263 xor  0000000111000111000111000000000000 7000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor264 xor  0000000111000111000111000000000000 8000000111000111000111000000000000 ->  NaN Invalid_operation
dqxor265 xor  0000000111000111000111000000000000 9000000111000111000111000000000000 ->  NaN Invalid_operation
-- test MSD-1
dqxor270 xor  0200000111000111000111001000000000 1000000111000111000111100000000010 ->  NaN Invalid_operation
dqxor271 xor  0700000111000111000111000100000000 1000000111000111000111010000000100 ->  NaN Invalid_operation
dqxor272 xor  0800000111000111000111000010000000 1000000111000111000111001000001000 ->  NaN Invalid_operation
dqxor273 xor  0900000111000111000111000001000000 1000000111000111000111000100010000 ->  NaN Invalid_operation
dqxor274 xor  1000000111000111000111000000100000 0200000111000111000111000010100000 ->  NaN Invalid_operation
dqxor275 xor  1000000111000111000111000000010000 0700000111000111000111000001000000 ->  NaN Invalid_operation
dqxor276 xor  1000000111000111000111000000001000 0800000111000111000111000010100000 ->  NaN Invalid_operation
dqxor277 xor  1000000111000111000111000000000100 0900000111000111000111000000010000 ->  NaN Invalid_operation
-- test LSD
dqxor280 xor  0010000111000111000111000000000002 1000000111000111000111000100000001 ->  NaN Invalid_operation
dqxor281 xor  0001000111000111000111000000000007 1000000111000111000111001000000011 ->  NaN Invalid_operation
dqxor282 xor  0000000111000111000111100000000008 1000000111000111000111010000000001 ->  NaN Invalid_operation
dqxor283 xor  0000000111000111000111010000000009 1000000111000111000111100000000001 ->  NaN Invalid_operation
dqxor284 xor  1000000111000111000111001000000000 0001000111000111000111000000000002 ->  NaN Invalid_operation
dqxor285 xor  1000000111000111000111000100000000 0010000111000111000111000000000007 ->  NaN Invalid_operation
dqxor286 xor  1000000111000111000111000010000000 0100000111000111000111000000000008 ->  NaN Invalid_operation
dqxor287 xor  1000000111000111000111000001000000 1000000111000111000111000000000009 ->  NaN Invalid_operation
-- test Middie
dqxor288 xor  0010000111000111000111000020000000 1000000111000111000111001000000000 ->  NaN Invalid_operation
dqxor289 xor  0001000111000111000111000070000001 1000000111000111000111000100000000 ->  NaN Invalid_operation
dqxor290 xor  0000000111000111000111100080000010 1000000111000111000111000010000000 ->  NaN Invalid_operation
dqxor291 xor  0000000111000111000111010090000100 1000000111000111000111000001000000 ->  NaN Invalid_operation
dqxor292 xor  1000000111000111000111001000001000 0000000111000111000111000020100000 ->  NaN Invalid_operation
dqxor293 xor  1000000111000111000111000100010000 0000000111000111000111000070010000 ->  NaN Invalid_operation
dqxor294 xor  1000000111000111000111000010100000 0000000111000111000111000080001000 ->  NaN Invalid_operation
dqxor295 xor  1000000111000111000111000001000000 0000000111000111000111000090000100 ->  NaN Invalid_operation
-- signs
dqxor296 xor -1000000111000111000111000001000000 -0000001110001110001110010000000100 ->  NaN Invalid_operation
dqxor297 xor -1000000111000111000111000001000000  0000001110001110001110000010000100 ->  NaN Invalid_operation
dqxor298 xor  1000000111000111000111000001000000 -0000001110001110001110001000000100 ->  NaN Invalid_operation
dqxor299 xor  1000000111000111000111000001000000  0000001110001110001110000011000100 ->  1000001001001001001001000010000100

-- Nmax, Nmin, Ntiny-like
dqxor331 xor  2   9.99999999E+999     -> NaN Invalid_operation
dqxor332 xor  3   1E-999              -> NaN Invalid_operation
dqxor333 xor  4   1.00000000E-2821    -> NaN Invalid_operation
dqxor334 xor  5   1E-900              -> NaN Invalid_operation
dqxor335 xor  6   -1E-900             -> NaN Invalid_operation
dqxor336 xor  7   -1.00000000E-999    -> NaN Invalid_operation
dqxor337 xor  8   -1E-999             -> NaN Invalid_operation
dqxor338 xor  9   -9.99999999E+999    -> NaN Invalid_operation
dqxor341 xor  9.99999999E+999     -18 -> NaN Invalid_operation
dqxor342 xor  1E-999               01 -> NaN Invalid_operation
dqxor343 xor  1.00000000E-999     -18 -> NaN Invalid_operation
dqxor344 xor  1E-908               18 -> NaN Invalid_operation
dqxor345 xor  -1E-907             -10 -> NaN Invalid_operation
dqxor346 xor  -1.00000000E-999     18 -> NaN Invalid_operation
dqxor347 xor  -1E-999              10 -> NaN Invalid_operation
dqxor348 xor  -9.99999999E+2991   -18 -> NaN Invalid_operation

-- A few other non-integers
dqxor361 xor  1.0                  1  -> NaN Invalid_operation
dqxor362 xor  1E+1                 1  -> NaN Invalid_operation
dqxor363 xor  0.0                  1  -> NaN Invalid_operation
dqxor364 xor  0E+1                 1  -> NaN Invalid_operation
dqxor365 xor  9.9                  1  -> NaN Invalid_operation
dqxor366 xor  9E+1                 1  -> NaN Invalid_operation
dqxor371 xor  0 1.0                   -> NaN Invalid_operation
dqxor372 xor  0 1E+1                  -> NaN Invalid_operation
dqxor373 xor  0 0.0                   -> NaN Invalid_operation
dqxor374 xor  0 0E+1                  -> NaN Invalid_operation
dqxor375 xor  0 9.9                   -> NaN Invalid_operation
dqxor376 xor  0 9E+1                  -> NaN Invalid_operation

-- All Specials are in error
dqxor780 xor -Inf  -Inf   -> NaN Invalid_operation
dqxor781 xor -Inf  -1000  -> NaN Invalid_operation
dqxor782 xor -Inf  -1     -> NaN Invalid_operation
dqxor783 xor -Inf  -0     -> NaN Invalid_operation
dqxor784 xor -Inf   0     -> NaN Invalid_operation
dqxor785 xor -Inf   1     -> NaN Invalid_operation
dqxor786 xor -Inf   1000  -> NaN Invalid_operation
dqxor787 xor -1000 -Inf   -> NaN Invalid_operation
dqxor788 xor -Inf  -Inf   -> NaN Invalid_operation
dqxor789 xor -1    -Inf   -> NaN Invalid_operation
dqxor790 xor -0    -Inf   -> NaN Invalid_operation
dqxor791 xor  0    -Inf   -> NaN Invalid_operation
dqxor792 xor  1    -Inf   -> NaN Invalid_operation
dqxor793 xor  1000 -Inf   -> NaN Invalid_operation
dqxor794 xor  Inf  -Inf   -> NaN Invalid_operation

dqxor800 xor  Inf  -Inf   -> NaN Invalid_operation
dqxor801 xor  Inf  -1000  -> NaN Invalid_operation
dqxor802 xor  Inf  -1     -> NaN Invalid_operation
dqxor803 xor  Inf  -0     -> NaN Invalid_operation
dqxor804 xor  Inf   0     -> NaN Invalid_operation
dqxor805 xor  Inf   1     -> NaN Invalid_operation
dqxor806 xor  Inf   1000  -> NaN Invalid_operation
dqxor807 xor  Inf   Inf   -> NaN Invalid_operation
dqxor808 xor -1000  Inf   -> NaN Invalid_operation
dqxor809 xor -Inf   Inf   -> NaN Invalid_operation
dqxor810 xor -1     Inf   -> NaN Invalid_operation
dqxor811 xor -0     Inf   -> NaN Invalid_operation
dqxor812 xor  0     Inf   -> NaN Invalid_operation
dqxor813 xor  1     Inf   -> NaN Invalid_operation
dqxor814 xor  1000  Inf   -> NaN Invalid_operation
dqxor815 xor  Inf   Inf   -> NaN Invalid_operation

dqxor821 xor  NaN -Inf    -> NaN Invalid_operation
dqxor822 xor  NaN -1000   -> NaN Invalid_operation
dqxor823 xor  NaN -1      -> NaN Invalid_operation
dqxor824 xor  NaN -0      -> NaN Invalid_operation
dqxor825 xor  NaN  0      -> NaN Invalid_operation
dqxor826 xor  NaN  1      -> NaN Invalid_operation
dqxor827 xor  NaN  1000   -> NaN Invalid_operation
dqxor828 xor  NaN  Inf    -> NaN Invalid_operation
dqxor829 xor  NaN  NaN    -> NaN Invalid_operation
dqxor830 xor -Inf  NaN    -> NaN Invalid_operation
dqxor831 xor -1000 NaN    -> NaN Invalid_operation
dqxor832 xor -1    NaN    -> NaN Invalid_operation
dqxor833 xor -0    NaN    -> NaN Invalid_operation
dqxor834 xor  0    NaN    -> NaN Invalid_operation
dqxor835 xor  1    NaN    -> NaN Invalid_operation
dqxor836 xor  1000 NaN    -> NaN Invalid_operation
dqxor837 xor  Inf  NaN    -> NaN Invalid_operation

dqxor841 xor  sNaN -Inf   ->  NaN  Invalid_operation
dqxor842 xor  sNaN -1000  ->  NaN  Invalid_operation
dqxor843 xor  sNaN -1     ->  NaN  Invalid_operation
dqxor844 xor  sNaN -0     ->  NaN  Invalid_operation
dqxor845 xor  sNaN  0     ->  NaN  Invalid_operation
dqxor846 xor  sNaN  1     ->  NaN  Invalid_operation
dqxor847 xor  sNaN  1000  ->  NaN  Invalid_operation
dqxor848 xor  sNaN  NaN   ->  NaN  Invalid_operation
dqxor849 xor  sNaN sNaN   ->  NaN  Invalid_operation
dqxor850 xor  NaN  sNaN   ->  NaN  Invalid_operation
dqxor851 xor -Inf  sNaN   ->  NaN  Invalid_operation
dqxor852 xor -1000 sNaN   ->  NaN  Invalid_operation
dqxor853 xor -1    sNaN   ->  NaN  Invalid_operation
dqxor854 xor -0    sNaN   ->  NaN  Invalid_operation
dqxor855 xor  0    sNaN   ->  NaN  Invalid_operation
dqxor856 xor  1    sNaN   ->  NaN  Invalid_operation
dqxor857 xor  1000 sNaN   ->  NaN  Invalid_operation
dqxor858 xor  Inf  sNaN   ->  NaN  Invalid_operation
dqxor859 xor  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
dqxor861 xor  NaN1   -Inf    -> NaN Invalid_operation
dqxor862 xor +NaN2   -1000   -> NaN Invalid_operation
dqxor863 xor  NaN3    1000   -> NaN Invalid_operation
dqxor864 xor  NaN4    Inf    -> NaN Invalid_operation
dqxor865 xor  NaN5   +NaN6   -> NaN Invalid_operation
dqxor866 xor -Inf     NaN7   -> NaN Invalid_operation
dqxor867 xor -1000    NaN8   -> NaN Invalid_operation
dqxor868 xor  1000    NaN9   -> NaN Invalid_operation
dqxor869 xor  Inf    +NaN10  -> NaN Invalid_operation
dqxor871 xor  sNaN11  -Inf   -> NaN Invalid_operation
dqxor872 xor  sNaN12  -1000  -> NaN Invalid_operation
dqxor873 xor  sNaN13   1000  -> NaN Invalid_operation
dqxor874 xor  sNaN14   NaN17 -> NaN Invalid_operation
dqxor875 xor  sNaN15  sNaN18 -> NaN Invalid_operation
dqxor876 xor  NaN16   sNaN19 -> NaN Invalid_operation
dqxor877 xor -Inf    +sNaN20 -> NaN Invalid_operation
dqxor878 xor -1000    sNaN21 -> NaN Invalid_operation
dqxor879 xor  1000    sNaN22 -> NaN Invalid_operation
dqxor880 xor  Inf     sNaN23 -> NaN Invalid_operation
dqxor881 xor +NaN25  +sNaN24 -> NaN Invalid_operation
dqxor882 xor -NaN26    NaN28 -> NaN Invalid_operation
dqxor883 xor -sNaN27  sNaN29 -> NaN Invalid_operation
dqxor884 xor  1000    -NaN30 -> NaN Invalid_operation
dqxor885 xor  1000   -sNaN31 -> NaN Invalid_operation

Added test/dectest/dsBase.decTest.











































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
------------------------------------------------------------------------
-- dsBase.decTest -- base decSingle <--> string conversions           --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This file tests base conversions from string to a decimal number
-- and back to a string (in Scientific form)

-- Note that unlike other operations the operand is subject to rounding
-- to conform to emax and precision settings (that is, numbers will
-- conform to rules and exponent will be in permitted range).  The
-- 'left hand side', therefore, may have numbers that cannot be
-- represented in a decSingle.  Some testcases go to the limit of the
-- next-wider format, and hence these testcases may also be used to
-- test narrowing and widening operations.

extended:    1
clamp:       1
precision:   7
maxExponent: 96
minExponent: -95
rounding:    half_even

dsbas001 toSci       0 -> 0
dsbas002 toSci       1 -> 1
dsbas003 toSci     1.0 -> 1.0
dsbas004 toSci    1.00 -> 1.00
dsbas005 toSci      10 -> 10
dsbas006 toSci    1000 -> 1000
dsbas007 toSci    10.0 -> 10.0
dsbas008 toSci    10.1 -> 10.1
dsbas009 toSci    10.4 -> 10.4
dsbas010 toSci    10.5 -> 10.5
dsbas011 toSci    10.6 -> 10.6
dsbas012 toSci    10.9 -> 10.9
dsbas013 toSci    11.0 -> 11.0
dsbas014 toSci  1.234 -> 1.234
dsbas015 toSci  0.123 -> 0.123
dsbas016 toSci  0.012 -> 0.012
dsbas017 toSci  -0    -> -0
dsbas018 toSci  -0.0  -> -0.0
dsbas019 toSci -00.00 -> -0.00

dsbas021 toSci     -1 -> -1
dsbas022 toSci   -1.0 -> -1.0
dsbas023 toSci   -0.1 -> -0.1
dsbas024 toSci   -9.1 -> -9.1
dsbas025 toSci   -9.11 -> -9.11
dsbas026 toSci   -9.119 -> -9.119
dsbas027 toSci   -9.999 -> -9.999

dsbas030 toSci  '1234.567'   -> '1234.567'
dsbas031 toSci  '1234.000'   -> '1234.000'
dsbas032 toSci   '1234912'   -> '1234912'
dsbas033 toSci   '0.00001234567'   -> '0.00001234567'
dsbas034 toSci  '0.000001234567'   -> '0.000001234567'
dsbas035 toSci '0.0000001234567'   -> '1.234567E-7'
dsbas036 toSci '0.00000001234567'  -> '1.234567E-8'

dsbas037 toSci '0.1234564'   -> '0.1234564'
dsbas038 toSci '0.1234565'   -> '0.1234565'

-- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
dsbsn001 toSci -9.999999E+96 -> -9.999999E+96
dsbsn002 toSci -1E-95 -> -1E-95
dsbsn003 toSci -1E-101 -> -1E-101 Subnormal
dsbsn004 toSci -0 -> -0
dsbsn005 toSci +0 ->  0
dsbsn006 toSci +1E-101 ->  1E-101 Subnormal
dsbsn007 toSci +1E-95 ->  1E-95
dsbsn008 toSci +9.999999E+96 ->  9.999999E+96

-- String [many more examples are implicitly tested elsewhere]
-- strings without E cannot generate E in result
dsbas040 toSci "12"        -> '12'
dsbas041 toSci "-76"       -> '-76'
dsbas042 toSci "12.76"     -> '12.76'
dsbas043 toSci "+12.76"    -> '12.76'
dsbas044 toSci "012.76"    -> '12.76'
dsbas045 toSci "+0.003"    -> '0.003'
dsbas046 toSci "17."       -> '17'
dsbas047 toSci ".5"        -> '0.5'
dsbas048 toSci "044"       -> '44'
dsbas049 toSci "0044"      -> '44'
dsbas050 toSci "0.0005"      -> '0.0005'
dsbas051 toSci "00.00005"    -> '0.00005'
dsbas052 toSci "0.000005"    -> '0.000005'
dsbas053 toSci "0.0000050"   -> '0.0000050'
dsbas054 toSci "0.0000005"   -> '5E-7'
dsbas055 toSci "0.00000005"  -> '5E-8'
dsbas056 toSci "12678.54" -> '12678.54'
dsbas057 toSci "2678.543" -> '2678.543'
dsbas058 toSci "345678.5" -> '345678.5'
dsbas059 toSci "0678.5432" -> '678.5432'
dsbas060 toSci "678.5432" -> '678.5432'
dsbas061 toSci "+678.5432" -> '678.5432'
dsbas062 toSci "+0678.5432" -> '678.5432'
dsbas063 toSci "+00678.5432" -> '678.5432'
dsbas064 toSci "-678.5432"  -> '-678.5432'
dsbas065 toSci "-0678.5432"  -> '-678.5432'
dsbas066 toSci "-00678.5432"  -> '-678.5432'
-- examples
dsbas067 toSci "5E-6"        -> '0.000005'
dsbas068 toSci "50E-7"       -> '0.0000050'
dsbas069 toSci "5E-7"        -> '5E-7'

-- [No exotics as no Unicode]

-- rounded with dots in all (including edge) places
dsbas071 toSci  .1234567890123456  -> 0.1234568 Inexact Rounded
dsbas072 toSci  1.234567890123456  -> 1.234568 Inexact Rounded
dsbas073 toSci  12.34567890123456  -> 12.34568 Inexact Rounded
dsbas074 toSci  123.4567890123456  -> 123.4568 Inexact Rounded
dsbas075 toSci  1234.567890123456  -> 1234.568 Inexact Rounded
dsbas076 toSci  12345.67890123456  -> 12345.68 Inexact Rounded
dsbas077 toSci  123456.7890123456  -> 123456.8 Inexact Rounded
dsbas078 toSci  1234567.890123456  -> 1234568  Inexact Rounded
dsbas079 toSci  12345678.90123456  -> 1.234568E+7 Inexact Rounded
dsbas080 toSci  123456789.0123456  -> 1.234568E+8 Inexact Rounded
dsbas081 toSci  1234567890.123456  -> 1.234568E+9 Inexact Rounded
dsbas082 toSci  12345678901.23456  -> 1.234568E+10 Inexact Rounded
dsbas083 toSci  123456789012.3456  -> 1.234568E+11 Inexact Rounded
dsbas084 toSci  1234567890123.456  -> 1.234568E+12 Inexact Rounded
dsbas085 toSci  12345678901234.56  -> 1.234568E+13 Inexact Rounded
dsbas086 toSci  123456789012345.6  -> 1.234568E+14 Inexact Rounded
dsbas087 toSci  1234567890123456.  -> 1.234568E+15 Inexact Rounded
dsbas088 toSci  1234567890123456   -> 1.234568E+15 Inexact Rounded

-- Numbers with E
dsbas130 toSci "0.000E-1"  -> '0.0000'
dsbas131 toSci "0.000E-2"  -> '0.00000'
dsbas132 toSci "0.000E-3"  -> '0.000000'
dsbas133 toSci "0.000E-4"  -> '0E-7'
dsbas134 toSci "0.00E-2"   -> '0.0000'
dsbas135 toSci "0.00E-3"   -> '0.00000'
dsbas136 toSci "0.00E-4"   -> '0.000000'
dsbas137 toSci "0.00E-5"   -> '0E-7'
dsbas138 toSci "+0E+9"     -> '0E+9'
dsbas139 toSci "-0E+9"     -> '-0E+9'
dsbas140 toSci "1E+9"      -> '1E+9'
dsbas141 toSci "1e+09"     -> '1E+9'
dsbas142 toSci "1E+90"     -> '1E+90'
dsbas143 toSci "+1E+009"   -> '1E+9'
dsbas144 toSci "0E+9"      -> '0E+9'
dsbas145 toSci "1E+9"      -> '1E+9'
dsbas146 toSci "1E+09"     -> '1E+9'
dsbas147 toSci "1e+90"     -> '1E+90'
dsbas148 toSci "1E+009"    -> '1E+9'
dsbas149 toSci "000E+9"    -> '0E+9'
dsbas150 toSci "1E9"       -> '1E+9'
dsbas151 toSci "1e09"      -> '1E+9'
dsbas152 toSci "1E90"      -> '1E+90'
dsbas153 toSci "1E009"     -> '1E+9'
dsbas154 toSci "0E9"       -> '0E+9'
dsbas155 toSci "0.000e+0"  -> '0.000'
dsbas156 toSci "0.000E-1"  -> '0.0000'
dsbas157 toSci "4E+9"      -> '4E+9'
dsbas158 toSci "44E+9"     -> '4.4E+10'
dsbas159 toSci "0.73e-7"   -> '7.3E-8'
dsbas160 toSci "00E+9"     -> '0E+9'
dsbas161 toSci "00E-9"     -> '0E-9'
dsbas162 toSci "10E+9"     -> '1.0E+10'
dsbas163 toSci "10E+09"    -> '1.0E+10'
dsbas164 toSci "10e+90"    -> '1.0E+91'
dsbas165 toSci "10E+009"   -> '1.0E+10'
dsbas166 toSci "100e+9"    -> '1.00E+11'
dsbas167 toSci "100e+09"   -> '1.00E+11'
dsbas168 toSci "100E+90"   -> '1.00E+92'
dsbas169 toSci "100e+009"  -> '1.00E+11'

dsbas170 toSci "1.265"     -> '1.265'
dsbas171 toSci "1.265E-20" -> '1.265E-20'
dsbas172 toSci "1.265E-8"  -> '1.265E-8'
dsbas173 toSci "1.265E-4"  -> '0.0001265'
dsbas174 toSci "1.265E-3"  -> '0.001265'
dsbas175 toSci "1.265E-2"  -> '0.01265'
dsbas176 toSci "1.265E-1"  -> '0.1265'
dsbas177 toSci "1.265E-0"  -> '1.265'
dsbas178 toSci "1.265E+1"  -> '12.65'
dsbas179 toSci "1.265E+2"  -> '126.5'
dsbas180 toSci "1.265E+3"  -> '1265'
dsbas181 toSci "1.265E+4"  -> '1.265E+4'
dsbas182 toSci "1.265E+8"  -> '1.265E+8'
dsbas183 toSci "1.265E+20" -> '1.265E+20'

dsbas190 toSci "12.65"     -> '12.65'
dsbas191 toSci "12.65E-20" -> '1.265E-19'
dsbas192 toSci "12.65E-8"  -> '1.265E-7'
dsbas193 toSci "12.65E-4"  -> '0.001265'
dsbas194 toSci "12.65E-3"  -> '0.01265'
dsbas195 toSci "12.65E-2"  -> '0.1265'
dsbas196 toSci "12.65E-1"  -> '1.265'
dsbas197 toSci "12.65E-0"  -> '12.65'
dsbas198 toSci "12.65E+1"  -> '126.5'
dsbas199 toSci "12.65E+2"  -> '1265'
dsbas200 toSci "12.65E+3"  -> '1.265E+4'
dsbas201 toSci "12.65E+4"  -> '1.265E+5'
dsbas202 toSci "12.65E+8"  -> '1.265E+9'
dsbas203 toSci "12.65E+20" -> '1.265E+21'

dsbas210 toSci "126.5"     -> '126.5'
dsbas211 toSci "126.5E-20" -> '1.265E-18'
dsbas212 toSci "126.5E-8"  -> '0.000001265'
dsbas213 toSci "126.5E-4"  -> '0.01265'
dsbas214 toSci "126.5E-3"  -> '0.1265'
dsbas215 toSci "126.5E-2"  -> '1.265'
dsbas216 toSci "126.5E-1"  -> '12.65'
dsbas217 toSci "126.5E-0"  -> '126.5'
dsbas218 toSci "126.5E+1"  -> '1265'
dsbas219 toSci "126.5E+2"  -> '1.265E+4'
dsbas220 toSci "126.5E+3"  -> '1.265E+5'
dsbas221 toSci "126.5E+4"  -> '1.265E+6'
dsbas222 toSci "126.5E+8"  -> '1.265E+10'
dsbas223 toSci "126.5E+20" -> '1.265E+22'

dsbas230 toSci "1265"     -> '1265'
dsbas231 toSci "1265E-20" -> '1.265E-17'
dsbas232 toSci "1265E-8"  -> '0.00001265'
dsbas233 toSci "1265E-4"  -> '0.1265'
dsbas234 toSci "1265E-3"  -> '1.265'
dsbas235 toSci "1265E-2"  -> '12.65'
dsbas236 toSci "1265E-1"  -> '126.5'
dsbas237 toSci "1265E-0"  -> '1265'
dsbas238 toSci "1265E+1"  -> '1.265E+4'
dsbas239 toSci "1265E+2"  -> '1.265E+5'
dsbas240 toSci "1265E+3"  -> '1.265E+6'
dsbas241 toSci "1265E+4"  -> '1.265E+7'
dsbas242 toSci "1265E+8"  -> '1.265E+11'
dsbas243 toSci "1265E+20" -> '1.265E+23'

dsbas250 toSci "0.1265"     -> '0.1265'
dsbas251 toSci "0.1265E-20" -> '1.265E-21'
dsbas252 toSci "0.1265E-8"  -> '1.265E-9'
dsbas253 toSci "0.1265E-4"  -> '0.00001265'
dsbas254 toSci "0.1265E-3"  -> '0.0001265'
dsbas255 toSci "0.1265E-2"  -> '0.001265'
dsbas256 toSci "0.1265E-1"  -> '0.01265'
dsbas257 toSci "0.1265E-0"  -> '0.1265'
dsbas258 toSci "0.1265E+1"  -> '1.265'
dsbas259 toSci "0.1265E+2"  -> '12.65'
dsbas260 toSci "0.1265E+3"  -> '126.5'
dsbas261 toSci "0.1265E+4"  -> '1265'
dsbas262 toSci "0.1265E+8"  -> '1.265E+7'
dsbas263 toSci "0.1265E+20" -> '1.265E+19'

-- some more negative zeros [systematic tests below]
dsbas290 toSci "-0.000E-1"  -> '-0.0000'
dsbas291 toSci "-0.000E-2"  -> '-0.00000'
dsbas292 toSci "-0.000E-3"  -> '-0.000000'
dsbas293 toSci "-0.000E-4"  -> '-0E-7'
dsbas294 toSci "-0.00E-2"   -> '-0.0000'
dsbas295 toSci "-0.00E-3"   -> '-0.00000'
dsbas296 toSci "-0.0E-2"    -> '-0.000'
dsbas297 toSci "-0.0E-3"    -> '-0.0000'
dsbas298 toSci "-0E-2"      -> '-0.00'
dsbas299 toSci "-0E-3"      -> '-0.000'

-- Engineering notation tests
dsbas301  toSci 10e12  -> 1.0E+13
dsbas302  toEng 10e12  -> 10E+12
dsbas303  toSci 10e11  -> 1.0E+12
dsbas304  toEng 10e11  -> 1.0E+12
dsbas305  toSci 10e10  -> 1.0E+11
dsbas306  toEng 10e10  -> 100E+9
dsbas307  toSci 10e9   -> 1.0E+10
dsbas308  toEng 10e9   -> 10E+9
dsbas309  toSci 10e8   -> 1.0E+9
dsbas310  toEng 10e8   -> 1.0E+9
dsbas311  toSci 10e7   -> 1.0E+8
dsbas312  toEng 10e7   -> 100E+6
dsbas313  toSci 10e6   -> 1.0E+7
dsbas314  toEng 10e6   -> 10E+6
dsbas315  toSci 10e5   -> 1.0E+6
dsbas316  toEng 10e5   -> 1.0E+6
dsbas317  toSci 10e4   -> 1.0E+5
dsbas318  toEng 10e4   -> 100E+3
dsbas319  toSci 10e3   -> 1.0E+4
dsbas320  toEng 10e3   -> 10E+3
dsbas321  toSci 10e2   -> 1.0E+3
dsbas322  toEng 10e2   -> 1.0E+3
dsbas323  toSci 10e1   -> 1.0E+2
dsbas324  toEng 10e1   -> 100
dsbas325  toSci 10e0   -> 10
dsbas326  toEng 10e0   -> 10
dsbas327  toSci 10e-1  -> 1.0
dsbas328  toEng 10e-1  -> 1.0
dsbas329  toSci 10e-2  -> 0.10
dsbas330  toEng 10e-2  -> 0.10
dsbas331  toSci 10e-3  -> 0.010
dsbas332  toEng 10e-3  -> 0.010
dsbas333  toSci 10e-4  -> 0.0010
dsbas334  toEng 10e-4  -> 0.0010
dsbas335  toSci 10e-5  -> 0.00010
dsbas336  toEng 10e-5  -> 0.00010
dsbas337  toSci 10e-6  -> 0.000010
dsbas338  toEng 10e-6  -> 0.000010
dsbas339  toSci 10e-7  -> 0.0000010
dsbas340  toEng 10e-7  -> 0.0000010
dsbas341  toSci 10e-8  -> 1.0E-7
dsbas342  toEng 10e-8  -> 100E-9
dsbas343  toSci 10e-9  -> 1.0E-8
dsbas344  toEng 10e-9  -> 10E-9
dsbas345  toSci 10e-10 -> 1.0E-9
dsbas346  toEng 10e-10 -> 1.0E-9
dsbas347  toSci 10e-11 -> 1.0E-10
dsbas348  toEng 10e-11 -> 100E-12
dsbas349  toSci 10e-12 -> 1.0E-11
dsbas350  toEng 10e-12 -> 10E-12
dsbas351  toSci 10e-13 -> 1.0E-12
dsbas352  toEng 10e-13 -> 1.0E-12

dsbas361  toSci 7E12  -> 7E+12
dsbas362  toEng 7E12  -> 7E+12
dsbas363  toSci 7E11  -> 7E+11
dsbas364  toEng 7E11  -> 700E+9
dsbas365  toSci 7E10  -> 7E+10
dsbas366  toEng 7E10  -> 70E+9
dsbas367  toSci 7E9   -> 7E+9
dsbas368  toEng 7E9   -> 7E+9
dsbas369  toSci 7E8   -> 7E+8
dsbas370  toEng 7E8   -> 700E+6
dsbas371  toSci 7E7   -> 7E+7
dsbas372  toEng 7E7   -> 70E+6
dsbas373  toSci 7E6   -> 7E+6
dsbas374  toEng 7E6   -> 7E+6
dsbas375  toSci 7E5   -> 7E+5
dsbas376  toEng 7E5   -> 700E+3
dsbas377  toSci 7E4   -> 7E+4
dsbas378  toEng 7E4   -> 70E+3
dsbas379  toSci 7E3   -> 7E+3
dsbas380  toEng 7E3   -> 7E+3
dsbas381  toSci 7E2   -> 7E+2
dsbas382  toEng 7E2   -> 700
dsbas383  toSci 7E1   -> 7E+1
dsbas384  toEng 7E1   -> 70
dsbas385  toSci 7E0   -> 7
dsbas386  toEng 7E0   -> 7
dsbas387  toSci 7E-1  -> 0.7
dsbas388  toEng 7E-1  -> 0.7
dsbas389  toSci 7E-2  -> 0.07
dsbas390  toEng 7E-2  -> 0.07
dsbas391  toSci 7E-3  -> 0.007
dsbas392  toEng 7E-3  -> 0.007
dsbas393  toSci 7E-4  -> 0.0007
dsbas394  toEng 7E-4  -> 0.0007
dsbas395  toSci 7E-5  -> 0.00007
dsbas396  toEng 7E-5  -> 0.00007
dsbas397  toSci 7E-6  -> 0.000007
dsbas398  toEng 7E-6  -> 0.000007
dsbas399  toSci 7E-7  -> 7E-7
dsbas400  toEng 7E-7  -> 700E-9
dsbas401  toSci 7E-8  -> 7E-8
dsbas402  toEng 7E-8  -> 70E-9
dsbas403  toSci 7E-9  -> 7E-9
dsbas404  toEng 7E-9  -> 7E-9
dsbas405  toSci 7E-10 -> 7E-10
dsbas406  toEng 7E-10 -> 700E-12
dsbas407  toSci 7E-11 -> 7E-11
dsbas408  toEng 7E-11 -> 70E-12
dsbas409  toSci 7E-12 -> 7E-12
dsbas410  toEng 7E-12 -> 7E-12
dsbas411  toSci 7E-13 -> 7E-13
dsbas412  toEng 7E-13 -> 700E-15

-- Exacts remain exact up to precision ..
dsbas420  toSci    100 -> 100
dsbas422  toSci   1000 -> 1000
dsbas424  toSci  999.9 ->  999.9
dsbas426  toSci 1000.0 -> 1000.0
dsbas428  toSci 1000.1 -> 1000.1
dsbas430  toSci 10000 -> 10000
dsbas432  toSci 1000        -> 1000
dsbas434  toSci 10000       -> 10000
dsbas436  toSci 100000      -> 100000
dsbas438  toSci 1000000     -> 1000000
dsbas440  toSci 10000000    -> 1.000000E+7   Rounded
dsbas442  toSci 10000000    -> 1.000000E+7   Rounded
dsbas444  toSci 10000003    -> 1.000000E+7   Rounded Inexact
dsbas446  toSci 10000005    -> 1.000000E+7   Rounded Inexact
dsbas448  toSci 100000050   -> 1.000000E+8   Rounded Inexact
dsbas450  toSci 10000009    -> 1.000001E+7   Rounded Inexact
dsbas452  toSci 100000000   -> 1.000000E+8   Rounded
dsbas454  toSci 100000003   -> 1.000000E+8   Rounded Inexact
dsbas456  toSci 100000005   -> 1.000000E+8   Rounded Inexact
dsbas458  toSci 100000009   -> 1.000000E+8   Rounded Inexact
dsbas460  toSci 1000000000  -> 1.000000E+9   Rounded
dsbas462  toSci 1000000300  -> 1.000000E+9   Rounded Inexact
dsbas464  toSci 1000000500  -> 1.000000E+9   Rounded Inexact
dsbas466  toSci 1000000900  -> 1.000001E+9   Rounded Inexact
dsbas468  toSci 10000000000 -> 1.000000E+10  Rounded
dsbas470  toSci 10000003000 -> 1.000000E+10  Rounded Inexact
dsbas472  toSci 10000005000 -> 1.000000E+10  Rounded Inexact
dsbas474  toSci 10000009000 -> 1.000001E+10  Rounded Inexact

-- check rounding modes heeded
rounding:  ceiling
dsbsr401  toSci  1.1123450    ->  1.112345  Rounded
dsbsr402  toSci  1.11234549   ->  1.112346  Rounded Inexact
dsbsr403  toSci  1.11234550   ->  1.112346  Rounded Inexact
dsbsr404  toSci  1.11234551   ->  1.112346  Rounded Inexact
rounding:  up
dsbsr405  toSci  1.1123450    ->  1.112345  Rounded
dsbsr406  toSci  1.11234549   ->  1.112346  Rounded Inexact
dsbsr407  toSci  1.11234550   ->  1.112346  Rounded Inexact
dsbsr408  toSci  1.11234551   ->  1.112346  Rounded Inexact
rounding:  floor
dsbsr410  toSci  1.1123450    ->  1.112345  Rounded
dsbsr411  toSci  1.11234549   ->  1.112345  Rounded Inexact
dsbsr412  toSci  1.11234550   ->  1.112345  Rounded Inexact
dsbsr413  toSci  1.11234551   ->  1.112345  Rounded Inexact
rounding:  half_down
dsbsr415  toSci  1.1123450    ->  1.112345  Rounded
dsbsr416  toSci  1.11234549   ->  1.112345  Rounded Inexact
dsbsr417  toSci  1.11234550   ->  1.112345  Rounded Inexact
dsbsr418  toSci  1.11234650   ->  1.112346  Rounded Inexact
dsbsr419  toSci  1.11234551   ->  1.112346  Rounded Inexact
rounding:  half_even
dsbsr421  toSci  1.1123450    ->  1.112345  Rounded
dsbsr422  toSci  1.11234549   ->  1.112345  Rounded Inexact
dsbsr423  toSci  1.11234550   ->  1.112346  Rounded Inexact
dsbsr424  toSci  1.11234650   ->  1.112346  Rounded Inexact
dsbsr425  toSci  1.11234551   ->  1.112346  Rounded Inexact
rounding:  down
dsbsr426  toSci  1.1123450    ->  1.112345  Rounded
dsbsr427  toSci  1.11234549   ->  1.112345  Rounded Inexact
dsbsr428  toSci  1.11234550   ->  1.112345  Rounded Inexact
dsbsr429  toSci  1.11234551   ->  1.112345  Rounded Inexact
rounding:  half_up
dsbsr431  toSci  1.1123450    ->  1.112345  Rounded
dsbsr432  toSci  1.11234549   ->  1.112345  Rounded Inexact
dsbsr433  toSci  1.11234550   ->  1.112346  Rounded Inexact
dsbsr434  toSci  1.11234650   ->  1.112347  Rounded Inexact
dsbsr435  toSci  1.11234551   ->  1.112346  Rounded Inexact
-- negatives
rounding:  ceiling
dsbsr501  toSci -1.1123450    -> -1.112345  Rounded
dsbsr502  toSci -1.11234549   -> -1.112345  Rounded Inexact
dsbsr503  toSci -1.11234550   -> -1.112345  Rounded Inexact
dsbsr504  toSci -1.11234551   -> -1.112345  Rounded Inexact
rounding:  up
dsbsr505  toSci -1.1123450    -> -1.112345  Rounded
dsbsr506  toSci -1.11234549   -> -1.112346  Rounded Inexact
dsbsr507  toSci -1.11234550   -> -1.112346  Rounded Inexact
dsbsr508  toSci -1.11234551   -> -1.112346  Rounded Inexact
rounding:  floor
dsbsr510  toSci -1.1123450    -> -1.112345  Rounded
dsbsr511  toSci -1.11234549   -> -1.112346  Rounded Inexact
dsbsr512  toSci -1.11234550   -> -1.112346  Rounded Inexact
dsbsr513  toSci -1.11234551   -> -1.112346  Rounded Inexact
rounding:  half_down
dsbsr515  toSci -1.1123450    -> -1.112345  Rounded
dsbsr516  toSci -1.11234549   -> -1.112345  Rounded Inexact
dsbsr517  toSci -1.11234550   -> -1.112345  Rounded Inexact
dsbsr518  toSci -1.11234650   -> -1.112346  Rounded Inexact
dsbsr519  toSci -1.11234551   -> -1.112346  Rounded Inexact
rounding:  half_even
dsbsr521  toSci -1.1123450    -> -1.112345  Rounded
dsbsr522  toSci -1.11234549   -> -1.112345  Rounded Inexact
dsbsr523  toSci -1.11234550   -> -1.112346  Rounded Inexact
dsbsr524  toSci -1.11234650   -> -1.112346  Rounded Inexact
dsbsr525  toSci -1.11234551   -> -1.112346  Rounded Inexact
rounding:  down
dsbsr526  toSci -1.1123450    -> -1.112345  Rounded
dsbsr527  toSci -1.11234549   -> -1.112345  Rounded Inexact
dsbsr528  toSci -1.11234550   -> -1.112345  Rounded Inexact
dsbsr529  toSci -1.11234551   -> -1.112345  Rounded Inexact
rounding:  half_up
dsbsr531  toSci -1.1123450    -> -1.112345  Rounded
dsbsr532  toSci -1.11234549   -> -1.112345  Rounded Inexact
dsbsr533  toSci -1.11234550   -> -1.112346  Rounded Inexact
dsbsr534  toSci -1.11234650   -> -1.112347  Rounded Inexact
dsbsr535  toSci -1.11234551   -> -1.112346  Rounded Inexact

rounding:    half_even

-- The 'baddies' tests from DiagBigDecimal, plus some new ones
dsbas500 toSci '1..2'            -> NaN Conversion_syntax
dsbas501 toSci '.'               -> NaN Conversion_syntax
dsbas502 toSci '..'              -> NaN Conversion_syntax
dsbas503 toSci '++1'             -> NaN Conversion_syntax
dsbas504 toSci '--1'             -> NaN Conversion_syntax
dsbas505 toSci '-+1'             -> NaN Conversion_syntax
dsbas506 toSci '+-1'             -> NaN Conversion_syntax
dsbas507 toSci '12e'             -> NaN Conversion_syntax
dsbas508 toSci '12e++'           -> NaN Conversion_syntax
dsbas509 toSci '12f4'            -> NaN Conversion_syntax
dsbas510 toSci ' +1'             -> NaN Conversion_syntax
dsbas511 toSci '+ 1'             -> NaN Conversion_syntax
dsbas512 toSci '12 '             -> NaN Conversion_syntax
dsbas513 toSci ' + 1'            -> NaN Conversion_syntax
dsbas514 toSci ' - 1 '           -> NaN Conversion_syntax
dsbas515 toSci 'x'               -> NaN Conversion_syntax
dsbas516 toSci '-1-'             -> NaN Conversion_syntax
dsbas517 toSci '12-'             -> NaN Conversion_syntax
dsbas518 toSci '3+'              -> NaN Conversion_syntax
dsbas519 toSci ''                -> NaN Conversion_syntax
dsbas520 toSci '1e-'             -> NaN Conversion_syntax
dsbas521 toSci '7e99999a'        -> NaN Conversion_syntax
dsbas522 toSci '7e123567890x'    -> NaN Conversion_syntax
dsbas523 toSci '7e12356789012x'  -> NaN Conversion_syntax
dsbas524 toSci ''                -> NaN Conversion_syntax
dsbas525 toSci 'e100'            -> NaN Conversion_syntax
dsbas526 toSci '\u0e5a'          -> NaN Conversion_syntax
dsbas527 toSci '\u0b65'          -> NaN Conversion_syntax
dsbas528 toSci '123,65'          -> NaN Conversion_syntax
dsbas529 toSci '1.34.5'          -> NaN Conversion_syntax
dsbas530 toSci '.123.5'          -> NaN Conversion_syntax
dsbas531 toSci '01.35.'          -> NaN Conversion_syntax
dsbas532 toSci '01.35-'          -> NaN Conversion_syntax
dsbas533 toSci '0000..'          -> NaN Conversion_syntax
dsbas534 toSci '.0000.'          -> NaN Conversion_syntax
dsbas535 toSci '00..00'          -> NaN Conversion_syntax
dsbas536 toSci '111e*123'        -> NaN Conversion_syntax
dsbas537 toSci '111e123-'        -> NaN Conversion_syntax
dsbas538 toSci '111e+12+'        -> NaN Conversion_syntax
dsbas539 toSci '111e1-3-'        -> NaN Conversion_syntax
dsbas540 toSci '111e1*23'        -> NaN Conversion_syntax
dsbas541 toSci '111e1e+3'        -> NaN Conversion_syntax
dsbas542 toSci '1e1.0'           -> NaN Conversion_syntax
dsbas543 toSci '1e123e'          -> NaN Conversion_syntax
dsbas544 toSci 'ten'             -> NaN Conversion_syntax
dsbas545 toSci 'ONE'             -> NaN Conversion_syntax
dsbas546 toSci '1e.1'            -> NaN Conversion_syntax
dsbas547 toSci '1e1.'            -> NaN Conversion_syntax
dsbas548 toSci '1ee'             -> NaN Conversion_syntax
dsbas549 toSci 'e+1'             -> NaN Conversion_syntax
dsbas550 toSci '1.23.4'          -> NaN Conversion_syntax
dsbas551 toSci '1.2.1'           -> NaN Conversion_syntax
dsbas552 toSci '1E+1.2'          -> NaN Conversion_syntax
dsbas553 toSci '1E+1.2.3'        -> NaN Conversion_syntax
dsbas554 toSci '1E++1'           -> NaN Conversion_syntax
dsbas555 toSci '1E--1'           -> NaN Conversion_syntax
dsbas556 toSci '1E+-1'           -> NaN Conversion_syntax
dsbas557 toSci '1E-+1'           -> NaN Conversion_syntax
dsbas558 toSci '1E''1'           -> NaN Conversion_syntax
dsbas559 toSci "1E""1"           -> NaN Conversion_syntax
dsbas560 toSci "1E"""""          -> NaN Conversion_syntax
-- Near-specials
dsbas561 toSci "qNaN"            -> NaN Conversion_syntax
dsbas562 toSci "NaNq"            -> NaN Conversion_syntax
dsbas563 toSci "NaNs"            -> NaN Conversion_syntax
dsbas564 toSci "Infi"            -> NaN Conversion_syntax
dsbas565 toSci "Infin"           -> NaN Conversion_syntax
dsbas566 toSci "Infini"          -> NaN Conversion_syntax
dsbas567 toSci "Infinit"         -> NaN Conversion_syntax
dsbas568 toSci "-Infinit"        -> NaN Conversion_syntax
dsbas569 toSci "0Inf"            -> NaN Conversion_syntax
dsbas570 toSci "9Inf"            -> NaN Conversion_syntax
dsbas571 toSci "-0Inf"           -> NaN Conversion_syntax
dsbas572 toSci "-9Inf"           -> NaN Conversion_syntax
dsbas573 toSci "-sNa"            -> NaN Conversion_syntax
dsbas574 toSci "xNaN"            -> NaN Conversion_syntax
dsbas575 toSci "0sNaN"           -> NaN Conversion_syntax

-- some baddies with dots and Es and dots and specials
dsbas576 toSci  'e+1'            ->  NaN Conversion_syntax
dsbas577 toSci  '.e+1'           ->  NaN Conversion_syntax
dsbas578 toSci  '+.e+1'          ->  NaN Conversion_syntax
dsbas579 toSci  '-.e+'           ->  NaN Conversion_syntax
dsbas580 toSci  '-.e'            ->  NaN Conversion_syntax
dsbas581 toSci  'E+1'            ->  NaN Conversion_syntax
dsbas582 toSci  '.E+1'           ->  NaN Conversion_syntax
dsbas583 toSci  '+.E+1'          ->  NaN Conversion_syntax
dsbas584 toSci  '-.E+'           ->  NaN Conversion_syntax
dsbas585 toSci  '-.E'            ->  NaN Conversion_syntax

dsbas586 toSci  '.NaN'           ->  NaN Conversion_syntax
dsbas587 toSci  '-.NaN'          ->  NaN Conversion_syntax
dsbas588 toSci  '+.sNaN'         ->  NaN Conversion_syntax
dsbas589 toSci  '+.Inf'          ->  NaN Conversion_syntax
dsbas590 toSci  '.Infinity'      ->  NaN Conversion_syntax

-- Zeros
dsbas601 toSci 0.000000000       -> 0E-9
dsbas602 toSci 0.00000000        -> 0E-8
dsbas603 toSci 0.0000000         -> 0E-7
dsbas604 toSci 0.000000          -> 0.000000
dsbas605 toSci 0.00000           -> 0.00000
dsbas606 toSci 0.0000            -> 0.0000
dsbas607 toSci 0.000             -> 0.000
dsbas608 toSci 0.00              -> 0.00
dsbas609 toSci 0.0               -> 0.0
dsbas610 toSci  .0               -> 0.0
dsbas611 toSci 0.                -> 0
dsbas612 toSci -.0               -> -0.0
dsbas613 toSci -0.               -> -0
dsbas614 toSci -0.0              -> -0.0
dsbas615 toSci -0.00             -> -0.00
dsbas616 toSci -0.000            -> -0.000
dsbas617 toSci -0.0000           -> -0.0000
dsbas618 toSci -0.00000          -> -0.00000
dsbas619 toSci -0.000000         -> -0.000000
dsbas620 toSci -0.0000000        -> -0E-7
dsbas621 toSci -0.00000000       -> -0E-8
dsbas622 toSci -0.000000000      -> -0E-9

dsbas630 toSci  0.00E+0          -> 0.00
dsbas631 toSci  0.00E+1          -> 0.0
dsbas632 toSci  0.00E+2          -> 0
dsbas633 toSci  0.00E+3          -> 0E+1
dsbas634 toSci  0.00E+4          -> 0E+2
dsbas635 toSci  0.00E+5          -> 0E+3
dsbas636 toSci  0.00E+6          -> 0E+4
dsbas637 toSci  0.00E+7          -> 0E+5
dsbas638 toSci  0.00E+8          -> 0E+6
dsbas639 toSci  0.00E+9          -> 0E+7

dsbas640 toSci  0.0E+0           -> 0.0
dsbas641 toSci  0.0E+1           -> 0
dsbas642 toSci  0.0E+2           -> 0E+1
dsbas643 toSci  0.0E+3           -> 0E+2
dsbas644 toSci  0.0E+4           -> 0E+3
dsbas645 toSci  0.0E+5           -> 0E+4
dsbas646 toSci  0.0E+6           -> 0E+5
dsbas647 toSci  0.0E+7           -> 0E+6
dsbas648 toSci  0.0E+8           -> 0E+7
dsbas649 toSci  0.0E+9           -> 0E+8

dsbas650 toSci  0E+0             -> 0
dsbas651 toSci  0E+1             -> 0E+1
dsbas652 toSci  0E+2             -> 0E+2
dsbas653 toSci  0E+3             -> 0E+3
dsbas654 toSci  0E+4             -> 0E+4
dsbas655 toSci  0E+5             -> 0E+5
dsbas656 toSci  0E+6             -> 0E+6
dsbas657 toSci  0E+7             -> 0E+7
dsbas658 toSci  0E+8             -> 0E+8
dsbas659 toSci  0E+9             -> 0E+9

dsbas660 toSci  0.0E-0           -> 0.0
dsbas661 toSci  0.0E-1           -> 0.00
dsbas662 toSci  0.0E-2           -> 0.000
dsbas663 toSci  0.0E-3           -> 0.0000
dsbas664 toSci  0.0E-4           -> 0.00000
dsbas665 toSci  0.0E-5           -> 0.000000
dsbas666 toSci  0.0E-6           -> 0E-7
dsbas667 toSci  0.0E-7           -> 0E-8
dsbas668 toSci  0.0E-8           -> 0E-9
dsbas669 toSci  0.0E-9           -> 0E-10

dsbas670 toSci  0.00E-0          -> 0.00
dsbas671 toSci  0.00E-1          -> 0.000
dsbas672 toSci  0.00E-2          -> 0.0000
dsbas673 toSci  0.00E-3          -> 0.00000
dsbas674 toSci  0.00E-4          -> 0.000000
dsbas675 toSci  0.00E-5          -> 0E-7
dsbas676 toSci  0.00E-6          -> 0E-8
dsbas677 toSci  0.00E-7          -> 0E-9
dsbas678 toSci  0.00E-8          -> 0E-10
dsbas679 toSci  0.00E-9          -> 0E-11

dsbas680 toSci  000000.          ->  0
dsbas681 toSci   00000.          ->  0
dsbas682 toSci    0000.          ->  0
dsbas683 toSci     000.          ->  0
dsbas684 toSci      00.          ->  0
dsbas685 toSci       0.          ->  0
dsbas686 toSci  +00000.          ->  0
dsbas687 toSci  -00000.          -> -0
dsbas688 toSci  +0.              ->  0
dsbas689 toSci  -0.              -> -0

-- Specials
dsbas700 toSci "NaN"             -> NaN
dsbas701 toSci "nan"             -> NaN
dsbas702 toSci "nAn"             -> NaN
dsbas703 toSci "NAN"             -> NaN
dsbas704 toSci "+NaN"            -> NaN
dsbas705 toSci "+nan"            -> NaN
dsbas706 toSci "+nAn"            -> NaN
dsbas707 toSci "+NAN"            -> NaN
dsbas708 toSci "-NaN"            -> -NaN
dsbas709 toSci "-nan"            -> -NaN
dsbas710 toSci "-nAn"            -> -NaN
dsbas711 toSci "-NAN"            -> -NaN
dsbas712 toSci 'NaN0'            -> NaN
dsbas713 toSci 'NaN1'            -> NaN1
dsbas714 toSci 'NaN12'           -> NaN12
dsbas715 toSci 'NaN123'          -> NaN123
dsbas716 toSci 'NaN1234'         -> NaN1234
dsbas717 toSci 'NaN01'           -> NaN1
dsbas718 toSci 'NaN012'          -> NaN12
dsbas719 toSci 'NaN0123'         -> NaN123
dsbas720 toSci 'NaN01234'        -> NaN1234
dsbas721 toSci 'NaN001'          -> NaN1
dsbas722 toSci 'NaN0012'         -> NaN12
dsbas723 toSci 'NaN00123'        -> NaN123
dsbas724 toSci 'NaN001234'       -> NaN1234
dsbas725 toSci 'NaN1234567890123456' -> NaN Conversion_syntax
dsbas726 toSci 'NaN123e+1'       -> NaN Conversion_syntax
dsbas727 toSci 'NaN12.45'        -> NaN Conversion_syntax
dsbas728 toSci 'NaN-12'          -> NaN Conversion_syntax
dsbas729 toSci 'NaN+12'          -> NaN Conversion_syntax

dsbas730 toSci "sNaN"            -> sNaN
dsbas731 toSci "snan"            -> sNaN
dsbas732 toSci "SnAn"            -> sNaN
dsbas733 toSci "SNAN"            -> sNaN
dsbas734 toSci "+sNaN"           -> sNaN
dsbas735 toSci "+snan"           -> sNaN
dsbas736 toSci "+SnAn"           -> sNaN
dsbas737 toSci "+SNAN"           -> sNaN
dsbas738 toSci "-sNaN"           -> -sNaN
dsbas739 toSci "-snan"           -> -sNaN
dsbas740 toSci "-SnAn"           -> -sNaN
dsbas741 toSci "-SNAN"           -> -sNaN
dsbas742 toSci 'sNaN0000'        -> sNaN
dsbas743 toSci 'sNaN7'           -> sNaN7
dsbas744 toSci 'sNaN007234'      -> sNaN7234
dsbas745 toSci 'sNaN7234561234567890' -> NaN Conversion_syntax
dsbas746 toSci 'sNaN72.45'       -> NaN Conversion_syntax
dsbas747 toSci 'sNaN-72'         -> NaN Conversion_syntax

dsbas748 toSci "Inf"             -> Infinity
dsbas749 toSci "inf"             -> Infinity
dsbas750 toSci "iNf"             -> Infinity
dsbas751 toSci "INF"             -> Infinity
dsbas752 toSci "+Inf"            -> Infinity
dsbas753 toSci "+inf"            -> Infinity
dsbas754 toSci "+iNf"            -> Infinity
dsbas755 toSci "+INF"            -> Infinity
dsbas756 toSci "-Inf"            -> -Infinity
dsbas757 toSci "-inf"            -> -Infinity
dsbas758 toSci "-iNf"            -> -Infinity
dsbas759 toSci "-INF"            -> -Infinity

dsbas760 toSci "Infinity"        -> Infinity
dsbas761 toSci "infinity"        -> Infinity
dsbas762 toSci "iNfInItY"        -> Infinity
dsbas763 toSci "INFINITY"        -> Infinity
dsbas764 toSci "+Infinity"       -> Infinity
dsbas765 toSci "+infinity"       -> Infinity
dsbas766 toSci "+iNfInItY"       -> Infinity
dsbas767 toSci "+INFINITY"       -> Infinity
dsbas768 toSci "-Infinity"       -> -Infinity
dsbas769 toSci "-infinity"       -> -Infinity
dsbas770 toSci "-iNfInItY"       -> -Infinity
dsbas771 toSci "-INFINITY"       -> -Infinity

-- Specials and zeros for toEng
dsbast772 toEng "NaN"              -> NaN
dsbast773 toEng "-Infinity"        -> -Infinity
dsbast774 toEng "-sNaN"            -> -sNaN
dsbast775 toEng "-NaN"             -> -NaN
dsbast776 toEng "+Infinity"        -> Infinity
dsbast778 toEng "+sNaN"            -> sNaN
dsbast779 toEng "+NaN"             -> NaN
dsbast780 toEng "INFINITY"         -> Infinity
dsbast781 toEng "SNAN"             -> sNaN
dsbast782 toEng "NAN"              -> NaN
dsbast783 toEng "infinity"         -> Infinity
dsbast784 toEng "snan"             -> sNaN
dsbast785 toEng "nan"              -> NaN
dsbast786 toEng "InFINITY"         -> Infinity
dsbast787 toEng "SnAN"             -> sNaN
dsbast788 toEng "nAN"              -> NaN
dsbast789 toEng "iNfinity"         -> Infinity
dsbast790 toEng "sNan"             -> sNaN
dsbast791 toEng "Nan"              -> NaN
dsbast792 toEng "Infinity"         -> Infinity
dsbast793 toEng "sNaN"             -> sNaN

-- Zero toEng, etc.
dsbast800 toEng 0e+1              -> "0.00E+3"  -- doc example

dsbast801 toEng 0.000000000       -> 0E-9
dsbast802 toEng 0.00000000        -> 0.00E-6
dsbast803 toEng 0.0000000         -> 0.0E-6
dsbast804 toEng 0.000000          -> 0.000000
dsbast805 toEng 0.00000           -> 0.00000
dsbast806 toEng 0.0000            -> 0.0000
dsbast807 toEng 0.000             -> 0.000
dsbast808 toEng 0.00              -> 0.00
dsbast809 toEng 0.0               -> 0.0
dsbast810 toEng  .0               -> 0.0
dsbast811 toEng 0.                -> 0
dsbast812 toEng -.0               -> -0.0
dsbast813 toEng -0.               -> -0
dsbast814 toEng -0.0              -> -0.0
dsbast815 toEng -0.00             -> -0.00
dsbast816 toEng -0.000            -> -0.000
dsbast817 toEng -0.0000           -> -0.0000
dsbast818 toEng -0.00000          -> -0.00000
dsbast819 toEng -0.000000         -> -0.000000
dsbast820 toEng -0.0000000        -> -0.0E-6
dsbast821 toEng -0.00000000       -> -0.00E-6
dsbast822 toEng -0.000000000      -> -0E-9

dsbast830 toEng  0.00E+0          -> 0.00
dsbast831 toEng  0.00E+1          -> 0.0
dsbast832 toEng  0.00E+2          -> 0
dsbast833 toEng  0.00E+3          -> 0.00E+3
dsbast834 toEng  0.00E+4          -> 0.0E+3
dsbast835 toEng  0.00E+5          -> 0E+3
dsbast836 toEng  0.00E+6          -> 0.00E+6
dsbast837 toEng  0.00E+7          -> 0.0E+6
dsbast838 toEng  0.00E+8          -> 0E+6
dsbast839 toEng  0.00E+9          -> 0.00E+9

dsbast840 toEng  0.0E+0           -> 0.0
dsbast841 toEng  0.0E+1           -> 0
dsbast842 toEng  0.0E+2           -> 0.00E+3
dsbast843 toEng  0.0E+3           -> 0.0E+3
dsbast844 toEng  0.0E+4           -> 0E+3
dsbast845 toEng  0.0E+5           -> 0.00E+6
dsbast846 toEng  0.0E+6           -> 0.0E+6
dsbast847 toEng  0.0E+7           -> 0E+6
dsbast848 toEng  0.0E+8           -> 0.00E+9
dsbast849 toEng  0.0E+9           -> 0.0E+9

dsbast850 toEng  0E+0             -> 0
dsbast851 toEng  0E+1             -> 0.00E+3
dsbast852 toEng  0E+2             -> 0.0E+3
dsbast853 toEng  0E+3             -> 0E+3
dsbast854 toEng  0E+4             -> 0.00E+6
dsbast855 toEng  0E+5             -> 0.0E+6
dsbast856 toEng  0E+6             -> 0E+6
dsbast857 toEng  0E+7             -> 0.00E+9
dsbast858 toEng  0E+8             -> 0.0E+9
dsbast859 toEng  0E+9             -> 0E+9

dsbast860 toEng  0.0E-0           -> 0.0
dsbast861 toEng  0.0E-1           -> 0.00
dsbast862 toEng  0.0E-2           -> 0.000
dsbast863 toEng  0.0E-3           -> 0.0000
dsbast864 toEng  0.0E-4           -> 0.00000
dsbast865 toEng  0.0E-5           -> 0.000000
dsbast866 toEng  0.0E-6           -> 0.0E-6
dsbast867 toEng  0.0E-7           -> 0.00E-6
dsbast868 toEng  0.0E-8           -> 0E-9
dsbast869 toEng  0.0E-9           -> 0.0E-9

dsbast870 toEng  0.00E-0          -> 0.00
dsbast871 toEng  0.00E-1          -> 0.000
dsbast872 toEng  0.00E-2          -> 0.0000
dsbast873 toEng  0.00E-3          -> 0.00000
dsbast874 toEng  0.00E-4          -> 0.000000
dsbast875 toEng  0.00E-5          -> 0.0E-6
dsbast876 toEng  0.00E-6          -> 0.00E-6
dsbast877 toEng  0.00E-7          -> 0E-9
dsbast878 toEng  0.00E-8          -> 0.0E-9
dsbast879 toEng  0.00E-9          -> 0.00E-9

-- long input strings
dsbas801 tosci          '01234567' -> 1234567
dsbas802 tosci         '001234567' -> 1234567
dsbas803 tosci        '0001234567' -> 1234567
dsbas804 tosci       '00001234567' -> 1234567
dsbas805 tosci      '000001234567' -> 1234567
dsbas806 tosci     '0000001234567' -> 1234567
dsbas807 tosci    '00000001234567' -> 1234567
dsbas808 tosci   '000000001234567' -> 1234567
dsbas809 tosci  '0000000001234567' -> 1234567
dsbas810 tosci '00000000001234567' -> 1234567

dsbas811 tosci          '0.1234567' ->      0.1234567
dsbas812 tosci         '0.01234567' ->     0.01234567
dsbas813 tosci        '0.001234567' ->    0.001234567
dsbas814 tosci       '0.0001234567' ->   0.0001234567
dsbas815 tosci      '0.00001234567' ->  0.00001234567
dsbas816 tosci     '0.000001234567' -> 0.000001234567
dsbas817 tosci    '0.0000001234567' ->       1.234567E-7
dsbas818 tosci   '0.00000001234567' ->       1.234567E-8
dsbas819 tosci  '0.000000001234567' ->       1.234567E-9
dsbas820 tosci '0.0000000001234567' ->       1.234567E-10

dsbas821 tosci '123456790'         -> 1.234568E+8 Inexact Rounded
dsbas822 tosci '1234567901'        -> 1.234568E+9  Inexact Rounded
dsbas823 tosci '12345679012'       -> 1.234568E+10 Inexact Rounded
dsbas824 tosci '123456790123'      -> 1.234568E+11 Inexact Rounded
dsbas825 tosci '1234567901234'     -> 1.234568E+12 Inexact Rounded
dsbas826 tosci '12345679012345'    -> 1.234568E+13 Inexact Rounded
dsbas827 tosci '123456790123456'   -> 1.234568E+14 Inexact Rounded
dsbas828 tosci '1234567901234567'  -> 1.234568E+15 Inexact Rounded
dsbas829 tosci '1234567890123456'  -> 1.234568E+15 Inexact Rounded

-- subnormals and overflows
dsbas906 toSci '99e999999999'       -> Infinity Overflow  Inexact Rounded
dsbas907 toSci '999e999999999'      -> Infinity Overflow  Inexact Rounded
dsbas908 toSci '0.9e-999999999'     -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas909 toSci '0.09e-999999999'    -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas910 toSci '0.1e1000000000'     -> Infinity Overflow  Inexact Rounded
dsbas911 toSci '10e-1000000000'     -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas912 toSci '0.9e9999999999'     -> Infinity Overflow  Inexact Rounded
dsbas913 toSci '99e-9999999999'     -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas914 toSci '111e9999999999'     -> Infinity Overflow  Inexact Rounded
dsbas915 toSci '1111e-9999999999'   -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas916 toSci '1111e-99999999999'  -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas917 toSci '7e1000000000'       -> Infinity Overflow  Inexact Rounded
-- negatives the same
dsbas918 toSci '-99e999999999'      -> -Infinity Overflow  Inexact Rounded
dsbas919 toSci '-999e999999999'     -> -Infinity Overflow  Inexact Rounded
dsbas920 toSci '-0.9e-999999999'    -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas921 toSci '-0.09e-999999999'   -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas922 toSci '-0.1e1000000000'    -> -Infinity Overflow  Inexact Rounded
dsbas923 toSci '-10e-1000000000'    -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas924 toSci '-0.9e9999999999'    -> -Infinity Overflow  Inexact Rounded
dsbas925 toSci '-99e-9999999999'    -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas926 toSci '-111e9999999999'    -> -Infinity Overflow  Inexact Rounded
dsbas927 toSci '-1111e-9999999999'  -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas928 toSci '-1111e-99999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas929 toSci '-7e1000000000'      -> -Infinity Overflow  Inexact Rounded

-- overflow results at different rounding modes
rounding:  ceiling
dsbas930 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
dsbas931 toSci '-7e10000'  -> -9.999999E+96 Overflow  Inexact Rounded
rounding:  up
dsbas932 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
dsbas933 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded
rounding:  down
dsbas934 toSci  '7e10000'  ->  9.999999E+96 Overflow  Inexact Rounded
dsbas935 toSci '-7e10000'  -> -9.999999E+96 Overflow  Inexact Rounded
rounding:  floor
dsbas936 toSci  '7e10000'  ->  9.999999E+96 Overflow  Inexact Rounded
dsbas937 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded

rounding:  half_up
dsbas938 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
dsbas939 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded
rounding:  half_even
dsbas940 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
dsbas941 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded
rounding:  half_down
dsbas942 toSci  '7e10000'  ->  Infinity Overflow  Inexact Rounded
dsbas943 toSci '-7e10000'  -> -Infinity Overflow  Inexact Rounded

rounding:  half_even

-- Now check 854/754r some subnormals and underflow to 0
dsbem400 toSci  1.0000E-86     -> 1.0000E-86
dsbem401 toSci  0.1E-97        -> 1E-98       Subnormal
dsbem402 toSci  0.1000E-97     -> 1.000E-98   Subnormal
dsbem403 toSci  0.0100E-97     -> 1.00E-99    Subnormal
dsbem404 toSci  0.0010E-97     -> 1.0E-100     Subnormal
dsbem405 toSci  0.0001E-97     -> 1E-101       Subnormal
dsbem406 toSci  0.00010E-97    -> 1E-101     Subnormal Rounded
dsbem407 toSci  0.00013E-97    -> 1E-101     Underflow Subnormal Inexact Rounded
dsbem408 toSci  0.00015E-97    -> 2E-101     Underflow Subnormal Inexact Rounded
dsbem409 toSci  0.00017E-97    -> 2E-101     Underflow Subnormal Inexact Rounded
dsbem410 toSci  0.00023E-97    -> 2E-101     Underflow Subnormal Inexact Rounded
dsbem411 toSci  0.00025E-97    -> 2E-101     Underflow Subnormal Inexact Rounded
dsbem412 toSci  0.00027E-97    -> 3E-101     Underflow Subnormal Inexact Rounded
dsbem413 toSci  0.000149E-97   -> 1E-101     Underflow Subnormal Inexact Rounded
dsbem414 toSci  0.000150E-97   -> 2E-101     Underflow Subnormal Inexact Rounded
dsbem415 toSci  0.000151E-97   -> 2E-101     Underflow Subnormal Inexact Rounded
dsbem416 toSci  0.000249E-97   -> 2E-101     Underflow Subnormal Inexact Rounded
dsbem417 toSci  0.000250E-97   -> 2E-101     Underflow Subnormal Inexact Rounded
dsbem418 toSci  0.000251E-97   -> 3E-101     Underflow Subnormal Inexact Rounded
dsbem419 toSci  0.00009E-97    -> 1E-101     Underflow Subnormal Inexact Rounded
dsbem420 toSci  0.00005E-97    -> 0E-101     Underflow Subnormal Inexact Rounded Clamped
dsbem421 toSci  0.00003E-97    -> 0E-101     Underflow Subnormal Inexact Rounded Clamped
dsbem422 toSci  0.000009E-97   -> 0E-101     Underflow Subnormal Inexact Rounded Clamped
dsbem423 toSci  0.000005E-97   -> 0E-101     Underflow Subnormal Inexact Rounded Clamped
dsbem424 toSci  0.000003E-97   -> 0E-101     Underflow Subnormal Inexact Rounded Clamped

dsbem425 toSci  0.001049E-97   -> 1.0E-100   Underflow Subnormal Inexact Rounded
dsbem426 toSci  0.001050E-97   -> 1.0E-100   Underflow Subnormal Inexact Rounded
dsbem427 toSci  0.001051E-97   -> 1.1E-100   Underflow Subnormal Inexact Rounded
dsbem428 toSci  0.001149E-97   -> 1.1E-100   Underflow Subnormal Inexact Rounded
dsbem429 toSci  0.001150E-97   -> 1.2E-100   Underflow Subnormal Inexact Rounded
dsbem430 toSci  0.001151E-97   -> 1.2E-100   Underflow Subnormal Inexact Rounded

dsbem432 toSci  0.010049E-97   -> 1.00E-99  Underflow Subnormal Inexact Rounded
dsbem433 toSci  0.010050E-97   -> 1.00E-99  Underflow Subnormal Inexact Rounded
dsbem434 toSci  0.010051E-97   -> 1.01E-99  Underflow Subnormal Inexact Rounded
dsbem435 toSci  0.010149E-97   -> 1.01E-99  Underflow Subnormal Inexact Rounded
dsbem436 toSci  0.010150E-97   -> 1.02E-99  Underflow Subnormal Inexact Rounded
dsbem437 toSci  0.010151E-97   -> 1.02E-99  Underflow Subnormal Inexact Rounded

dsbem440 toSci  0.10103E-97    -> 1.010E-98 Underflow Subnormal Inexact Rounded
dsbem441 toSci  0.10105E-97    -> 1.010E-98 Underflow Subnormal Inexact Rounded
dsbem442 toSci  0.10107E-97    -> 1.011E-98 Underflow Subnormal Inexact Rounded
dsbem443 toSci  0.10113E-97    -> 1.011E-98 Underflow Subnormal Inexact Rounded
dsbem444 toSci  0.10115E-97    -> 1.012E-98 Underflow Subnormal Inexact Rounded
dsbem445 toSci  0.10117E-97    -> 1.012E-98 Underflow Subnormal Inexact Rounded

dsbem450 toSci  1.10730E-98    -> 1.107E-98 Underflow Subnormal Inexact Rounded
dsbem451 toSci  1.10750E-98    -> 1.108E-98 Underflow Subnormal Inexact Rounded
dsbem452 toSci  1.10770E-98    -> 1.108E-98 Underflow Subnormal Inexact Rounded
dsbem453 toSci  1.10830E-98    -> 1.108E-98 Underflow Subnormal Inexact Rounded
dsbem454 toSci  1.10850E-98    -> 1.108E-98 Underflow Subnormal Inexact Rounded
dsbem455 toSci  1.10870E-98    -> 1.109E-98 Underflow Subnormal Inexact Rounded

-- make sure sign OK
dsbem456 toSci  -0.10103E-97   -> -1.010E-98 Underflow Subnormal Inexact Rounded
dsbem457 toSci  -0.10105E-97   -> -1.010E-98 Underflow Subnormal Inexact Rounded
dsbem458 toSci  -0.10107E-97   -> -1.011E-98 Underflow Subnormal Inexact Rounded
dsbem459 toSci  -0.10113E-97   -> -1.011E-98 Underflow Subnormal Inexact Rounded
dsbem460 toSci  -0.10115E-97   -> -1.012E-98 Underflow Subnormal Inexact Rounded
dsbem461 toSci  -0.10117E-97   -> -1.012E-98 Underflow Subnormal Inexact Rounded

-- '999s' cases
dsbem464 toSci  999999E-98         -> 9.99999E-93
dsbem465 toSci  99999.0E-97        -> 9.99990E-93
dsbem466 toSci  99999.E-97         -> 9.9999E-93
dsbem467 toSci  9999.9E-97         -> 9.9999E-94
dsbem468 toSci  999.99E-97         -> 9.9999E-95
dsbem469 toSci  99.999E-97         -> 9.9999E-96 Subnormal
dsbem470 toSci  9.9999E-97         -> 9.9999E-97 Subnormal
dsbem471 toSci  0.99999E-97        -> 1.0000E-97 Underflow Subnormal Inexact Rounded
dsbem472 toSci  0.099999E-97       -> 1.000E-98  Underflow Subnormal Inexact Rounded
dsbem473 toSci  0.0099999E-97      -> 1.00E-99   Underflow Subnormal Inexact Rounded
dsbem474 toSci  0.00099999E-97     -> 1.0E-100   Underflow Subnormal Inexact Rounded
dsbem475 toSci  0.000099999E-97    -> 1E-101     Underflow Subnormal Inexact Rounded
dsbem476 toSci  0.0000099999E-97   -> 0E-101     Underflow Subnormal Inexact Rounded Clamped
dsbem477 toSci  0.00000099999E-97  -> 0E-101     Underflow Subnormal Inexact Rounded Clamped
dsbem478 toSci  0.000000099999E-97 -> 0E-101     Underflow Subnormal Inexact Rounded Clamped

-- Exponents with insignificant leading zeros
dsbas1001 toSci  1e999999999 -> Infinity Overflow Inexact Rounded
dsbas1002 toSci  1e0999999999 -> Infinity Overflow Inexact Rounded
dsbas1003 toSci  1e00999999999 -> Infinity Overflow Inexact Rounded
dsbas1004 toSci  1e000999999999 -> Infinity Overflow Inexact Rounded
dsbas1005 toSci  1e000000000000999999999 -> Infinity Overflow Inexact Rounded
dsbas1006 toSci  1e000000000001000000007 -> Infinity Overflow Inexact Rounded
dsbas1007 toSci  1e-999999999 -> 0E-101             Underflow Subnormal Inexact Rounded Clamped
dsbas1008 toSci  1e-0999999999 -> 0E-101            Underflow Subnormal Inexact Rounded Clamped
dsbas1009 toSci  1e-00999999999 -> 0E-101           Underflow Subnormal Inexact Rounded Clamped
dsbas1010 toSci  1e-000999999999 -> 0E-101          Underflow Subnormal Inexact Rounded Clamped
dsbas1011 toSci  1e-000000000000999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
dsbas1012 toSci  1e-000000000001000000007 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped

-- check for double-rounded subnormals
dsbas1041 toSci     1.1152444E-96 ->  1.11524E-96 Inexact Rounded Subnormal Underflow
dsbas1042 toSci     1.1152445E-96 ->  1.11524E-96 Inexact Rounded Subnormal Underflow
dsbas1043 toSci     1.1152446E-96 ->  1.11524E-96 Inexact Rounded Subnormal Underflow

-- clamped zeros [see also clamp.decTest]
dsbas1075 toSci   0e+10000  ->  0E+90   Clamped
dsbas1076 toSci   0e-10000  ->  0E-101  Clamped
dsbas1077 toSci  -0e+10000  -> -0E+90   Clamped
dsbas1078 toSci  -0e-10000  -> -0E-101  Clamped

-- extreme values from next-wider
dsbas1101 toSci -9.999999999999999E+384 -> -Infinity Overflow Inexact Rounded
dsbas1102 toSci -1E-383 -> -0E-101 Inexact Rounded Subnormal Underflow Clamped
dsbas1103 toSci -1E-398 -> -0E-101 Inexact Rounded Subnormal Underflow Clamped
dsbas1104 toSci -0 -> -0
dsbas1105 toSci +0 ->  0
dsbas1106 toSci +1E-398 ->  0E-101 Inexact Rounded Subnormal Underflow Clamped
dsbas1107 toSci +1E-383 ->  0E-101 Inexact Rounded Subnormal Underflow Clamped
dsbas1108 toSci +9.999999999999999E+384 ->  Infinity Overflow Inexact Rounded


Added test/dectest/dsEncode.decTest.



































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
------------------------------------------------------------------------
-- dsEncode.decTest -- decimal four-byte format testcases             --
-- Copyright (c) IBM Corporation, 2000, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
-- [Previously called decimal32.decTest]
version: 2.55

-- This set of tests is for the four-byte concrete representation.
-- Its characteristics are:
--
--  1 bit  sign
--  5 bits combination field
--  6 bits exponent continuation
-- 20 bits coefficient continuation
--
-- Total exponent length 8 bits
-- Total coefficient length 24 bits (7 digits)
--
-- Elimit =  191 (maximum encoded exponent)
-- Emax   =   96 (largest exponent value)
-- Emin   =  -95 (smallest exponent value)
-- bias   =  101 (subtracted from encoded exponent) = -Etiny

-- The testcases here have only exactly representable data on the
-- 'left-hand-side'; rounding from strings is tested in 'base'
-- testcase groups.

extended:    1
clamp:       1
precision:   7
rounding:    half_up
maxExponent: 96
minExponent: -95

-- General testcases
-- (mostly derived from the Strawman 4 document and examples)
decs001 apply   #A23003D0          -> -7.50
decs002 apply   -7.50              -> #A23003D0
-- derivative canonical plain strings
decs003 apply   #A26003D0         -> -7.50E+3
decs004 apply   -7.50E+3          -> #A26003D0
decs005 apply   #A25003D0         -> -750
decs006 apply   -750              -> #A25003D0
decs007 apply   #A24003D0         -> -75.0
decs008 apply   -75.0             -> #A24003D0
decs009 apply   #A22003D0         -> -0.750
decs010 apply   -0.750            -> #A22003D0
decs011 apply   #A21003D0         -> -0.0750
decs012 apply   -0.0750           -> #A21003D0
decs013 apply   #A1f003D0         -> -0.000750
decs014 apply   -0.000750         -> #A1f003D0
decs015 apply   #A1d003D0         -> -0.00000750
decs016 apply   -0.00000750       -> #A1d003D0
decs017 apply   #A1c003D0         -> -7.50E-7
decs018 apply   -7.50E-7          -> #A1c003D0

-- Normality
decs020 apply   1234567            -> #2654d2e7
decs021 apply  -1234567            -> #a654d2e7
decs022 apply   1111111            -> #26524491

-- Nmax and similar
decs031 apply   9.999999E+96            -> #77f3fcff
decs032 apply   #77f3fcff               -> 9.999999E+96
decs033 apply   1.234567E+96            -> #47f4d2e7
decs034 apply   #47f4d2e7               -> 1.234567E+96
-- fold-downs (more below)
decs035 apply   1.23E+96                -> #47f4c000 Clamped
decs036 apply   #47f4c000               -> 1.230000E+96
decs037 apply   1E+96                   -> #47f00000 Clamped
decs038 apply   #47f00000               -> 1.000000E+96

decs051 apply   12345                   -> #225049c5
decs052 apply   #225049c5               -> 12345
decs053 apply   1234                    -> #22500534
decs054 apply   #22500534               -> 1234
decs055 apply   123                     -> #225000a3
decs056 apply   #225000a3               -> 123
decs057 apply   12                      -> #22500012
decs058 apply   #22500012               -> 12
decs059 apply   1                       -> #22500001
decs060 apply   #22500001               -> 1
decs061 apply   1.23                    -> #223000a3
decs062 apply   #223000a3               -> 1.23
decs063 apply   123.45                  -> #223049c5
decs064 apply   #223049c5               -> 123.45

-- Nmin and below
decs071 apply   1E-95                   -> #00600001
decs072 apply   #00600001               -> 1E-95
decs073 apply   1.000000E-95            -> #04000000
decs074 apply   #04000000               -> 1.000000E-95
decs075 apply   1.000001E-95            -> #04000001
decs076 apply   #04000001               -> 1.000001E-95

decs077 apply   0.100000E-95            -> #00020000     Subnormal
decs07x apply   1.00000E-96             -> 1.00000E-96   Subnormal
decs078 apply   #00020000               -> 1.00000E-96   Subnormal
decs079 apply   0.000010E-95            -> #00000010     Subnormal
decs080 apply   #00000010               -> 1.0E-100      Subnormal
decs081 apply   0.000001E-95            -> #00000001     Subnormal
decs082 apply   #00000001               -> 1E-101        Subnormal
decs083 apply   1e-101                  -> #00000001     Subnormal
decs084 apply   #00000001               -> 1E-101        Subnormal
decs08x apply   1e-101                  -> 1E-101        Subnormal

-- underflows cannot be tested; just check edge case
decs090 apply   1e-101                  -> #00000001  Subnormal

-- same again, negatives --

-- Nmax and similar
decs122 apply  -9.999999E+96            -> #f7f3fcff
decs123 apply   #f7f3fcff               -> -9.999999E+96
decs124 apply  -1.234567E+96            -> #c7f4d2e7
decs125 apply   #c7f4d2e7               -> -1.234567E+96
-- fold-downs (more below)
decs130 apply  -1.23E+96                -> #c7f4c000 Clamped
decs131 apply   #c7f4c000               -> -1.230000E+96
decs132 apply  -1E+96                   -> #c7f00000 Clamped
decs133 apply   #c7f00000               -> -1.000000E+96

decs151 apply  -12345                   -> #a25049c5
decs152 apply   #a25049c5               -> -12345
decs153 apply  -1234                    -> #a2500534
decs154 apply   #a2500534               -> -1234
decs155 apply  -123                     -> #a25000a3
decs156 apply   #a25000a3               -> -123
decs157 apply  -12                      -> #a2500012
decs158 apply   #a2500012               -> -12
decs159 apply  -1                       -> #a2500001
decs160 apply   #a2500001               -> -1
decs161 apply  -1.23                    -> #a23000a3
decs162 apply   #a23000a3               -> -1.23
decs163 apply  -123.45                  -> #a23049c5
decs164 apply   #a23049c5               -> -123.45

-- Nmin and below
decs171 apply  -1E-95                   -> #80600001
decs172 apply   #80600001               -> -1E-95
decs173 apply  -1.000000E-95            -> #84000000
decs174 apply   #84000000               -> -1.000000E-95
decs175 apply  -1.000001E-95            -> #84000001
decs176 apply   #84000001               -> -1.000001E-95

decs177 apply  -0.100000E-95            -> #80020000     Subnormal
decs178 apply   #80020000               -> -1.00000E-96  Subnormal
decs179 apply  -0.000010E-95            -> #80000010     Subnormal
decs180 apply   #80000010               -> -1.0E-100     Subnormal
decs181 apply  -0.000001E-95            -> #80000001     Subnormal
decs182 apply   #80000001               -> -1E-101       Subnormal
decs183 apply  -1e-101                  -> #80000001     Subnormal
decs184 apply   #80000001               -> -1E-101       Subnormal

-- underflow edge case
decs190 apply  -1e-101                  -> #80000001  Subnormal

-- zeros
decs400 apply   0E-400                  -> #00000000  Clamped
decs401 apply   0E-101                  -> #00000000
decs402 apply   #00000000               -> 0E-101
decs403 apply   0.000000E-95            -> #00000000
decs404 apply   #00000000               -> 0E-101
decs405 apply   0E-2                    -> #22300000
decs406 apply   #22300000               -> 0.00
decs407 apply   0                       -> #22500000
decs408 apply   #22500000               -> 0
decs409 apply   0E+3                    -> #22800000
decs410 apply   #22800000               -> 0E+3
decs411 apply   0E+90                   -> #43f00000
decs412 apply   #43f00000               -> 0E+90
-- clamped zeros...
decs413 apply   0E+91                   -> #43f00000  Clamped
decs414 apply   #43f00000               -> 0E+90
decs415 apply   0E+96                   -> #43f00000  Clamped
decs416 apply   #43f00000               -> 0E+90
decs417 apply   0E+400                  -> #43f00000  Clamped
decs418 apply   #43f00000               -> 0E+90

-- negative zeros
decs420 apply   -0E-400                 -> #80000000  Clamped
decs421 apply   -0E-101                 -> #80000000
decs422 apply   #80000000               -> -0E-101
decs423 apply   -0.000000E-95           -> #80000000
decs424 apply   #80000000               -> -0E-101
decs425 apply   -0E-2                   -> #a2300000
decs426 apply   #a2300000               -> -0.00
decs427 apply   -0                      -> #a2500000
decs428 apply   #a2500000               -> -0
decs429 apply   -0E+3                   -> #a2800000
decs430 apply   #a2800000               -> -0E+3
decs431 apply   -0E+90                  -> #c3f00000
decs432 apply   #c3f00000               -> -0E+90
-- clamped zeros...
decs433 apply   -0E+91                  -> #c3f00000  Clamped
decs434 apply   #c3f00000               -> -0E+90
decs435 apply   -0E+96                  -> #c3f00000  Clamped
decs436 apply   #c3f00000               -> -0E+90
decs437 apply   -0E+400                 -> #c3f00000  Clamped
decs438 apply   #c3f00000               -> -0E+90

-- Specials
decs500 apply   Infinity  -> #78000000
decs501 apply   #78787878 -> #78000000
decs502 apply   #78000000 -> Infinity
decs503 apply   #79797979 -> #78000000
decs504 apply   #79000000 -> Infinity
decs505 apply   #7a7a7a7a -> #78000000
decs506 apply   #7a000000 -> Infinity
decs507 apply   #7b7b7b7b -> #78000000
decs508 apply   #7b000000 -> Infinity
decs509 apply   #7c7c7c7c -> #7c0c7c7c

decs510 apply   NaN       -> #7c000000
decs511 apply   #7c000000 -> NaN
decs512 apply   #7d7d7d7d -> #7c0d7d7d
decs513 apply   #7d000000 -> NaN
decs514 apply   #7e7e7e7e -> #7e0e7c7e
decs515 apply   #7e000000 -> sNaN
decs516 apply   #7f7f7f7f -> #7e0f7c7f
decs517 apply   #7f000000 -> sNaN
decs518 apply   #7fffffff -> sNaN999999
decs519 apply   #7fffffff -> #7e03fcff

decs520 apply   -Infinity -> #f8000000
decs521 apply   #f8787878 -> #f8000000
decs522 apply   #f8000000 -> -Infinity
decs523 apply   #f9797979 -> #f8000000
decs524 apply   #f9000000 -> -Infinity
decs525 apply   #fa7a7a7a -> #f8000000
decs526 apply   #fa000000 -> -Infinity
decs527 apply   #fb7b7b7b -> #f8000000
decs528 apply   #fb000000 -> -Infinity

decs529 apply   -NaN      -> #fc000000
decs530 apply   #fc7c7c7c -> #fc0c7c7c
decs531 apply   #fc000000 -> -NaN
decs532 apply   #fd7d7d7d -> #fc0d7d7d
decs533 apply   #fd000000 -> -NaN
decs534 apply   #fe7e7e7e -> #fe0e7c7e
decs535 apply   #fe000000 -> -sNaN
decs536 apply   #ff7f7f7f -> #fe0f7c7f
decs537 apply   #ff000000 -> -sNaN
decs538 apply   #ffffffff -> -sNaN999999
decs539 apply   #ffffffff -> #fe03fcff

-- diagnostic NaNs
decs540 apply   NaN       -> #7c000000
decs541 apply   NaN0      -> #7c000000
decs542 apply   NaN1      -> #7c000001
decs543 apply   NaN12     -> #7c000012
decs544 apply   NaN79     -> #7c000079
decs545 apply   NaN12345   -> #7c0049c5
decs546 apply   NaN123456  -> #7c028e56
decs547 apply   NaN799799  -> #7c0f7fdf
decs548 apply   NaN999999  -> #7c03fcff


-- fold-down full sequence
decs601 apply   1E+96                   -> #47f00000 Clamped
decs602 apply   #47f00000               -> 1.000000E+96
decs603 apply   1E+95                   -> #43f20000 Clamped
decs604 apply   #43f20000               -> 1.00000E+95
decs605 apply   1E+94                   -> #43f04000 Clamped
decs606 apply   #43f04000               -> 1.0000E+94
decs607 apply   1E+93                   -> #43f00400 Clamped
decs608 apply   #43f00400               -> 1.000E+93
decs609 apply   1E+92                   -> #43f00080 Clamped
decs610 apply   #43f00080               -> 1.00E+92
decs611 apply   1E+91                   -> #43f00010 Clamped
decs612 apply   #43f00010               -> 1.0E+91
decs613 apply   1E+90                   -> #43f00001
decs614 apply   #43f00001               -> 1E+90


-- Selected DPD codes
decs700 apply   #22500000       -> 0
decs701 apply   #22500009       -> 9
decs702 apply   #22500010       -> 10
decs703 apply   #22500019       -> 19
decs704 apply   #22500020       -> 20
decs705 apply   #22500029       -> 29
decs706 apply   #22500030       -> 30
decs707 apply   #22500039       -> 39
decs708 apply   #22500040       -> 40
decs709 apply   #22500049       -> 49
decs710 apply   #22500050       -> 50
decs711 apply   #22500059       -> 59
decs712 apply   #22500060       -> 60
decs713 apply   #22500069       -> 69
decs714 apply   #22500070       -> 70
decs715 apply   #22500071       -> 71
decs716 apply   #22500072       -> 72
decs717 apply   #22500073       -> 73
decs718 apply   #22500074       -> 74
decs719 apply   #22500075       -> 75
decs720 apply   #22500076       -> 76
decs721 apply   #22500077       -> 77
decs722 apply   #22500078       -> 78
decs723 apply   #22500079       -> 79

decs730 apply   #2250029e       -> 994
decs731 apply   #2250029f       -> 995
decs732 apply   #225002a0       -> 520
decs733 apply   #225002a1       -> 521

-- DPD: one of each of the huffman groups
decs740 apply   #225003f7       -> 777
decs741 apply   #225003f8       -> 778
decs742 apply   #225003eb       -> 787
decs743 apply   #2250037d       -> 877
decs744 apply   #2250039f       -> 997
decs745 apply   #225003bf       -> 979
decs746 apply   #225003df       -> 799
decs747 apply   #2250006e       -> 888


-- DPD all-highs cases (includes the 24 redundant codes)
decs750 apply   #2250006e       -> 888
decs751 apply   #2250016e       -> 888
decs752 apply   #2250026e       -> 888
decs753 apply   #2250036e       -> 888
decs754 apply   #2250006f       -> 889
decs755 apply   #2250016f       -> 889
decs756 apply   #2250026f       -> 889
decs757 apply   #2250036f       -> 889

decs760 apply   #2250007e       -> 898
decs761 apply   #2250017e       -> 898
decs762 apply   #2250027e       -> 898
decs763 apply   #2250037e       -> 898
decs764 apply   #2250007f       -> 899
decs765 apply   #2250017f       -> 899
decs766 apply   #2250027f       -> 899
decs767 apply   #2250037f       -> 899

decs770 apply   #225000ee       -> 988
decs771 apply   #225001ee       -> 988
decs772 apply   #225002ee       -> 988
decs773 apply   #225003ee       -> 988
decs774 apply   #225000ef       -> 989
decs775 apply   #225001ef       -> 989
decs776 apply   #225002ef       -> 989
decs777 apply   #225003ef       -> 989

decs780 apply   #225000fe       -> 998
decs781 apply   #225001fe       -> 998
decs782 apply   #225002fe       -> 998
decs783 apply   #225003fe       -> 998
decs784 apply   #225000ff       -> 999
decs785 apply   #225001ff       -> 999
decs786 apply   #225002ff       -> 999
decs787 apply   #225003ff       -> 999

Changes to test/dectest/exp.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- exp.decTest -- decimal natural exponentiation                      --
-- Copyright (c) IBM Corporation, 2005.  All rights reserved.         --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- Tests of the exponential funtion.  Currently all testcases here
-- show results which are correctly rounded (within <= 0.5 ulp).

extended:    1
precision:   9
rounding:    half_even


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- exp.decTest -- decimal natural exponentiation                      --
-- Copyright (c) IBM Corporation, 2005, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Tests of the exponential funtion.  Currently all testcases here
-- show results which are correctly rounded (within <= 0.5 ulp).

extended:    1
precision:   9
rounding:    half_even
529
530
531
532
533
534
535




536
537
538
539
540
541
542
expx1535 exp 0.00000000015772064569640613142823203726821076239561 -> 1.0000000001577206457088440324683315788358926129830 Inexact Rounded
expx1536 exp 0.58179346473959531432624153576883440625538017532480 -> 1.7892445018275360163797022372655837188423194863605 Inexact Rounded
expx1537 exp 33.555726197149525061455517784870570470833498096559  -> 374168069896324.62578073148993526626307095854407952 Inexact Rounded
expx1538 exp 9.7898079803906215094140010009583375537259810398659  -> 17850.878119912208888217100998019986634620368538426 Inexact Rounded
expx1539 exp 89.157697327174521542502447953032536541038636966347  -> 525649152320166503771224149330448089550.67293829227 Inexact Rounded
expx1540 exp 25.022947600123328912029051897171319573322888514885  -> 73676343442.952517824345431437683153304645851960524 Inexact Rounded





-- Randoms P=34, within 0-999
Precision: 34
maxExponent: 6144
minExponent: -6143
expx1201 exp 309.5948855821510212996700645087188  -> 2.853319692901387521201738015050724E+134 Inexact Rounded
expx1202 exp 9.936543068706211420422803962680164  -> 20672.15839203171877476511093276022 Inexact Rounded
expx1203 exp 6.307870323881505684429839491707908  -> 548.8747777054637296137277391754665 Inexact Rounded







>
>
>
>







529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
expx1535 exp 0.00000000015772064569640613142823203726821076239561 -> 1.0000000001577206457088440324683315788358926129830 Inexact Rounded
expx1536 exp 0.58179346473959531432624153576883440625538017532480 -> 1.7892445018275360163797022372655837188423194863605 Inexact Rounded
expx1537 exp 33.555726197149525061455517784870570470833498096559  -> 374168069896324.62578073148993526626307095854407952 Inexact Rounded
expx1538 exp 9.7898079803906215094140010009583375537259810398659  -> 17850.878119912208888217100998019986634620368538426 Inexact Rounded
expx1539 exp 89.157697327174521542502447953032536541038636966347  -> 525649152320166503771224149330448089550.67293829227 Inexact Rounded
expx1540 exp 25.022947600123328912029051897171319573322888514885  -> 73676343442.952517824345431437683153304645851960524 Inexact Rounded

-- exp(1) at 34
Precision: 34
expx1200 exp 1 -> 2.718281828459045235360287471352662 Inexact Rounded

-- Randoms P=34, within 0-999
Precision: 34
maxExponent: 6144
minExponent: -6143
expx1201 exp 309.5948855821510212996700645087188  -> 2.853319692901387521201738015050724E+134 Inexact Rounded
expx1202 exp 9.936543068706211420422803962680164  -> 20672.15839203171877476511093276022 Inexact Rounded
expx1203 exp 6.307870323881505684429839491707908  -> 548.8747777054637296137277391754665 Inexact Rounded

Added test/dectest/fma.decTest.

































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
------------------------------------------------------------------------
-- fma.decTest -- decimal fused multiply add                          --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

-- These tests comprese three parts:
--   1. Sanity checks and other three-operand tests (especially those
--      where the fused operation makes a difference)
--   2. Multiply tests (third operand is neutral zero [0E+emax])
--   3. Addition tests (first operand is 1)
-- The multiply and addition tests are extensive because FMA may have
-- its own dedicated multiplication or addition routine(s), and they
-- also inherently check the left-to-right properties.

-- Sanity checks
fmax0001 fma  1   1   1 ->   2
fmax0002 fma  1   1   2 ->   3
fmax0003 fma  2   2   3 ->   7
fmax0004 fma  9   9   9 ->  90
fmax0005 fma -1   1   1 ->   0
fmax0006 fma -1   1   2 ->   1
fmax0007 fma -2   2   3 ->  -1
fmax0008 fma -9   9   9 -> -72
fmax0011 fma  1  -1   1 ->   0
fmax0012 fma  1  -1   2 ->   1
fmax0013 fma  2  -2   3 ->  -1
fmax0014 fma  9  -9   9 -> -72
fmax0015 fma  1   1  -1 ->   0
fmax0016 fma  1   1  -2 ->  -1
fmax0017 fma  2   2  -3 ->   1
fmax0018 fma  9   9  -9 ->  72
fmax0019 fma  3   5   7 ->  22
fmax0029 fma  3  -5   7 ->  -8

-- non-integer exacts
fma0100  fma    25.2   63.6   -438  ->  1164.72
fma0101  fma   0.301  0.380    334  ->  334.114380
fma0102  fma    49.2   -4.8   23.3  ->  -212.86
fma0103  fma    4.22  0.079  -94.6  ->  -94.26662
fma0104  fma     903  0.797  0.887  ->  720.578
fma0105  fma    6.13   -161   65.9  ->  -921.03
fma0106  fma    28.2    727   5.45  ->  20506.85
fma0107  fma       4    605    688  ->  3108
fma0108  fma    93.3   0.19  0.226  ->  17.953
fma0109  fma   0.169   -341   5.61  ->  -52.019
fma0110  fma   -72.2     30  -51.2  ->  -2217.2
fma0111  fma  -0.409     13   20.4  ->  15.083
fma0112  fma     317   77.0   19.0  ->  24428.0
fma0113  fma      47   6.58   1.62  ->  310.88
fma0114  fma    1.36  0.984  0.493  ->  1.83124
fma0115  fma    72.7    274   1.56  ->  19921.36
fma0116  fma     335    847     83  ->  283828
fma0117  fma     666  0.247   25.4  ->  189.902
fma0118  fma   -3.87   3.06   78.0  ->  66.1578
fma0119  fma   0.742    192   35.6  ->  178.064
fma0120  fma   -91.6   5.29  0.153  ->  -484.411

-- cases where result is different from separate multiply + add; each
-- is preceded by the result of unfused multiply and add
-- [this is about 20% of all similar  cases in general]
--               888565290   1557.96930  -86087.7578  -> 1.38435735E+12
fma0201  fma     888565290   1557.96930  -86087.7578  -> 1.38435736E+12  Inexact Rounded
--             -85519342.9    735155419     42010431  -> -6.28700084E+16
fma0205  fma   -85519342.9    735155419     42010431  -> -6.28700083E+16 Inexact Rounded
--                -98025.5  -294603.472   10414348.2  -> 2.88890669E+10
fma0208  fma      -98025.5  -294603.472   10414348.2  -> 2.88890670E+10  Inexact Rounded
--              5967627.39   83526540.6   498494.810  -> 4.98455271E+14
fma0211  fma    5967627.39   83526540.6   498494.810  -> 4.98455272E+14  Inexact Rounded
--               3456.9433    874.39518   197866.615  ->  3220601.18
fma0216  fma     3456.9433    874.39518   197866.615  ->  3220601.17     Inexact Rounded
--              62769.8287   2096.98927    48.420317  ->  131627705
fma0218  fma    62769.8287   2096.98927    48.420317  ->  131627706      Inexact Rounded
--               -68.81500   59961113.9     -8988862  -> -4.13521291E+9
fma0219  fma     -68.81500   59961113.9     -8988862  -> -4.13521292E+9  Inexact Rounded
--              2126341.02   63491.5152    302427455  -> 1.35307040E+11
fma0226  fma    2126341.02   63491.5152    302427455  -> 1.35307041E+11  Inexact Rounded


-- Infinite combinations
fmax0800 fma  Inf   Inf   Inf    ->  Infinity
fmax0801 fma  Inf   Inf  -Inf    ->  NaN Invalid_operation
fmax0802 fma  Inf  -Inf   Inf    ->  NaN Invalid_operation
fmax0803 fma  Inf  -Inf  -Inf    -> -Infinity
fmax0804 fma -Inf   Inf   Inf    ->  NaN Invalid_operation
fmax0805 fma -Inf   Inf  -Inf    -> -Infinity
fmax0806 fma -Inf  -Inf   Inf    ->  Infinity
fmax0807 fma -Inf  -Inf  -Inf    ->  NaN Invalid_operation

-- Triple NaN propagation
fmax0900 fma  NaN2  NaN3  NaN5   ->  NaN2
fmax0901 fma  0     NaN3  NaN5   ->  NaN3
fmax0902 fma  0     0     NaN5   ->  NaN5
-- first sNaN wins (consider qNaN from earlier sNaN being
-- overridden by an sNaN in third operand)
fmax0903 fma  sNaN1 sNaN2 sNaN3  ->  NaN1 Invalid_operation
fmax0904 fma  0     sNaN2 sNaN3  ->  NaN2 Invalid_operation
fmax0905 fma  0     0     sNaN3  ->  NaN3 Invalid_operation
fmax0906 fma  sNaN1 sNaN2 sNaN3  ->  NaN1 Invalid_operation
fmax0907 fma  NaN7  sNaN2 sNaN3  ->  NaN2 Invalid_operation
fmax0908 fma  NaN7  NaN5  sNaN3  ->  NaN3 Invalid_operation

-- MULTIPLICATION TESTS ------------------------------------------------
-- sanity checks (as base, above)
fmax2000 fma 2      2  0E+999999  -> 4
fmax2001 fma 2      3  0E+999999  -> 6
fmax2002 fma 5      1  0E+999999  -> 5
fmax2003 fma 5      2  0E+999999  -> 10
fmax2004 fma 1.20   2  0E+999999  -> 2.40
fmax2005 fma 1.20   0  0E+999999  -> 0.00
fmax2006 fma 1.20  -2  0E+999999  -> -2.40
fmax2007 fma -1.20  2  0E+999999  -> -2.40
fmax2008 fma -1.20  0  0E+999999  -> 0.00
fmax2009 fma -1.20 -2  0E+999999  -> 2.40
fmax2010 fma 5.09 7.1  0E+999999  -> 36.139
fmax2011 fma 2.5    4  0E+999999  -> 10.0
fmax2012 fma 2.50   4  0E+999999  -> 10.00
fmax2013 fma 1.23456789 1.00000000  0E+999999  -> 1.23456789 Rounded
fmax2014 fma 9.999999999 9.999999999  0E+999999  -> 100.000000 Inexact Rounded
fmax2015 fma 2.50   4  0E+999999  -> 10.00
precision: 6
fmax2016 fma 2.50   4  0E+999999  -> 10.00
fmax2017 fma  9.999999  9.999999  0E+999999  ->  100.000 Inexact Rounded
fmax2018 fma  9.999999 -9.999999  0E+999999  -> -100.000 Inexact Rounded
fmax2019 fma -9.999999  9.999999  0E+999999  -> -100.000 Inexact Rounded
fmax2020 fma -9.999999 -9.999999  0E+999999  ->  100.000 Inexact Rounded

-- 1999.12.21: next one is a edge case if intermediate longs are used
precision: 15
fmax2059 fma 999999999999 9765625  0E+999999  -> 9.76562499999023E+18 Inexact Rounded
precision: 30
fmax2160 fma 999999999999 9765625  0E+999999  -> 9765624999990234375
precision: 9
-----

-- zeros, etc.
fmax2021 fma  0      0      0E+999999  ->  0
fmax2022 fma  0     -0      0E+999999  ->  0
fmax2023 fma -0      0      0E+999999  ->  0
fmax2024 fma -0     -0      0E+999999  ->  0
fmax2025 fma -0.0   -0.0    0E+999999  ->  0.00
fmax2026 fma -0.0   -0.0    0E+999999  ->  0.00
fmax2027 fma -0.0   -0.0    0E+999999  ->  0.00
fmax2028 fma -0.0   -0.0    0E+999999  ->  0.00
fmax2030 fma  5.00   1E-3   0E+999999  ->  0.00500
fmax2031 fma  00.00  0.000  0E+999999  ->  0.00000
fmax2032 fma  00.00  0E-3   0E+999999  ->  0.00000     -- rhs is 0
fmax2033 fma  0E-3   00.00  0E+999999  ->  0.00000     -- lhs is 0
fmax2034 fma -5.00   1E-3   0E+999999  -> -0.00500
fmax2035 fma -00.00  0.000  0E+999999  ->  0.00000
fmax2036 fma -00.00  0E-3   0E+999999  ->  0.00000     -- rhs is 0
fmax2037 fma -0E-3   00.00  0E+999999  ->  0.00000     -- lhs is 0
fmax2038 fma  5.00  -1E-3   0E+999999  -> -0.00500
fmax2039 fma  00.00 -0.000  0E+999999  ->  0.00000
fmax2040 fma  00.00 -0E-3   0E+999999  ->  0.00000     -- rhs is 0
fmax2041 fma  0E-3  -00.00  0E+999999  ->  0.00000     -- lhs is 0
fmax2042 fma -5.00  -1E-3   0E+999999  ->  0.00500
fmax2043 fma -00.00 -0.000  0E+999999  ->  0.00000
fmax2044 fma -00.00 -0E-3   0E+999999  ->  0.00000     -- rhs is 0
fmax2045 fma -0E-3  -00.00  0E+999999  ->  0.00000     -- lhs is 0

-- examples from decarith multiply
fmax2050 fma 1.20 3         0E+999999  -> 3.60
fmax2051 fma 7    3         0E+999999  -> 21
fmax2052 fma 0.9  0.8       0E+999999  -> 0.72
fmax2053 fma 0.9  -0        0E+999999  -> 0.0
fmax2054 fma 654321 654321  0E+999999  -> 4.28135971E+11  Inexact Rounded

fmax2060 fma 123.45 1e7   0E+999999  ->  1.2345E+9
fmax2061 fma 123.45 1e8   0E+999999  ->  1.2345E+10
fmax2062 fma 123.45 1e+9  0E+999999  ->  1.2345E+11
fmax2063 fma 123.45 1e10  0E+999999  ->  1.2345E+12
fmax2064 fma 123.45 1e11  0E+999999  ->  1.2345E+13
fmax2065 fma 123.45 1e12  0E+999999  ->  1.2345E+14
fmax2066 fma 123.45 1e13  0E+999999  ->  1.2345E+15


-- test some intermediate lengths
precision: 9
fmax2080 fma 0.1 123456789           0E+999999  -> 12345678.9
fmax2081 fma 0.1 1234567891          0E+999999  -> 123456789 Inexact Rounded
fmax2082 fma 0.1 12345678912         0E+999999  -> 1.23456789E+9 Inexact Rounded
fmax2083 fma 0.1 12345678912345      0E+999999  -> 1.23456789E+12 Inexact Rounded
fmax2084 fma 0.1 123456789           0E+999999  -> 12345678.9
precision: 8
fmax2085 fma 0.1 12345678912         0E+999999  -> 1.2345679E+9 Inexact Rounded
fmax2086 fma 0.1 12345678912345      0E+999999  -> 1.2345679E+12 Inexact Rounded
precision: 7
fmax2087 fma 0.1 12345678912         0E+999999  -> 1.234568E+9 Inexact Rounded
fmax2088 fma 0.1 12345678912345      0E+999999  -> 1.234568E+12 Inexact Rounded

precision: 9
fmax2090 fma 123456789          0.1  0E+999999  -> 12345678.9
fmax2091 fma 1234567891         0.1  0E+999999  -> 123456789 Inexact Rounded
fmax2092 fma 12345678912        0.1  0E+999999  -> 1.23456789E+9 Inexact Rounded
fmax2093 fma 12345678912345     0.1  0E+999999  -> 1.23456789E+12 Inexact Rounded
fmax2094 fma 123456789          0.1  0E+999999  -> 12345678.9
precision: 8
fmax2095 fma 12345678912        0.1  0E+999999  -> 1.2345679E+9 Inexact Rounded
fmax2096 fma 12345678912345     0.1  0E+999999  -> 1.2345679E+12 Inexact Rounded
precision: 7
fmax2097 fma 12345678912        0.1  0E+999999  -> 1.234568E+9 Inexact Rounded
fmax2098 fma 12345678912345     0.1  0E+999999  -> 1.234568E+12 Inexact Rounded

-- test some more edge cases and carries
maxexponent: 9999
minexponent: -9999
precision: 33
fmax2101 fma 9 9    0E+999999  -> 81
fmax2102 fma 9 90    0E+999999  -> 810
fmax2103 fma 9 900    0E+999999  -> 8100
fmax2104 fma 9 9000    0E+999999  -> 81000
fmax2105 fma 9 90000    0E+999999  -> 810000
fmax2106 fma 9 900000    0E+999999  -> 8100000
fmax2107 fma 9 9000000    0E+999999  -> 81000000
fmax2108 fma 9 90000000    0E+999999  -> 810000000
fmax2109 fma 9 900000000    0E+999999  -> 8100000000
fmax2110 fma 9 9000000000    0E+999999  -> 81000000000
fmax2111 fma 9 90000000000    0E+999999  -> 810000000000
fmax2112 fma 9 900000000000    0E+999999  -> 8100000000000
fmax2113 fma 9 9000000000000    0E+999999  -> 81000000000000
fmax2114 fma 9 90000000000000    0E+999999  -> 810000000000000
fmax2115 fma 9 900000000000000    0E+999999  -> 8100000000000000
fmax2116 fma 9 9000000000000000    0E+999999  -> 81000000000000000
fmax2117 fma 9 90000000000000000    0E+999999  -> 810000000000000000
fmax2118 fma 9 900000000000000000    0E+999999  -> 8100000000000000000
fmax2119 fma 9 9000000000000000000    0E+999999  -> 81000000000000000000
fmax2120 fma 9 90000000000000000000    0E+999999  -> 810000000000000000000
fmax2121 fma 9 900000000000000000000    0E+999999  -> 8100000000000000000000
fmax2122 fma 9 9000000000000000000000    0E+999999  -> 81000000000000000000000
fmax2123 fma 9 90000000000000000000000    0E+999999  -> 810000000000000000000000
-- test some more edge cases without carries
fmax2131 fma 3 3    0E+999999  -> 9
fmax2132 fma 3 30    0E+999999  -> 90
fmax2133 fma 3 300    0E+999999  -> 900
fmax2134 fma 3 3000    0E+999999  -> 9000
fmax2135 fma 3 30000    0E+999999  -> 90000
fmax2136 fma 3 300000    0E+999999  -> 900000
fmax2137 fma 3 3000000    0E+999999  -> 9000000
fmax2138 fma 3 30000000    0E+999999  -> 90000000
fmax2139 fma 3 300000000    0E+999999  -> 900000000
fmax2140 fma 3 3000000000    0E+999999  -> 9000000000
fmax2141 fma 3 30000000000    0E+999999  -> 90000000000
fmax2142 fma 3 300000000000    0E+999999  -> 900000000000
fmax2143 fma 3 3000000000000    0E+999999  -> 9000000000000
fmax2144 fma 3 30000000000000    0E+999999  -> 90000000000000
fmax2145 fma 3 300000000000000    0E+999999  -> 900000000000000
fmax2146 fma 3 3000000000000000    0E+999999  -> 9000000000000000
fmax2147 fma 3 30000000000000000    0E+999999  -> 90000000000000000
fmax2148 fma 3 300000000000000000    0E+999999  -> 900000000000000000
fmax2149 fma 3 3000000000000000000    0E+999999  -> 9000000000000000000
fmax2150 fma 3 30000000000000000000    0E+999999  -> 90000000000000000000
fmax2151 fma 3 300000000000000000000    0E+999999  -> 900000000000000000000
fmax2152 fma 3 3000000000000000000000    0E+999999  -> 9000000000000000000000
fmax2153 fma 3 30000000000000000000000    0E+999999  -> 90000000000000000000000

maxexponent: 999999
minexponent: -999999
precision: 9
-- test some cases that are close to exponent overflow/underflow
fmax2170 fma 1 9e999999     0E+999999  -> 9E+999999
fmax2171 fma 1 9.9e999999   0E+999999  -> 9.9E+999999
fmax2172 fma 1 9.99e999999  0E+999999  -> 9.99E+999999
fmax2173 fma 9e999999    1  0E+999999  -> 9E+999999
fmax2174 fma 9.9e999999  1  0E+999999  -> 9.9E+999999
fmax2176 fma 9.99e999999 1  0E+999999  -> 9.99E+999999
fmax2177 fma 1 9.99999e999999  0E+999999  -> 9.99999E+999999
fmax2178 fma 9.99999e999999 1  0E+999999  -> 9.99999E+999999

fmax2180 fma 0.1 9e-999998    0E+999999  -> 9E-999999
fmax2181 fma 0.1 99e-999998   0E+999999  -> 9.9E-999998
fmax2182 fma 0.1 999e-999998  0E+999999  -> 9.99E-999997

fmax2183 fma 0.1 9e-999998      0E+999999  -> 9E-999999
fmax2184 fma 0.1 99e-999998     0E+999999  -> 9.9E-999998
fmax2185 fma 0.1 999e-999998    0E+999999  -> 9.99E-999997
fmax2186 fma 0.1 999e-999997    0E+999999  -> 9.99E-999996
fmax2187 fma 0.1 9999e-999997   0E+999999  -> 9.999E-999995
fmax2188 fma 0.1 99999e-999997  0E+999999  -> 9.9999E-999994

fmax2190 fma 1 9e-999998    0E+999999  -> 9E-999998
fmax2191 fma 1 99e-999998   0E+999999  -> 9.9E-999997
fmax2192 fma 1 999e-999998  0E+999999  -> 9.99E-999996
fmax2193 fma 9e-999998   1  0E+999999  -> 9E-999998
fmax2194 fma 99e-999998  1  0E+999999  -> 9.9E-999997
fmax2195 fma 999e-999998 1  0E+999999  -> 9.99E-999996

-- long operand triangle
precision: 33
fmax2246 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.290801193369671916511992830 Inexact Rounded
precision: 32
fmax2247 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.29080119336967191651199283  Inexact Rounded
precision: 31
fmax2248 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.2908011933696719165119928   Inexact Rounded
precision: 30
fmax2249 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.290801193369671916511993    Inexact Rounded
precision: 29
fmax2250 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.29080119336967191651199     Inexact Rounded
precision: 28
fmax2251 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.2908011933696719165120      Inexact Rounded
precision: 27
fmax2252 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.290801193369671916512       Inexact Rounded
precision: 26
fmax2253 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.29080119336967191651        Inexact Rounded
precision: 25
fmax2254 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.2908011933696719165         Inexact Rounded
precision: 24
fmax2255 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.290801193369671917          Inexact Rounded
precision: 23
fmax2256 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.29080119336967192           Inexact Rounded
precision: 22
fmax2257 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.2908011933696719            Inexact Rounded
precision: 21
fmax2258 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.290801193369672             Inexact Rounded
precision: 20
fmax2259 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.29080119336967              Inexact Rounded
precision: 19
fmax2260 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.2908011933697               Inexact Rounded
precision: 18
fmax2261 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.290801193370                Inexact Rounded
precision: 17
fmax2262 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.29080119337                 Inexact Rounded
precision: 16
fmax2263 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.2908011934                  Inexact Rounded
precision: 15
fmax2264 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.290801193                   Inexact Rounded
precision: 14
fmax2265 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.29080119                    Inexact Rounded
precision: 13
fmax2266 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.2908012                     Inexact Rounded
precision: 12
fmax2267 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.290801                      Inexact Rounded
precision: 11
fmax2268 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.29080                       Inexact Rounded
precision: 10
fmax2269 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.2908                        Inexact Rounded
precision:  9
fmax2270 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.291                         Inexact Rounded
precision:  8
fmax2271 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.29                          Inexact Rounded
precision:  7
fmax2272 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433.3                           Inexact Rounded
precision:  6
fmax2273 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 145433                            Inexact Rounded
precision:  5
fmax2274 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 1.4543E+5                         Inexact Rounded
precision:  4
fmax2275 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 1.454E+5                         Inexact Rounded
precision:  3
fmax2276 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 1.45E+5                         Inexact Rounded
precision:  2
fmax2277 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 1.5E+5                         Inexact Rounded
precision:  1
fmax2278 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543  0E+999999  -> 1E+5                          Inexact Rounded

-- test some edge cases with exact rounding
maxexponent: 9999
minexponent: -9999
precision: 9
fmax2301 fma 9 9    0E+999999  -> 81
fmax2302 fma 9 90    0E+999999  -> 810
fmax2303 fma 9 900    0E+999999  -> 8100
fmax2304 fma 9 9000    0E+999999  -> 81000
fmax2305 fma 9 90000    0E+999999  -> 810000
fmax2306 fma 9 900000    0E+999999  -> 8100000
fmax2307 fma 9 9000000    0E+999999  -> 81000000
fmax2308 fma 9 90000000    0E+999999  -> 810000000
fmax2309 fma 9 900000000    0E+999999  -> 8.10000000E+9   Rounded
fmax2310 fma 9 9000000000    0E+999999  -> 8.10000000E+10  Rounded
fmax2311 fma 9 90000000000    0E+999999  -> 8.10000000E+11  Rounded
fmax2312 fma 9 900000000000    0E+999999  -> 8.10000000E+12  Rounded
fmax2313 fma 9 9000000000000    0E+999999  -> 8.10000000E+13  Rounded
fmax2314 fma 9 90000000000000    0E+999999  -> 8.10000000E+14  Rounded
fmax2315 fma 9 900000000000000    0E+999999  -> 8.10000000E+15  Rounded
fmax2316 fma 9 9000000000000000    0E+999999  -> 8.10000000E+16  Rounded
fmax2317 fma 9 90000000000000000    0E+999999  -> 8.10000000E+17  Rounded
fmax2318 fma 9 900000000000000000    0E+999999  -> 8.10000000E+18  Rounded
fmax2319 fma 9 9000000000000000000    0E+999999  -> 8.10000000E+19  Rounded
fmax2320 fma 9 90000000000000000000    0E+999999  -> 8.10000000E+20  Rounded
fmax2321 fma 9 900000000000000000000    0E+999999  -> 8.10000000E+21  Rounded
fmax2322 fma 9 9000000000000000000000    0E+999999  -> 8.10000000E+22  Rounded
fmax2323 fma 9 90000000000000000000000    0E+999999  -> 8.10000000E+23  Rounded

-- fastpath breakers
precision:   29
fmax2330 fma 1.491824697641270317824852952837224 1.105170918075647624811707826490246514675628614562883537345747603  0E+999999  -> 1.6487212707001281468486507878 Inexact Rounded
precision:   55
fmax2331 fma 0.8958341352965282506768545828765117803873717284891040428 0.8958341352965282506768545828765117803873717284891040428  0E+999999  -> 0.8025187979624784829842553829934069955890983696752228299 Inexact Rounded


-- tryzeros cases
precision:   7
rounding:    half_up
maxExponent: 92
minexponent: -92
fmax2504  fma  0E-60 1000E-60   0E+999999  -> 0E-98 Clamped
fmax2505  fma  100E+60 0E+60    0E+999999  -> 0E+92 Clamped

-- mixed with zeros
maxexponent: 999999
minexponent: -999999
precision: 9
fmax2541 fma  0    -1      0E+999999  ->  0
fmax2542 fma -0    -1      0E+999999  ->  0
fmax2543 fma  0     1      0E+999999  ->  0
fmax2544 fma -0     1      0E+999999  ->  0
fmax2545 fma -1     0      0E+999999  ->  0
fmax2546 fma -1    -0      0E+999999  ->  0
fmax2547 fma  1     0      0E+999999  ->  0
fmax2548 fma  1    -0      0E+999999  ->  0

fmax2551 fma  0.0  -1      0E+999999  ->  0.0
fmax2552 fma -0.0  -1      0E+999999  ->  0.0
fmax2553 fma  0.0   1      0E+999999  ->  0.0
fmax2554 fma -0.0   1      0E+999999  ->  0.0
fmax2555 fma -1.0   0      0E+999999  ->  0.0
fmax2556 fma -1.0  -0      0E+999999  ->  0.0
fmax2557 fma  1.0   0      0E+999999  ->  0.0
fmax2558 fma  1.0  -0      0E+999999  ->  0.0

fmax2561 fma  0    -1.0    0E+999999  ->  0.0
fmax2562 fma -0    -1.0    0E+999999  ->  0.0
fmax2563 fma  0     1.0    0E+999999  ->  0.0
fmax2564 fma -0     1.0    0E+999999  ->  0.0
fmax2565 fma -1     0.0    0E+999999  ->  0.0
fmax2566 fma -1    -0.0    0E+999999  ->  0.0
fmax2567 fma  1     0.0    0E+999999  ->  0.0
fmax2568 fma  1    -0.0    0E+999999  ->  0.0

fmax2571 fma  0.0  -1.0    0E+999999  ->  0.00
fmax2572 fma -0.0  -1.0    0E+999999  ->  0.00
fmax2573 fma  0.0   1.0    0E+999999  ->  0.00
fmax2574 fma -0.0   1.0    0E+999999  ->  0.00
fmax2575 fma -1.0   0.0    0E+999999  ->  0.00
fmax2576 fma -1.0  -0.0    0E+999999  ->  0.00
fmax2577 fma  1.0   0.0    0E+999999  ->  0.00
fmax2578 fma  1.0  -0.0    0E+999999  ->  0.00


-- Specials
fmax2580 fma  Inf  -Inf    0E+999999  -> -Infinity
fmax2581 fma  Inf  -1000   0E+999999  -> -Infinity
fmax2582 fma  Inf  -1      0E+999999  -> -Infinity
fmax2583 fma  Inf  -0      0E+999999  ->  NaN  Invalid_operation
fmax2584 fma  Inf   0      0E+999999  ->  NaN  Invalid_operation
fmax2585 fma  Inf   1      0E+999999  ->  Infinity
fmax2586 fma  Inf   1000   0E+999999  ->  Infinity
fmax2587 fma  Inf   Inf    0E+999999  ->  Infinity
fmax2588 fma -1000  Inf    0E+999999  -> -Infinity
fmax2589 fma -Inf   Inf    0E+999999  -> -Infinity
fmax2590 fma -1     Inf    0E+999999  -> -Infinity
fmax2591 fma -0     Inf    0E+999999  ->  NaN  Invalid_operation
fmax2592 fma  0     Inf    0E+999999  ->  NaN  Invalid_operation
fmax2593 fma  1     Inf    0E+999999  ->  Infinity
fmax2594 fma  1000  Inf    0E+999999  ->  Infinity
fmax2595 fma  Inf   Inf    0E+999999  ->  Infinity

fmax2600 fma -Inf  -Inf    0E+999999  ->  Infinity
fmax2601 fma -Inf  -1000   0E+999999  ->  Infinity
fmax2602 fma -Inf  -1      0E+999999  ->  Infinity
fmax2603 fma -Inf  -0      0E+999999  ->  NaN  Invalid_operation
fmax2604 fma -Inf   0      0E+999999  ->  NaN  Invalid_operation
fmax2605 fma -Inf   1      0E+999999  -> -Infinity
fmax2606 fma -Inf   1000   0E+999999  -> -Infinity
fmax2607 fma -Inf   Inf    0E+999999  -> -Infinity
fmax2608 fma -1000  Inf    0E+999999  -> -Infinity
fmax2609 fma -Inf  -Inf    0E+999999  ->  Infinity
fmax2610 fma -1    -Inf    0E+999999  ->  Infinity
fmax2611 fma -0    -Inf    0E+999999  ->  NaN  Invalid_operation
fmax2612 fma  0    -Inf    0E+999999  ->  NaN  Invalid_operation
fmax2613 fma  1    -Inf    0E+999999  -> -Infinity
fmax2614 fma  1000 -Inf    0E+999999  -> -Infinity
fmax2615 fma  Inf  -Inf    0E+999999  -> -Infinity

fmax2621 fma  NaN -Inf     0E+999999  ->  NaN
fmax2622 fma  NaN -1000    0E+999999  ->  NaN
fmax2623 fma  NaN -1       0E+999999  ->  NaN
fmax2624 fma  NaN -0       0E+999999  ->  NaN
fmax2625 fma  NaN  0       0E+999999  ->  NaN
fmax2626 fma  NaN  1       0E+999999  ->  NaN
fmax2627 fma  NaN  1000    0E+999999  ->  NaN
fmax2628 fma  NaN  Inf     0E+999999  ->  NaN
fmax2629 fma  NaN  NaN     0E+999999  ->  NaN
fmax2630 fma -Inf  NaN     0E+999999  ->  NaN
fmax2631 fma -1000 NaN     0E+999999  ->  NaN
fmax2632 fma -1    NaN     0E+999999  ->  NaN
fmax2633 fma -0    NaN     0E+999999  ->  NaN
fmax2634 fma  0    NaN     0E+999999  ->  NaN
fmax2635 fma  1    NaN     0E+999999  ->  NaN
fmax2636 fma  1000 NaN     0E+999999  ->  NaN
fmax2637 fma  Inf  NaN     0E+999999  ->  NaN

fmax2641 fma  sNaN -Inf    0E+999999  ->  NaN  Invalid_operation
fmax2642 fma  sNaN -1000   0E+999999  ->  NaN  Invalid_operation
fmax2643 fma  sNaN -1      0E+999999  ->  NaN  Invalid_operation
fmax2644 fma  sNaN -0      0E+999999  ->  NaN  Invalid_operation
fmax2645 fma  sNaN  0      0E+999999  ->  NaN  Invalid_operation
fmax2646 fma  sNaN  1      0E+999999  ->  NaN  Invalid_operation
fmax2647 fma  sNaN  1000   0E+999999  ->  NaN  Invalid_operation
fmax2648 fma  sNaN  NaN    0E+999999  ->  NaN  Invalid_operation
fmax2649 fma  sNaN sNaN    0E+999999  ->  NaN  Invalid_operation
fmax2650 fma  NaN  sNaN    0E+999999  ->  NaN  Invalid_operation
fmax2651 fma -Inf  sNaN    0E+999999  ->  NaN  Invalid_operation
fmax2652 fma -1000 sNaN    0E+999999  ->  NaN  Invalid_operation
fmax2653 fma -1    sNaN    0E+999999  ->  NaN  Invalid_operation
fmax2654 fma -0    sNaN    0E+999999  ->  NaN  Invalid_operation
fmax2655 fma  0    sNaN    0E+999999  ->  NaN  Invalid_operation
fmax2656 fma  1    sNaN    0E+999999  ->  NaN  Invalid_operation
fmax2657 fma  1000 sNaN    0E+999999  ->  NaN  Invalid_operation
fmax2658 fma  Inf  sNaN    0E+999999  ->  NaN  Invalid_operation
fmax2659 fma  NaN  sNaN    0E+999999  ->  NaN  Invalid_operation

-- propagating NaNs
fmax2661 fma  NaN9 -Inf    0E+999999  ->  NaN9
fmax2662 fma  NaN8  999    0E+999999  ->  NaN8
fmax2663 fma  NaN71 Inf    0E+999999  ->  NaN71
fmax2664 fma  NaN6  NaN5   0E+999999  ->  NaN6
fmax2665 fma -Inf   NaN4   0E+999999  ->  NaN4
fmax2666 fma -999   NaN33  0E+999999  ->  NaN33
fmax2667 fma  Inf   NaN2   0E+999999  ->  NaN2

fmax2671 fma  sNaN99 -Inf     0E+999999  ->  NaN99 Invalid_operation
fmax2672 fma  sNaN98 -11      0E+999999  ->  NaN98 Invalid_operation
fmax2673 fma  sNaN97  NaN     0E+999999  ->  NaN97 Invalid_operation
fmax2674 fma  sNaN16 sNaN94   0E+999999  ->  NaN16 Invalid_operation
fmax2675 fma  NaN95  sNaN93   0E+999999  ->  NaN93 Invalid_operation
fmax2676 fma -Inf    sNaN92   0E+999999  ->  NaN92 Invalid_operation
fmax2677 fma  088    sNaN91   0E+999999  ->  NaN91 Invalid_operation
fmax2678 fma  Inf    sNaN90   0E+999999  ->  NaN90 Invalid_operation
fmax2679 fma  NaN    sNaN89   0E+999999  ->  NaN89 Invalid_operation

fmax2681 fma -NaN9 -Inf    0E+999999  -> -NaN9
fmax2682 fma -NaN8  999    0E+999999  -> -NaN8
fmax2683 fma -NaN71 Inf    0E+999999  -> -NaN71
fmax2684 fma -NaN6 -NaN5   0E+999999  -> -NaN6
fmax2685 fma -Inf  -NaN4   0E+999999  -> -NaN4
fmax2686 fma -999  -NaN33  0E+999999  -> -NaN33
fmax2687 fma  Inf  -NaN2   0E+999999  -> -NaN2

fmax2691 fma -sNaN99 -Inf     0E+999999  -> -NaN99 Invalid_operation
fmax2692 fma -sNaN98 -11      0E+999999  -> -NaN98 Invalid_operation
fmax2693 fma -sNaN97  NaN     0E+999999  -> -NaN97 Invalid_operation
fmax2694 fma -sNaN16 -sNaN94  0E+999999  -> -NaN16 Invalid_operation
fmax2695 fma -NaN95  -sNaN93  0E+999999  -> -NaN93 Invalid_operation
fmax2696 fma -Inf    -sNaN92  0E+999999  -> -NaN92 Invalid_operation
fmax2697 fma  088    -sNaN91  0E+999999  -> -NaN91 Invalid_operation
fmax2698 fma  Inf    -sNaN90  0E+999999  -> -NaN90 Invalid_operation
fmax2699 fma -NaN    -sNaN89  0E+999999  -> -NaN89 Invalid_operation

fmax2701 fma -NaN  -Inf    0E+999999  -> -NaN
fmax2702 fma -NaN   999    0E+999999  -> -NaN
fmax2703 fma -NaN   Inf    0E+999999  -> -NaN
fmax2704 fma -NaN  -NaN    0E+999999  -> -NaN
fmax2705 fma -Inf  -NaN0   0E+999999  -> -NaN
fmax2706 fma -999  -NaN    0E+999999  -> -NaN
fmax2707 fma  Inf  -NaN    0E+999999  -> -NaN

fmax2711 fma -sNaN   -Inf     0E+999999  -> -NaN Invalid_operation
fmax2712 fma -sNaN   -11      0E+999999  -> -NaN Invalid_operation
fmax2713 fma -sNaN00  NaN     0E+999999  -> -NaN Invalid_operation
fmax2714 fma -sNaN   -sNaN    0E+999999  -> -NaN Invalid_operation
fmax2715 fma -NaN    -sNaN    0E+999999  -> -NaN Invalid_operation
fmax2716 fma -Inf    -sNaN    0E+999999  -> -NaN Invalid_operation
fmax2717 fma  088    -sNaN    0E+999999  -> -NaN Invalid_operation
fmax2718 fma  Inf    -sNaN    0E+999999  -> -NaN Invalid_operation
fmax2719 fma -NaN    -sNaN    0E+999999  -> -NaN Invalid_operation

-- overflow and underflow tests .. note subnormal results
maxexponent: 999999
minexponent: -999999
fmax2730 fma +1.23456789012345E-0 9E+999999  0E+999999  -> Infinity Inexact Overflow Rounded
fmax2731 fma 9E+999999 +1.23456789012345E-0  0E+999999  -> Infinity Inexact Overflow Rounded
fmax2732 fma +0.100 9E-999999  0E+999999  -> 9.00E-1000000 Subnormal
fmax2733 fma 9E-999999 +0.100  0E+999999  -> 9.00E-1000000 Subnormal
fmax2735 fma -1.23456789012345E-0 9E+999999  0E+999999  -> -Infinity Inexact Overflow Rounded
fmax2736 fma 9E+999999 -1.23456789012345E-0  0E+999999  -> -Infinity Inexact Overflow Rounded
fmax2737 fma -0.100 9E-999999  0E+999999  -> -9.00E-1000000 Subnormal
fmax2738 fma 9E-999999 -0.100  0E+999999  -> -9.00E-1000000 Subnormal

-- signs
fmax2751 fma  1e+777777  1e+411111  0E+999999  ->  Infinity Overflow Inexact Rounded
fmax2752 fma  1e+777777 -1e+411111  0E+999999  -> -Infinity Overflow Inexact Rounded
fmax2753 fma -1e+777777  1e+411111  0E+999999  -> -Infinity Overflow Inexact Rounded
fmax2754 fma -1e+777777 -1e+411111  0E+999999  ->  Infinity Overflow Inexact Rounded
fmax2755 fma  1e-777777  1e-411111  0E+999999  ->  0E-1000007 Underflow Subnormal Inexact Rounded Clamped
fmax2756 fma  1e-777777 -1e-411111  0E+999999  -> -0E-1000007 Underflow Subnormal Inexact Rounded Clamped
fmax2757 fma -1e-777777  1e-411111  0E+999999  -> -0E-1000007 Underflow Subnormal Inexact Rounded Clamped
fmax2758 fma -1e-777777 -1e-411111  0E+999999  ->  0E-1000007 Underflow Subnormal Inexact Rounded Clamped

-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
precision: 9
fmax2760 fma 1e-600000 1e-400001  0E+999999  -> 1E-1000001 Subnormal
fmax2761 fma 1e-600000 1e-400002  0E+999999  -> 1E-1000002 Subnormal
fmax2762 fma 1e-600000 1e-400003  0E+999999  -> 1E-1000003 Subnormal
fmax2763 fma 1e-600000 1e-400004  0E+999999  -> 1E-1000004 Subnormal
fmax2764 fma 1e-600000 1e-400005  0E+999999  -> 1E-1000005 Subnormal
fmax2765 fma 1e-600000 1e-400006  0E+999999  -> 1E-1000006 Subnormal
fmax2766 fma 1e-600000 1e-400007  0E+999999  -> 1E-1000007 Subnormal
fmax2767 fma 1e-600000 1e-400008  0E+999999  -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
fmax2768 fma 1e-600000 1e-400009  0E+999999  -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
fmax2769 fma 1e-600000 1e-400010  0E+999999  -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-- [no equivalent of 'subnormal' for overflow]
fmax2770 fma 1e+600000 1e+400001  0E+999999  -> Infinity Overflow Inexact Rounded
fmax2771 fma 1e+600000 1e+400002  0E+999999  -> Infinity Overflow Inexact Rounded
fmax2772 fma 1e+600000 1e+400003  0E+999999  -> Infinity Overflow Inexact Rounded
fmax2773 fma 1e+600000 1e+400004  0E+999999  -> Infinity Overflow Inexact Rounded
fmax2774 fma 1e+600000 1e+400005  0E+999999  -> Infinity Overflow Inexact Rounded
fmax2775 fma 1e+600000 1e+400006  0E+999999  -> Infinity Overflow Inexact Rounded
fmax2776 fma 1e+600000 1e+400007  0E+999999  -> Infinity Overflow Inexact Rounded
fmax2777 fma 1e+600000 1e+400008  0E+999999  -> Infinity Overflow Inexact Rounded
fmax2778 fma 1e+600000 1e+400009  0E+999999  -> Infinity Overflow Inexact Rounded
fmax2779 fma 1e+600000 1e+400010  0E+999999  -> Infinity Overflow Inexact Rounded

-- 'subnormal' test edge condition at higher precisions
precision: 99
fmax2780 fma 1e-600000 1e-400007  0E+999999  -> 1E-1000007 Subnormal
fmax2781 fma 1e-600000 1e-400008  0E+999999  -> 1E-1000008 Subnormal
fmax2782 fma 1e-600000 1e-400097  0E+999999  -> 1E-1000097 Subnormal
fmax2783 fma 1e-600000 1e-400098  0E+999999  -> 0E-1000097 Underflow Subnormal Inexact Rounded Clamped
precision: 999
fmax2784 fma 1e-600000 1e-400997  0E+999999  -> 1E-1000997 Subnormal
fmax2785 fma 1e-600000 1e-400998  0E+999999  -> 0E-1000997 Underflow Subnormal Inexact Rounded Clamped

-- test subnormals rounding
precision:   5
maxExponent: 999
minexponent: -999
rounding:    half_even

fmax2801 fma  1.0000E-999  1      0E+999999  -> 1.0000E-999
fmax2802 fma  1.000E-999   1e-1   0E+999999  -> 1.000E-1000 Subnormal
fmax2803 fma  1.00E-999    1e-2   0E+999999  -> 1.00E-1001  Subnormal
fmax2804 fma  1.0E-999     1e-3   0E+999999  -> 1.0E-1002   Subnormal
fmax2805 fma  1.0E-999     1e-4   0E+999999  -> 1E-1003     Subnormal Rounded
fmax2806 fma  1.3E-999     1e-4   0E+999999  -> 1E-1003     Underflow Subnormal Inexact Rounded
fmax2807 fma  1.5E-999     1e-4   0E+999999  -> 2E-1003     Underflow Subnormal Inexact Rounded
fmax2808 fma  1.7E-999     1e-4   0E+999999  -> 2E-1003     Underflow Subnormal Inexact Rounded
fmax2809 fma  2.3E-999     1e-4   0E+999999  -> 2E-1003     Underflow Subnormal Inexact Rounded
fmax2810 fma  2.5E-999     1e-4   0E+999999  -> 2E-1003     Underflow Subnormal Inexact Rounded
fmax2811 fma  2.7E-999     1e-4   0E+999999  -> 3E-1003     Underflow Subnormal Inexact Rounded
fmax2812 fma  1.49E-999    1e-4   0E+999999  -> 1E-1003     Underflow Subnormal Inexact Rounded
fmax2813 fma  1.50E-999    1e-4   0E+999999  -> 2E-1003     Underflow Subnormal Inexact Rounded
fmax2814 fma  1.51E-999    1e-4   0E+999999  -> 2E-1003     Underflow Subnormal Inexact Rounded
fmax2815 fma  2.49E-999    1e-4   0E+999999  -> 2E-1003     Underflow Subnormal Inexact Rounded
fmax2816 fma  2.50E-999    1e-4   0E+999999  -> 2E-1003     Underflow Subnormal Inexact Rounded
fmax2817 fma  2.51E-999    1e-4   0E+999999  -> 3E-1003     Underflow Subnormal Inexact Rounded

fmax2818 fma  1E-999       1e-4   0E+999999  -> 1E-1003     Subnormal
fmax2819 fma  3E-999       1e-5   0E+999999  -> 0E-1003     Underflow Subnormal Inexact Rounded Clamped
fmax2820 fma  5E-999       1e-5   0E+999999  -> 0E-1003     Underflow Subnormal Inexact Rounded Clamped
fmax2821 fma  7E-999       1e-5   0E+999999  -> 1E-1003     Underflow Subnormal Inexact Rounded
fmax2822 fma  9E-999       1e-5   0E+999999  -> 1E-1003     Underflow Subnormal Inexact Rounded
fmax2823 fma  9.9E-999     1e-5   0E+999999  -> 1E-1003     Underflow Subnormal Inexact Rounded

fmax2824 fma  1E-999      -1e-4   0E+999999  -> -1E-1003    Subnormal
fmax2825 fma  3E-999      -1e-5   0E+999999  -> -0E-1003    Underflow Subnormal Inexact Rounded Clamped
fmax2826 fma -5E-999       1e-5   0E+999999  -> -0E-1003    Underflow Subnormal Inexact Rounded Clamped
fmax2827 fma  7E-999      -1e-5   0E+999999  -> -1E-1003    Underflow Subnormal Inexact Rounded
fmax2828 fma -9E-999       1e-5   0E+999999  -> -1E-1003    Underflow Subnormal Inexact Rounded
fmax2829 fma  9.9E-999    -1e-5   0E+999999  -> -1E-1003    Underflow Subnormal Inexact Rounded
fmax2830 fma  3.0E-999    -1e-5   0E+999999  -> -0E-1003    Underflow Subnormal Inexact Rounded Clamped

fmax2831 fma  1.0E-501     1e-501  0E+999999  -> 1.0E-1002   Subnormal
fmax2832 fma  2.0E-501     2e-501  0E+999999  -> 4.0E-1002   Subnormal
fmax2833 fma  4.0E-501     4e-501  0E+999999  -> 1.60E-1001  Subnormal
fmax2834 fma 10.0E-501    10e-501  0E+999999  -> 1.000E-1000 Subnormal
fmax2835 fma 30.0E-501    30e-501  0E+999999  -> 9.000E-1000 Subnormal
fmax2836 fma 40.0E-501    40e-501  0E+999999  -> 1.6000E-999

-- squares
fmax2840 fma  1E-502       1e-502  0E+999999  -> 0E-1003     Underflow Subnormal Inexact Rounded Clamped
fmax2841 fma  1E-501       1e-501  0E+999999  -> 1E-1002     Subnormal
fmax2842 fma  2E-501       2e-501  0E+999999  -> 4E-1002     Subnormal
fmax2843 fma  4E-501       4e-501  0E+999999  -> 1.6E-1001   Subnormal
fmax2844 fma 10E-501      10e-501  0E+999999  -> 1.00E-1000  Subnormal
fmax2845 fma 30E-501      30e-501  0E+999999  -> 9.00E-1000  Subnormal
fmax2846 fma 40E-501      40e-501  0E+999999  -> 1.600E-999

-- cubes
fmax2850 fma  1E-670     1e-335  0E+999999  -> 0E-1003    Underflow Subnormal Inexact Rounded Clamped
fmax2851 fma  1E-668     1e-334  0E+999999  -> 1E-1002    Subnormal
fmax2852 fma  4E-668     2e-334  0E+999999  -> 8E-1002    Subnormal
fmax2853 fma  9E-668     3e-334  0E+999999  -> 2.7E-1001  Subnormal
fmax2854 fma 16E-668     4e-334  0E+999999  -> 6.4E-1001  Subnormal
fmax2855 fma 25E-668     5e-334  0E+999999  -> 1.25E-1000 Subnormal
fmax2856 fma 10E-668   100e-334  0E+999999  -> 1.000E-999

-- test derived from result of 0.099 ** 999 at 15 digits with unlimited exponent
precision: 19
fmax2860 fma  6636851557994578716E-520 6636851557994578716E-520  0E+999999  -> 4.40477986028551E-1003 Underflow Subnormal Inexact Rounded

-- Long operand overflow may be a different path
precision: 3
maxExponent: 999999
minexponent: -999999
fmax2870 fma 1  9.999E+999999    0E+999999  ->  Infinity Inexact Overflow Rounded
fmax2871 fma 1 -9.999E+999999    0E+999999  -> -Infinity Inexact Overflow Rounded
fmax2872 fma    9.999E+999999 1  0E+999999  ->  Infinity Inexact Overflow Rounded
fmax2873 fma   -9.999E+999999 1  0E+999999  -> -Infinity Inexact Overflow Rounded

-- check for double-rounded subnormals
precision:   5
maxexponent: 79
minexponent: -79
fmax2881 fma  1.2347E-40  1.2347E-40   0E+999999  ->  1.524E-80  Inexact Rounded Subnormal Underflow
fmax2882 fma  1.234E-40  1.234E-40     0E+999999  ->  1.523E-80  Inexact Rounded Subnormal Underflow
fmax2883 fma  1.23E-40   1.23E-40      0E+999999  ->  1.513E-80  Inexact Rounded Subnormal Underflow
fmax2884 fma  1.2E-40    1.2E-40       0E+999999  ->  1.44E-80   Subnormal
fmax2885 fma  1.2E-40    1.2E-41       0E+999999  ->  1.44E-81   Subnormal
fmax2886 fma  1.2E-40    1.2E-42       0E+999999  ->  1.4E-82    Subnormal Inexact Rounded Underflow
fmax2887 fma  1.2E-40    1.3E-42       0E+999999  ->  1.6E-82    Subnormal Inexact Rounded Underflow
fmax2888 fma  1.3E-40    1.3E-42       0E+999999  ->  1.7E-82    Subnormal Inexact Rounded Underflow
fmax2889 fma  1.3E-40    1.3E-43       0E+999999  ->    2E-83    Subnormal Inexact Rounded Underflow
fmax2890 fma  1.3E-41    1.3E-43       0E+999999  ->    0E-83    Clamped Subnormal Inexact Rounded Underflow

fmax2891 fma  1.2345E-39   1.234E-40   0E+999999  ->  1.5234E-79 Inexact Rounded
fmax2892 fma  1.23456E-39  1.234E-40   0E+999999  ->  1.5234E-79 Inexact Rounded
fmax2893 fma  1.2345E-40   1.234E-40   0E+999999  ->  1.523E-80  Inexact Rounded Subnormal Underflow
fmax2894 fma  1.23456E-40  1.234E-40   0E+999999  ->  1.523E-80  Inexact Rounded Subnormal Underflow
fmax2895 fma  1.2345E-41   1.234E-40   0E+999999  ->  1.52E-81   Inexact Rounded Subnormal Underflow
fmax2896 fma  1.23456E-41  1.234E-40   0E+999999  ->  1.52E-81   Inexact Rounded Subnormal Underflow

-- Now explore the case where we get a normal result with Underflow
precision:   16
rounding:    half_up
maxExponent: 384
minExponent: -383

fmax2900 fma  0.3000000000E-191 0.3000000000E-191  0E+999999  -> 9.00000000000000E-384 Subnormal Rounded
fmax2901 fma  0.3000000001E-191 0.3000000001E-191  0E+999999  -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
fmax2902 fma  9.999999999999999E-383  0.0999999999999          0E+999999  -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
fmax2903 fma  9.999999999999999E-383  0.09999999999999         0E+999999  -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
fmax2904 fma  9.999999999999999E-383  0.099999999999999        0E+999999  -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
fmax2905 fma  9.999999999999999E-383  0.0999999999999999       0E+999999  -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
-- prove operands are exact
fmax2906 fma  9.999999999999999E-383  1                        0E+999999  -> 9.999999999999999E-383
fmax2907 fma                       1  0.09999999999999999      0E+999999  -> 0.09999999999999999
-- the next rounds to Nmin
fmax2908 fma  9.999999999999999E-383  0.09999999999999999      0E+999999  -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
fmax2909 fma  9.999999999999999E-383  0.099999999999999999     0E+999999  -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
fmax2910 fma  9.999999999999999E-383  0.0999999999999999999    0E+999999  -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
fmax2911 fma  9.999999999999999E-383  0.09999999999999999999   0E+999999  -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded

-- Examples from SQL proposal (Krishna Kulkarni)
precision:   34
rounding:    half_up
maxExponent: 6144
minExponent: -6143
fmax2921  fma 130E-2  120E-2  0E+999999  -> 1.5600
fmax2922  fma 130E-2  12E-1   0E+999999  -> 1.560
fmax2923  fma 130E-2  1E0     0E+999999  -> 1.30

-- Null tests
fmax2990 fma  # 10  0E+999999  -> NaN Invalid_operation
fmax2991 fma 10  #  0E+999999  -> NaN Invalid_operation

-- ADDITION TESTS ------------------------------------------------------
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

-- [first group are 'quick confidence check']
fmax3001 fma  1   1       1       ->  2
fmax3002 fma  1   2       3       ->  5
fmax3003 fma  1   '5.75'  '3.3'   ->  9.05
fmax3004 fma  1   '5'     '-3'    ->  2
fmax3005 fma  1   '-5'    '-3'    ->  -8
fmax3006 fma  1   '-7'    '2.5'   ->  -4.5
fmax3007 fma  1   '0.7'   '0.3'   ->  1.0
fmax3008 fma  1   '1.25'  '1.25'  ->  2.50
fmax3009 fma  1   '1.23456789'  '1.00000000' -> '2.23456789'
fmax3010 fma  1   '1.23456789'  '1.00000011' -> '2.23456800'

fmax3011 fma  1   '0.4444444444'  '0.5555555555' -> '1.00000000' Inexact Rounded
fmax3012 fma  1   '0.4444444440'  '0.5555555555' -> '1.00000000' Inexact Rounded
fmax3013 fma  1   '0.4444444444'  '0.5555555550' -> '0.999999999' Inexact Rounded
fmax3014 fma  1   '0.44444444449'    '0' -> '0.444444444' Inexact Rounded
fmax3015 fma  1   '0.444444444499'   '0' -> '0.444444444' Inexact Rounded
fmax3016 fma  1   '0.4444444444999'  '0' -> '0.444444444' Inexact Rounded
fmax3017 fma  1   '0.4444444445000'  '0' -> '0.444444445' Inexact Rounded
fmax3018 fma  1   '0.4444444445001'  '0' -> '0.444444445' Inexact Rounded
fmax3019 fma  1   '0.444444444501'   '0' -> '0.444444445' Inexact Rounded
fmax3020 fma  1   '0.44444444451'    '0' -> '0.444444445' Inexact Rounded

fmax3021 fma  1   0 1 -> 1
fmax3022 fma  1   1 1 -> 2
fmax3023 fma  1   2 1 -> 3
fmax3024 fma  1   3 1 -> 4
fmax3025 fma  1   4 1 -> 5
fmax3026 fma  1   5 1 -> 6
fmax3027 fma  1   6 1 -> 7
fmax3028 fma  1   7 1 -> 8
fmax3029 fma  1   8 1 -> 9
fmax3030 fma  1   9 1 -> 10

-- some carrying effects
fmax3031 fma  1   '0.9998'  '0.0000' -> '0.9998'
fmax3032 fma  1   '0.9998'  '0.0001' -> '0.9999'
fmax3033 fma  1   '0.9998'  '0.0002' -> '1.0000'
fmax3034 fma  1   '0.9998'  '0.0003' -> '1.0001'

fmax3035 fma  1   '70'  '10000e+9' -> '1.00000000E+13' Inexact Rounded
fmax3036 fma  1   '700'  '10000e+9' -> '1.00000000E+13' Inexact Rounded
fmax3037 fma  1   '7000'  '10000e+9' -> '1.00000000E+13' Inexact Rounded
fmax3038 fma  1   '70000'  '10000e+9' -> '1.00000001E+13' Inexact Rounded
fmax3039 fma  1   '700000'  '10000e+9' -> '1.00000007E+13' Rounded

-- symmetry:
fmax3040 fma  1   '10000e+9'  '70' -> '1.00000000E+13' Inexact Rounded
fmax3041 fma  1   '10000e+9'  '700' -> '1.00000000E+13' Inexact Rounded
fmax3042 fma  1   '10000e+9'  '7000' -> '1.00000000E+13' Inexact Rounded
fmax3044 fma  1   '10000e+9'  '70000' -> '1.00000001E+13' Inexact Rounded
fmax3045 fma  1   '10000e+9'  '700000' -> '1.00000007E+13' Rounded

-- same, higher precision
precision: 15
fmax3046 fma  1   '10000e+9'  '7' -> '10000000000007'
fmax3047 fma  1   '10000e+9'  '70' -> '10000000000070'
fmax3048 fma  1   '10000e+9'  '700' -> '10000000000700'
fmax3049 fma  1   '10000e+9'  '7000' -> '10000000007000'
fmax3050 fma  1   '10000e+9'  '70000' -> '10000000070000'
fmax3051 fma  1   '10000e+9'  '700000' -> '10000000700000'
fmax3052 fma  1   '10000e+9'  '7000000' -> '10000007000000'

-- examples from decarith
fmax3053 fma  1   '12' '7.00' -> '19.00'
fmax3054 fma  1   '1.3' '-1.07' -> '0.23'
fmax3055 fma  1   '1.3' '-1.30' -> '0.00'
fmax3056 fma  1   '1.3' '-2.07' -> '-0.77'
fmax3057 fma  1   '1E+2' '1E+4' -> '1.01E+4'

-- zero preservation
precision: 6
fmax3060 fma  1   '10000e+9'  '70000' -> '1.00000E+13' Inexact Rounded
fmax3061 fma  1   1 '0.0001' -> '1.0001'
fmax3062 fma  1   1 '0.00001' -> '1.00001'
fmax3063 fma  1   1 '0.000001' -> '1.00000' Inexact Rounded
fmax3064 fma  1   1 '0.0000001' -> '1.00000' Inexact Rounded
fmax3065 fma  1   1 '0.00000001' -> '1.00000' Inexact Rounded

-- some funny zeros [in case of bad signum]
fmax3070 fma  1   1  0    -> 1
fmax3071 fma  1   1 0.    -> 1
fmax3072 fma  1   1  .0   -> 1.0
fmax3073 fma  1   1 0.0   -> 1.0
fmax3074 fma  1   1 0.00  -> 1.00
fmax3075 fma  1    0  1   -> 1
fmax3076 fma  1   0.  1   -> 1
fmax3077 fma  1    .0 1   -> 1.0
fmax3078 fma  1   0.0 1   -> 1.0
fmax3079 fma  1   0.00 1  -> 1.00

precision: 9

-- some carries
fmax3080 fma  1   999999998 1  -> 999999999
fmax3081 fma  1   999999999 1  -> 1.00000000E+9 Rounded
fmax3082 fma  1    99999999 1  -> 100000000
fmax3083 fma  1     9999999 1  -> 10000000
fmax3084 fma  1      999999 1  -> 1000000
fmax3085 fma  1       99999 1  -> 100000
fmax3086 fma  1        9999 1  -> 10000
fmax3087 fma  1         999 1  -> 1000
fmax3088 fma  1          99 1  -> 100
fmax3089 fma  1           9 1  -> 10


-- more LHS swaps
fmax3090 fma  1   '-56267E-10'   0 ->  '-0.0000056267'
fmax3091 fma  1   '-56267E-6'    0 ->  '-0.056267'
fmax3092 fma  1   '-56267E-5'    0 ->  '-0.56267'
fmax3093 fma  1   '-56267E-4'    0 ->  '-5.6267'
fmax3094 fma  1   '-56267E-3'    0 ->  '-56.267'
fmax3095 fma  1   '-56267E-2'    0 ->  '-562.67'
fmax3096 fma  1   '-56267E-1'    0 ->  '-5626.7'
fmax3097 fma  1   '-56267E-0'    0 ->  '-56267'
fmax3098 fma  1   '-5E-10'       0 ->  '-5E-10'
fmax3099 fma  1   '-5E-7'        0 ->  '-5E-7'
fmax3100 fma  1   '-5E-6'        0 ->  '-0.000005'
fmax3101 fma  1   '-5E-5'        0 ->  '-0.00005'
fmax3102 fma  1   '-5E-4'        0 ->  '-0.0005'
fmax3103 fma  1   '-5E-1'        0 ->  '-0.5'
fmax3104 fma  1   '-5E0'         0 ->  '-5'
fmax3105 fma  1   '-5E1'         0 ->  '-50'
fmax3106 fma  1   '-5E5'         0 ->  '-500000'
fmax3107 fma  1   '-5E8'         0 ->  '-500000000'
fmax3108 fma  1   '-5E9'         0 ->  '-5.00000000E+9'   Rounded
fmax3109 fma  1   '-5E10'        0 ->  '-5.00000000E+10'  Rounded
fmax3110 fma  1   '-5E11'        0 ->  '-5.00000000E+11'  Rounded
fmax3111 fma  1   '-5E100'       0 ->  '-5.00000000E+100' Rounded

-- more RHS swaps
fmax3113 fma  1   0  '-56267E-10' ->  '-0.0000056267'
fmax3114 fma  1   0  '-56267E-6'  ->  '-0.056267'
fmax3116 fma  1   0  '-56267E-5'  ->  '-0.56267'
fmax3117 fma  1   0  '-56267E-4'  ->  '-5.6267'
fmax3119 fma  1   0  '-56267E-3'  ->  '-56.267'
fmax3120 fma  1   0  '-56267E-2'  ->  '-562.67'
fmax3121 fma  1   0  '-56267E-1'  ->  '-5626.7'
fmax3122 fma  1   0  '-56267E-0'  ->  '-56267'
fmax3123 fma  1   0  '-5E-10'     ->  '-5E-10'
fmax3124 fma  1   0  '-5E-7'      ->  '-5E-7'
fmax3125 fma  1   0  '-5E-6'      ->  '-0.000005'
fmax3126 fma  1   0  '-5E-5'      ->  '-0.00005'
fmax3127 fma  1   0  '-5E-4'      ->  '-0.0005'
fmax3128 fma  1   0  '-5E-1'      ->  '-0.5'
fmax3129 fma  1   0  '-5E0'       ->  '-5'
fmax3130 fma  1   0  '-5E1'       ->  '-50'
fmax3131 fma  1   0  '-5E5'       ->  '-500000'
fmax3132 fma  1   0  '-5E8'       ->  '-500000000'
fmax3133 fma  1   0  '-5E9'       ->  '-5.00000000E+9'    Rounded
fmax3134 fma  1   0  '-5E10'      ->  '-5.00000000E+10'   Rounded
fmax3135 fma  1   0  '-5E11'      ->  '-5.00000000E+11'   Rounded
fmax3136 fma  1   0  '-5E100'     ->  '-5.00000000E+100'  Rounded

-- related
fmax3137 fma  1    1  '0E-12'      ->  '1.00000000'  Rounded
fmax3138 fma  1   -1  '0E-12'      ->  '-1.00000000' Rounded
fmax3139 fma  1   '0E-12' 1        ->  '1.00000000'  Rounded
fmax3140 fma  1   '0E-12' -1       ->  '-1.00000000' Rounded
fmax3141 fma  1   1E+4    0.0000   ->  '10000.0000'
fmax3142 fma  1   1E+4    0.00000  ->  '10000.0000'  Rounded
fmax3143 fma  1   0.000   1E+5     ->  '100000.000'
fmax3144 fma  1   0.0000  1E+5     ->  '100000.000'  Rounded

-- [some of the next group are really constructor tests]
fmax3146 fma  1   '00.0'  0       ->  '0.0'
fmax3147 fma  1   '0.00'  0       ->  '0.00'
fmax3148 fma  1    0      '0.00'  ->  '0.00'
fmax3149 fma  1    0      '00.0'  ->  '0.0'
fmax3150 fma  1   '00.0'  '0.00'  ->  '0.00'
fmax3151 fma  1   '0.00'  '00.0'  ->  '0.00'
fmax3152 fma  1   '3'     '.3'    ->  '3.3'
fmax3153 fma  1   '3.'    '.3'    ->  '3.3'
fmax3154 fma  1   '3.0'   '.3'    ->  '3.3'
fmax3155 fma  1   '3.00'  '.3'    ->  '3.30'
fmax3156 fma  1   '3'     '3'     ->  '6'
fmax3157 fma  1   '3'     '+3'    ->  '6'
fmax3158 fma  1   '3'     '-3'    ->  '0'
fmax3159 fma  1   '0.3'   '-0.3'  ->  '0.0'
fmax3160 fma  1   '0.03'  '-0.03' ->  '0.00'

-- try borderline precision, with carries, etc.
precision: 15
fmax3161 fma  1   '1E+12' '-1'    -> '999999999999'
fmax3162 fma  1   '1E+12'  '1.11' -> '1000000000001.11'
fmax3163 fma  1   '1.11'  '1E+12' -> '1000000000001.11'
fmax3164 fma  1   '-1'    '1E+12' -> '999999999999'
fmax3165 fma  1   '7E+12' '-1'    -> '6999999999999'
fmax3166 fma  1   '7E+12'  '1.11' -> '7000000000001.11'
fmax3167 fma  1   '1.11'  '7E+12' -> '7000000000001.11'
fmax3168 fma  1   '-1'    '7E+12' -> '6999999999999'

--             123456789012345      123456789012345      1 23456789012345
fmax3170 fma  1   '0.444444444444444'  '0.555555555555563' -> '1.00000000000001' Inexact Rounded
fmax3171 fma  1   '0.444444444444444'  '0.555555555555562' -> '1.00000000000001' Inexact Rounded
fmax3172 fma  1   '0.444444444444444'  '0.555555555555561' -> '1.00000000000001' Inexact Rounded
fmax3173 fma  1   '0.444444444444444'  '0.555555555555560' -> '1.00000000000000' Inexact Rounded
fmax3174 fma  1   '0.444444444444444'  '0.555555555555559' -> '1.00000000000000' Inexact Rounded
fmax3175 fma  1   '0.444444444444444'  '0.555555555555558' -> '1.00000000000000' Inexact Rounded
fmax3176 fma  1   '0.444444444444444'  '0.555555555555557' -> '1.00000000000000' Inexact Rounded
fmax3177 fma  1   '0.444444444444444'  '0.555555555555556' -> '1.00000000000000' Rounded
fmax3178 fma  1   '0.444444444444444'  '0.555555555555555' -> '0.999999999999999'
fmax3179 fma  1   '0.444444444444444'  '0.555555555555554' -> '0.999999999999998'
fmax3180 fma  1   '0.444444444444444'  '0.555555555555553' -> '0.999999999999997'
fmax3181 fma  1   '0.444444444444444'  '0.555555555555552' -> '0.999999999999996'
fmax3182 fma  1   '0.444444444444444'  '0.555555555555551' -> '0.999999999999995'
fmax3183 fma  1   '0.444444444444444'  '0.555555555555550' -> '0.999999999999994'

-- and some more, including residue effects and different roundings
precision: 9
rounding: half_up
fmax3200 fma  1   '123456789' 0             -> '123456789'
fmax3201 fma  1   '123456789' 0.000000001   -> '123456789' Inexact Rounded
fmax3202 fma  1   '123456789' 0.000001      -> '123456789' Inexact Rounded
fmax3203 fma  1   '123456789' 0.1           -> '123456789' Inexact Rounded
fmax3204 fma  1   '123456789' 0.4           -> '123456789' Inexact Rounded
fmax3205 fma  1   '123456789' 0.49          -> '123456789' Inexact Rounded
fmax3206 fma  1   '123456789' 0.499999      -> '123456789' Inexact Rounded
fmax3207 fma  1   '123456789' 0.499999999   -> '123456789' Inexact Rounded
fmax3208 fma  1   '123456789' 0.5           -> '123456790' Inexact Rounded
fmax3209 fma  1   '123456789' 0.500000001   -> '123456790' Inexact Rounded
fmax3210 fma  1   '123456789' 0.500001      -> '123456790' Inexact Rounded
fmax3211 fma  1   '123456789' 0.51          -> '123456790' Inexact Rounded
fmax3212 fma  1   '123456789' 0.6           -> '123456790' Inexact Rounded
fmax3213 fma  1   '123456789' 0.9           -> '123456790' Inexact Rounded
fmax3214 fma  1   '123456789' 0.99999       -> '123456790' Inexact Rounded
fmax3215 fma  1   '123456789' 0.999999999   -> '123456790' Inexact Rounded
fmax3216 fma  1   '123456789' 1             -> '123456790'
fmax3217 fma  1   '123456789' 1.000000001   -> '123456790' Inexact Rounded
fmax3218 fma  1   '123456789' 1.00001       -> '123456790' Inexact Rounded
fmax3219 fma  1   '123456789' 1.1           -> '123456790' Inexact Rounded

rounding: half_even
fmax3220 fma  1   '123456789' 0             -> '123456789'
fmax3221 fma  1   '123456789' 0.000000001   -> '123456789' Inexact Rounded
fmax3222 fma  1   '123456789' 0.000001      -> '123456789' Inexact Rounded
fmax3223 fma  1   '123456789' 0.1           -> '123456789' Inexact Rounded
fmax3224 fma  1   '123456789' 0.4           -> '123456789' Inexact Rounded
fmax3225 fma  1   '123456789' 0.49          -> '123456789' Inexact Rounded
fmax3226 fma  1   '123456789' 0.499999      -> '123456789' Inexact Rounded
fmax3227 fma  1   '123456789' 0.499999999   -> '123456789' Inexact Rounded
fmax3228 fma  1   '123456789' 0.5           -> '123456790' Inexact Rounded
fmax3229 fma  1   '123456789' 0.500000001   -> '123456790' Inexact Rounded
fmax3230 fma  1   '123456789' 0.500001      -> '123456790' Inexact Rounded
fmax3231 fma  1   '123456789' 0.51          -> '123456790' Inexact Rounded
fmax3232 fma  1   '123456789' 0.6           -> '123456790' Inexact Rounded
fmax3233 fma  1   '123456789' 0.9           -> '123456790' Inexact Rounded
fmax3234 fma  1   '123456789' 0.99999       -> '123456790' Inexact Rounded
fmax3235 fma  1   '123456789' 0.999999999   -> '123456790' Inexact Rounded
fmax3236 fma  1   '123456789' 1             -> '123456790'
fmax3237 fma  1   '123456789' 1.00000001    -> '123456790' Inexact Rounded
fmax3238 fma  1   '123456789' 1.00001       -> '123456790' Inexact Rounded
fmax3239 fma  1   '123456789' 1.1           -> '123456790' Inexact Rounded
-- critical few with even bottom digit...
fmax3240 fma  1   '123456788' 0.499999999   -> '123456788' Inexact Rounded
fmax3241 fma  1   '123456788' 0.5           -> '123456788' Inexact Rounded
fmax3242 fma  1   '123456788' 0.500000001   -> '123456789' Inexact Rounded

rounding: down
fmax3250 fma  1   '123456789' 0             -> '123456789'
fmax3251 fma  1   '123456789' 0.000000001   -> '123456789' Inexact Rounded
fmax3252 fma  1   '123456789' 0.000001      -> '123456789' Inexact Rounded
fmax3253 fma  1   '123456789' 0.1           -> '123456789' Inexact Rounded
fmax3254 fma  1   '123456789' 0.4           -> '123456789' Inexact Rounded
fmax3255 fma  1   '123456789' 0.49          -> '123456789' Inexact Rounded
fmax3256 fma  1   '123456789' 0.499999      -> '123456789' Inexact Rounded
fmax3257 fma  1   '123456789' 0.499999999   -> '123456789' Inexact Rounded
fmax3258 fma  1   '123456789' 0.5           -> '123456789' Inexact Rounded
fmax3259 fma  1   '123456789' 0.500000001   -> '123456789' Inexact Rounded
fmax3260 fma  1   '123456789' 0.500001      -> '123456789' Inexact Rounded
fmax3261 fma  1   '123456789' 0.51          -> '123456789' Inexact Rounded
fmax3262 fma  1   '123456789' 0.6           -> '123456789' Inexact Rounded
fmax3263 fma  1   '123456789' 0.9           -> '123456789' Inexact Rounded
fmax3264 fma  1   '123456789' 0.99999       -> '123456789' Inexact Rounded
fmax3265 fma  1   '123456789' 0.999999999   -> '123456789' Inexact Rounded
fmax3266 fma  1   '123456789' 1             -> '123456790'
fmax3267 fma  1   '123456789' 1.00000001    -> '123456790' Inexact Rounded
fmax3268 fma  1   '123456789' 1.00001       -> '123456790' Inexact Rounded
fmax3269 fma  1   '123456789' 1.1           -> '123456790' Inexact Rounded

-- input preparation tests (operands should not be rounded)
precision: 3
rounding: half_up

fmax3270 fma  1   '12345678900000'  9999999999999 ->  '2.23E+13' Inexact Rounded
fmax3271 fma  1    '9999999999999' 12345678900000 ->  '2.23E+13' Inexact Rounded

fmax3272 fma  1   '12E+3'  '3444'   ->  '1.54E+4' Inexact Rounded
fmax3273 fma  1   '12E+3'  '3446'   ->  '1.54E+4' Inexact Rounded
fmax3274 fma  1   '12E+3'  '3449.9' ->  '1.54E+4' Inexact Rounded
fmax3275 fma  1   '12E+3'  '3450.0' ->  '1.55E+4' Inexact Rounded
fmax3276 fma  1   '12E+3'  '3450.1' ->  '1.55E+4' Inexact Rounded
fmax3277 fma  1   '12E+3'  '3454'   ->  '1.55E+4' Inexact Rounded
fmax3278 fma  1   '12E+3'  '3456'   ->  '1.55E+4' Inexact Rounded

fmax3281 fma  1   '3444'   '12E+3'  ->  '1.54E+4' Inexact Rounded
fmax3282 fma  1   '3446'   '12E+3'  ->  '1.54E+4' Inexact Rounded
fmax3283 fma  1   '3449.9' '12E+3'  ->  '1.54E+4' Inexact Rounded
fmax3284 fma  1   '3450.0' '12E+3'  ->  '1.55E+4' Inexact Rounded
fmax3285 fma  1   '3450.1' '12E+3'  ->  '1.55E+4' Inexact Rounded
fmax3286 fma  1   '3454'   '12E+3'  ->  '1.55E+4' Inexact Rounded
fmax3287 fma  1   '3456'   '12E+3'  ->  '1.55E+4' Inexact Rounded

rounding: half_down
fmax3291 fma  1   '3444'   '12E+3'  ->  '1.54E+4' Inexact Rounded
fmax3292 fma  1   '3446'   '12E+3'  ->  '1.54E+4' Inexact Rounded
fmax3293 fma  1   '3449.9' '12E+3'  ->  '1.54E+4' Inexact Rounded
fmax3294 fma  1   '3450.0' '12E+3'  ->  '1.54E+4' Inexact Rounded
fmax3295 fma  1   '3450.1' '12E+3'  ->  '1.55E+4' Inexact Rounded
fmax3296 fma  1   '3454'   '12E+3'  ->  '1.55E+4' Inexact Rounded
fmax3297 fma  1   '3456'   '12E+3'  ->  '1.55E+4' Inexact Rounded

-- 1 in last place tests
rounding: half_up
fmax3301 fma  1    -1   1      ->   0
fmax3302 fma  1     0   1      ->   1
fmax3303 fma  1     1   1      ->   2
fmax3304 fma  1    12   1      ->  13
fmax3305 fma  1    98   1      ->  99
fmax3306 fma  1    99   1      -> 100
fmax3307 fma  1   100   1      -> 101
fmax3308 fma  1   101   1      -> 102
fmax3309 fma  1    -1  -1      ->  -2
fmax3310 fma  1     0  -1      ->  -1
fmax3311 fma  1     1  -1      ->   0
fmax3312 fma  1    12  -1      ->  11
fmax3313 fma  1    98  -1      ->  97
fmax3314 fma  1    99  -1      ->  98
fmax3315 fma  1   100  -1      ->  99
fmax3316 fma  1   101  -1      -> 100

fmax3321 fma  1   -0.01  0.01    ->  0.00
fmax3322 fma  1    0.00  0.01    ->  0.01
fmax3323 fma  1    0.01  0.01    ->  0.02
fmax3324 fma  1    0.12  0.01    ->  0.13
fmax3325 fma  1    0.98  0.01    ->  0.99
fmax3326 fma  1    0.99  0.01    ->  1.00
fmax3327 fma  1    1.00  0.01    ->  1.01
fmax3328 fma  1    1.01  0.01    ->  1.02
fmax3329 fma  1   -0.01 -0.01    -> -0.02
fmax3330 fma  1    0.00 -0.01    -> -0.01
fmax3331 fma  1    0.01 -0.01    ->  0.00
fmax3332 fma  1    0.12 -0.01    ->  0.11
fmax3333 fma  1    0.98 -0.01    ->  0.97
fmax3334 fma  1    0.99 -0.01    ->  0.98
fmax3335 fma  1    1.00 -0.01    ->  0.99
fmax3336 fma  1    1.01 -0.01    ->  1.00

-- some more cases where fma  1  ing 0 affects the coefficient
precision: 9
fmax3340 fma  1   1E+3    0    ->         1000
fmax3341 fma  1   1E+8    0    ->    100000000
fmax3342 fma  1   1E+9    0    ->   1.00000000E+9   Rounded
fmax3343 fma  1   1E+10   0    ->   1.00000000E+10  Rounded
-- which simply follow from these cases ...
fmax3344 fma  1   1E+3    1    ->         1001
fmax3345 fma  1   1E+8    1    ->    100000001
fmax3346 fma  1   1E+9    1    ->   1.00000000E+9   Inexact Rounded
fmax3347 fma  1   1E+10   1    ->   1.00000000E+10  Inexact Rounded
fmax3348 fma  1   1E+3    7    ->         1007
fmax3349 fma  1   1E+8    7    ->    100000007
fmax3350 fma  1   1E+9    7    ->   1.00000001E+9   Inexact Rounded
fmax3351 fma  1   1E+10   7    ->   1.00000000E+10  Inexact Rounded

-- tryzeros cases
precision:   7
rounding:    half_up
maxExponent: 92
minexponent: -92
fmax3361  fma  1   0E+50 10000E+1  -> 1.0000E+5
fmax3362  fma  1   10000E+1 0E-50  -> 100000.0  Rounded
fmax3363  fma  1   10000E+1 10000E-50  -> 100000.0  Rounded Inexact
fmax3364  fma  1   9.999999E+92 -9.999999E+92 -> 0E+86

-- a curiosity from JSR 13 testing
rounding:    half_down
precision:   10
fmax3370 fma  1   99999999 81512 -> 100081511
precision:      6
fmax3371 fma  1   99999999 81512 -> 1.00082E+8 Rounded Inexact
rounding:    half_up
precision:   10
fmax3372 fma  1   99999999 81512 -> 100081511
precision:      6
fmax3373 fma  1   99999999 81512 -> 1.00082E+8 Rounded Inexact
rounding:    half_even
precision:   10
fmax3374 fma  1   99999999 81512 -> 100081511
precision:      6
fmax3375 fma  1   99999999 81512 -> 1.00082E+8 Rounded Inexact

-- ulp replacement tests
precision: 9
maxexponent: 999999
minexponent: -999999
fmax3400 fma  1     1   77e-7       ->  1.0000077
fmax3401 fma  1     1   77e-8       ->  1.00000077
fmax3402 fma  1     1   77e-9       ->  1.00000008 Inexact Rounded
fmax3403 fma  1     1   77e-10      ->  1.00000001 Inexact Rounded
fmax3404 fma  1     1   77e-11      ->  1.00000000 Inexact Rounded
fmax3405 fma  1     1   77e-12      ->  1.00000000 Inexact Rounded
fmax3406 fma  1     1   77e-999     ->  1.00000000 Inexact Rounded
fmax3407 fma  1     1   77e-999999  ->  1.00000000 Inexact Rounded

fmax3410 fma  1    10   77e-7       ->  10.0000077
fmax3411 fma  1    10   77e-8       ->  10.0000008 Inexact Rounded
fmax3412 fma  1    10   77e-9       ->  10.0000001 Inexact Rounded
fmax3413 fma  1    10   77e-10      ->  10.0000000 Inexact Rounded
fmax3414 fma  1    10   77e-11      ->  10.0000000 Inexact Rounded
fmax3415 fma  1    10   77e-12      ->  10.0000000 Inexact Rounded
fmax3416 fma  1    10   77e-999     ->  10.0000000 Inexact Rounded
fmax3417 fma  1    10   77e-999999  ->  10.0000000 Inexact Rounded

fmax3420 fma  1    77e-7        1   ->  1.0000077
fmax3421 fma  1    77e-8        1   ->  1.00000077
fmax3422 fma  1    77e-9        1   ->  1.00000008 Inexact Rounded
fmax3423 fma  1    77e-10       1   ->  1.00000001 Inexact Rounded
fmax3424 fma  1    77e-11       1   ->  1.00000000 Inexact Rounded
fmax3425 fma  1    77e-12       1   ->  1.00000000 Inexact Rounded
fmax3426 fma  1    77e-999      1   ->  1.00000000 Inexact Rounded
fmax3427 fma  1    77e-999999   1   ->  1.00000000 Inexact Rounded

fmax3430 fma  1    77e-7       10   ->  10.0000077
fmax3431 fma  1    77e-8       10   ->  10.0000008 Inexact Rounded
fmax3432 fma  1    77e-9       10   ->  10.0000001 Inexact Rounded
fmax3433 fma  1    77e-10      10   ->  10.0000000 Inexact Rounded
fmax3434 fma  1    77e-11      10   ->  10.0000000 Inexact Rounded
fmax3435 fma  1    77e-12      10   ->  10.0000000 Inexact Rounded
fmax3436 fma  1    77e-999     10   ->  10.0000000 Inexact Rounded
fmax3437 fma  1    77e-999999  10   ->  10.0000000 Inexact Rounded

-- negative ulps
fmax3440 fma  1     1   -77e-7       ->  0.9999923
fmax3441 fma  1     1   -77e-8       ->  0.99999923
fmax3442 fma  1     1   -77e-9       ->  0.999999923
fmax3443 fma  1     1   -77e-10      ->  0.999999992 Inexact Rounded
fmax3444 fma  1     1   -77e-11      ->  0.999999999 Inexact Rounded
fmax3445 fma  1     1   -77e-12      ->  1.00000000 Inexact Rounded
fmax3446 fma  1     1   -77e-999     ->  1.00000000 Inexact Rounded
fmax3447 fma  1     1   -77e-999999  ->  1.00000000 Inexact Rounded

fmax3450 fma  1    10   -77e-7       ->   9.9999923
fmax3451 fma  1    10   -77e-8       ->   9.99999923
fmax3452 fma  1    10   -77e-9       ->   9.99999992 Inexact Rounded
fmax3453 fma  1    10   -77e-10      ->   9.99999999 Inexact Rounded
fmax3454 fma  1    10   -77e-11      ->  10.0000000 Inexact Rounded
fmax3455 fma  1    10   -77e-12      ->  10.0000000 Inexact Rounded
fmax3456 fma  1    10   -77e-999     ->  10.0000000 Inexact Rounded
fmax3457 fma  1    10   -77e-999999  ->  10.0000000 Inexact Rounded

fmax3460 fma  1    -77e-7        1   ->  0.9999923
fmax3461 fma  1    -77e-8        1   ->  0.99999923
fmax3462 fma  1    -77e-9        1   ->  0.999999923
fmax3463 fma  1    -77e-10       1   ->  0.999999992 Inexact Rounded
fmax3464 fma  1    -77e-11       1   ->  0.999999999 Inexact Rounded
fmax3465 fma  1    -77e-12       1   ->  1.00000000 Inexact Rounded
fmax3466 fma  1    -77e-999      1   ->  1.00000000 Inexact Rounded
fmax3467 fma  1    -77e-999999   1   ->  1.00000000 Inexact Rounded

fmax3470 fma  1    -77e-7       10   ->   9.9999923
fmax3471 fma  1    -77e-8       10   ->   9.99999923
fmax3472 fma  1    -77e-9       10   ->   9.99999992 Inexact Rounded
fmax3473 fma  1    -77e-10      10   ->   9.99999999 Inexact Rounded
fmax3474 fma  1    -77e-11      10   ->  10.0000000 Inexact Rounded
fmax3475 fma  1    -77e-12      10   ->  10.0000000 Inexact Rounded
fmax3476 fma  1    -77e-999     10   ->  10.0000000 Inexact Rounded
fmax3477 fma  1    -77e-999999  10   ->  10.0000000 Inexact Rounded

-- negative ulps
fmax3480 fma  1    -1    77e-7       ->  -0.9999923
fmax3481 fma  1    -1    77e-8       ->  -0.99999923
fmax3482 fma  1    -1    77e-9       ->  -0.999999923
fmax3483 fma  1    -1    77e-10      ->  -0.999999992 Inexact Rounded
fmax3484 fma  1    -1    77e-11      ->  -0.999999999 Inexact Rounded
fmax3485 fma  1    -1    77e-12      ->  -1.00000000 Inexact Rounded
fmax3486 fma  1    -1    77e-999     ->  -1.00000000 Inexact Rounded
fmax3487 fma  1    -1    77e-999999  ->  -1.00000000 Inexact Rounded

fmax3490 fma  1   -10    77e-7       ->   -9.9999923
fmax3491 fma  1   -10    77e-8       ->   -9.99999923
fmax3492 fma  1   -10    77e-9       ->   -9.99999992 Inexact Rounded
fmax3493 fma  1   -10    77e-10      ->   -9.99999999 Inexact Rounded
fmax3494 fma  1   -10    77e-11      ->  -10.0000000 Inexact Rounded
fmax3495 fma  1   -10    77e-12      ->  -10.0000000 Inexact Rounded
fmax3496 fma  1   -10    77e-999     ->  -10.0000000 Inexact Rounded
fmax3497 fma  1   -10    77e-999999  ->  -10.0000000 Inexact Rounded

fmax3500 fma  1     77e-7       -1   ->  -0.9999923
fmax3501 fma  1     77e-8       -1   ->  -0.99999923
fmax3502 fma  1     77e-9       -1   ->  -0.999999923
fmax3503 fma  1     77e-10      -1   ->  -0.999999992 Inexact Rounded
fmax3504 fma  1     77e-11      -1   ->  -0.999999999 Inexact Rounded
fmax3505 fma  1     77e-12      -1   ->  -1.00000000 Inexact Rounded
fmax3506 fma  1     77e-999     -1   ->  -1.00000000 Inexact Rounded
fmax3507 fma  1     77e-999999  -1   ->  -1.00000000 Inexact Rounded

fmax3510 fma  1     77e-7       -10  ->   -9.9999923
fmax3511 fma  1     77e-8       -10  ->   -9.99999923
fmax3512 fma  1     77e-9       -10  ->   -9.99999992 Inexact Rounded
fmax3513 fma  1     77e-10      -10  ->   -9.99999999 Inexact Rounded
fmax3514 fma  1     77e-11      -10  ->  -10.0000000 Inexact Rounded
fmax3515 fma  1     77e-12      -10  ->  -10.0000000 Inexact Rounded
fmax3516 fma  1     77e-999     -10  ->  -10.0000000 Inexact Rounded
fmax3517 fma  1     77e-999999  -10  ->  -10.0000000 Inexact Rounded


-- long operands
maxexponent: 999
minexponent: -999
precision: 9
fmax3521 fma  1   12345678000 0 -> 1.23456780E+10 Rounded
fmax3522 fma  1   0 12345678000 -> 1.23456780E+10 Rounded
fmax3523 fma  1   1234567800  0 -> 1.23456780E+9 Rounded
fmax3524 fma  1   0 1234567800  -> 1.23456780E+9 Rounded
fmax3525 fma  1   1234567890  0 -> 1.23456789E+9 Rounded
fmax3526 fma  1   0 1234567890  -> 1.23456789E+9 Rounded
fmax3527 fma  1   1234567891  0 -> 1.23456789E+9 Inexact Rounded
fmax3528 fma  1   0 1234567891  -> 1.23456789E+9 Inexact Rounded
fmax3529 fma  1   12345678901 0 -> 1.23456789E+10 Inexact Rounded
fmax3530 fma  1   0 12345678901 -> 1.23456789E+10 Inexact Rounded
fmax3531 fma  1   1234567896  0 -> 1.23456790E+9 Inexact Rounded
fmax3532 fma  1   0 1234567896  -> 1.23456790E+9 Inexact Rounded

precision: 15
-- still checking
fmax3541 fma  1   12345678000 0 -> 12345678000
fmax3542 fma  1   0 12345678000 -> 12345678000
fmax3543 fma  1   1234567800  0 -> 1234567800
fmax3544 fma  1   0 1234567800  -> 1234567800
fmax3545 fma  1   1234567890  0 -> 1234567890
fmax3546 fma  1   0 1234567890  -> 1234567890
fmax3547 fma  1   1234567891  0 -> 1234567891
fmax3548 fma  1   0 1234567891  -> 1234567891
fmax3549 fma  1   12345678901 0 -> 12345678901
fmax3550 fma  1   0 12345678901 -> 12345678901
fmax3551 fma  1   1234567896  0 -> 1234567896
fmax3552 fma  1   0 1234567896  -> 1234567896

-- verify a query
precision:    16
maxExponent: +394
minExponent: -393
rounding:     down
fmax3561 fma  1   1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
fmax3562 fma  1        0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
-- and using decimal64 bounds...
precision:    16
maxExponent: +384
minExponent: -383
rounding:     down
fmax3563 fma  1   1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
fmax3564 fma  1        0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded


-- some more residue effects with extreme rounding
precision:   9
rounding: half_up
fmax3601 fma  1   123456789  0.000001 -> 123456789 Inexact Rounded
rounding: half_even
fmax3602 fma  1   123456789  0.000001 -> 123456789 Inexact Rounded
rounding: half_down
fmax3603 fma  1   123456789  0.000001 -> 123456789 Inexact Rounded
rounding: floor
fmax3604 fma  1   123456789  0.000001 -> 123456789 Inexact Rounded
rounding: ceiling
fmax3605 fma  1   123456789  0.000001 -> 123456790 Inexact Rounded
rounding: up
fmax3606 fma  1   123456789  0.000001 -> 123456790 Inexact Rounded
rounding: down
fmax3607 fma  1   123456789  0.000001 -> 123456789 Inexact Rounded

rounding: half_up
fmax3611 fma  1   123456789 -0.000001 -> 123456789 Inexact Rounded
rounding: half_even
fmax3612 fma  1   123456789 -0.000001 -> 123456789 Inexact Rounded
rounding: half_down
fmax3613 fma  1   123456789 -0.000001 -> 123456789 Inexact Rounded
rounding: floor
fmax3614 fma  1   123456789 -0.000001 -> 123456788 Inexact Rounded
rounding: ceiling
fmax3615 fma  1   123456789 -0.000001 -> 123456789 Inexact Rounded
rounding: up
fmax3616 fma  1   123456789 -0.000001 -> 123456789 Inexact Rounded
rounding: down
fmax3617 fma  1   123456789 -0.000001 -> 123456788 Inexact Rounded

rounding: half_up
fmax3621 fma  1   123456789  0.499999 -> 123456789 Inexact Rounded
rounding: half_even
fmax3622 fma  1   123456789  0.499999 -> 123456789 Inexact Rounded
rounding: half_down
fmax3623 fma  1   123456789  0.499999 -> 123456789 Inexact Rounded
rounding: floor
fmax3624 fma  1   123456789  0.499999 -> 123456789 Inexact Rounded
rounding: ceiling
fmax3625 fma  1   123456789  0.499999 -> 123456790 Inexact Rounded
rounding: up
fmax3626 fma  1   123456789  0.499999 -> 123456790 Inexact Rounded
rounding: down
fmax3627 fma  1   123456789  0.499999 -> 123456789 Inexact Rounded

rounding: half_up
fmax3631 fma  1   123456789 -0.499999 -> 123456789 Inexact Rounded
rounding: half_even
fmax3632 fma  1   123456789 -0.499999 -> 123456789 Inexact Rounded
rounding: half_down
fmax3633 fma  1   123456789 -0.499999 -> 123456789 Inexact Rounded
rounding: floor
fmax3634 fma  1   123456789 -0.499999 -> 123456788 Inexact Rounded
rounding: ceiling
fmax3635 fma  1   123456789 -0.499999 -> 123456789 Inexact Rounded
rounding: up
fmax3636 fma  1   123456789 -0.499999 -> 123456789 Inexact Rounded
rounding: down
fmax3637 fma  1   123456789 -0.499999 -> 123456788 Inexact Rounded

rounding: half_up
fmax3641 fma  1   123456789  0.500001 -> 123456790 Inexact Rounded
rounding: half_even
fmax3642 fma  1   123456789  0.500001 -> 123456790 Inexact Rounded
rounding: half_down
fmax3643 fma  1   123456789  0.500001 -> 123456790 Inexact Rounded
rounding: floor
fmax3644 fma  1   123456789  0.500001 -> 123456789 Inexact Rounded
rounding: ceiling
fmax3645 fma  1   123456789  0.500001 -> 123456790 Inexact Rounded
rounding: up
fmax3646 fma  1   123456789  0.500001 -> 123456790 Inexact Rounded
rounding: down
fmax3647 fma  1   123456789  0.500001 -> 123456789 Inexact Rounded

rounding: half_up
fmax3651 fma  1   123456789 -0.500001 -> 123456788 Inexact Rounded
rounding: half_even
fmax3652 fma  1   123456789 -0.500001 -> 123456788 Inexact Rounded
rounding: half_down
fmax3653 fma  1   123456789 -0.500001 -> 123456788 Inexact Rounded
rounding: floor
fmax3654 fma  1   123456789 -0.500001 -> 123456788 Inexact Rounded
rounding: ceiling
fmax3655 fma  1   123456789 -0.500001 -> 123456789 Inexact Rounded
rounding: up
fmax3656 fma  1   123456789 -0.500001 -> 123456789 Inexact Rounded
rounding: down
fmax3657 fma  1   123456789 -0.500001 -> 123456788 Inexact Rounded

-- long operand triangle
rounding: half_up
precision:  37
fmax3660 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337114834538
precision:  36
fmax3661 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711483454  Inexact Rounded
precision:  35
fmax3662 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371148345   Inexact Rounded
precision:  34
fmax3663 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337114835    Inexact Rounded
precision:  33
fmax3664 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711483     Inexact Rounded
precision:  32
fmax3665 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371148      Inexact Rounded
precision:  31
fmax3666 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337115       Inexact Rounded
precision:  30
fmax3667 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711        Inexact Rounded
precision:  29
fmax3668 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371         Inexact Rounded
precision:  28
fmax3669 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337          Inexact Rounded
precision:  27
fmax3670 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892234           Inexact Rounded
precision:  26
fmax3671 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223            Inexact Rounded
precision:  25
fmax3672 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922             Inexact Rounded
precision:  24
fmax3673 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892              Inexact Rounded
precision:  23
fmax3674 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389               Inexact Rounded
precision:  22
fmax3675 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023639                Inexact Rounded
precision:  21
fmax3676 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102364                 Inexact Rounded
precision:  20
fmax3677 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236                  Inexact Rounded
precision:  19
fmax3678 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211024                   Inexact Rounded
precision:  18
fmax3679 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102                    Inexact Rounded
precision:  17
fmax3680 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110                     Inexact Rounded
precision:  16
fmax3681 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211                      Inexact Rounded
precision:  15
fmax3682 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221                       Inexact Rounded
precision:  14
fmax3683 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422                        Inexact Rounded
precision:  13
fmax3684 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42                         Inexact Rounded
precision:  12
fmax3685 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4                          Inexact Rounded
precision:  11
fmax3686 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166                            Inexact Rounded
precision:  10
fmax3687 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847117417E+10                        Inexact Rounded
precision:   9
fmax3688 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.84711742E+10                         Inexact Rounded
precision:   8
fmax3689 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8471174E+10                          Inexact Rounded
precision:   7
fmax3690 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847117E+10                          Inexact Rounded
precision:   6
fmax3691 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.84712E+10                          Inexact Rounded
precision:   5
fmax3692 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8471E+10                          Inexact Rounded
precision:   4
fmax3693 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847E+10                          Inexact Rounded
precision:   3
fmax3694 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.85E+10                          Inexact Rounded
precision:   2
fmax3695 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8E+10                          Inexact Rounded
precision:   1
fmax3696 fma  1   98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 1E+11                          Inexact Rounded

-- more zeros, etc.
rounding: half_up
precision:   9

fmax3701 fma  1   5.00 1.00E-3 -> 5.00100
fmax3702 fma  1   00.00 0.000  -> 0.000
fmax3703 fma  1   00.00 0E-3   -> 0.000
fmax3704 fma  1   0E-3  00.00  -> 0.000

fmax3710 fma  1   0E+3  00.00  -> 0.00
fmax3711 fma  1   0E+3  00.0   -> 0.0
fmax3712 fma  1   0E+3  00.    -> 0
fmax3713 fma  1   0E+3  00.E+1 -> 0E+1
fmax3714 fma  1   0E+3  00.E+2 -> 0E+2
fmax3715 fma  1   0E+3  00.E+3 -> 0E+3
fmax3716 fma  1   0E+3  00.E+4 -> 0E+3
fmax3717 fma  1   0E+3  00.E+5 -> 0E+3
fmax3718 fma  1   0E+3  -00.0   -> 0.0
fmax3719 fma  1   0E+3  -00.    -> 0
fmax3731 fma  1   0E+3  -00.E+1 -> 0E+1

fmax3720 fma  1   00.00  0E+3  -> 0.00
fmax3721 fma  1   00.0   0E+3  -> 0.0
fmax3722 fma  1   00.    0E+3  -> 0
fmax3723 fma  1   00.E+1 0E+3  -> 0E+1
fmax3724 fma  1   00.E+2 0E+3  -> 0E+2
fmax3725 fma  1   00.E+3 0E+3  -> 0E+3
fmax3726 fma  1   00.E+4 0E+3  -> 0E+3
fmax3727 fma  1   00.E+5 0E+3  -> 0E+3
fmax3728 fma  1   -00.00 0E+3  -> 0.00
fmax3729 fma  1   -00.0  0E+3  -> 0.0
fmax3730 fma  1   -00.   0E+3  -> 0

fmax3732 fma  1    0     0     ->  0
fmax3733 fma  1    0    -0     ->  0
fmax3734 fma  1   -0     0     ->  0
fmax3735 fma  1   -0    -0     -> -0     -- IEEE 854 special case

fmax3736 fma  1    1    -1     ->  0
fmax3737 fma  1   -1    -1     -> -2
fmax3738 fma  1    1     1     ->  2
fmax3739 fma  1   -1     1     ->  0

fmax3741 fma  1    0    -1     -> -1
fmax3742 fma  1   -0    -1     -> -1
fmax3743 fma  1    0     1     ->  1
fmax3744 fma  1   -0     1     ->  1
fmax3745 fma  1   -1     0     -> -1
fmax3746 fma  1   -1    -0     -> -1
fmax3747 fma  1    1     0     ->  1
fmax3748 fma  1    1    -0     ->  1

fmax3751 fma  1    0.0  -1     -> -1.0
fmax3752 fma  1   -0.0  -1     -> -1.0
fmax3753 fma  1    0.0   1     ->  1.0
fmax3754 fma  1   -0.0   1     ->  1.0
fmax3755 fma  1   -1.0   0     -> -1.0
fmax3756 fma  1   -1.0  -0     -> -1.0
fmax3757 fma  1    1.0   0     ->  1.0
fmax3758 fma  1    1.0  -0     ->  1.0

fmax3761 fma  1    0    -1.0   -> -1.0
fmax3762 fma  1   -0    -1.0   -> -1.0
fmax3763 fma  1    0     1.0   ->  1.0
fmax3764 fma  1   -0     1.0   ->  1.0
fmax3765 fma  1   -1     0.0   -> -1.0
fmax3766 fma  1   -1    -0.0   -> -1.0
fmax3767 fma  1    1     0.0   ->  1.0
fmax3768 fma  1    1    -0.0   ->  1.0

fmax3771 fma  1    0.0  -1.0   -> -1.0
fmax3772 fma  1   -0.0  -1.0   -> -1.0
fmax3773 fma  1    0.0   1.0   ->  1.0
fmax3774 fma  1   -0.0   1.0   ->  1.0
fmax3775 fma  1   -1.0   0.0   -> -1.0
fmax3776 fma  1   -1.0  -0.0   -> -1.0
fmax3777 fma  1    1.0   0.0   ->  1.0
fmax3778 fma  1    1.0  -0.0   ->  1.0

-- Specials
fmax3780 fma  1   -Inf  -Inf   -> -Infinity
fmax3781 fma  1   -Inf  -1000  -> -Infinity
fmax3782 fma  1   -Inf  -1     -> -Infinity
fmax3783 fma  1   -Inf  -0     -> -Infinity
fmax3784 fma  1   -Inf   0     -> -Infinity
fmax3785 fma  1   -Inf   1     -> -Infinity
fmax3786 fma  1   -Inf   1000  -> -Infinity
fmax3787 fma  1   -1000 -Inf   -> -Infinity
fmax3788 fma  1   -Inf  -Inf   -> -Infinity
fmax3789 fma  1   -1    -Inf   -> -Infinity
fmax3790 fma  1   -0    -Inf   -> -Infinity
fmax3791 fma  1    0    -Inf   -> -Infinity
fmax3792 fma  1    1    -Inf   -> -Infinity
fmax3793 fma  1    1000 -Inf   -> -Infinity
fmax3794 fma  1    Inf  -Inf   ->  NaN  Invalid_operation

fmax3800 fma  1    Inf  -Inf   ->  NaN  Invalid_operation
fmax3801 fma  1    Inf  -1000  ->  Infinity
fmax3802 fma  1    Inf  -1     ->  Infinity
fmax3803 fma  1    Inf  -0     ->  Infinity
fmax3804 fma  1    Inf   0     ->  Infinity
fmax3805 fma  1    Inf   1     ->  Infinity
fmax3806 fma  1    Inf   1000  ->  Infinity
fmax3807 fma  1    Inf   Inf   ->  Infinity
fmax3808 fma  1   -1000  Inf   ->  Infinity
fmax3809 fma  1   -Inf   Inf   ->  NaN  Invalid_operation
fmax3810 fma  1   -1     Inf   ->  Infinity
fmax3811 fma  1   -0     Inf   ->  Infinity
fmax3812 fma  1    0     Inf   ->  Infinity
fmax3813 fma  1    1     Inf   ->  Infinity
fmax3814 fma  1    1000  Inf   ->  Infinity
fmax3815 fma  1    Inf   Inf   ->  Infinity

fmax3821 fma  1    NaN -Inf    ->  NaN
fmax3822 fma  1    NaN -1000   ->  NaN
fmax3823 fma  1    NaN -1      ->  NaN
fmax3824 fma  1    NaN -0      ->  NaN
fmax3825 fma  1    NaN  0      ->  NaN
fmax3826 fma  1    NaN  1      ->  NaN
fmax3827 fma  1    NaN  1000   ->  NaN
fmax3828 fma  1    NaN  Inf    ->  NaN
fmax3829 fma  1    NaN  NaN    ->  NaN
fmax3830 fma  1   -Inf  NaN    ->  NaN
fmax3831 fma  1   -1000 NaN    ->  NaN
fmax3832 fma  1   -1    NaN    ->  NaN
fmax3833 fma  1   -0    NaN    ->  NaN
fmax3834 fma  1    0    NaN    ->  NaN
fmax3835 fma  1    1    NaN    ->  NaN
fmax3836 fma  1    1000 NaN    ->  NaN
fmax3837 fma  1    Inf  NaN    ->  NaN

fmax3841 fma  1    sNaN -Inf   ->  NaN  Invalid_operation
fmax3842 fma  1    sNaN -1000  ->  NaN  Invalid_operation
fmax3843 fma  1    sNaN -1     ->  NaN  Invalid_operation
fmax3844 fma  1    sNaN -0     ->  NaN  Invalid_operation
fmax3845 fma  1    sNaN  0     ->  NaN  Invalid_operation
fmax3846 fma  1    sNaN  1     ->  NaN  Invalid_operation
fmax3847 fma  1    sNaN  1000  ->  NaN  Invalid_operation
fmax3848 fma  1    sNaN  NaN   ->  NaN  Invalid_operation
fmax3849 fma  1    sNaN sNaN   ->  NaN  Invalid_operation
fmax3850 fma  1    NaN  sNaN   ->  NaN  Invalid_operation
fmax3851 fma  1   -Inf  sNaN   ->  NaN  Invalid_operation
fmax3852 fma  1   -1000 sNaN   ->  NaN  Invalid_operation
fmax3853 fma  1   -1    sNaN   ->  NaN  Invalid_operation
fmax3854 fma  1   -0    sNaN   ->  NaN  Invalid_operation
fmax3855 fma  1    0    sNaN   ->  NaN  Invalid_operation
fmax3856 fma  1    1    sNaN   ->  NaN  Invalid_operation
fmax3857 fma  1    1000 sNaN   ->  NaN  Invalid_operation
fmax3858 fma  1    Inf  sNaN   ->  NaN  Invalid_operation
fmax3859 fma  1    NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
fmax3861 fma  1    NaN1   -Inf    ->  NaN1
fmax3862 fma  1   +NaN2   -1000   ->  NaN2
fmax3863 fma  1    NaN3    1000   ->  NaN3
fmax3864 fma  1    NaN4    Inf    ->  NaN4
fmax3865 fma  1    NaN5   +NaN6   ->  NaN5
fmax3866 fma  1   -Inf     NaN7   ->  NaN7
fmax3867 fma  1   -1000    NaN8   ->  NaN8
fmax3868 fma  1    1000    NaN9   ->  NaN9
fmax3869 fma  1    Inf    +NaN10  ->  NaN10
fmax3871 fma  1    sNaN11  -Inf   ->  NaN11  Invalid_operation
fmax3872 fma  1    sNaN12  -1000  ->  NaN12  Invalid_operation
fmax3873 fma  1    sNaN13   1000  ->  NaN13  Invalid_operation
fmax3874 fma  1    sNaN14   NaN17 ->  NaN14  Invalid_operation
fmax3875 fma  1    sNaN15  sNaN18 ->  NaN15  Invalid_operation
fmax3876 fma  1    NaN16   sNaN19 ->  NaN19  Invalid_operation
fmax3877 fma  1   -Inf    +sNaN20 ->  NaN20  Invalid_operation
fmax3878 fma  1   -1000    sNaN21 ->  NaN21  Invalid_operation
fmax3879 fma  1    1000    sNaN22 ->  NaN22  Invalid_operation
fmax3880 fma  1    Inf     sNaN23 ->  NaN23  Invalid_operation
fmax3881 fma  1   +NaN25  +sNaN24 ->  NaN24  Invalid_operation
fmax3882 fma  1   -NaN26    NaN28 -> -NaN26
fmax3883 fma  1   -sNaN27  sNaN29 -> -NaN27  Invalid_operation
fmax3884 fma  1    1000    -NaN30 -> -NaN30
fmax3885 fma  1    1000   -sNaN31 -> -NaN31  Invalid_operation

-- overflow, underflow and subnormal tests
maxexponent: 999999
minexponent: -999999
precision: 9
fmax3890 fma  1   1E+999999     9E+999999   -> Infinity Overflow Inexact Rounded
fmax3891 fma  1   9E+999999     1E+999999   -> Infinity Overflow Inexact Rounded
fmax3892 fma  1   -1.1E-999999  1E-999999   -> -1E-1000000    Subnormal
fmax3893 fma  1   1E-999999    -1.1e-999999 -> -1E-1000000    Subnormal
fmax3894 fma  1   -1.0001E-999999  1E-999999   -> -1E-1000003 Subnormal
fmax3895 fma  1   1E-999999    -1.0001e-999999 -> -1E-1000003 Subnormal
fmax3896 fma  1   -1E+999999   -9E+999999   -> -Infinity Overflow Inexact Rounded
fmax3897 fma  1   -9E+999999   -1E+999999   -> -Infinity Overflow Inexact Rounded
fmax3898 fma  1   +1.1E-999999 -1E-999999   -> 1E-1000000   Subnormal
fmax3899 fma  1   -1E-999999   +1.1e-999999 -> 1E-1000000    Subnormal
fmax3900 fma  1   +1.0001E-999999 -1E-999999   -> 1E-1000003 Subnormal
fmax3901 fma  1   -1E-999999   +1.0001e-999999 -> 1E-1000003 Subnormal
fmax3902 fma  1   -1E+999999   +9E+999999   ->  8E+999999
fmax3903 fma  1   -9E+999999   +1E+999999   -> -8E+999999

precision: 3
fmax3904 fma  1        0 -9.999E+999999   -> -Infinity Inexact Overflow Rounded
fmax3905 fma  1          -9.999E+999999 0 -> -Infinity Inexact Overflow Rounded
fmax3906 fma  1        0  9.999E+999999   ->  Infinity Inexact Overflow Rounded
fmax3907 fma  1           9.999E+999999 0 ->  Infinity Inexact Overflow Rounded

precision: 3
maxexponent: 999
minexponent: -999
fmax3910 fma  1    1.00E-999   0    ->   1.00E-999
fmax3911 fma  1    0.1E-999    0    ->   1E-1000   Subnormal
fmax3912 fma  1    0.10E-999   0    ->   1.0E-1000 Subnormal
fmax3913 fma  1    0.100E-999  0    ->   1.0E-1000 Subnormal Rounded
fmax3914 fma  1    0.01E-999   0    ->   1E-1001   Subnormal
-- next is rounded to Nmin
fmax3915 fma  1    0.999E-999  0    ->   1.00E-999 Inexact Rounded Subnormal Underflow
fmax3916 fma  1    0.099E-999  0    ->   1.0E-1000 Inexact Rounded Subnormal Underflow
fmax3917 fma  1    0.009E-999  0    ->   1E-1001   Inexact Rounded Subnormal Underflow
fmax3918 fma  1    0.001E-999  0    ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
fmax3919 fma  1    0.0009E-999 0    ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
fmax3920 fma  1    0.0001E-999 0    ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped

fmax3930 fma  1   -1.00E-999   0    ->  -1.00E-999
fmax3931 fma  1   -0.1E-999    0    ->  -1E-1000   Subnormal
fmax3932 fma  1   -0.10E-999   0    ->  -1.0E-1000 Subnormal
fmax3933 fma  1   -0.100E-999  0    ->  -1.0E-1000 Subnormal Rounded
fmax3934 fma  1   -0.01E-999   0    ->  -1E-1001   Subnormal
-- next is rounded to Nmin
fmax3935 fma  1   -0.999E-999  0    ->  -1.00E-999 Inexact Rounded Subnormal Underflow
fmax3936 fma  1   -0.099E-999  0    ->  -1.0E-1000 Inexact Rounded Subnormal Underflow
fmax3937 fma  1   -0.009E-999  0    ->  -1E-1001   Inexact Rounded Subnormal Underflow
fmax3938 fma  1   -0.001E-999  0    ->  -0E-1001   Inexact Rounded Subnormal Underflow Clamped
fmax3939 fma  1   -0.0009E-999 0    ->  -0E-1001   Inexact Rounded Subnormal Underflow Clamped
fmax3940 fma  1   -0.0001E-999 0    ->  -0E-1001   Inexact Rounded Subnormal Underflow Clamped

-- some non-zero subnormal fma  1  s
fmax3950 fma  1    1.00E-999    0.1E-999  ->   1.10E-999
fmax3951 fma  1    0.1E-999     0.1E-999  ->   2E-1000    Subnormal
fmax3952 fma  1    0.10E-999    0.1E-999  ->   2.0E-1000  Subnormal
fmax3953 fma  1    0.100E-999   0.1E-999  ->   2.0E-1000  Subnormal Rounded
fmax3954 fma  1    0.01E-999    0.1E-999  ->   1.1E-1000  Subnormal
fmax3955 fma  1    0.999E-999   0.1E-999  ->   1.10E-999  Inexact Rounded
fmax3956 fma  1    0.099E-999   0.1E-999  ->   2.0E-1000  Inexact Rounded Subnormal Underflow
fmax3957 fma  1    0.009E-999   0.1E-999  ->   1.1E-1000  Inexact Rounded Subnormal Underflow
fmax3958 fma  1    0.001E-999   0.1E-999  ->   1.0E-1000  Inexact Rounded Subnormal Underflow
fmax3959 fma  1    0.0009E-999  0.1E-999  ->   1.0E-1000  Inexact Rounded Subnormal Underflow
fmax3960 fma  1    0.0001E-999  0.1E-999  ->   1.0E-1000  Inexact Rounded Subnormal Underflow
-- negatives...
fmax3961 fma  1    1.00E-999   -0.1E-999  ->   9.0E-1000  Subnormal
fmax3962 fma  1    0.1E-999    -0.1E-999  ->   0E-1000
fmax3963 fma  1    0.10E-999   -0.1E-999  ->   0E-1001
fmax3964 fma  1    0.100E-999  -0.1E-999  ->   0E-1001    Clamped
fmax3965 fma  1    0.01E-999   -0.1E-999  ->   -9E-1001   Subnormal
fmax3966 fma  1    0.999E-999  -0.1E-999  ->   9.0E-1000  Inexact Rounded Subnormal Underflow
fmax3967 fma  1    0.099E-999  -0.1E-999  ->   -0E-1001   Inexact Rounded Subnormal Underflow Clamped
fmax3968 fma  1    0.009E-999  -0.1E-999  ->   -9E-1001   Inexact Rounded Subnormal Underflow
fmax3969 fma  1    0.001E-999  -0.1E-999  ->   -1.0E-1000 Inexact Rounded Subnormal Underflow
fmax3970 fma  1    0.0009E-999 -0.1E-999  ->   -1.0E-1000 Inexact Rounded Subnormal Underflow
fmax3971 fma  1    0.0001E-999 -0.1E-999  ->   -1.0E-1000 Inexact Rounded Subnormal Underflow

-- some 'real' numbers
maxExponent: 384
minExponent: -383
precision: 8
fmax3566 fma  1   99999061735E-394  0E-394 -> 9.999906E-384 Inexact Rounded Underflow Subnormal
precision: 7
fmax3567 fma  1   99999061735E-394  0E-394 -> 9.99991E-384 Inexact Rounded Underflow Subnormal
precision: 6
fmax3568 fma  1   99999061735E-394  0E-394 -> 9.9999E-384 Inexact Rounded Underflow Subnormal

-- now the case where we can get underflow but the result is normal
-- [note this can't happen if the operands are also bounded, as we
-- cannot represent 1E-399, for example]
precision:   16
rounding:    half_up
maxExponent: 384
minExponent: -383

fmax3571 fma  1         1E-383       0  -> 1E-383
fmax3572 fma  1         1E-384       0  -> 1E-384   Subnormal
fmax3573 fma  1         1E-383  1E-384  -> 1.1E-383
fmax3574 subtract  1E-383  1E-384  ->   9E-384 Subnormal

-- Here we explore the boundary of rounding a subnormal to Nmin
fmax3575 subtract  1E-383  1E-398  ->   9.99999999999999E-384  Subnormal
fmax3576 subtract  1E-383  1E-398  ->   9.99999999999999E-384  Subnormal
fmax3577 subtract  1E-383  1E-399  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
fmax3578 subtract  1E-383  1E-400  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
fmax3579 subtract  1E-383  1E-401  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
fmax3580 subtract  1E-383  1E-402  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded

-- check for double-rounded subnormals
precision:   5
maxexponent: 79
minexponent: -79
-- Add: lhs and rhs 0
fmax31001 fma  1         1.52444E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
fmax31002 fma  1         1.52445E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
fmax31003 fma  1         1.52446E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
fmax31004 fma  1         0 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
fmax31005 fma  1         0 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
fmax31006 fma  1         0 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow

-- Add: lhs >> rhs and vice versa
fmax31011 fma  1         1.52444E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
fmax31012 fma  1         1.52445E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
fmax31013 fma  1         1.52446E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
fmax31014 fma  1         1E-100 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
fmax31015 fma  1         1E-100 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
fmax31016 fma  1         1E-100 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow

-- Add: lhs + rhs fma  1  ition carried out
fmax31021 fma  1         1.52443E-80 1.00001E-80  -> 2.524E-80 Inexact Rounded Subnormal Underflow
fmax31022 fma  1         1.52444E-80 1.00001E-80  -> 2.524E-80 Inexact Rounded Subnormal Underflow
fmax31023 fma  1         1.52445E-80 1.00001E-80  -> 2.524E-80 Inexact Rounded Subnormal Underflow
fmax31024 fma  1         1.00001E-80  1.52443E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
fmax31025 fma  1         1.00001E-80  1.52444E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
fmax31026 fma  1         1.00001E-80  1.52445E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow

-- And for round down full and subnormal results
precision:    16
maxExponent: +384
minExponent: -383
rounding:     down

fmax31100 fma  1   1e+2 -1e-383    -> 99.99999999999999 Rounded Inexact
fmax31101 fma  1   1e+1 -1e-383    -> 9.999999999999999  Rounded Inexact
fmax31103 fma  1     +1 -1e-383    -> 0.9999999999999999  Rounded Inexact
fmax31104 fma  1   1e-1 -1e-383    -> 0.09999999999999999  Rounded Inexact
fmax31105 fma  1   1e-2 -1e-383    -> 0.009999999999999999  Rounded Inexact
fmax31106 fma  1   1e-3 -1e-383    -> 0.0009999999999999999  Rounded Inexact
fmax31107 fma  1   1e-4 -1e-383    -> 0.00009999999999999999  Rounded Inexact
fmax31108 fma  1   1e-5 -1e-383    -> 0.000009999999999999999  Rounded Inexact
fmax31109 fma  1   1e-6 -1e-383    -> 9.999999999999999E-7  Rounded Inexact

rounding:     ceiling
fmax31110 fma  1   -1e+2 +1e-383   -> -99.99999999999999 Rounded Inexact
fmax31111 fma  1   -1e+1 +1e-383   -> -9.999999999999999  Rounded Inexact
fmax31113 fma  1      -1 +1e-383   -> -0.9999999999999999  Rounded Inexact
fmax31114 fma  1   -1e-1 +1e-383   -> -0.09999999999999999  Rounded Inexact
fmax31115 fma  1   -1e-2 +1e-383   -> -0.009999999999999999  Rounded Inexact
fmax31116 fma  1   -1e-3 +1e-383   -> -0.0009999999999999999  Rounded Inexact
fmax31117 fma  1   -1e-4 +1e-383   -> -0.00009999999999999999  Rounded Inexact
fmax31118 fma  1   -1e-5 +1e-383   -> -0.000009999999999999999  Rounded Inexact
fmax31119 fma  1   -1e-6 +1e-383   -> -9.999999999999999E-7  Rounded Inexact

rounding:     down
precision:    7
maxExponent: +96
minExponent: -95
fmax31130 fma  1     1            -1e-200  -> 0.9999999  Rounded Inexact
-- subnormal boundary
fmax31131 fma  1     1.000000E-94  -1e-200  ->  9.999999E-95  Rounded Inexact
fmax31132 fma  1     1.000001E-95  -1e-200  ->  1.000000E-95  Rounded Inexact
fmax31133 fma  1     1.000000E-95  -1e-200  ->  9.99999E-96  Rounded Inexact Subnormal Underflow
fmax31134 fma  1     0.999999E-95  -1e-200  ->  9.99998E-96  Rounded Inexact Subnormal Underflow
fmax31135 fma  1     0.001000E-95  -1e-200  ->  9.99E-99  Rounded Inexact Subnormal Underflow
fmax31136 fma  1     0.000999E-95  -1e-200  ->  9.98E-99  Rounded Inexact Subnormal Underflow
fmax31137 fma  1     1.000000E-95  -1e-101  ->  9.99999E-96  Subnormal
fmax31138 fma  1        10000E-101 -1e-200  ->  9.999E-98  Subnormal Inexact Rounded Underflow
fmax31139 fma  1         1000E-101 -1e-200  ->  9.99E-99   Subnormal Inexact Rounded Underflow
fmax31140 fma  1          100E-101 -1e-200  ->  9.9E-100   Subnormal Inexact Rounded Underflow
fmax31141 fma  1           10E-101 -1e-200  ->  9E-101     Subnormal Inexact Rounded Underflow
fmax31142 fma  1            1E-101 -1e-200  ->  0E-101     Subnormal Inexact Rounded Underflow Clamped
fmax31143 fma  1            0E-101 -1e-200  -> -0E-101     Subnormal Inexact Rounded Underflow Clamped
fmax31144 fma  1            1E-102 -1e-200  ->  0E-101     Subnormal Inexact Rounded Underflow Clamped

fmax31151 fma  1        10000E-102 -1e-200  ->  9.99E-99  Subnormal Inexact Rounded Underflow
fmax31152 fma  1         1000E-102 -1e-200  ->  9.9E-100  Subnormal Inexact Rounded Underflow
fmax31153 fma  1          100E-102 -1e-200  ->  9E-101   Subnormal Inexact Rounded Underflow
fmax31154 fma  1           10E-102 -1e-200  ->  0E-101     Subnormal Inexact Rounded Underflow Clamped
fmax31155 fma  1            1E-102 -1e-200  ->  0E-101     Subnormal Inexact Rounded Underflow Clamped
fmax31156 fma  1            0E-102 -1e-200  -> -0E-101     Subnormal Inexact Rounded Underflow Clamped
fmax31157 fma  1            1E-103 -1e-200  ->  0E-101     Subnormal Inexact Rounded Underflow Clamped

fmax31160 fma  1          100E-105 -1e-101  -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
fmax31161 fma  1          100E-105 -1e-201  ->  0E-101 Subnormal Inexact Rounded Underflow Clamped

-- tests based on Gunnar Degnbol's edge case
precision:   15
rounding:    half_up
maxExponent: 384
minexponent: -383

fmax31200 fma  1   1E15  -0.5                 ->  1.00000000000000E+15 Inexact Rounded
fmax31201 fma  1   1E15  -0.50                ->  1.00000000000000E+15 Inexact Rounded
fmax31210 fma  1   1E15  -0.51                ->  999999999999999      Inexact Rounded
fmax31211 fma  1   1E15  -0.501               ->  999999999999999      Inexact Rounded
fmax31212 fma  1   1E15  -0.5001              ->  999999999999999      Inexact Rounded
fmax31213 fma  1   1E15  -0.50001             ->  999999999999999      Inexact Rounded
fmax31214 fma  1   1E15  -0.500001            ->  999999999999999      Inexact Rounded
fmax31215 fma  1   1E15  -0.5000001           ->  999999999999999      Inexact Rounded
fmax31216 fma  1   1E15  -0.50000001          ->  999999999999999      Inexact Rounded
fmax31217 fma  1   1E15  -0.500000001         ->  999999999999999      Inexact Rounded
fmax31218 fma  1   1E15  -0.5000000001        ->  999999999999999      Inexact Rounded
fmax31219 fma  1   1E15  -0.50000000001       ->  999999999999999      Inexact Rounded
fmax31220 fma  1   1E15  -0.500000000001      ->  999999999999999      Inexact Rounded
fmax31221 fma  1   1E15  -0.5000000000001     ->  999999999999999      Inexact Rounded
fmax31222 fma  1   1E15  -0.50000000000001    ->  999999999999999      Inexact Rounded
fmax31223 fma  1   1E15  -0.500000000000001   ->  999999999999999      Inexact Rounded
fmax31224 fma  1   1E15  -0.5000000000000001  ->  999999999999999      Inexact Rounded
fmax31225 fma  1   1E15  -0.5000000000000000  ->  1.00000000000000E+15 Inexact Rounded
fmax31230 fma  1   1E15  -5000000.000000001   ->  999999995000000      Inexact Rounded

precision:   16

fmax31300 fma  1   1E16  -0.5                 ->  1.000000000000000E+16 Inexact Rounded
fmax31310 fma  1   1E16  -0.51                ->  9999999999999999      Inexact Rounded
fmax31311 fma  1   1E16  -0.501               ->  9999999999999999      Inexact Rounded
fmax31312 fma  1   1E16  -0.5001              ->  9999999999999999      Inexact Rounded
fmax31313 fma  1   1E16  -0.50001             ->  9999999999999999      Inexact Rounded
fmax31314 fma  1   1E16  -0.500001            ->  9999999999999999      Inexact Rounded
fmax31315 fma  1   1E16  -0.5000001           ->  9999999999999999      Inexact Rounded
fmax31316 fma  1   1E16  -0.50000001          ->  9999999999999999      Inexact Rounded
fmax31317 fma  1   1E16  -0.500000001         ->  9999999999999999      Inexact Rounded
fmax31318 fma  1   1E16  -0.5000000001        ->  9999999999999999      Inexact Rounded
fmax31319 fma  1   1E16  -0.50000000001       ->  9999999999999999      Inexact Rounded
fmax31320 fma  1   1E16  -0.500000000001      ->  9999999999999999      Inexact Rounded
fmax31321 fma  1   1E16  -0.5000000000001     ->  9999999999999999      Inexact Rounded
fmax31322 fma  1   1E16  -0.50000000000001    ->  9999999999999999      Inexact Rounded
fmax31323 fma  1   1E16  -0.500000000000001   ->  9999999999999999      Inexact Rounded
fmax31324 fma  1   1E16  -0.5000000000000001  ->  9999999999999999      Inexact Rounded
fmax31325 fma  1   1E16  -0.5000000000000000  ->  1.000000000000000E+16 Inexact Rounded
fmax31326 fma  1   1E16  -0.500000000000000   ->  1.000000000000000E+16 Inexact Rounded
fmax31327 fma  1   1E16  -0.50000000000000    ->  1.000000000000000E+16 Inexact Rounded
fmax31328 fma  1   1E16  -0.5000000000000     ->  1.000000000000000E+16 Inexact Rounded
fmax31329 fma  1   1E16  -0.500000000000      ->  1.000000000000000E+16 Inexact Rounded
fmax31330 fma  1   1E16  -0.50000000000       ->  1.000000000000000E+16 Inexact Rounded
fmax31331 fma  1   1E16  -0.5000000000        ->  1.000000000000000E+16 Inexact Rounded
fmax31332 fma  1   1E16  -0.500000000         ->  1.000000000000000E+16 Inexact Rounded
fmax31333 fma  1   1E16  -0.50000000          ->  1.000000000000000E+16 Inexact Rounded
fmax31334 fma  1   1E16  -0.5000000           ->  1.000000000000000E+16 Inexact Rounded
fmax31335 fma  1   1E16  -0.500000            ->  1.000000000000000E+16 Inexact Rounded
fmax31336 fma  1   1E16  -0.50000             ->  1.000000000000000E+16 Inexact Rounded
fmax31337 fma  1   1E16  -0.5000              ->  1.000000000000000E+16 Inexact Rounded
fmax31338 fma  1   1E16  -0.500               ->  1.000000000000000E+16 Inexact Rounded
fmax31339 fma  1   1E16  -0.50                ->  1.000000000000000E+16 Inexact Rounded

fmax31340 fma  1   1E16  -5000000.000010001   ->  9999999995000000      Inexact Rounded
fmax31341 fma  1   1E16  -5000000.000000001   ->  9999999995000000      Inexact Rounded

fmax31349 fma  1   9999999999999999 0.4                 ->  9999999999999999      Inexact Rounded
fmax31350 fma  1   9999999999999999 0.49                ->  9999999999999999      Inexact Rounded
fmax31351 fma  1   9999999999999999 0.499               ->  9999999999999999      Inexact Rounded
fmax31352 fma  1   9999999999999999 0.4999              ->  9999999999999999      Inexact Rounded
fmax31353 fma  1   9999999999999999 0.49999             ->  9999999999999999      Inexact Rounded
fmax31354 fma  1   9999999999999999 0.499999            ->  9999999999999999      Inexact Rounded
fmax31355 fma  1   9999999999999999 0.4999999           ->  9999999999999999      Inexact Rounded
fmax31356 fma  1   9999999999999999 0.49999999          ->  9999999999999999      Inexact Rounded
fmax31357 fma  1   9999999999999999 0.499999999         ->  9999999999999999      Inexact Rounded
fmax31358 fma  1   9999999999999999 0.4999999999        ->  9999999999999999      Inexact Rounded
fmax31359 fma  1   9999999999999999 0.49999999999       ->  9999999999999999      Inexact Rounded
fmax31360 fma  1   9999999999999999 0.499999999999      ->  9999999999999999      Inexact Rounded
fmax31361 fma  1   9999999999999999 0.4999999999999     ->  9999999999999999      Inexact Rounded
fmax31362 fma  1   9999999999999999 0.49999999999999    ->  9999999999999999      Inexact Rounded
fmax31363 fma  1   9999999999999999 0.499999999999999   ->  9999999999999999      Inexact Rounded
fmax31364 fma  1   9999999999999999 0.4999999999999999  ->  9999999999999999      Inexact Rounded
fmax31365 fma  1   9999999999999999 0.5000000000000000  ->  1.000000000000000E+16 Inexact Rounded
fmax31367 fma  1   9999999999999999 0.500000000000000   ->  1.000000000000000E+16 Inexact Rounded
fmax31368 fma  1   9999999999999999 0.50000000000000    ->  1.000000000000000E+16 Inexact Rounded
fmax31369 fma  1   9999999999999999 0.5000000000000     ->  1.000000000000000E+16 Inexact Rounded
fmax31370 fma  1   9999999999999999 0.500000000000      ->  1.000000000000000E+16 Inexact Rounded
fmax31371 fma  1   9999999999999999 0.50000000000       ->  1.000000000000000E+16 Inexact Rounded
fmax31372 fma  1   9999999999999999 0.5000000000        ->  1.000000000000000E+16 Inexact Rounded
fmax31373 fma  1   9999999999999999 0.500000000         ->  1.000000000000000E+16 Inexact Rounded
fmax31374 fma  1   9999999999999999 0.50000000          ->  1.000000000000000E+16 Inexact Rounded
fmax31375 fma  1   9999999999999999 0.5000000           ->  1.000000000000000E+16 Inexact Rounded
fmax31376 fma  1   9999999999999999 0.500000            ->  1.000000000000000E+16 Inexact Rounded
fmax31377 fma  1   9999999999999999 0.50000             ->  1.000000000000000E+16 Inexact Rounded
fmax31378 fma  1   9999999999999999 0.5000              ->  1.000000000000000E+16 Inexact Rounded
fmax31379 fma  1   9999999999999999 0.500               ->  1.000000000000000E+16 Inexact Rounded
fmax31380 fma  1   9999999999999999 0.50                ->  1.000000000000000E+16 Inexact Rounded
fmax31381 fma  1   9999999999999999 0.5                 ->  1.000000000000000E+16 Inexact Rounded
fmax31382 fma  1   9999999999999999 0.5000000000000001  ->  1.000000000000000E+16 Inexact Rounded
fmax31383 fma  1   9999999999999999 0.500000000000001   ->  1.000000000000000E+16 Inexact Rounded
fmax31384 fma  1   9999999999999999 0.50000000000001    ->  1.000000000000000E+16 Inexact Rounded
fmax31385 fma  1   9999999999999999 0.5000000000001     ->  1.000000000000000E+16 Inexact Rounded
fmax31386 fma  1   9999999999999999 0.500000000001      ->  1.000000000000000E+16 Inexact Rounded
fmax31387 fma  1   9999999999999999 0.50000000001       ->  1.000000000000000E+16 Inexact Rounded
fmax31388 fma  1   9999999999999999 0.5000000001        ->  1.000000000000000E+16 Inexact Rounded
fmax31389 fma  1   9999999999999999 0.500000001         ->  1.000000000000000E+16 Inexact Rounded
fmax31390 fma  1   9999999999999999 0.50000001          ->  1.000000000000000E+16 Inexact Rounded
fmax31391 fma  1   9999999999999999 0.5000001           ->  1.000000000000000E+16 Inexact Rounded
fmax31392 fma  1   9999999999999999 0.500001            ->  1.000000000000000E+16 Inexact Rounded
fmax31393 fma  1   9999999999999999 0.50001             ->  1.000000000000000E+16 Inexact Rounded
fmax31394 fma  1   9999999999999999 0.5001              ->  1.000000000000000E+16 Inexact Rounded
fmax31395 fma  1   9999999999999999 0.501               ->  1.000000000000000E+16 Inexact Rounded
fmax31396 fma  1   9999999999999999 0.51                ->  1.000000000000000E+16 Inexact Rounded

-- More GD edge cases, where difference between the unadjusted
-- exponents is larger than the maximum precision and one side is 0
precision:   15
rounding:    half_up
maxExponent: 384
minexponent: -383

fmax31400 fma  1    0 1.23456789012345     -> 1.23456789012345
fmax31401 fma  1    0 1.23456789012345E-1  -> 0.123456789012345
fmax31402 fma  1    0 1.23456789012345E-2  -> 0.0123456789012345
fmax31403 fma  1    0 1.23456789012345E-3  -> 0.00123456789012345
fmax31404 fma  1    0 1.23456789012345E-4  -> 0.000123456789012345
fmax31405 fma  1    0 1.23456789012345E-5  -> 0.0000123456789012345
fmax31406 fma  1    0 1.23456789012345E-6  -> 0.00000123456789012345
fmax31407 fma  1    0 1.23456789012345E-7  -> 1.23456789012345E-7
fmax31408 fma  1    0 1.23456789012345E-8  -> 1.23456789012345E-8
fmax31409 fma  1    0 1.23456789012345E-9  -> 1.23456789012345E-9
fmax31410 fma  1    0 1.23456789012345E-10 -> 1.23456789012345E-10
fmax31411 fma  1    0 1.23456789012345E-11 -> 1.23456789012345E-11
fmax31412 fma  1    0 1.23456789012345E-12 -> 1.23456789012345E-12
fmax31413 fma  1    0 1.23456789012345E-13 -> 1.23456789012345E-13
fmax31414 fma  1    0 1.23456789012345E-14 -> 1.23456789012345E-14
fmax31415 fma  1    0 1.23456789012345E-15 -> 1.23456789012345E-15
fmax31416 fma  1    0 1.23456789012345E-16 -> 1.23456789012345E-16
fmax31417 fma  1    0 1.23456789012345E-17 -> 1.23456789012345E-17
fmax31418 fma  1    0 1.23456789012345E-18 -> 1.23456789012345E-18
fmax31419 fma  1    0 1.23456789012345E-19 -> 1.23456789012345E-19

-- same, precision 16..
precision:   16
fmax31420 fma  1    0 1.123456789012345     -> 1.123456789012345
fmax31421 fma  1    0 1.123456789012345E-1  -> 0.1123456789012345
fmax31422 fma  1    0 1.123456789012345E-2  -> 0.01123456789012345
fmax31423 fma  1    0 1.123456789012345E-3  -> 0.001123456789012345
fmax31424 fma  1    0 1.123456789012345E-4  -> 0.0001123456789012345
fmax31425 fma  1    0 1.123456789012345E-5  -> 0.00001123456789012345
fmax31426 fma  1    0 1.123456789012345E-6  -> 0.000001123456789012345
fmax31427 fma  1    0 1.123456789012345E-7  -> 1.123456789012345E-7
fmax31428 fma  1    0 1.123456789012345E-8  -> 1.123456789012345E-8
fmax31429 fma  1    0 1.123456789012345E-9  -> 1.123456789012345E-9
fmax31430 fma  1    0 1.123456789012345E-10 -> 1.123456789012345E-10
fmax31431 fma  1    0 1.123456789012345E-11 -> 1.123456789012345E-11
fmax31432 fma  1    0 1.123456789012345E-12 -> 1.123456789012345E-12
fmax31433 fma  1    0 1.123456789012345E-13 -> 1.123456789012345E-13
fmax31434 fma  1    0 1.123456789012345E-14 -> 1.123456789012345E-14
fmax31435 fma  1    0 1.123456789012345E-15 -> 1.123456789012345E-15
fmax31436 fma  1    0 1.123456789012345E-16 -> 1.123456789012345E-16
fmax31437 fma  1    0 1.123456789012345E-17 -> 1.123456789012345E-17
fmax31438 fma  1    0 1.123456789012345E-18 -> 1.123456789012345E-18
fmax31439 fma  1    0 1.123456789012345E-19 -> 1.123456789012345E-19

-- same, reversed 0
fmax31440 fma  1   1.123456789012345     0 -> 1.123456789012345
fmax31441 fma  1   1.123456789012345E-1  0 -> 0.1123456789012345
fmax31442 fma  1   1.123456789012345E-2  0 -> 0.01123456789012345
fmax31443 fma  1   1.123456789012345E-3  0 -> 0.001123456789012345
fmax31444 fma  1   1.123456789012345E-4  0 -> 0.0001123456789012345
fmax31445 fma  1   1.123456789012345E-5  0 -> 0.00001123456789012345
fmax31446 fma  1   1.123456789012345E-6  0 -> 0.000001123456789012345
fmax31447 fma  1   1.123456789012345E-7  0 -> 1.123456789012345E-7
fmax31448 fma  1   1.123456789012345E-8  0 -> 1.123456789012345E-8
fmax31449 fma  1   1.123456789012345E-9  0 -> 1.123456789012345E-9
fmax31450 fma  1   1.123456789012345E-10 0 -> 1.123456789012345E-10
fmax31451 fma  1   1.123456789012345E-11 0 -> 1.123456789012345E-11
fmax31452 fma  1   1.123456789012345E-12 0 -> 1.123456789012345E-12
fmax31453 fma  1   1.123456789012345E-13 0 -> 1.123456789012345E-13
fmax31454 fma  1   1.123456789012345E-14 0 -> 1.123456789012345E-14
fmax31455 fma  1   1.123456789012345E-15 0 -> 1.123456789012345E-15
fmax31456 fma  1   1.123456789012345E-16 0 -> 1.123456789012345E-16
fmax31457 fma  1   1.123456789012345E-17 0 -> 1.123456789012345E-17
fmax31458 fma  1   1.123456789012345E-18 0 -> 1.123456789012345E-18
fmax31459 fma  1   1.123456789012345E-19 0 -> 1.123456789012345E-19

-- same, Es on the 0
fmax31460 fma  1   1.123456789012345  0E-0   -> 1.123456789012345
fmax31461 fma  1   1.123456789012345  0E-1   -> 1.123456789012345
fmax31462 fma  1   1.123456789012345  0E-2   -> 1.123456789012345
fmax31463 fma  1   1.123456789012345  0E-3   -> 1.123456789012345
fmax31464 fma  1   1.123456789012345  0E-4   -> 1.123456789012345
fmax31465 fma  1   1.123456789012345  0E-5   -> 1.123456789012345
fmax31466 fma  1   1.123456789012345  0E-6   -> 1.123456789012345
fmax31467 fma  1   1.123456789012345  0E-7   -> 1.123456789012345
fmax31468 fma  1   1.123456789012345  0E-8   -> 1.123456789012345
fmax31469 fma  1   1.123456789012345  0E-9   -> 1.123456789012345
fmax31470 fma  1   1.123456789012345  0E-10  -> 1.123456789012345
fmax31471 fma  1   1.123456789012345  0E-11  -> 1.123456789012345
fmax31472 fma  1   1.123456789012345  0E-12  -> 1.123456789012345
fmax31473 fma  1   1.123456789012345  0E-13  -> 1.123456789012345
fmax31474 fma  1   1.123456789012345  0E-14  -> 1.123456789012345
fmax31475 fma  1   1.123456789012345  0E-15  -> 1.123456789012345
-- next four flag Rounded because the 0 extends the result
fmax31476 fma  1   1.123456789012345  0E-16  -> 1.123456789012345 Rounded
fmax31477 fma  1   1.123456789012345  0E-17  -> 1.123456789012345 Rounded
fmax31478 fma  1   1.123456789012345  0E-18  -> 1.123456789012345 Rounded
fmax31479 fma  1   1.123456789012345  0E-19  -> 1.123456789012345 Rounded

-- sum of two opposite-sign operands is exactly 0 and floor => -0
precision:   16
maxExponent: 384
minexponent: -383

rounding:    half_up
-- exact zeros from zeros
fmax31500 fma  1    0        0E-19  ->  0E-19
fmax31501 fma  1   -0        0E-19  ->  0E-19
fmax31502 fma  1    0       -0E-19  ->  0E-19
fmax31503 fma  1   -0       -0E-19  -> -0E-19
fmax31504 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax31505 fma  1   -0E-400   0E-19  ->  0E-398 Clamped
fmax31506 fma  1    0E-400  -0E-19  ->  0E-398 Clamped
fmax31507 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax31511 fma  1    1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31512 fma  1   -1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31513 fma  1    1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31514 fma  1   -1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-- some exact zeros from non-zeros
fmax31515 fma  1    1E-401   1E-401 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31516 fma  1   -1E-401   1E-401 ->  0E-398 Clamped
fmax31517 fma  1    1E-401  -1E-401 ->  0E-398 Clamped
fmax31518 fma  1   -1E-401  -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped

rounding:    half_down
-- exact zeros from zeros
fmax31520 fma  1    0        0E-19  ->  0E-19
fmax31521 fma  1   -0        0E-19  ->  0E-19
fmax31522 fma  1    0       -0E-19  ->  0E-19
fmax31523 fma  1   -0       -0E-19  -> -0E-19
fmax31524 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax31525 fma  1   -0E-400   0E-19  ->  0E-398 Clamped
fmax31526 fma  1    0E-400  -0E-19  ->  0E-398 Clamped
fmax31527 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax31531 fma  1    1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31532 fma  1   -1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31533 fma  1    1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31534 fma  1   -1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-- some exact zeros from non-zeros
fmax31535 fma  1    1E-401   1E-401 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31536 fma  1   -1E-401   1E-401 ->  0E-398 Clamped
fmax31537 fma  1    1E-401  -1E-401 ->  0E-398 Clamped
fmax31538 fma  1   -1E-401  -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped

rounding:    half_even
-- exact zeros from zeros
fmax31540 fma  1    0        0E-19  ->  0E-19
fmax31541 fma  1   -0        0E-19  ->  0E-19
fmax31542 fma  1    0       -0E-19  ->  0E-19
fmax31543 fma  1   -0       -0E-19  -> -0E-19
fmax31544 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax31545 fma  1   -0E-400   0E-19  ->  0E-398 Clamped
fmax31546 fma  1    0E-400  -0E-19  ->  0E-398 Clamped
fmax31547 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax31551 fma  1    1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31552 fma  1   -1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31553 fma  1    1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31554 fma  1   -1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-- some exact zeros from non-zeros
fmax31555 fma  1    1E-401   1E-401 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31556 fma  1   -1E-401   1E-401 ->  0E-398 Clamped
fmax31557 fma  1    1E-401  -1E-401 ->  0E-398 Clamped
fmax31558 fma  1   -1E-401  -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped

rounding:    up
-- exact zeros from zeros
fmax31560 fma  1    0        0E-19  ->  0E-19
fmax31561 fma  1   -0        0E-19  ->  0E-19
fmax31562 fma  1    0       -0E-19  ->  0E-19
fmax31563 fma  1   -0       -0E-19  -> -0E-19
fmax31564 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax31565 fma  1   -0E-400   0E-19  ->  0E-398 Clamped
fmax31566 fma  1    0E-400  -0E-19  ->  0E-398 Clamped
fmax31567 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax31571 fma  1    1E-401   1E-400 ->  1E-398 Subnormal Inexact Rounded Underflow
fmax31572 fma  1   -1E-401   1E-400 ->  1E-398 Subnormal Inexact Rounded Underflow
fmax31573 fma  1    1E-401  -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
fmax31574 fma  1   -1E-401  -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
-- some exact zeros from non-zeros
fmax31575 fma  1    1E-401   1E-401 ->  1E-398 Subnormal Inexact Rounded Underflow
fmax31576 fma  1   -1E-401   1E-401 ->  0E-398 Clamped
fmax31577 fma  1    1E-401  -1E-401 ->  0E-398 Clamped
fmax31578 fma  1   -1E-401  -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow

rounding:    down
-- exact zeros from zeros
fmax31580 fma  1    0        0E-19  ->  0E-19
fmax31581 fma  1   -0        0E-19  ->  0E-19
fmax31582 fma  1    0       -0E-19  ->  0E-19
fmax31583 fma  1   -0       -0E-19  -> -0E-19
fmax31584 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax31585 fma  1   -0E-400   0E-19  ->  0E-398 Clamped
fmax31586 fma  1    0E-400  -0E-19  ->  0E-398 Clamped
fmax31587 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax31591 fma  1    1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31592 fma  1   -1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31593 fma  1    1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31594 fma  1   -1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-- some exact zeros from non-zeros
fmax31595 fma  1    1E-401   1E-401 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31596 fma  1   -1E-401   1E-401 ->  0E-398 Clamped
fmax31597 fma  1    1E-401  -1E-401 ->  0E-398 Clamped
fmax31598 fma  1   -1E-401  -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped

rounding:    ceiling
-- exact zeros from zeros
fmax31600 fma  1    0        0E-19  ->  0E-19
fmax31601 fma  1   -0        0E-19  ->  0E-19
fmax31602 fma  1    0       -0E-19  ->  0E-19
fmax31603 fma  1   -0       -0E-19  -> -0E-19
fmax31604 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax31605 fma  1   -0E-400   0E-19  ->  0E-398 Clamped
fmax31606 fma  1    0E-400  -0E-19  ->  0E-398 Clamped
fmax31607 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax31611 fma  1    1E-401   1E-400 ->  1E-398 Subnormal Inexact Rounded Underflow
fmax31612 fma  1   -1E-401   1E-400 ->  1E-398 Subnormal Inexact Rounded Underflow
fmax31613 fma  1    1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31614 fma  1   -1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-- some exact zeros from non-zeros
fmax31615 fma  1    1E-401   1E-401 ->  1E-398 Subnormal Inexact Rounded Underflow
fmax31616 fma  1   -1E-401   1E-401 ->  0E-398 Clamped
fmax31617 fma  1    1E-401  -1E-401 ->  0E-398 Clamped
fmax31618 fma  1   -1E-401  -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped

-- and the extra-special ugly case; unusual minuses marked by -- *
rounding:    floor
-- exact zeros from zeros
fmax31620 fma  1    0        0E-19  ->  0E-19
fmax31621 fma  1   -0        0E-19  -> -0E-19           -- *
fmax31622 fma  1    0       -0E-19  -> -0E-19           -- *
fmax31623 fma  1   -0       -0E-19  -> -0E-19
fmax31624 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax31625 fma  1   -0E-400   0E-19  -> -0E-398 Clamped  -- *
fmax31626 fma  1    0E-400  -0E-19  -> -0E-398 Clamped  -- *
fmax31627 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax31631 fma  1    1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31632 fma  1   -1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31633 fma  1    1E-401  -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
fmax31634 fma  1   -1E-401  -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
-- some exact zeros from non-zeros
fmax31635 fma  1    1E-401   1E-401 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax31636 fma  1   -1E-401   1E-401 -> -0E-398 Clamped  -- *
fmax31637 fma  1    1E-401  -1E-401 -> -0E-398 Clamped  -- *
fmax31638 fma  1   -1E-401  -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow

-- BigDecimal problem testcases 2006.01.23
precision:   16
maxExponent: 384
minexponent: -383

rounding:  down
precision: 7
fmax31651 fma  1    10001E+2  -2E+1 -> 1.00008E+6
precision: 6
fmax31652 fma  1    10001E+2  -2E+1 -> 1.00008E+6
precision: 5
fmax31653 fma  1    10001E+2  -2E+1 -> 1.0000E+6   Inexact Rounded
precision: 4
fmax31654 fma  1    10001E+2  -2E+1 -> 1.000E+6    Inexact Rounded
precision: 3
fmax31655 fma  1    10001E+2  -2E+1 -> 1.00E+6     Inexact Rounded
precision: 2
fmax31656 fma  1    10001E+2  -2E+1 -> 1.0E+6      Inexact Rounded
precision: 1
fmax31657 fma  1    10001E+2  -2E+1 -> 1E+6        Inexact Rounded

rounding:  half_even
precision: 7
fmax31661 fma  1    10001E+2  -2E+1 -> 1.00008E+6
precision: 6
fmax31662 fma  1    10001E+2  -2E+1 -> 1.00008E+6
precision: 5
fmax31663 fma  1    10001E+2  -2E+1 -> 1.0001E+6   Inexact Rounded
precision: 4
fmax31664 fma  1    10001E+2  -2E+1 -> 1.000E+6    Inexact Rounded
precision: 3
fmax31665 fma  1    10001E+2  -2E+1 -> 1.00E+6     Inexact Rounded
precision: 2
fmax31666 fma  1    10001E+2  -2E+1 -> 1.0E+6      Inexact Rounded
precision: 1
fmax31667 fma  1    10001E+2  -2E+1 -> 1E+6        Inexact Rounded

rounding:  up
precision: 7
fmax31671 fma  1    10001E+2  -2E+1 -> 1.00008E+6
precision: 6
fmax31672 fma  1    10001E+2  -2E+1 -> 1.00008E+6
precision: 5
fmax31673 fma  1    10001E+2  -2E+1 -> 1.0001E+6   Inexact Rounded
precision: 4
fmax31674 fma  1    10001E+2  -2E+1 -> 1.001E+6    Inexact Rounded
precision: 3
fmax31675 fma  1    10001E+2  -2E+1 -> 1.01E+6     Inexact Rounded
precision: 2
fmax31676 fma  1    10001E+2  -2E+1 -> 1.1E+6      Inexact Rounded
precision: 1
fmax31677 fma  1    10001E+2  -2E+1 -> 2E+6        Inexact Rounded

precision:   34
rounding:    half_up
maxExponent: 6144
minExponent: -6143
-- Examples from SQL proposal (Krishna Kulkarni)
fmax31701  fma  1   130E-2    120E-2    -> 2.50
fmax31702  fma  1   130E-2    12E-1     -> 2.50
fmax31703  fma  1   130E-2    1E0       -> 2.30
fmax31704  fma  1   1E2       1E4       -> 1.01E+4
fmax31705  subtract 130E-2  120E-2 -> 0.10
fmax31706  subtract 130E-2  12E-1  -> 0.10
fmax31707  subtract 130E-2  1E0    -> 0.30
fmax31708  subtract 1E2     1E4    -> -9.9E+3

------------------------------------------------------------------------
-- Same as above, using decimal64 default parameters                  --
------------------------------------------------------------------------
precision:   16
rounding:    half_even
maxExponent: 384
minexponent: -383

-- [first group are 'quick confidence check']
fmax36001 fma  1   1       1       ->  2
fmax36002 fma  1   2       3       ->  5
fmax36003 fma  1   '5.75'  '3.3'   ->  9.05
fmax36004 fma  1   '5'     '-3'    ->  2
fmax36005 fma  1   '-5'    '-3'    ->  -8
fmax36006 fma  1   '-7'    '2.5'   ->  -4.5
fmax36007 fma  1   '0.7'   '0.3'   ->  1.0
fmax36008 fma  1   '1.25'  '1.25'  ->  2.50
fmax36009 fma  1   '1.23456789'  '1.00000000' -> '2.23456789'
fmax36010 fma  1   '1.23456789'  '1.00000011' -> '2.23456800'

fmax36011 fma  1   '0.44444444444444444'  '0.55555555555555555' -> '1.000000000000000' Inexact Rounded
fmax36012 fma  1   '0.44444444444444440'  '0.55555555555555555' -> '1.000000000000000' Inexact Rounded
fmax36013 fma  1   '0.44444444444444444'  '0.55555555555555550' -> '0.9999999999999999' Inexact Rounded
fmax36014 fma  1   '0.444444444444444449'    '0' -> '0.4444444444444444' Inexact Rounded
fmax36015 fma  1   '0.4444444444444444499'   '0' -> '0.4444444444444444' Inexact Rounded
fmax36016 fma  1   '0.44444444444444444999'  '0' -> '0.4444444444444444' Inexact Rounded
fmax36017 fma  1   '0.44444444444444445000'  '0' -> '0.4444444444444444' Inexact Rounded
fmax36018 fma  1   '0.44444444444444445001'  '0' -> '0.4444444444444445' Inexact Rounded
fmax36019 fma  1   '0.4444444444444444501'   '0' -> '0.4444444444444445' Inexact Rounded
fmax36020 fma  1   '0.444444444444444451'    '0' -> '0.4444444444444445' Inexact Rounded

fmax36021 fma  1   0 1 -> 1
fmax36022 fma  1   1 1 -> 2
fmax36023 fma  1   2 1 -> 3
fmax36024 fma  1   3 1 -> 4
fmax36025 fma  1   4 1 -> 5
fmax36026 fma  1   5 1 -> 6
fmax36027 fma  1   6 1 -> 7
fmax36028 fma  1   7 1 -> 8
fmax36029 fma  1   8 1 -> 9
fmax36030 fma  1   9 1 -> 10

-- some carrying effects
fmax36031 fma  1   '0.9998'  '0.0000' -> '0.9998'
fmax36032 fma  1   '0.9998'  '0.0001' -> '0.9999'
fmax36033 fma  1   '0.9998'  '0.0002' -> '1.0000'
fmax36034 fma  1   '0.9998'  '0.0003' -> '1.0001'

fmax36035 fma  1   '70'      '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
fmax36036 fma  1   '700'     '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
fmax36037 fma  1   '7000'    '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
fmax36038 fma  1   '70000'   '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
fmax36039 fma  1   '700000'  '10000e+16' -> '1.000000000000007E+20' Rounded

-- symmetry:
fmax36040 fma  1   '10000e+16'  '70' -> '1.000000000000000E+20' Inexact Rounded
fmax36041 fma  1   '10000e+16'  '700' -> '1.000000000000000E+20' Inexact Rounded
fmax36042 fma  1   '10000e+16'  '7000' -> '1.000000000000000E+20' Inexact Rounded
fmax36044 fma  1   '10000e+16'  '70000' -> '1.000000000000001E+20' Inexact Rounded
fmax36045 fma  1   '10000e+16'  '700000' -> '1.000000000000007E+20' Rounded

fmax36046 fma  1   '10000e+9'  '7' -> '10000000000007'
fmax36047 fma  1   '10000e+9'  '70' -> '10000000000070'
fmax36048 fma  1   '10000e+9'  '700' -> '10000000000700'
fmax36049 fma  1   '10000e+9'  '7000' -> '10000000007000'
fmax36050 fma  1   '10000e+9'  '70000' -> '10000000070000'
fmax36051 fma  1   '10000e+9'  '700000' -> '10000000700000'

-- examples from decarith
fmax36053 fma  1   '12' '7.00' -> '19.00'
fmax36054 fma  1   '1.3' '-1.07' -> '0.23'
fmax36055 fma  1   '1.3' '-1.30' -> '0.00'
fmax36056 fma  1   '1.3' '-2.07' -> '-0.77'
fmax36057 fma  1   '1E+2' '1E+4' -> '1.01E+4'

-- from above
fmax36061 fma  1   1 '0.1' -> '1.1'
fmax36062 fma  1   1 '0.01' -> '1.01'
fmax36063 fma  1   1 '0.001' -> '1.001'
fmax36064 fma  1   1 '0.0001' -> '1.0001'
fmax36065 fma  1   1 '0.00001' -> '1.00001'
fmax36066 fma  1   1 '0.000001' -> '1.000001'
fmax36067 fma  1   1 '0.0000001' -> '1.0000001'
fmax36068 fma  1   1 '0.00000001' -> '1.00000001'

-- some funny zeros [in case of bad signum]
fmax36070 fma  1   1  0    -> 1
fmax36071 fma  1   1 0.    -> 1
fmax36072 fma  1   1  .0   -> 1.0
fmax36073 fma  1   1 0.0   -> 1.0
fmax36074 fma  1   1 0.00  -> 1.00
fmax36075 fma  1    0  1   -> 1
fmax36076 fma  1   0.  1   -> 1
fmax36077 fma  1    .0 1   -> 1.0
fmax36078 fma  1   0.0 1   -> 1.0
fmax36079 fma  1   0.00 1  -> 1.00

-- some carries
fmax36080 fma  1   9999999999999998 1  -> 9999999999999999
fmax36081 fma  1   9999999999999999 1  -> 1.000000000000000E+16 Rounded
fmax36082 fma  1    999999999999999 1  -> 1000000000000000
fmax36083 fma  1      9999999999999 1  -> 10000000000000
fmax36084 fma  1        99999999999 1  -> 100000000000
fmax36085 fma  1          999999999 1  -> 1000000000
fmax36086 fma  1            9999999 1  -> 10000000
fmax36087 fma  1              99999 1  -> 100000
fmax36088 fma  1                999 1  -> 1000
fmax36089 fma  1                  9 1  -> 10


-- more LHS swaps
fmax36090 fma  1   '-56267E-10'   0 ->  '-0.0000056267'
fmax36091 fma  1   '-56267E-6'    0 ->  '-0.056267'
fmax36092 fma  1   '-56267E-5'    0 ->  '-0.56267'
fmax36093 fma  1   '-56267E-4'    0 ->  '-5.6267'
fmax36094 fma  1   '-56267E-3'    0 ->  '-56.267'
fmax36095 fma  1   '-56267E-2'    0 ->  '-562.67'
fmax36096 fma  1   '-56267E-1'    0 ->  '-5626.7'
fmax36097 fma  1   '-56267E-0'    0 ->  '-56267'
fmax36098 fma  1   '-5E-10'       0 ->  '-5E-10'
fmax36099 fma  1   '-5E-7'        0 ->  '-5E-7'
fmax36100 fma  1   '-5E-6'        0 ->  '-0.000005'
fmax36101 fma  1   '-5E-5'        0 ->  '-0.00005'
fmax36102 fma  1   '-5E-4'        0 ->  '-0.0005'
fmax36103 fma  1   '-5E-1'        0 ->  '-0.5'
fmax36104 fma  1   '-5E0'         0 ->  '-5'
fmax36105 fma  1   '-5E1'         0 ->  '-50'
fmax36106 fma  1   '-5E5'         0 ->  '-500000'
fmax36107 fma  1   '-5E15'        0 ->  '-5000000000000000'
fmax36108 fma  1   '-5E16'        0 ->  '-5.000000000000000E+16'   Rounded
fmax36109 fma  1   '-5E17'        0 ->  '-5.000000000000000E+17'  Rounded
fmax36110 fma  1   '-5E18'        0 ->  '-5.000000000000000E+18'  Rounded
fmax36111 fma  1   '-5E100'       0 ->  '-5.000000000000000E+100' Rounded

-- more RHS swaps
fmax36113 fma  1   0  '-56267E-10' ->  '-0.0000056267'
fmax36114 fma  1   0  '-56267E-6'  ->  '-0.056267'
fmax36116 fma  1   0  '-56267E-5'  ->  '-0.56267'
fmax36117 fma  1   0  '-56267E-4'  ->  '-5.6267'
fmax36119 fma  1   0  '-56267E-3'  ->  '-56.267'
fmax36120 fma  1   0  '-56267E-2'  ->  '-562.67'
fmax36121 fma  1   0  '-56267E-1'  ->  '-5626.7'
fmax36122 fma  1   0  '-56267E-0'  ->  '-56267'
fmax36123 fma  1   0  '-5E-10'     ->  '-5E-10'
fmax36124 fma  1   0  '-5E-7'      ->  '-5E-7'
fmax36125 fma  1   0  '-5E-6'      ->  '-0.000005'
fmax36126 fma  1   0  '-5E-5'      ->  '-0.00005'
fmax36127 fma  1   0  '-5E-4'      ->  '-0.0005'
fmax36128 fma  1   0  '-5E-1'      ->  '-0.5'
fmax36129 fma  1   0  '-5E0'       ->  '-5'
fmax36130 fma  1   0  '-5E1'       ->  '-50'
fmax36131 fma  1   0  '-5E5'       ->  '-500000'
fmax36132 fma  1   0  '-5E15'      ->  '-5000000000000000'
fmax36133 fma  1   0  '-5E16'      ->  '-5.000000000000000E+16'   Rounded
fmax36134 fma  1   0  '-5E17'      ->  '-5.000000000000000E+17'   Rounded
fmax36135 fma  1   0  '-5E18'      ->  '-5.000000000000000E+18'   Rounded
fmax36136 fma  1   0  '-5E100'     ->  '-5.000000000000000E+100'  Rounded

-- related
fmax36137 fma  1    1  '0E-19'      ->  '1.000000000000000'  Rounded
fmax36138 fma  1   -1  '0E-19'      ->  '-1.000000000000000' Rounded
fmax36139 fma  1   '0E-19' 1        ->  '1.000000000000000'  Rounded
fmax36140 fma  1   '0E-19' -1       ->  '-1.000000000000000' Rounded
fmax36141 fma  1   1E+11   0.0000   ->  '100000000000.0000'
fmax36142 fma  1   1E+11   0.00000  ->  '100000000000.0000'  Rounded
fmax36143 fma  1   0.000   1E+12    ->  '1000000000000.000'
fmax36144 fma  1   0.0000  1E+12    ->  '1000000000000.000'  Rounded

-- [some of the next group are really constructor tests]
fmax36146 fma  1   '00.0'  0       ->  '0.0'
fmax36147 fma  1   '0.00'  0       ->  '0.00'
fmax36148 fma  1    0      '0.00'  ->  '0.00'
fmax36149 fma  1    0      '00.0'  ->  '0.0'
fmax36150 fma  1   '00.0'  '0.00'  ->  '0.00'
fmax36151 fma  1   '0.00'  '00.0'  ->  '0.00'
fmax36152 fma  1   '3'     '.3'    ->  '3.3'
fmax36153 fma  1   '3.'    '.3'    ->  '3.3'
fmax36154 fma  1   '3.0'   '.3'    ->  '3.3'
fmax36155 fma  1   '3.00'  '.3'    ->  '3.30'
fmax36156 fma  1   '3'     '3'     ->  '6'
fmax36157 fma  1   '3'     '+3'    ->  '6'
fmax36158 fma  1   '3'     '-3'    ->  '0'
fmax36159 fma  1   '0.3'   '-0.3'  ->  '0.0'
fmax36160 fma  1   '0.03'  '-0.03' ->  '0.00'

-- try borderline precision, with carries, etc.
fmax36161 fma  1   '1E+13' '-1'    -> '9999999999999'
fmax36162 fma  1   '1E+13'  '1.11' -> '10000000000001.11'
fmax36163 fma  1   '1.11'  '1E+13' -> '10000000000001.11'
fmax36164 fma  1   '-1'    '1E+13' -> '9999999999999'
fmax36165 fma  1   '7E+13' '-1'    -> '69999999999999'
fmax36166 fma  1   '7E+13'  '1.11' -> '70000000000001.11'
fmax36167 fma  1   '1.11'  '7E+13' -> '70000000000001.11'
fmax36168 fma  1   '-1'    '7E+13' -> '69999999999999'

--                    1234567890123456      1234567890123456      1 234567890123456
fmax36170 fma  1   '0.4444444444444444'  '0.5555555555555563' -> '1.000000000000001' Inexact Rounded
fmax36171 fma  1   '0.4444444444444444'  '0.5555555555555562' -> '1.000000000000001' Inexact Rounded
fmax36172 fma  1   '0.4444444444444444'  '0.5555555555555561' -> '1.000000000000000' Inexact Rounded
fmax36173 fma  1   '0.4444444444444444'  '0.5555555555555560' -> '1.000000000000000' Inexact Rounded
fmax36174 fma  1   '0.4444444444444444'  '0.5555555555555559' -> '1.000000000000000' Inexact Rounded
fmax36175 fma  1   '0.4444444444444444'  '0.5555555555555558' -> '1.000000000000000' Inexact Rounded
fmax36176 fma  1   '0.4444444444444444'  '0.5555555555555557' -> '1.000000000000000' Inexact Rounded
fmax36177 fma  1   '0.4444444444444444'  '0.5555555555555556' -> '1.000000000000000' Rounded
fmax36178 fma  1   '0.4444444444444444'  '0.5555555555555555' -> '0.9999999999999999'
fmax36179 fma  1   '0.4444444444444444'  '0.5555555555555554' -> '0.9999999999999998'
fmax36180 fma  1   '0.4444444444444444'  '0.5555555555555553' -> '0.9999999999999997'
fmax36181 fma  1   '0.4444444444444444'  '0.5555555555555552' -> '0.9999999999999996'
fmax36182 fma  1   '0.4444444444444444'  '0.5555555555555551' -> '0.9999999999999995'
fmax36183 fma  1   '0.4444444444444444'  '0.5555555555555550' -> '0.9999999999999994'

-- and some more, including residue effects and different roundings
rounding: half_up
fmax36200 fma  1   '6543210123456789' 0             -> '6543210123456789'
fmax36201 fma  1   '6543210123456789' 0.000000001   -> '6543210123456789' Inexact Rounded
fmax36202 fma  1   '6543210123456789' 0.000001      -> '6543210123456789' Inexact Rounded
fmax36203 fma  1   '6543210123456789' 0.1           -> '6543210123456789' Inexact Rounded
fmax36204 fma  1   '6543210123456789' 0.4           -> '6543210123456789' Inexact Rounded
fmax36205 fma  1   '6543210123456789' 0.49          -> '6543210123456789' Inexact Rounded
fmax36206 fma  1   '6543210123456789' 0.499999      -> '6543210123456789' Inexact Rounded
fmax36207 fma  1   '6543210123456789' 0.499999   -> '6543210123456789' Inexact Rounded
fmax36208 fma  1   '6543210123456789' 0.5           -> '6543210123456790' Inexact Rounded
fmax36209 fma  1   '6543210123456789' 0.500000001   -> '6543210123456790' Inexact Rounded
fmax36210 fma  1   '6543210123456789' 0.500001      -> '6543210123456790' Inexact Rounded
fmax36211 fma  1   '6543210123456789' 0.51          -> '6543210123456790' Inexact Rounded
fmax36212 fma  1   '6543210123456789' 0.6           -> '6543210123456790' Inexact Rounded
fmax36213 fma  1   '6543210123456789' 0.9           -> '6543210123456790' Inexact Rounded
fmax36214 fma  1   '6543210123456789' 0.99999       -> '6543210123456790' Inexact Rounded
fmax36215 fma  1   '6543210123456789' 0.999999   -> '6543210123456790' Inexact Rounded
fmax36216 fma  1   '6543210123456789' 1             -> '6543210123456790'
fmax36217 fma  1   '6543210123456789' 1.000000001   -> '6543210123456790' Inexact Rounded
fmax36218 fma  1   '6543210123456789' 1.00001       -> '6543210123456790' Inexact Rounded
fmax36219 fma  1   '6543210123456789' 1.1           -> '6543210123456790' Inexact Rounded

rounding: half_even
fmax36220 fma  1   '6543210123456789' 0             -> '6543210123456789'
fmax36221 fma  1   '6543210123456789' 0.000000001   -> '6543210123456789' Inexact Rounded
fmax36222 fma  1   '6543210123456789' 0.000001      -> '6543210123456789' Inexact Rounded
fmax36223 fma  1   '6543210123456789' 0.1           -> '6543210123456789' Inexact Rounded
fmax36224 fma  1   '6543210123456789' 0.4           -> '6543210123456789' Inexact Rounded
fmax36225 fma  1   '6543210123456789' 0.49          -> '6543210123456789' Inexact Rounded
fmax36226 fma  1   '6543210123456789' 0.499999      -> '6543210123456789' Inexact Rounded
fmax36227 fma  1   '6543210123456789' 0.499999   -> '6543210123456789' Inexact Rounded
fmax36228 fma  1   '6543210123456789' 0.5           -> '6543210123456790' Inexact Rounded
fmax36229 fma  1   '6543210123456789' 0.500000001   -> '6543210123456790' Inexact Rounded
fmax36230 fma  1   '6543210123456789' 0.500001      -> '6543210123456790' Inexact Rounded
fmax36231 fma  1   '6543210123456789' 0.51          -> '6543210123456790' Inexact Rounded
fmax36232 fma  1   '6543210123456789' 0.6           -> '6543210123456790' Inexact Rounded
fmax36233 fma  1   '6543210123456789' 0.9           -> '6543210123456790' Inexact Rounded
fmax36234 fma  1   '6543210123456789' 0.99999       -> '6543210123456790' Inexact Rounded
fmax36235 fma  1   '6543210123456789' 0.999999   -> '6543210123456790' Inexact Rounded
fmax36236 fma  1   '6543210123456789' 1             -> '6543210123456790'
fmax36237 fma  1   '6543210123456789' 1.00000001    -> '6543210123456790' Inexact Rounded
fmax36238 fma  1   '6543210123456789' 1.00001       -> '6543210123456790' Inexact Rounded
fmax36239 fma  1   '6543210123456789' 1.1           -> '6543210123456790' Inexact Rounded
-- critical few with even bottom digit...
fmax36240 fma  1   '6543210123456788' 0.499999   -> '6543210123456788' Inexact Rounded
fmax36241 fma  1   '6543210123456788' 0.5           -> '6543210123456788' Inexact Rounded
fmax36242 fma  1   '6543210123456788' 0.500000001   -> '6543210123456789' Inexact Rounded

rounding: down
fmax36250 fma  1   '6543210123456789' 0             -> '6543210123456789'
fmax36251 fma  1   '6543210123456789' 0.000000001   -> '6543210123456789' Inexact Rounded
fmax36252 fma  1   '6543210123456789' 0.000001      -> '6543210123456789' Inexact Rounded
fmax36253 fma  1   '6543210123456789' 0.1           -> '6543210123456789' Inexact Rounded
fmax36254 fma  1   '6543210123456789' 0.4           -> '6543210123456789' Inexact Rounded
fmax36255 fma  1   '6543210123456789' 0.49          -> '6543210123456789' Inexact Rounded
fmax36256 fma  1   '6543210123456789' 0.499999      -> '6543210123456789' Inexact Rounded
fmax36257 fma  1   '6543210123456789' 0.499999   -> '6543210123456789' Inexact Rounded
fmax36258 fma  1   '6543210123456789' 0.5           -> '6543210123456789' Inexact Rounded
fmax36259 fma  1   '6543210123456789' 0.500000001   -> '6543210123456789' Inexact Rounded
fmax36260 fma  1   '6543210123456789' 0.500001      -> '6543210123456789' Inexact Rounded
fmax36261 fma  1   '6543210123456789' 0.51          -> '6543210123456789' Inexact Rounded
fmax36262 fma  1   '6543210123456789' 0.6           -> '6543210123456789' Inexact Rounded
fmax36263 fma  1   '6543210123456789' 0.9           -> '6543210123456789' Inexact Rounded
fmax36264 fma  1   '6543210123456789' 0.99999       -> '6543210123456789' Inexact Rounded
fmax36265 fma  1   '6543210123456789' 0.999999   -> '6543210123456789' Inexact Rounded
fmax36266 fma  1   '6543210123456789' 1             -> '6543210123456790'
fmax36267 fma  1   '6543210123456789' 1.00000001    -> '6543210123456790' Inexact Rounded
fmax36268 fma  1   '6543210123456789' 1.00001       -> '6543210123456790' Inexact Rounded
fmax36269 fma  1   '6543210123456789' 1.1           -> '6543210123456790' Inexact Rounded

-- 1 in last place tests
rounding: half_even
fmax36301 fma  1    -1   1      ->   0
fmax36302 fma  1     0   1      ->   1
fmax36303 fma  1     1   1      ->   2
fmax36304 fma  1    12   1      ->  13
fmax36305 fma  1    98   1      ->  99
fmax36306 fma  1    99   1      -> 100
fmax36307 fma  1   100   1      -> 101
fmax36308 fma  1   101   1      -> 102
fmax36309 fma  1    -1  -1      ->  -2
fmax36310 fma  1     0  -1      ->  -1
fmax36311 fma  1     1  -1      ->   0
fmax36312 fma  1    12  -1      ->  11
fmax36313 fma  1    98  -1      ->  97
fmax36314 fma  1    99  -1      ->  98
fmax36315 fma  1   100  -1      ->  99
fmax36316 fma  1   101  -1      -> 100

fmax36321 fma  1   -0.01  0.01    ->  0.00
fmax36322 fma  1    0.00  0.01    ->  0.01
fmax36323 fma  1    0.01  0.01    ->  0.02
fmax36324 fma  1    0.12  0.01    ->  0.13
fmax36325 fma  1    0.98  0.01    ->  0.99
fmax36326 fma  1    0.99  0.01    ->  1.00
fmax36327 fma  1    1.00  0.01    ->  1.01
fmax36328 fma  1    1.01  0.01    ->  1.02
fmax36329 fma  1   -0.01 -0.01    -> -0.02
fmax36330 fma  1    0.00 -0.01    -> -0.01
fmax36331 fma  1    0.01 -0.01    ->  0.00
fmax36332 fma  1    0.12 -0.01    ->  0.11
fmax36333 fma  1    0.98 -0.01    ->  0.97
fmax36334 fma  1    0.99 -0.01    ->  0.98
fmax36335 fma  1    1.00 -0.01    ->  0.99
fmax36336 fma  1    1.01 -0.01    ->  1.00

-- some more cases where fma  1  ing 0 affects the coefficient
fmax36340 fma  1   1E+3    0    ->         1000
fmax36341 fma  1   1E+15   0    ->    1000000000000000
fmax36342 fma  1   1E+16   0    ->   1.000000000000000E+16  Rounded
fmax36343 fma  1   1E+17   0    ->   1.000000000000000E+17  Rounded
-- which simply follow from these cases ...
fmax36344 fma  1   1E+3    1    ->         1001
fmax36345 fma  1   1E+15   1    ->    1000000000000001
fmax36346 fma  1   1E+16   1    ->   1.000000000000000E+16  Inexact Rounded
fmax36347 fma  1   1E+17   1    ->   1.000000000000000E+17  Inexact Rounded
fmax36348 fma  1   1E+3    7    ->         1007
fmax36349 fma  1   1E+15   7    ->    1000000000000007
fmax36350 fma  1   1E+16   7    ->   1.000000000000001E+16  Inexact Rounded
fmax36351 fma  1   1E+17   7    ->   1.000000000000000E+17  Inexact Rounded

-- tryzeros cases
fmax36361  fma  1   0E+50 10000E+1  -> 1.0000E+5
fmax36362  fma  1   10000E+1 0E-50  -> 100000.0000000000  Rounded
fmax36363  fma  1   10000E+1 10000E-50  -> 100000.0000000000  Rounded Inexact
fmax36364  fma  1   12.34    0e-398  -> 12.34000000000000  Rounded

-- ulp replacement tests
fmax36400 fma  1     1   77e-14      ->  1.00000000000077
fmax36401 fma  1     1   77e-15      ->  1.000000000000077
fmax36402 fma  1     1   77e-16      ->  1.000000000000008 Inexact Rounded
fmax36403 fma  1     1   77e-17      ->  1.000000000000001 Inexact Rounded
fmax36404 fma  1     1   77e-18      ->  1.000000000000000 Inexact Rounded
fmax36405 fma  1     1   77e-19      ->  1.000000000000000 Inexact Rounded
fmax36406 fma  1     1   77e-99      ->  1.000000000000000 Inexact Rounded

fmax36410 fma  1    10   77e-14      ->  10.00000000000077
fmax36411 fma  1    10   77e-15      ->  10.00000000000008 Inexact Rounded
fmax36412 fma  1    10   77e-16      ->  10.00000000000001 Inexact Rounded
fmax36413 fma  1    10   77e-17      ->  10.00000000000000 Inexact Rounded
fmax36414 fma  1    10   77e-18      ->  10.00000000000000 Inexact Rounded
fmax36415 fma  1    10   77e-19      ->  10.00000000000000 Inexact Rounded
fmax36416 fma  1    10   77e-99      ->  10.00000000000000 Inexact Rounded

fmax36420 fma  1    77e-14       1   ->  1.00000000000077
fmax36421 fma  1    77e-15       1   ->  1.000000000000077
fmax36422 fma  1    77e-16       1   ->  1.000000000000008 Inexact Rounded
fmax36423 fma  1    77e-17       1   ->  1.000000000000001 Inexact Rounded
fmax36424 fma  1    77e-18       1   ->  1.000000000000000 Inexact Rounded
fmax36425 fma  1    77e-19       1   ->  1.000000000000000 Inexact Rounded
fmax36426 fma  1    77e-99       1   ->  1.000000000000000 Inexact Rounded

fmax36430 fma  1    77e-14      10   ->  10.00000000000077
fmax36431 fma  1    77e-15      10   ->  10.00000000000008 Inexact Rounded
fmax36432 fma  1    77e-16      10   ->  10.00000000000001 Inexact Rounded
fmax36433 fma  1    77e-17      10   ->  10.00000000000000 Inexact Rounded
fmax36434 fma  1    77e-18      10   ->  10.00000000000000 Inexact Rounded
fmax36435 fma  1    77e-19      10   ->  10.00000000000000 Inexact Rounded
fmax36436 fma  1    77e-99      10   ->  10.00000000000000 Inexact Rounded

-- negative ulps
fmax36440 fma  1     1   -77e-14      ->  0.99999999999923
fmax36441 fma  1     1   -77e-15      ->  0.999999999999923
fmax36442 fma  1     1   -77e-16      ->  0.9999999999999923
fmax36443 fma  1     1   -77e-17      ->  0.9999999999999992 Inexact Rounded
fmax36444 fma  1     1   -77e-18      ->  0.9999999999999999 Inexact Rounded
fmax36445 fma  1     1   -77e-19      ->  1.000000000000000 Inexact Rounded
fmax36446 fma  1     1   -77e-99      ->  1.000000000000000 Inexact Rounded

fmax36450 fma  1    10   -77e-14      ->   9.99999999999923
fmax36451 fma  1    10   -77e-15      ->   9.999999999999923
fmax36452 fma  1    10   -77e-16      ->   9.999999999999992 Inexact Rounded
fmax36453 fma  1    10   -77e-17      ->   9.999999999999999 Inexact Rounded
fmax36454 fma  1    10   -77e-18      ->  10.00000000000000 Inexact Rounded
fmax36455 fma  1    10   -77e-19      ->  10.00000000000000 Inexact Rounded
fmax36456 fma  1    10   -77e-99      ->  10.00000000000000 Inexact Rounded

fmax36460 fma  1    -77e-14       1   ->  0.99999999999923
fmax36461 fma  1    -77e-15       1   ->  0.999999999999923
fmax36462 fma  1    -77e-16       1   ->  0.9999999999999923
fmax36463 fma  1    -77e-17       1   ->  0.9999999999999992 Inexact Rounded
fmax36464 fma  1    -77e-18       1   ->  0.9999999999999999 Inexact Rounded
fmax36465 fma  1    -77e-19       1   ->  1.000000000000000 Inexact Rounded
fmax36466 fma  1    -77e-99       1   ->  1.000000000000000 Inexact Rounded

fmax36470 fma  1    -77e-14      10   ->   9.99999999999923
fmax36471 fma  1    -77e-15      10   ->   9.999999999999923
fmax36472 fma  1    -77e-16      10   ->   9.999999999999992 Inexact Rounded
fmax36473 fma  1    -77e-17      10   ->   9.999999999999999 Inexact Rounded
fmax36474 fma  1    -77e-18      10   ->  10.00000000000000 Inexact Rounded
fmax36475 fma  1    -77e-19      10   ->  10.00000000000000 Inexact Rounded
fmax36476 fma  1    -77e-99      10   ->  10.00000000000000 Inexact Rounded

-- negative ulps
fmax36480 fma  1    -1    77e-14      ->  -0.99999999999923
fmax36481 fma  1    -1    77e-15      ->  -0.999999999999923
fmax36482 fma  1    -1    77e-16      ->  -0.9999999999999923
fmax36483 fma  1    -1    77e-17      ->  -0.9999999999999992 Inexact Rounded
fmax36484 fma  1    -1    77e-18      ->  -0.9999999999999999 Inexact Rounded
fmax36485 fma  1    -1    77e-19      ->  -1.000000000000000 Inexact Rounded
fmax36486 fma  1    -1    77e-99      ->  -1.000000000000000 Inexact Rounded

fmax36490 fma  1   -10    77e-14      ->   -9.99999999999923
fmax36491 fma  1   -10    77e-15      ->   -9.999999999999923
fmax36492 fma  1   -10    77e-16      ->   -9.999999999999992 Inexact Rounded
fmax36493 fma  1   -10    77e-17      ->   -9.999999999999999 Inexact Rounded
fmax36494 fma  1   -10    77e-18      ->  -10.00000000000000 Inexact Rounded
fmax36495 fma  1   -10    77e-19      ->  -10.00000000000000 Inexact Rounded
fmax36496 fma  1   -10    77e-99      ->  -10.00000000000000 Inexact Rounded

fmax36500 fma  1     77e-14      -1   ->  -0.99999999999923
fmax36501 fma  1     77e-15      -1   ->  -0.999999999999923
fmax36502 fma  1     77e-16      -1   ->  -0.9999999999999923
fmax36503 fma  1     77e-17      -1   ->  -0.9999999999999992 Inexact Rounded
fmax36504 fma  1     77e-18      -1   ->  -0.9999999999999999 Inexact Rounded
fmax36505 fma  1     77e-19      -1   ->  -1.000000000000000 Inexact Rounded
fmax36506 fma  1     77e-99      -1   ->  -1.000000000000000 Inexact Rounded

fmax36510 fma  1     77e-14      -10  ->   -9.99999999999923
fmax36511 fma  1     77e-15      -10  ->   -9.999999999999923
fmax36512 fma  1     77e-16      -10  ->   -9.999999999999992 Inexact Rounded
fmax36513 fma  1     77e-17      -10  ->   -9.999999999999999 Inexact Rounded
fmax36514 fma  1     77e-18      -10  ->  -10.00000000000000 Inexact Rounded
fmax36515 fma  1     77e-19      -10  ->  -10.00000000000000 Inexact Rounded
fmax36516 fma  1     77e-99      -10  ->  -10.00000000000000 Inexact Rounded


-- long operands
fmax36521 fma  1   101234562345678000 0 -> 1.012345623456780E+17 Rounded
fmax36522 fma  1   0 101234562345678000 -> 1.012345623456780E+17 Rounded
fmax36523 fma  1   10123456234567800  0 -> 1.012345623456780E+16 Rounded
fmax36524 fma  1   0 10123456234567800  -> 1.012345623456780E+16 Rounded
fmax36525 fma  1   10123456234567890  0 -> 1.012345623456789E+16 Rounded
fmax36526 fma  1   0 10123456234567890  -> 1.012345623456789E+16 Rounded
fmax36527 fma  1   10123456234567891  0 -> 1.012345623456789E+16 Inexact Rounded
fmax36528 fma  1   0 10123456234567891  -> 1.012345623456789E+16 Inexact Rounded
fmax36529 fma  1   101234562345678901 0 -> 1.012345623456789E+17 Inexact Rounded
fmax36530 fma  1   0 101234562345678901 -> 1.012345623456789E+17 Inexact Rounded
fmax36531 fma  1   10123456234567896  0 -> 1.012345623456790E+16 Inexact Rounded
fmax36532 fma  1   0 10123456234567896  -> 1.012345623456790E+16 Inexact Rounded

-- verify a query
rounding:     down
fmax36561 fma  1   1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
fmax36562 fma  1        0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
-- and using decimal64 bounds...
rounding:     down
fmax36563 fma  1   1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
fmax36564 fma  1        0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded

-- more zeros, etc.
rounding: half_even

fmax36701 fma  1   5.00 1.00E-3 -> 5.00100
fmax36702 fma  1   00.00 0.000  -> 0.000
fmax36703 fma  1   00.00 0E-3   -> 0.000
fmax36704 fma  1   0E-3  00.00  -> 0.000

fmax36710 fma  1   0E+3  00.00  -> 0.00
fmax36711 fma  1   0E+3  00.0   -> 0.0
fmax36712 fma  1   0E+3  00.    -> 0
fmax36713 fma  1   0E+3  00.E+1 -> 0E+1
fmax36714 fma  1   0E+3  00.E+2 -> 0E+2
fmax36715 fma  1   0E+3  00.E+3 -> 0E+3
fmax36716 fma  1   0E+3  00.E+4 -> 0E+3
fmax36717 fma  1   0E+3  00.E+5 -> 0E+3
fmax36718 fma  1   0E+3  -00.0   -> 0.0
fmax36719 fma  1   0E+3  -00.    -> 0
fmax36731 fma  1   0E+3  -00.E+1 -> 0E+1

fmax36720 fma  1   00.00  0E+3  -> 0.00
fmax36721 fma  1   00.0   0E+3  -> 0.0
fmax36722 fma  1   00.    0E+3  -> 0
fmax36723 fma  1   00.E+1 0E+3  -> 0E+1
fmax36724 fma  1   00.E+2 0E+3  -> 0E+2
fmax36725 fma  1   00.E+3 0E+3  -> 0E+3
fmax36726 fma  1   00.E+4 0E+3  -> 0E+3
fmax36727 fma  1   00.E+5 0E+3  -> 0E+3
fmax36728 fma  1   -00.00 0E+3  -> 0.00
fmax36729 fma  1   -00.0  0E+3  -> 0.0
fmax36730 fma  1   -00.   0E+3  -> 0

fmax36732 fma  1    0     0     ->  0
fmax36733 fma  1    0    -0     ->  0
fmax36734 fma  1   -0     0     ->  0
fmax36735 fma  1   -0    -0     -> -0     -- IEEE 854 special case

fmax36736 fma  1    1    -1     ->  0
fmax36737 fma  1   -1    -1     -> -2
fmax36738 fma  1    1     1     ->  2
fmax36739 fma  1   -1     1     ->  0

fmax36741 fma  1    0    -1     -> -1
fmax36742 fma  1   -0    -1     -> -1
fmax36743 fma  1    0     1     ->  1
fmax36744 fma  1   -0     1     ->  1
fmax36745 fma  1   -1     0     -> -1
fmax36746 fma  1   -1    -0     -> -1
fmax36747 fma  1    1     0     ->  1
fmax36748 fma  1    1    -0     ->  1

fmax36751 fma  1    0.0  -1     -> -1.0
fmax36752 fma  1   -0.0  -1     -> -1.0
fmax36753 fma  1    0.0   1     ->  1.0
fmax36754 fma  1   -0.0   1     ->  1.0
fmax36755 fma  1   -1.0   0     -> -1.0
fmax36756 fma  1   -1.0  -0     -> -1.0
fmax36757 fma  1    1.0   0     ->  1.0
fmax36758 fma  1    1.0  -0     ->  1.0

fmax36761 fma  1    0    -1.0   -> -1.0
fmax36762 fma  1   -0    -1.0   -> -1.0
fmax36763 fma  1    0     1.0   ->  1.0
fmax36764 fma  1   -0     1.0   ->  1.0
fmax36765 fma  1   -1     0.0   -> -1.0
fmax36766 fma  1   -1    -0.0   -> -1.0
fmax36767 fma  1    1     0.0   ->  1.0
fmax36768 fma  1    1    -0.0   ->  1.0

fmax36771 fma  1    0.0  -1.0   -> -1.0
fmax36772 fma  1   -0.0  -1.0   -> -1.0
fmax36773 fma  1    0.0   1.0   ->  1.0
fmax36774 fma  1   -0.0   1.0   ->  1.0
fmax36775 fma  1   -1.0   0.0   -> -1.0
fmax36776 fma  1   -1.0  -0.0   -> -1.0
fmax36777 fma  1    1.0   0.0   ->  1.0
fmax36778 fma  1    1.0  -0.0   ->  1.0

-- Specials
fmax36780 fma  1   -Inf  -Inf   -> -Infinity
fmax36781 fma  1   -Inf  -1000  -> -Infinity
fmax36782 fma  1   -Inf  -1     -> -Infinity
fmax36783 fma  1   -Inf  -0     -> -Infinity
fmax36784 fma  1   -Inf   0     -> -Infinity
fmax36785 fma  1   -Inf   1     -> -Infinity
fmax36786 fma  1   -Inf   1000  -> -Infinity
fmax36787 fma  1   -1000 -Inf   -> -Infinity
fmax36788 fma  1   -Inf  -Inf   -> -Infinity
fmax36789 fma  1   -1    -Inf   -> -Infinity
fmax36790 fma  1   -0    -Inf   -> -Infinity
fmax36791 fma  1    0    -Inf   -> -Infinity
fmax36792 fma  1    1    -Inf   -> -Infinity
fmax36793 fma  1    1000 -Inf   -> -Infinity
fmax36794 fma  1    Inf  -Inf   ->  NaN  Invalid_operation

fmax36800 fma  1    Inf  -Inf   ->  NaN  Invalid_operation
fmax36801 fma  1    Inf  -1000  ->  Infinity
fmax36802 fma  1    Inf  -1     ->  Infinity
fmax36803 fma  1    Inf  -0     ->  Infinity
fmax36804 fma  1    Inf   0     ->  Infinity
fmax36805 fma  1    Inf   1     ->  Infinity
fmax36806 fma  1    Inf   1000  ->  Infinity
fmax36807 fma  1    Inf   Inf   ->  Infinity
fmax36808 fma  1   -1000  Inf   ->  Infinity
fmax36809 fma  1   -Inf   Inf   ->  NaN  Invalid_operation
fmax36810 fma  1   -1     Inf   ->  Infinity
fmax36811 fma  1   -0     Inf   ->  Infinity
fmax36812 fma  1    0     Inf   ->  Infinity
fmax36813 fma  1    1     Inf   ->  Infinity
fmax36814 fma  1    1000  Inf   ->  Infinity
fmax36815 fma  1    Inf   Inf   ->  Infinity

fmax36821 fma  1    NaN -Inf    ->  NaN
fmax36822 fma  1    NaN -1000   ->  NaN
fmax36823 fma  1    NaN -1      ->  NaN
fmax36824 fma  1    NaN -0      ->  NaN
fmax36825 fma  1    NaN  0      ->  NaN
fmax36826 fma  1    NaN  1      ->  NaN
fmax36827 fma  1    NaN  1000   ->  NaN
fmax36828 fma  1    NaN  Inf    ->  NaN
fmax36829 fma  1    NaN  NaN    ->  NaN
fmax36830 fma  1   -Inf  NaN    ->  NaN
fmax36831 fma  1   -1000 NaN    ->  NaN
fmax36832 fma  1   -1    NaN    ->  NaN
fmax36833 fma  1   -0    NaN    ->  NaN
fmax36834 fma  1    0    NaN    ->  NaN
fmax36835 fma  1    1    NaN    ->  NaN
fmax36836 fma  1    1000 NaN    ->  NaN
fmax36837 fma  1    Inf  NaN    ->  NaN

fmax36841 fma  1    sNaN -Inf   ->  NaN  Invalid_operation
fmax36842 fma  1    sNaN -1000  ->  NaN  Invalid_operation
fmax36843 fma  1    sNaN -1     ->  NaN  Invalid_operation
fmax36844 fma  1    sNaN -0     ->  NaN  Invalid_operation
fmax36845 fma  1    sNaN  0     ->  NaN  Invalid_operation
fmax36846 fma  1    sNaN  1     ->  NaN  Invalid_operation
fmax36847 fma  1    sNaN  1000  ->  NaN  Invalid_operation
fmax36848 fma  1    sNaN  NaN   ->  NaN  Invalid_operation
fmax36849 fma  1    sNaN sNaN   ->  NaN  Invalid_operation
fmax36850 fma  1    NaN  sNaN   ->  NaN  Invalid_operation
fmax36851 fma  1   -Inf  sNaN   ->  NaN  Invalid_operation
fmax36852 fma  1   -1000 sNaN   ->  NaN  Invalid_operation
fmax36853 fma  1   -1    sNaN   ->  NaN  Invalid_operation
fmax36854 fma  1   -0    sNaN   ->  NaN  Invalid_operation
fmax36855 fma  1    0    sNaN   ->  NaN  Invalid_operation
fmax36856 fma  1    1    sNaN   ->  NaN  Invalid_operation
fmax36857 fma  1    1000 sNaN   ->  NaN  Invalid_operation
fmax36858 fma  1    Inf  sNaN   ->  NaN  Invalid_operation
fmax36859 fma  1    NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
fmax36861 fma  1    NaN1   -Inf    ->  NaN1
fmax36862 fma  1   +NaN2   -1000   ->  NaN2
fmax36863 fma  1    NaN3    1000   ->  NaN3
fmax36864 fma  1    NaN4    Inf    ->  NaN4
fmax36865 fma  1    NaN5   +NaN6   ->  NaN5
fmax36866 fma  1   -Inf     NaN7   ->  NaN7
fmax36867 fma  1   -1000    NaN8   ->  NaN8
fmax36868 fma  1    1000    NaN9   ->  NaN9
fmax36869 fma  1    Inf    +NaN10  ->  NaN10
fmax36871 fma  1    sNaN11  -Inf   ->  NaN11  Invalid_operation
fmax36872 fma  1    sNaN12  -1000  ->  NaN12  Invalid_operation
fmax36873 fma  1    sNaN13   1000  ->  NaN13  Invalid_operation
fmax36874 fma  1    sNaN14   NaN17 ->  NaN14  Invalid_operation
fmax36875 fma  1    sNaN15  sNaN18 ->  NaN15  Invalid_operation
fmax36876 fma  1    NaN16   sNaN19 ->  NaN19  Invalid_operation
fmax36877 fma  1   -Inf    +sNaN20 ->  NaN20  Invalid_operation
fmax36878 fma  1   -1000    sNaN21 ->  NaN21  Invalid_operation
fmax36879 fma  1    1000    sNaN22 ->  NaN22  Invalid_operation
fmax36880 fma  1    Inf     sNaN23 ->  NaN23  Invalid_operation
fmax36881 fma  1   +NaN25  +sNaN24 ->  NaN24  Invalid_operation
fmax36882 fma  1   -NaN26    NaN28 -> -NaN26
fmax36883 fma  1   -sNaN27  sNaN29 -> -NaN27  Invalid_operation
fmax36884 fma  1    1000    -NaN30 -> -NaN30
fmax36885 fma  1    1000   -sNaN31 -> -NaN31  Invalid_operation

-- now the case where we can get underflow but the result is normal
-- [note this can't happen if the operands are also bounded, as we
-- cannot represent 1E-399, for example]

fmax36571 fma  1         1E-383       0  -> 1E-383
fmax36572 fma  1         1E-384       0  -> 1E-384   Subnormal
fmax36573 fma  1         1E-383  1E-384  -> 1.1E-383
fmax36574 subtract  1E-383  1E-384  ->   9E-384 Subnormal

-- Here we explore the boundary of rounding a subnormal to Nmin
fmax36575 subtract  1E-383  1E-398  ->   9.99999999999999E-384  Subnormal
fmax36576 subtract  1E-383  1E-398  ->   9.99999999999999E-384  Subnormal
fmax36577 subtract  1E-383  1E-399  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
fmax36578 subtract  1E-383  1E-400  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
fmax36579 subtract  1E-383  1E-401  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded
fmax36580 subtract  1E-383  1E-402  ->   1.000000000000000E-383 Underflow Inexact Subnormal Rounded

-- check overflow edge case
--               1234567890123456
fmax36972 apply        9.999999999999999E+384         -> 9.999999999999999E+384
fmax36973 fma  1       9.999999999999999E+384  1      -> 9.999999999999999E+384 Inexact Rounded
fmax36974 fma  1        9999999999999999E+369  1      -> 9.999999999999999E+384 Inexact Rounded
fmax36975 fma  1        9999999999999999E+369  1E+369  -> Infinity Overflow Inexact Rounded
fmax36976 fma  1        9999999999999999E+369  9E+368  -> Infinity Overflow Inexact Rounded
fmax36977 fma  1        9999999999999999E+369  8E+368  -> Infinity Overflow Inexact Rounded
fmax36978 fma  1        9999999999999999E+369  7E+368  -> Infinity Overflow Inexact Rounded
fmax36979 fma  1        9999999999999999E+369  6E+368  -> Infinity Overflow Inexact Rounded
fmax36980 fma  1        9999999999999999E+369  5E+368  -> Infinity Overflow Inexact Rounded
fmax36981 fma  1        9999999999999999E+369  4E+368  -> 9.999999999999999E+384 Inexact Rounded
fmax36982 fma  1        9999999999999999E+369  3E+368  -> 9.999999999999999E+384 Inexact Rounded
fmax36983 fma  1        9999999999999999E+369  2E+368  -> 9.999999999999999E+384 Inexact Rounded
fmax36984 fma  1        9999999999999999E+369  1E+368  -> 9.999999999999999E+384 Inexact Rounded

fmax36985 apply       -9.999999999999999E+384         -> -9.999999999999999E+384
fmax36986 fma  1      -9.999999999999999E+384 -1      -> -9.999999999999999E+384 Inexact Rounded
fmax36987 fma  1       -9999999999999999E+369 -1      -> -9.999999999999999E+384 Inexact Rounded
fmax36988 fma  1       -9999999999999999E+369 -1E+369  -> -Infinity Overflow Inexact Rounded
fmax36989 fma  1       -9999999999999999E+369 -9E+368  -> -Infinity Overflow Inexact Rounded
fmax36990 fma  1       -9999999999999999E+369 -8E+368  -> -Infinity Overflow Inexact Rounded
fmax36991 fma  1       -9999999999999999E+369 -7E+368  -> -Infinity Overflow Inexact Rounded
fmax36992 fma  1       -9999999999999999E+369 -6E+368  -> -Infinity Overflow Inexact Rounded
fmax36993 fma  1       -9999999999999999E+369 -5E+368  -> -Infinity Overflow Inexact Rounded
fmax36994 fma  1       -9999999999999999E+369 -4E+368  -> -9.999999999999999E+384 Inexact Rounded
fmax36995 fma  1       -9999999999999999E+369 -3E+368  -> -9.999999999999999E+384 Inexact Rounded
fmax36996 fma  1       -9999999999999999E+369 -2E+368  -> -9.999999999999999E+384 Inexact Rounded
fmax36997 fma  1       -9999999999999999E+369 -1E+368  -> -9.999999999999999E+384 Inexact Rounded

-- And for round down full and subnormal results
rounding:     down
fmax361100 fma  1   1e+2 -1e-383    -> 99.99999999999999 Rounded Inexact
fmax361101 fma  1   1e+1 -1e-383    -> 9.999999999999999  Rounded Inexact
fmax361103 fma  1     +1 -1e-383    -> 0.9999999999999999  Rounded Inexact
fmax361104 fma  1   1e-1 -1e-383    -> 0.09999999999999999  Rounded Inexact
fmax361105 fma  1   1e-2 -1e-383    -> 0.009999999999999999  Rounded Inexact
fmax361106 fma  1   1e-3 -1e-383    -> 0.0009999999999999999  Rounded Inexact
fmax361107 fma  1   1e-4 -1e-383    -> 0.00009999999999999999  Rounded Inexact
fmax361108 fma  1   1e-5 -1e-383    -> 0.000009999999999999999  Rounded Inexact
fmax361109 fma  1   1e-6 -1e-383    -> 9.999999999999999E-7  Rounded Inexact

rounding:     ceiling
fmax361110 fma  1   -1e+2 +1e-383   -> -99.99999999999999 Rounded Inexact
fmax361111 fma  1   -1e+1 +1e-383   -> -9.999999999999999  Rounded Inexact
fmax361113 fma  1      -1 +1e-383   -> -0.9999999999999999  Rounded Inexact
fmax361114 fma  1   -1e-1 +1e-383   -> -0.09999999999999999  Rounded Inexact
fmax361115 fma  1   -1e-2 +1e-383   -> -0.009999999999999999  Rounded Inexact
fmax361116 fma  1   -1e-3 +1e-383   -> -0.0009999999999999999  Rounded Inexact
fmax361117 fma  1   -1e-4 +1e-383   -> -0.00009999999999999999  Rounded Inexact
fmax361118 fma  1   -1e-5 +1e-383   -> -0.000009999999999999999  Rounded Inexact
fmax361119 fma  1   -1e-6 +1e-383   -> -9.999999999999999E-7  Rounded Inexact

-- tests based on Gunnar Degnbol's edge case
rounding:     half_even

fmax361300 fma  1   1E16  -0.5                 ->  1.000000000000000E+16 Inexact Rounded
fmax361310 fma  1   1E16  -0.51                ->  9999999999999999      Inexact Rounded
fmax361311 fma  1   1E16  -0.501               ->  9999999999999999      Inexact Rounded
fmax361312 fma  1   1E16  -0.5001              ->  9999999999999999      Inexact Rounded
fmax361313 fma  1   1E16  -0.50001             ->  9999999999999999      Inexact Rounded
fmax361314 fma  1   1E16  -0.500001            ->  9999999999999999      Inexact Rounded
fmax361315 fma  1   1E16  -0.5000001           ->  9999999999999999      Inexact Rounded
fmax361316 fma  1   1E16  -0.50000001          ->  9999999999999999      Inexact Rounded
fmax361317 fma  1   1E16  -0.500000001         ->  9999999999999999      Inexact Rounded
fmax361318 fma  1   1E16  -0.5000000001        ->  9999999999999999      Inexact Rounded
fmax361319 fma  1   1E16  -0.50000000001       ->  9999999999999999      Inexact Rounded
fmax361320 fma  1   1E16  -0.500000000001      ->  9999999999999999      Inexact Rounded
fmax361321 fma  1   1E16  -0.5000000000001     ->  9999999999999999      Inexact Rounded
fmax361322 fma  1   1E16  -0.50000000000001    ->  9999999999999999      Inexact Rounded
fmax361323 fma  1   1E16  -0.500000000000001   ->  9999999999999999      Inexact Rounded
fmax361324 fma  1   1E16  -0.5000000000000001  ->  9999999999999999      Inexact Rounded
fmax361325 fma  1   1E16  -0.5000000000000000  ->  1.000000000000000E+16 Inexact Rounded
fmax361326 fma  1   1E16  -0.500000000000000   ->  1.000000000000000E+16 Inexact Rounded
fmax361327 fma  1   1E16  -0.50000000000000    ->  1.000000000000000E+16 Inexact Rounded
fmax361328 fma  1   1E16  -0.5000000000000     ->  1.000000000000000E+16 Inexact Rounded
fmax361329 fma  1   1E16  -0.500000000000      ->  1.000000000000000E+16 Inexact Rounded
fmax361330 fma  1   1E16  -0.50000000000       ->  1.000000000000000E+16 Inexact Rounded
fmax361331 fma  1   1E16  -0.5000000000        ->  1.000000000000000E+16 Inexact Rounded
fmax361332 fma  1   1E16  -0.500000000         ->  1.000000000000000E+16 Inexact Rounded
fmax361333 fma  1   1E16  -0.50000000          ->  1.000000000000000E+16 Inexact Rounded
fmax361334 fma  1   1E16  -0.5000000           ->  1.000000000000000E+16 Inexact Rounded
fmax361335 fma  1   1E16  -0.500000            ->  1.000000000000000E+16 Inexact Rounded
fmax361336 fma  1   1E16  -0.50000             ->  1.000000000000000E+16 Inexact Rounded
fmax361337 fma  1   1E16  -0.5000              ->  1.000000000000000E+16 Inexact Rounded
fmax361338 fma  1   1E16  -0.500               ->  1.000000000000000E+16 Inexact Rounded
fmax361339 fma  1   1E16  -0.50                ->  1.000000000000000E+16 Inexact Rounded

fmax361340 fma  1   1E16  -5000000.000010001   ->  9999999995000000      Inexact Rounded
fmax361341 fma  1   1E16  -5000000.000000001   ->  9999999995000000      Inexact Rounded

fmax361349 fma  1   9999999999999999 0.4                 ->  9999999999999999      Inexact Rounded
fmax361350 fma  1   9999999999999999 0.49                ->  9999999999999999      Inexact Rounded
fmax361351 fma  1   9999999999999999 0.499               ->  9999999999999999      Inexact Rounded
fmax361352 fma  1   9999999999999999 0.4999              ->  9999999999999999      Inexact Rounded
fmax361353 fma  1   9999999999999999 0.49999             ->  9999999999999999      Inexact Rounded
fmax361354 fma  1   9999999999999999 0.499999            ->  9999999999999999      Inexact Rounded
fmax361355 fma  1   9999999999999999 0.4999999           ->  9999999999999999      Inexact Rounded
fmax361356 fma  1   9999999999999999 0.49999999          ->  9999999999999999      Inexact Rounded
fmax361357 fma  1   9999999999999999 0.499999999         ->  9999999999999999      Inexact Rounded
fmax361358 fma  1   9999999999999999 0.4999999999        ->  9999999999999999      Inexact Rounded
fmax361359 fma  1   9999999999999999 0.49999999999       ->  9999999999999999      Inexact Rounded
fmax361360 fma  1   9999999999999999 0.499999999999      ->  9999999999999999      Inexact Rounded
fmax361361 fma  1   9999999999999999 0.4999999999999     ->  9999999999999999      Inexact Rounded
fmax361362 fma  1   9999999999999999 0.49999999999999    ->  9999999999999999      Inexact Rounded
fmax361363 fma  1   9999999999999999 0.499999999999999   ->  9999999999999999      Inexact Rounded
fmax361364 fma  1   9999999999999999 0.4999999999999999  ->  9999999999999999      Inexact Rounded
fmax361365 fma  1   9999999999999999 0.5000000000000000  ->  1.000000000000000E+16 Inexact Rounded
fmax361367 fma  1   9999999999999999 0.500000000000000   ->  1.000000000000000E+16 Inexact Rounded
fmax361368 fma  1   9999999999999999 0.50000000000000    ->  1.000000000000000E+16 Inexact Rounded
fmax361369 fma  1   9999999999999999 0.5000000000000     ->  1.000000000000000E+16 Inexact Rounded
fmax361370 fma  1   9999999999999999 0.500000000000      ->  1.000000000000000E+16 Inexact Rounded
fmax361371 fma  1   9999999999999999 0.50000000000       ->  1.000000000000000E+16 Inexact Rounded
fmax361372 fma  1   9999999999999999 0.5000000000        ->  1.000000000000000E+16 Inexact Rounded
fmax361373 fma  1   9999999999999999 0.500000000         ->  1.000000000000000E+16 Inexact Rounded
fmax361374 fma  1   9999999999999999 0.50000000          ->  1.000000000000000E+16 Inexact Rounded
fmax361375 fma  1   9999999999999999 0.5000000           ->  1.000000000000000E+16 Inexact Rounded
fmax361376 fma  1   9999999999999999 0.500000            ->  1.000000000000000E+16 Inexact Rounded
fmax361377 fma  1   9999999999999999 0.50000             ->  1.000000000000000E+16 Inexact Rounded
fmax361378 fma  1   9999999999999999 0.5000              ->  1.000000000000000E+16 Inexact Rounded
fmax361379 fma  1   9999999999999999 0.500               ->  1.000000000000000E+16 Inexact Rounded
fmax361380 fma  1   9999999999999999 0.50                ->  1.000000000000000E+16 Inexact Rounded
fmax361381 fma  1   9999999999999999 0.5                 ->  1.000000000000000E+16 Inexact Rounded
fmax361382 fma  1   9999999999999999 0.5000000000000001  ->  1.000000000000000E+16 Inexact Rounded
fmax361383 fma  1   9999999999999999 0.500000000000001   ->  1.000000000000000E+16 Inexact Rounded
fmax361384 fma  1   9999999999999999 0.50000000000001    ->  1.000000000000000E+16 Inexact Rounded
fmax361385 fma  1   9999999999999999 0.5000000000001     ->  1.000000000000000E+16 Inexact Rounded
fmax361386 fma  1   9999999999999999 0.500000000001      ->  1.000000000000000E+16 Inexact Rounded
fmax361387 fma  1   9999999999999999 0.50000000001       ->  1.000000000000000E+16 Inexact Rounded
fmax361388 fma  1   9999999999999999 0.5000000001        ->  1.000000000000000E+16 Inexact Rounded
fmax361389 fma  1   9999999999999999 0.500000001         ->  1.000000000000000E+16 Inexact Rounded
fmax361390 fma  1   9999999999999999 0.50000001          ->  1.000000000000000E+16 Inexact Rounded
fmax361391 fma  1   9999999999999999 0.5000001           ->  1.000000000000000E+16 Inexact Rounded
fmax361392 fma  1   9999999999999999 0.500001            ->  1.000000000000000E+16 Inexact Rounded
fmax361393 fma  1   9999999999999999 0.50001             ->  1.000000000000000E+16 Inexact Rounded
fmax361394 fma  1   9999999999999999 0.5001              ->  1.000000000000000E+16 Inexact Rounded
fmax361395 fma  1   9999999999999999 0.501               ->  1.000000000000000E+16 Inexact Rounded
fmax361396 fma  1   9999999999999999 0.51                ->  1.000000000000000E+16 Inexact Rounded

-- More GD edge cases, where difference between the unadjusted
-- exponents is larger than the maximum precision and one side is 0
fmax361420 fma  1    0 1.123456789012345     -> 1.123456789012345
fmax361421 fma  1    0 1.123456789012345E-1  -> 0.1123456789012345
fmax361422 fma  1    0 1.123456789012345E-2  -> 0.01123456789012345
fmax361423 fma  1    0 1.123456789012345E-3  -> 0.001123456789012345
fmax361424 fma  1    0 1.123456789012345E-4  -> 0.0001123456789012345
fmax361425 fma  1    0 1.123456789012345E-5  -> 0.00001123456789012345
fmax361426 fma  1    0 1.123456789012345E-6  -> 0.000001123456789012345
fmax361427 fma  1    0 1.123456789012345E-7  -> 1.123456789012345E-7
fmax361428 fma  1    0 1.123456789012345E-8  -> 1.123456789012345E-8
fmax361429 fma  1    0 1.123456789012345E-9  -> 1.123456789012345E-9
fmax361430 fma  1    0 1.123456789012345E-10 -> 1.123456789012345E-10
fmax361431 fma  1    0 1.123456789012345E-11 -> 1.123456789012345E-11
fmax361432 fma  1    0 1.123456789012345E-12 -> 1.123456789012345E-12
fmax361433 fma  1    0 1.123456789012345E-13 -> 1.123456789012345E-13
fmax361434 fma  1    0 1.123456789012345E-14 -> 1.123456789012345E-14
fmax361435 fma  1    0 1.123456789012345E-15 -> 1.123456789012345E-15
fmax361436 fma  1    0 1.123456789012345E-16 -> 1.123456789012345E-16
fmax361437 fma  1    0 1.123456789012345E-17 -> 1.123456789012345E-17
fmax361438 fma  1    0 1.123456789012345E-18 -> 1.123456789012345E-18
fmax361439 fma  1    0 1.123456789012345E-19 -> 1.123456789012345E-19

-- same, reversed 0
fmax361440 fma  1   1.123456789012345     0 -> 1.123456789012345
fmax361441 fma  1   1.123456789012345E-1  0 -> 0.1123456789012345
fmax361442 fma  1   1.123456789012345E-2  0 -> 0.01123456789012345
fmax361443 fma  1   1.123456789012345E-3  0 -> 0.001123456789012345
fmax361444 fma  1   1.123456789012345E-4  0 -> 0.0001123456789012345
fmax361445 fma  1   1.123456789012345E-5  0 -> 0.00001123456789012345
fmax361446 fma  1   1.123456789012345E-6  0 -> 0.000001123456789012345
fmax361447 fma  1   1.123456789012345E-7  0 -> 1.123456789012345E-7
fmax361448 fma  1   1.123456789012345E-8  0 -> 1.123456789012345E-8
fmax361449 fma  1   1.123456789012345E-9  0 -> 1.123456789012345E-9
fmax361450 fma  1   1.123456789012345E-10 0 -> 1.123456789012345E-10
fmax361451 fma  1   1.123456789012345E-11 0 -> 1.123456789012345E-11
fmax361452 fma  1   1.123456789012345E-12 0 -> 1.123456789012345E-12
fmax361453 fma  1   1.123456789012345E-13 0 -> 1.123456789012345E-13
fmax361454 fma  1   1.123456789012345E-14 0 -> 1.123456789012345E-14
fmax361455 fma  1   1.123456789012345E-15 0 -> 1.123456789012345E-15
fmax361456 fma  1   1.123456789012345E-16 0 -> 1.123456789012345E-16
fmax361457 fma  1   1.123456789012345E-17 0 -> 1.123456789012345E-17
fmax361458 fma  1   1.123456789012345E-18 0 -> 1.123456789012345E-18
fmax361459 fma  1   1.123456789012345E-19 0 -> 1.123456789012345E-19

-- same, Es on the 0
fmax361460 fma  1   1.123456789012345  0E-0   -> 1.123456789012345
fmax361461 fma  1   1.123456789012345  0E-1   -> 1.123456789012345
fmax361462 fma  1   1.123456789012345  0E-2   -> 1.123456789012345
fmax361463 fma  1   1.123456789012345  0E-3   -> 1.123456789012345
fmax361464 fma  1   1.123456789012345  0E-4   -> 1.123456789012345
fmax361465 fma  1   1.123456789012345  0E-5   -> 1.123456789012345
fmax361466 fma  1   1.123456789012345  0E-6   -> 1.123456789012345
fmax361467 fma  1   1.123456789012345  0E-7   -> 1.123456789012345
fmax361468 fma  1   1.123456789012345  0E-8   -> 1.123456789012345
fmax361469 fma  1   1.123456789012345  0E-9   -> 1.123456789012345
fmax361470 fma  1   1.123456789012345  0E-10  -> 1.123456789012345
fmax361471 fma  1   1.123456789012345  0E-11  -> 1.123456789012345
fmax361472 fma  1   1.123456789012345  0E-12  -> 1.123456789012345
fmax361473 fma  1   1.123456789012345  0E-13  -> 1.123456789012345
fmax361474 fma  1   1.123456789012345  0E-14  -> 1.123456789012345
fmax361475 fma  1   1.123456789012345  0E-15  -> 1.123456789012345
-- next four flag Rounded because the 0 extends the result
fmax361476 fma  1   1.123456789012345  0E-16  -> 1.123456789012345 Rounded
fmax361477 fma  1   1.123456789012345  0E-17  -> 1.123456789012345 Rounded
fmax361478 fma  1   1.123456789012345  0E-18  -> 1.123456789012345 Rounded
fmax361479 fma  1   1.123456789012345  0E-19  -> 1.123456789012345 Rounded

-- sum of two opposite-sign operands is exactly 0 and floor => -0
rounding:    half_up
-- exact zeros from zeros
fmax361500 fma  1    0        0E-19  ->  0E-19
fmax361501 fma  1   -0        0E-19  ->  0E-19
fmax361502 fma  1    0       -0E-19  ->  0E-19
fmax361503 fma  1   -0       -0E-19  -> -0E-19
fmax361504 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax361505 fma  1   -0E-400   0E-19  ->  0E-398 Clamped
fmax361506 fma  1    0E-400  -0E-19  ->  0E-398 Clamped
fmax361507 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax361511 fma  1    1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361512 fma  1   -1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361513 fma  1    1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361514 fma  1   -1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-- some exact zeros from non-zeros
fmax361515 fma  1    1E-401   1E-401 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361516 fma  1   -1E-401   1E-401 ->  0E-398 Clamped
fmax361517 fma  1    1E-401  -1E-401 ->  0E-398 Clamped
fmax361518 fma  1   -1E-401  -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped

rounding:    half_down
-- exact zeros from zeros
fmax361520 fma  1    0        0E-19  ->  0E-19
fmax361521 fma  1   -0        0E-19  ->  0E-19
fmax361522 fma  1    0       -0E-19  ->  0E-19
fmax361523 fma  1   -0       -0E-19  -> -0E-19
fmax361524 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax361525 fma  1   -0E-400   0E-19  ->  0E-398 Clamped
fmax361526 fma  1    0E-400  -0E-19  ->  0E-398 Clamped
fmax361527 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax361531 fma  1    1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361532 fma  1   -1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361533 fma  1    1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361534 fma  1   -1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-- some exact zeros from non-zeros
fmax361535 fma  1    1E-401   1E-401 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361536 fma  1   -1E-401   1E-401 ->  0E-398 Clamped
fmax361537 fma  1    1E-401  -1E-401 ->  0E-398 Clamped
fmax361538 fma  1   -1E-401  -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped

rounding:    half_even
-- exact zeros from zeros
fmax361540 fma  1    0        0E-19  ->  0E-19
fmax361541 fma  1   -0        0E-19  ->  0E-19
fmax361542 fma  1    0       -0E-19  ->  0E-19
fmax361543 fma  1   -0       -0E-19  -> -0E-19
fmax361544 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax361545 fma  1   -0E-400   0E-19  ->  0E-398 Clamped
fmax361546 fma  1    0E-400  -0E-19  ->  0E-398 Clamped
fmax361547 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax361551 fma  1    1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361552 fma  1   -1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361553 fma  1    1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361554 fma  1   -1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-- some exact zeros from non-zeros
fmax361555 fma  1    1E-401   1E-401 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361556 fma  1   -1E-401   1E-401 ->  0E-398 Clamped
fmax361557 fma  1    1E-401  -1E-401 ->  0E-398 Clamped
fmax361558 fma  1   -1E-401  -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped

rounding:    up
-- exact zeros from zeros
fmax361560 fma  1    0        0E-19  ->  0E-19
fmax361561 fma  1   -0        0E-19  ->  0E-19
fmax361562 fma  1    0       -0E-19  ->  0E-19
fmax361563 fma  1   -0       -0E-19  -> -0E-19
fmax361564 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax361565 fma  1   -0E-400   0E-19  ->  0E-398 Clamped
fmax361566 fma  1    0E-400  -0E-19  ->  0E-398 Clamped
fmax361567 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax361571 fma  1    1E-401   1E-400 ->  1E-398 Subnormal Inexact Rounded Underflow
fmax361572 fma  1   -1E-401   1E-400 ->  1E-398 Subnormal Inexact Rounded Underflow
fmax361573 fma  1    1E-401  -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
fmax361574 fma  1   -1E-401  -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
-- some exact zeros from non-zeros
fmax361575 fma  1    1E-401   1E-401 ->  1E-398 Subnormal Inexact Rounded Underflow
fmax361576 fma  1   -1E-401   1E-401 ->  0E-398 Clamped
fmax361577 fma  1    1E-401  -1E-401 ->  0E-398 Clamped
fmax361578 fma  1   -1E-401  -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow

rounding:    down
-- exact zeros from zeros
fmax361580 fma  1    0        0E-19  ->  0E-19
fmax361581 fma  1   -0        0E-19  ->  0E-19
fmax361582 fma  1    0       -0E-19  ->  0E-19
fmax361583 fma  1   -0       -0E-19  -> -0E-19
fmax361584 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax361585 fma  1   -0E-400   0E-19  ->  0E-398 Clamped
fmax361586 fma  1    0E-400  -0E-19  ->  0E-398 Clamped
fmax361587 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax361591 fma  1    1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361592 fma  1   -1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361593 fma  1    1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361594 fma  1   -1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-- some exact zeros from non-zeros
fmax361595 fma  1    1E-401   1E-401 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361596 fma  1   -1E-401   1E-401 ->  0E-398 Clamped
fmax361597 fma  1    1E-401  -1E-401 ->  0E-398 Clamped
fmax361598 fma  1   -1E-401  -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped

rounding:    ceiling
-- exact zeros from zeros
fmax361600 fma  1    0        0E-19  ->  0E-19
fmax361601 fma  1   -0        0E-19  ->  0E-19
fmax361602 fma  1    0       -0E-19  ->  0E-19
fmax361603 fma  1   -0       -0E-19  -> -0E-19
fmax361604 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax361605 fma  1   -0E-400   0E-19  ->  0E-398 Clamped
fmax361606 fma  1    0E-400  -0E-19  ->  0E-398 Clamped
fmax361607 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax361611 fma  1    1E-401   1E-400 ->  1E-398 Subnormal Inexact Rounded Underflow
fmax361612 fma  1   -1E-401   1E-400 ->  1E-398 Subnormal Inexact Rounded Underflow
fmax361613 fma  1    1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361614 fma  1   -1E-401  -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-- some exact zeros from non-zeros
fmax361615 fma  1    1E-401   1E-401 ->  1E-398 Subnormal Inexact Rounded Underflow
fmax361616 fma  1   -1E-401   1E-401 ->  0E-398 Clamped
fmax361617 fma  1    1E-401  -1E-401 ->  0E-398 Clamped
fmax361618 fma  1   -1E-401  -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped

-- and the extra-special ugly case; unusual minuses marked by -- *
rounding:    floor
-- exact zeros from zeros
fmax361620 fma  1    0        0E-19  ->  0E-19
fmax361621 fma  1   -0        0E-19  -> -0E-19           -- *
fmax361622 fma  1    0       -0E-19  -> -0E-19           -- *
fmax361623 fma  1   -0       -0E-19  -> -0E-19
fmax361624 fma  1    0E-400   0E-19  ->  0E-398 Clamped
fmax361625 fma  1   -0E-400   0E-19  -> -0E-398 Clamped  -- *
fmax361626 fma  1    0E-400  -0E-19  -> -0E-398 Clamped  -- *
fmax361627 fma  1   -0E-400  -0E-19  -> -0E-398 Clamped
-- inexact zeros
fmax361631 fma  1    1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361632 fma  1   -1E-401   1E-400 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361633 fma  1    1E-401  -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
fmax361634 fma  1   -1E-401  -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
-- some exact zeros from non-zeros
fmax361635 fma  1    1E-401   1E-401 ->  0E-398 Subnormal Inexact Rounded Underflow Clamped
fmax361636 fma  1   -1E-401   1E-401 -> -0E-398 Clamped  -- *
fmax361637 fma  1    1E-401  -1E-401 -> -0E-398 Clamped  -- *
fmax361638 fma  1   -1E-401  -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow

-- Examples from SQL proposal (Krishna Kulkarni)
fmax361701 fma  1   130E-2    120E-2    -> 2.50
fmax361702 fma  1   130E-2    12E-1     -> 2.50
fmax361703 fma  1   130E-2    1E0       -> 2.30
fmax361704 fma  1   1E2       1E4       -> 1.01E+4
fmax361705 subtract 130E-2  120E-2 -> 0.10
fmax361706 subtract 130E-2  12E-1  -> 0.10
fmax361707 subtract 130E-2  1E0    -> 0.30
fmax361708 subtract 1E2     1E4    -> -9.9E+3

-- Gappy coefficients; check residue handling even with full coefficient gap
rounding: half_even

fmax362001 fma  1   1234567890123456 1      -> 1234567890123457
fmax362002 fma  1   1234567890123456 0.6    -> 1234567890123457  Inexact Rounded
fmax362003 fma  1   1234567890123456 0.06   -> 1234567890123456  Inexact Rounded
fmax362004 fma  1   1234567890123456 6E-3   -> 1234567890123456  Inexact Rounded
fmax362005 fma  1   1234567890123456 6E-4   -> 1234567890123456  Inexact Rounded
fmax362006 fma  1   1234567890123456 6E-5   -> 1234567890123456  Inexact Rounded
fmax362007 fma  1   1234567890123456 6E-6   -> 1234567890123456  Inexact Rounded
fmax362008 fma  1   1234567890123456 6E-7   -> 1234567890123456  Inexact Rounded
fmax362009 fma  1   1234567890123456 6E-8   -> 1234567890123456  Inexact Rounded
fmax362010 fma  1   1234567890123456 6E-9   -> 1234567890123456  Inexact Rounded
fmax362011 fma  1   1234567890123456 6E-10  -> 1234567890123456  Inexact Rounded
fmax362012 fma  1   1234567890123456 6E-11  -> 1234567890123456  Inexact Rounded
fmax362013 fma  1   1234567890123456 6E-12  -> 1234567890123456  Inexact Rounded
fmax362014 fma  1   1234567890123456 6E-13  -> 1234567890123456  Inexact Rounded
fmax362015 fma  1   1234567890123456 6E-14  -> 1234567890123456  Inexact Rounded
fmax362016 fma  1   1234567890123456 6E-15  -> 1234567890123456  Inexact Rounded
fmax362017 fma  1   1234567890123456 6E-16  -> 1234567890123456  Inexact Rounded
fmax362018 fma  1   1234567890123456 6E-17  -> 1234567890123456  Inexact Rounded
fmax362019 fma  1   1234567890123456 6E-18  -> 1234567890123456  Inexact Rounded
fmax362020 fma  1   1234567890123456 6E-19  -> 1234567890123456  Inexact Rounded
fmax362021 fma  1   1234567890123456 6E-20  -> 1234567890123456  Inexact Rounded

-- widening second argument at gap
fmax362030 fma  1   12345678 1                       -> 12345679
fmax362031 fma  1   12345678 0.1                     -> 12345678.1
fmax362032 fma  1   12345678 0.12                    -> 12345678.12
fmax362033 fma  1   12345678 0.123                   -> 12345678.123
fmax362034 fma  1   12345678 0.1234                  -> 12345678.1234
fmax362035 fma  1   12345678 0.12345                 -> 12345678.12345
fmax362036 fma  1   12345678 0.123456                -> 12345678.123456
fmax362037 fma  1   12345678 0.1234567               -> 12345678.1234567
fmax362038 fma  1   12345678 0.12345678              -> 12345678.12345678
fmax362039 fma  1   12345678 0.123456789             -> 12345678.12345679 Inexact Rounded
fmax362040 fma  1   12345678 0.123456785             -> 12345678.12345678 Inexact Rounded
fmax362041 fma  1   12345678 0.1234567850            -> 12345678.12345678 Inexact Rounded
fmax362042 fma  1   12345678 0.1234567851            -> 12345678.12345679 Inexact Rounded
fmax362043 fma  1   12345678 0.12345678501           -> 12345678.12345679 Inexact Rounded
fmax362044 fma  1   12345678 0.123456785001          -> 12345678.12345679 Inexact Rounded
fmax362045 fma  1   12345678 0.1234567850001         -> 12345678.12345679 Inexact Rounded
fmax362046 fma  1   12345678 0.12345678500001        -> 12345678.12345679 Inexact Rounded
fmax362047 fma  1   12345678 0.123456785000001       -> 12345678.12345679 Inexact Rounded
fmax362048 fma  1   12345678 0.1234567850000001      -> 12345678.12345679 Inexact Rounded
fmax362049 fma  1   12345678 0.1234567850000000      -> 12345678.12345678 Inexact Rounded
--                               90123456
rounding: half_even
fmax362050 fma  1   12345678 0.0234567750000000      -> 12345678.02345678 Inexact Rounded
fmax362051 fma  1   12345678 0.0034567750000000      -> 12345678.00345678 Inexact Rounded
fmax362052 fma  1   12345678 0.0004567750000000      -> 12345678.00045678 Inexact Rounded
fmax362053 fma  1   12345678 0.0000567750000000      -> 12345678.00005678 Inexact Rounded
fmax362054 fma  1   12345678 0.0000067750000000      -> 12345678.00000678 Inexact Rounded
fmax362055 fma  1   12345678 0.0000007750000000      -> 12345678.00000078 Inexact Rounded
fmax362056 fma  1   12345678 0.0000000750000000      -> 12345678.00000008 Inexact Rounded
fmax362057 fma  1   12345678 0.0000000050000000      -> 12345678.00000000 Inexact Rounded
fmax362060 fma  1   12345678 0.0234567750000001      -> 12345678.02345678 Inexact Rounded
fmax362061 fma  1   12345678 0.0034567750000001      -> 12345678.00345678 Inexact Rounded
fmax362062 fma  1   12345678 0.0004567750000001      -> 12345678.00045678 Inexact Rounded
fmax362063 fma  1   12345678 0.0000567750000001      -> 12345678.00005678 Inexact Rounded
fmax362064 fma  1   12345678 0.0000067750000001      -> 12345678.00000678 Inexact Rounded
fmax362065 fma  1   12345678 0.0000007750000001      -> 12345678.00000078 Inexact Rounded
fmax362066 fma  1   12345678 0.0000000750000001      -> 12345678.00000008 Inexact Rounded
fmax362067 fma  1   12345678 0.0000000050000001      -> 12345678.00000001 Inexact Rounded
-- far-out residues (full coefficient gap is 16+15 digits)
rounding: up
fmax362070 fma  1   12345678 1E-8                    -> 12345678.00000001
fmax362071 fma  1   12345678 1E-9                    -> 12345678.00000001 Inexact Rounded
fmax362072 fma  1   12345678 1E-10                   -> 12345678.00000001 Inexact Rounded
fmax362073 fma  1   12345678 1E-11                   -> 12345678.00000001 Inexact Rounded
fmax362074 fma  1   12345678 1E-12                   -> 12345678.00000001 Inexact Rounded
fmax362075 fma  1   12345678 1E-13                   -> 12345678.00000001 Inexact Rounded
fmax362076 fma  1   12345678 1E-14                   -> 12345678.00000001 Inexact Rounded
fmax362077 fma  1   12345678 1E-15                   -> 12345678.00000001 Inexact Rounded
fmax362078 fma  1   12345678 1E-16                   -> 12345678.00000001 Inexact Rounded
fmax362079 fma  1   12345678 1E-17                   -> 12345678.00000001 Inexact Rounded
fmax362080 fma  1   12345678 1E-18                   -> 12345678.00000001 Inexact Rounded
fmax362081 fma  1   12345678 1E-19                   -> 12345678.00000001 Inexact Rounded
fmax362082 fma  1   12345678 1E-20                   -> 12345678.00000001 Inexact Rounded
fmax362083 fma  1   12345678 1E-25                   -> 12345678.00000001 Inexact Rounded
fmax362084 fma  1   12345678 1E-30                   -> 12345678.00000001 Inexact Rounded
fmax362085 fma  1   12345678 1E-31                   -> 12345678.00000001 Inexact Rounded
fmax362086 fma  1   12345678 1E-32                   -> 12345678.00000001 Inexact Rounded
fmax362087 fma  1   12345678 1E-33                   -> 12345678.00000001 Inexact Rounded
fmax362088 fma  1   12345678 1E-34                   -> 12345678.00000001 Inexact Rounded
fmax362089 fma  1   12345678 1E-35                   -> 12345678.00000001 Inexact Rounded

-- payload decapitate x3
precision: 5
fmax363000 fma  1 1  sNaN1234567890     ->  NaN67890  Invalid_operation
fmax363001 fma    1 -sNaN1234512345 1   -> -NaN12345  Invalid_operation
fmax363002 fma       sNaN1234554321 1 1 ->  NaN54321  Invalid_operation

-- Null tests
fmax39990 fma  1   10  # -> NaN Invalid_operation
fmax39991 fma  1    # 10 -> NaN Invalid_operation

Changes to test/dectest/inexact.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- inexact.decTest -- decimal inexact and rounded edge cases          --
-- Copyright (c) IBM Corporation, 1981, 2003.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minexponent: -999



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- inexact.decTest -- decimal inexact and rounded edge cases          --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minexponent: -999

Added test/dectest/invert.decTest.

































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
------------------------------------------------------------------------
-- invert.decTest -- digitwise logical INVERT                         --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

-- Sanity check (truth table), and examples from decArith
invx001 invert             0 -> 111111111
invx002 invert             1 -> 111111110
invx003 invert            10 -> 111111101
invx004 invert     111111111 ->         0
invx005 invert     000000000 -> 111111111
invx006 invert     101010101 -> '10101010'
-- and at msd and msd-1
invx007 invert 000000000 ->   111111111
invx009 invert 100000000 ->    11111111
invx011 invert 000000000 ->   111111111
invx013 invert 010000000 ->   101111111

-- Various lengths
--             123456789         123456789
invx021 invert 111111111     ->  0
invx022 invert 111111111111  ->  0
invx023 invert  11111111     ->  100000000
invx025 invert   1111111     ->  110000000
invx026 invert    111111     ->  111000000
invx027 invert     11111     ->  111100000
invx028 invert      1111     ->  111110000
invx029 invert       111     ->  111111000
invx031 invert        11     ->  111111100
invx032 invert         1     ->  111111110
invx033 invert 111111111111  ->  0
invx034 invert 11111111111   ->  0
invx035 invert 1111111111    ->  0
invx036 invert 111111111     ->  0

invx080 invert 011111111   ->  100000000
invx081 invert 101111111   ->   10000000
invx082 invert 110111111   ->    1000000
invx083 invert 111011111   ->     100000
invx084 invert 111101111   ->      10000
invx085 invert 111110111   ->       1000
invx086 invert 111111011   ->        100
invx087 invert 111111101   ->         10
invx088 invert 111111110   ->          1
invx089 invert 011111011   ->  100000100
invx090 invert 101111101   ->   10000010
invx091 invert 110111110   ->    1000001
invx092 invert 111011101   ->     100010
invx093 invert 111101011   ->      10100
invx094 invert 111110111   ->       1000
invx095 invert 111101011   ->      10100
invx096 invert 111011101   ->     100010
invx097 invert 110111110   ->    1000001
invx098 invert 101111101   ->   10000010
invx099 invert 011111011   ->  100000100

-- non-0/1 should not be accepted, nor should signs
invx220 invert 111111112   ->  NaN Invalid_operation
invx221 invert 333333333   ->  NaN Invalid_operation
invx222 invert 555555555   ->  NaN Invalid_operation
invx223 invert 777777777   ->  NaN Invalid_operation
invx224 invert 999999999   ->  NaN Invalid_operation
invx225 invert 222222222   ->  NaN Invalid_operation
invx226 invert 444444444   ->  NaN Invalid_operation
invx227 invert 666666666   ->  NaN Invalid_operation
invx228 invert 888888888   ->  NaN Invalid_operation
invx229 invert 999999999   ->  NaN Invalid_operation
invx230 invert 999999999   ->  NaN Invalid_operation
invx231 invert 999999999   ->  NaN Invalid_operation
invx232 invert 999999999   ->  NaN Invalid_operation
-- a few randoms
invx240 invert  567468689  ->  NaN Invalid_operation
invx241 invert  567367689  ->  NaN Invalid_operation
invx242 invert -631917772  ->  NaN Invalid_operation
invx243 invert -756253257  ->  NaN Invalid_operation
invx244 invert  835590149  ->  NaN Invalid_operation
-- test MSD
invx250 invert  200000000  ->  NaN Invalid_operation
invx251 invert  300000000  ->  NaN Invalid_operation
invx252 invert  400000000  ->  NaN Invalid_operation
invx253 invert  500000000  ->  NaN Invalid_operation
invx254 invert  600000000  ->  NaN Invalid_operation
invx255 invert  700000000  ->  NaN Invalid_operation
invx256 invert  800000000  ->  NaN Invalid_operation
invx257 invert  900000000  ->  NaN Invalid_operation
-- test MSD-1
invx270 invert  021000000  ->  NaN Invalid_operation
invx271 invert  030100000  ->  NaN Invalid_operation
invx272 invert  040010000  ->  NaN Invalid_operation
invx273 invert  050001000  ->  NaN Invalid_operation
invx274 invert  160000100  ->  NaN Invalid_operation
invx275 invert  170000010  ->  NaN Invalid_operation
invx276 invert  180000000  ->  NaN Invalid_operation
invx277 invert  190000000  ->  NaN Invalid_operation
-- test LSD
invx280 invert  000000002  ->  NaN Invalid_operation
invx281 invert  000000003  ->  NaN Invalid_operation
invx282 invert  000000004  ->  NaN Invalid_operation
invx283 invert  000000005  ->  NaN Invalid_operation
invx284 invert  101000006  ->  NaN Invalid_operation
invx285 invert  100100007  ->  NaN Invalid_operation
invx286 invert  100010008  ->  NaN Invalid_operation
invx287 invert  100001009  ->  NaN Invalid_operation
-- test Middie
invx288 invert  000020000  ->  NaN Invalid_operation
invx289 invert  000030001  ->  NaN Invalid_operation
invx290 invert  000040000  ->  NaN Invalid_operation
invx291 invert  000050000  ->  NaN Invalid_operation
invx292 invert  101060000  ->  NaN Invalid_operation
invx293 invert  100170010  ->  NaN Invalid_operation
invx294 invert  100080100  ->  NaN Invalid_operation
invx295 invert  100091000  ->  NaN Invalid_operation
-- signs
invx296 invert -100001000  ->  NaN Invalid_operation
invx299 invert  100001000  ->  11110111

-- Nmax, Nmin, Ntiny
invx341 invert  9.99999999E+999   -> NaN Invalid_operation
invx342 invert  1E-999            -> NaN Invalid_operation
invx343 invert  1.00000000E-999   -> NaN Invalid_operation
invx344 invert  1E-1007           -> NaN Invalid_operation
invx345 invert  -1E-1007          -> NaN Invalid_operation
invx346 invert  -1.00000000E-999  -> NaN Invalid_operation
invx347 invert  -1E-999           -> NaN Invalid_operation
invx348 invert  -9.99999999E+999  -> NaN Invalid_operation

-- A few other non-integers
invx361 invert  1.0               -> NaN Invalid_operation
invx362 invert  1E+1              -> NaN Invalid_operation
invx363 invert  0.0               -> NaN Invalid_operation
invx364 invert  0E+1              -> NaN Invalid_operation
invx365 invert  9.9               -> NaN Invalid_operation
invx366 invert  9E+1              -> NaN Invalid_operation

-- All Specials are in error
invx788 invert -Inf     -> NaN  Invalid_operation
invx794 invert  Inf     -> NaN  Invalid_operation
invx821 invert  NaN     -> NaN  Invalid_operation
invx841 invert  sNaN    -> NaN  Invalid_operation
-- propagating NaNs
invx861 invert  NaN1    -> NaN Invalid_operation
invx862 invert +NaN2    -> NaN Invalid_operation
invx863 invert  NaN3    -> NaN Invalid_operation
invx864 invert  NaN4    -> NaN Invalid_operation
invx865 invert  NaN5    -> NaN Invalid_operation
invx871 invert  sNaN11  -> NaN Invalid_operation
invx872 invert  sNaN12  -> NaN Invalid_operation
invx873 invert  sNaN13  -> NaN Invalid_operation
invx874 invert  sNaN14  -> NaN Invalid_operation
invx875 invert  sNaN15  -> NaN Invalid_operation
invx876 invert  NaN16   -> NaN Invalid_operation
invx881 invert +NaN25   -> NaN Invalid_operation
invx882 invert -NaN26   -> NaN Invalid_operation
invx883 invert -sNaN27  -> NaN Invalid_operation

Changes to test/dectest/ln.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- ln.decTest -- decimal natural logarithm                            --
-- Copyright (c) IBM Corporation, 2005.  All rights reserved.         --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
precision:   16
rounding:    half_even
maxExponent: 384
minexponent: -383



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- ln.decTest -- decimal natural logarithm                            --
-- Copyright (c) IBM Corporation, 2005, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   16
rounding:    half_even
maxExponent: 384
minexponent: -383

562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
lnx763  ln 1.7E-388 -> -892.8724           Inexact Rounded
lnx764  ln 1.5E-388 -> -892.9976           Inexact Rounded
lnx765  ln 9E-389 -> -893.5084             Inexact Rounded
lnx766  ln 1E-389 -> -895.7056             Inexact Rounded
lnx774  ln 0E-389 -> -Infinity

-- special values
maxexponent: 999
minexponent: -999
lnx820  ln Infinity ->   Infinity
lnx821  ln 0        ->  -Infinity
lnx822  ln NaN      ->   NaN
lnx823  ln sNaN     ->   NaN     Invalid_operation
-- propagating NaNs
lnx824  ln sNaN123  ->  NaN123  Invalid_operation
lnx825  ln -sNaN321 -> -NaN321  Invalid_operation
lnx826  ln NaN456   ->   NaN456
lnx827  ln -NaN654  ->  -NaN654
lnx828  ln NaN1     ->   NaN1

-- Invalid operations due to restrictions
-- [next two probably skipped by most test harnesses]
precision: 100000000







<
<





|
|







562
563
564
565
566
567
568


569
570
571
572
573
574
575
576
577
578
579
580
581
582
lnx763  ln 1.7E-388 -> -892.8724           Inexact Rounded
lnx764  ln 1.5E-388 -> -892.9976           Inexact Rounded
lnx765  ln 9E-389 -> -893.5084             Inexact Rounded
lnx766  ln 1E-389 -> -895.7056             Inexact Rounded
lnx774  ln 0E-389 -> -Infinity

-- special values


lnx820  ln Infinity ->   Infinity
lnx821  ln 0        ->  -Infinity
lnx822  ln NaN      ->   NaN
lnx823  ln sNaN     ->   NaN     Invalid_operation
-- propagating NaNs
lnx824  ln sNaN123  ->   NaN123  Invalid_operation
lnx825  ln -sNaN321 ->  -NaN321  Invalid_operation
lnx826  ln NaN456   ->   NaN456
lnx827  ln -NaN654  ->  -NaN654
lnx828  ln NaN1     ->   NaN1

-- Invalid operations due to restrictions
-- [next two probably skipped by most test harnesses]
precision: 100000000
596
597
598
599
600
601
602
603
604
605
606
607

608
609
610
611
612
maxExponent:    999999
minExponent:  -1000000
lnx905  ln 1   ->  NaN          Invalid_context
maxExponent:    999999
minExponent:   -999998
lnx906  ln 0 ->  -Infinity

--
maxExponent: 384
minExponent: -383
precision:   16
rounding:    half_even


-- Null test
lnx900  ln #   -> NaN Invalid_operation









|
<
<
|
<
>





594
595
596
597
598
599
600
601


602

603
604
605
606
607
608
maxExponent:    999999
minExponent:  -1000000
lnx905  ln 1   ->  NaN          Invalid_context
maxExponent:    999999
minExponent:   -999998
lnx906  ln 0 ->  -Infinity

-- payload decapitate


precision: 5

lnx910  ln -sNaN1234567890 -> -NaN67890  Invalid_operation

-- Null test
lnx900  ln #   -> NaN Invalid_operation


Changes to test/dectest/log10.dectest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- log10.decTest -- decimal logarithm in base 10                      --
-- Copyright (c) IBM Corporation, 2005.  All rights reserved.         --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- This emphasises the testing of notable cases, as they will often
-- have unusual paths (especially the 10**n results).

extended:    1
precision:   16
rounding:    half_even


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- log10.decTest -- decimal logarithm in base 10                      --
-- Copyright (c) IBM Corporation, 2005, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This emphasises the testing of notable cases, as they will often
-- have unusual paths (especially the 10**n results).

extended:    1
precision:   16
rounding:    half_even
506
507
508
509
510
511
512













513
514
515
516
517
518
519
logx2040 log10 6.356276  -> 0.8032027 Inexact Rounded

--------
maxExponent: 384
minExponent: -383
precision:   16
rounding:    half_even














-- Invalid operations due to restrictions
-- [next two probably skipped by most test harnesses]
precision: 100000000
logx901  log10 1 ->  NaN            Invalid_context
precision:  99999999
logx902  log10 0 ->  NaN            Invalid_context







>
>
>
>
>
>
>
>
>
>
>
>
>







506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
logx2040 log10 6.356276  -> 0.8032027 Inexact Rounded

--------
maxExponent: 384
minExponent: -383
precision:   16
rounding:    half_even

-- special values
logx820  log10   Infinity ->   Infinity
logx821  log10   0        ->  -Infinity
logx822  log10   NaN      ->   NaN
logx823  log10   sNaN     ->   NaN     Invalid_operation
-- propagating NaNs
logx824  log10   sNaN123  ->   NaN123  Invalid_operation
logx825  log10   -sNaN321 ->  -NaN321  Invalid_operation
logx826  log10   NaN456   ->   NaN456
logx827  log10   -NaN654  ->  -NaN654
logx828  log10   NaN1     ->   NaN1


-- Invalid operations due to restrictions
-- [next two probably skipped by most test harnesses]
precision: 100000000
logx901  log10 1 ->  NaN            Invalid_context
precision:  99999999
logx902  log10 0 ->  NaN            Invalid_context

Added test/dectest/logb.decTest.





































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
------------------------------------------------------------------------
-- logb.decTest -- return integral adjusted exponent as per 754r      --
-- Copyright (c) IBM Corporation, 2005, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This emphasises the testing of notable cases, as they will often
-- have unusual paths (especially the 10**n results).

extended:    1
rounding:    half_even
maxExponent: 999
minexponent: -999

-- basics & examples
precision:   9
logbx001 logb  0                 -> -Infinity  Division_by_zero
logbx002 logb  1E-999            -> -999
logbx003 logb  9E-999            -> -999
logbx004 logb  0.001             -> -3
logbx005 logb  0.03              -> -2
logbx006 logb  1                 ->  0
logbx007 logb  2                 ->  0
logbx008 logb  2.5               ->  0
logbx009 logb  2.50              ->  0
logbx010 logb  10                ->  1
logbx011 logb  70                ->  1
logbx012 logb  100               ->  2
logbx013 logb  250               ->  2
logbx014 logb +Infinity          ->  Infinity

-- negatives are treated as positives
logbx021 logb -0                 -> -Infinity  Division_by_zero
logbx022 logb -1E-999            -> -999
logbx023 logb -9E-999            -> -999
logbx024 logb -0.001             -> -3
logbx025 logb -1                 ->  0
logbx026 logb -2                 ->  0
logbx027 logb -10                ->  1
logbx028 logb -70                ->  1
logbx029 logb -100               ->  2
logbx030 logb -100000000         ->  8
logbx031 logb -Infinity          ->  Infinity

-- zeros
logbx111 logb          0   -> -Infinity  Division_by_zero
logbx112 logb         -0   -> -Infinity  Division_by_zero
logbx113 logb       0E+4   -> -Infinity  Division_by_zero
logbx114 logb      -0E+4   -> -Infinity  Division_by_zero
logbx115 logb     0.0000   -> -Infinity  Division_by_zero
logbx116 logb    -0.0000   -> -Infinity  Division_by_zero
logbx117 logb      0E-141  -> -Infinity  Division_by_zero
logbx118 logb     -0E-141  -> -Infinity  Division_by_zero

-- full coefficients, alternating bits
logbx121 logb   268268268        -> 8
logbx122 logb  -268268268        -> 8
logbx123 logb   134134134        -> 8
logbx124 logb  -134134134        -> 8

-- Nmax, Nmin, Ntiny
logbx131 logb  9.99999999E+999   -> 999
logbx132 logb  1E-999            -> -999
logbx133 logb  1.00000000E-999   -> -999
logbx134 logb  1E-1007           -> -1007

logbx135 logb  -1E-1007          -> -1007
logbx136 logb  -1.00000000E-999  -> -999
logbx137 logb  -1E-999           -> -999
logbx138 logb  -9.99999999E+999  ->  999

-- ones
logbx0061 logb  1                 ->   0
logbx0062 logb  1.0               ->   0
logbx0063 logb  1.000000000000000 ->   0
logbx0064 logb  1.000000000000000000 ->   0

-- notable cases -- exact powers of 10
logbx1100 logb 1             -> 0
logbx1101 logb 10            -> 1
logbx1102 logb 100           -> 2
logbx1103 logb 1000          -> 3
logbx1104 logb 10000         -> 4
logbx1105 logb 100000        -> 5
logbx1106 logb 1000000       -> 6
logbx1107 logb 10000000      -> 7
logbx1108 logb 100000000     -> 8
logbx1109 logb 1000000000    -> 9
logbx1110 logb 10000000000   -> 10
logbx1111 logb 100000000000  -> 11
logbx1112 logb 1000000000000 -> 12
logbx1113 logb 0.00000000001 -> -11
logbx1114 logb 0.0000000001 -> -10
logbx1115 logb 0.000000001 -> -9
logbx1116 logb 0.00000001 -> -8
logbx1117 logb 0.0000001 -> -7
logbx1118 logb 0.000001 -> -6
logbx1119 logb 0.00001 -> -5
logbx1120 logb 0.0001 -> -4
logbx1121 logb 0.001 -> -3
logbx1122 logb 0.01 -> -2
logbx1123 logb 0.1 -> -1
logbx1124 logb 1E-99  -> -99
logbx1125 logb 1E-100 -> -100
logbx1126 logb 1E-383 -> -383
logbx1127 logb 1E-999 -> -999

-- suggestions from Ilan Nehama
logbx1400 logb 10E-3    -> -2
logbx1401 logb 10E-2    -> -1
logbx1402 logb 100E-2   ->  0
logbx1403 logb 1000E-2  ->  1
logbx1404 logb 10000E-2 ->  2
logbx1405 logb 10E-1    ->  0
logbx1406 logb 100E-1   ->  1
logbx1407 logb 1000E-1  ->  2
logbx1408 logb 10000E-1 ->  3
logbx1409 logb 10E0     ->  1
logbx1410 logb 100E0    ->  2
logbx1411 logb 1000E0   ->  3
logbx1412 logb 10000E0  ->  4
logbx1413 logb 10E1     ->  2
logbx1414 logb 100E1    ->  3
logbx1415 logb 1000E1   ->  4
logbx1416 logb 10000E1  ->  5
logbx1417 logb 10E2     ->  3
logbx1418 logb 100E2    ->  4
logbx1419 logb 1000E2   ->  5
logbx1420 logb 10000E2  ->  6

-- special values
logbx820  logb   Infinity ->   Infinity
logbx821  logb  -Infinity ->   Infinity
logbx822  logb   0        ->  -Infinity Division_by_zero
logbx823  logb   NaN      ->   NaN
logbx824  logb   sNaN     ->   NaN     Invalid_operation
-- propagating NaNs
logbx825  logb   sNaN123  ->   NaN123  Invalid_operation
logbx826  logb   -sNaN321 ->  -NaN321  Invalid_operation
logbx827  logb   NaN456   ->   NaN456
logbx828  logb   -NaN654  ->  -NaN654
logbx829  logb   NaN1     ->   NaN1

-- Null test
logbx900  logb #   -> NaN Invalid_operation


Changes to test/dectest/max.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- max.decTest -- decimal maximum                                     --
-- Copyright (c) IBM Corporation, 1981, 2004.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding

extended:    1
precision:   9
rounding:    half_up


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- max.decTest -- decimal maximum                                     --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding

extended:    1
precision:   9
rounding:    half_up
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397





















398
399
400
401
402
403
maxexponent: 999
minexponent: -999
maxx510 max  1.00E-999       0  ->   1.00E-999
maxx511 max  0.1E-999        0  ->   1E-1000   Subnormal
maxx512 max  0.10E-999       0  ->   1.0E-1000 Subnormal
maxx513 max  0.100E-999      0  ->   1.0E-1000 Subnormal Rounded
maxx514 max  0.01E-999       0  ->   1E-1001   Subnormal
-- next is rounded to Emin
maxx515 max  0.999E-999      0  ->   1.00E-999 Inexact Rounded Subnormal Underflow
maxx516 max  0.099E-999      0  ->   1.0E-1000 Inexact Rounded Subnormal Underflow
maxx517 max  0.009E-999      0  ->   1E-1001   Inexact Rounded Subnormal Underflow
maxx518 max  0.001E-999      0  ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
maxx519 max  0.0009E-999     0  ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
maxx520 max  0.0001E-999     0  ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped

maxx530 max -1.00E-999       0  ->   0
maxx531 max -0.1E-999        0  ->   0
maxx532 max -0.10E-999       0  ->   0
maxx533 max -0.100E-999      0  ->   0
maxx534 max -0.01E-999       0  ->   0
maxx535 max -0.999E-999      0  ->   0
maxx536 max -0.099E-999      0  ->   0
maxx537 max -0.009E-999      0  ->   0
maxx538 max -0.001E-999      0  ->   0
maxx539 max -0.0009E-999     0  ->   0
maxx540 max -0.0001E-999     0  ->   0






















-- Null tests
maxx900 max 10  #  -> NaN Invalid_operation
maxx901 max  # 10  -> NaN Invalid_operation










|



















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
maxexponent: 999
minexponent: -999
maxx510 max  1.00E-999       0  ->   1.00E-999
maxx511 max  0.1E-999        0  ->   1E-1000   Subnormal
maxx512 max  0.10E-999       0  ->   1.0E-1000 Subnormal
maxx513 max  0.100E-999      0  ->   1.0E-1000 Subnormal Rounded
maxx514 max  0.01E-999       0  ->   1E-1001   Subnormal
-- next is rounded to Nmin
maxx515 max  0.999E-999      0  ->   1.00E-999 Inexact Rounded Subnormal Underflow
maxx516 max  0.099E-999      0  ->   1.0E-1000 Inexact Rounded Subnormal Underflow
maxx517 max  0.009E-999      0  ->   1E-1001   Inexact Rounded Subnormal Underflow
maxx518 max  0.001E-999      0  ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
maxx519 max  0.0009E-999     0  ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
maxx520 max  0.0001E-999     0  ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped

maxx530 max -1.00E-999       0  ->   0
maxx531 max -0.1E-999        0  ->   0
maxx532 max -0.10E-999       0  ->   0
maxx533 max -0.100E-999      0  ->   0
maxx534 max -0.01E-999       0  ->   0
maxx535 max -0.999E-999      0  ->   0
maxx536 max -0.099E-999      0  ->   0
maxx537 max -0.009E-999      0  ->   0
maxx538 max -0.001E-999      0  ->   0
maxx539 max -0.0009E-999     0  ->   0
maxx540 max -0.0001E-999     0  ->   0

-- misalignment traps for little-endian
precision: 9
maxx551 max      1.0       0.1  -> 1.0
maxx552 max      0.1       1.0  -> 1.0
maxx553 max     10.0       0.1  -> 10.0
maxx554 max      0.1      10.0  -> 10.0
maxx555 max      100       1.0  -> 100
maxx556 max      1.0       100  -> 100
maxx557 max     1000      10.0  -> 1000
maxx558 max     10.0      1000  -> 1000
maxx559 max    10000     100.0  -> 10000
maxx560 max    100.0     10000  -> 10000
maxx661 max   100000    1000.0  -> 100000
maxx662 max   1000.0    100000  -> 100000
maxx663 max  1000000   10000.0  -> 1000000
maxx664 max  10000.0   1000000  -> 1000000

-- payload decapitate
precision: 5
maxx670 max      11 -sNaN12345678901 -> -NaN78901  Invalid_operation

-- Null tests
maxx900 max 10  #  -> NaN Invalid_operation
maxx901 max  # 10  -> NaN Invalid_operation



Added test/dectest/maxmag.decTest.









































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
------------------------------------------------------------------------
-- maxmag.decTest -- decimal maximum by magnitude                     --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

-- sanity checks
mxgx001 maxmag  -2  -2  -> -2
mxgx002 maxmag  -2  -1  -> -2
mxgx003 maxmag  -2   0  -> -2
mxgx004 maxmag  -2   1  -> -2
mxgx005 maxmag  -2   2  ->  2
mxgx006 maxmag  -1  -2  -> -2
mxgx007 maxmag  -1  -1  -> -1
mxgx008 maxmag  -1   0  -> -1
mxgx009 maxmag  -1   1  ->  1
mxgx010 maxmag  -1   2  ->  2
mxgx011 maxmag   0  -2  -> -2
mxgx012 maxmag   0  -1  -> -1
mxgx013 maxmag   0   0  ->  0
mxgx014 maxmag   0   1  ->  1
mxgx015 maxmag   0   2  ->  2
mxgx016 maxmag   1  -2  -> -2
mxgx017 maxmag   1  -1  ->  1
mxgx018 maxmag   1   0  ->  1
mxgx019 maxmag   1   1  ->  1
mxgx020 maxmag   1   2  ->  2
mxgx021 maxmag   2  -2  ->  2
mxgx022 maxmag   2  -1  ->  2
mxgx023 maxmag   2   0  ->  2
mxgx025 maxmag   2   1  ->  2
mxgx026 maxmag   2   2  ->  2

-- extended zeros
mxgx030 maxmag   0     0   ->  0
mxgx031 maxmag   0    -0   ->  0
mxgx032 maxmag   0    -0.0 ->  0
mxgx033 maxmag   0     0.0 ->  0
mxgx034 maxmag  -0     0   ->  0    -- note: -0 = 0, but 0 chosen
mxgx035 maxmag  -0    -0   -> -0
mxgx036 maxmag  -0    -0.0 -> -0.0
mxgx037 maxmag  -0     0.0 ->  0.0
mxgx038 maxmag   0.0   0   ->  0
mxgx039 maxmag   0.0  -0   ->  0.0
mxgx040 maxmag   0.0  -0.0 ->  0.0
mxgx041 maxmag   0.0   0.0 ->  0.0
mxgx042 maxmag  -0.0   0   ->  0
mxgx043 maxmag  -0.0  -0   -> -0.0
mxgx044 maxmag  -0.0  -0.0 -> -0.0
mxgx045 maxmag  -0.0   0.0 ->  0.0

mxgx050 maxmag  -0E1   0E1 ->  0E+1
mxgx051 maxmag  -0E2   0E2 ->  0E+2
mxgx052 maxmag  -0E2   0E1 ->  0E+1
mxgx053 maxmag  -0E1   0E2 ->  0E+2
mxgx054 maxmag   0E1  -0E1 ->  0E+1
mxgx055 maxmag   0E2  -0E2 ->  0E+2
mxgx056 maxmag   0E2  -0E1 ->  0E+2
mxgx057 maxmag   0E1  -0E2 ->  0E+1

mxgx058 maxmag   0E1   0E1 ->  0E+1
mxgx059 maxmag   0E2   0E2 ->  0E+2
mxgx060 maxmag   0E2   0E1 ->  0E+2
mxgx061 maxmag   0E1   0E2 ->  0E+2
mxgx062 maxmag  -0E1  -0E1 -> -0E+1
mxgx063 maxmag  -0E2  -0E2 -> -0E+2
mxgx064 maxmag  -0E2  -0E1 -> -0E+1
mxgx065 maxmag  -0E1  -0E2 -> -0E+1

-- Specials
precision: 9
mxgx090 maxmag  Inf  -Inf   ->  Infinity
mxgx091 maxmag  Inf  -1000  ->  Infinity
mxgx092 maxmag  Inf  -1     ->  Infinity
mxgx093 maxmag  Inf  -0     ->  Infinity
mxgx094 maxmag  Inf   0     ->  Infinity
mxgx095 maxmag  Inf   1     ->  Infinity
mxgx096 maxmag  Inf   1000  ->  Infinity
mxgx097 maxmag  Inf   Inf   ->  Infinity
mxgx098 maxmag -1000  Inf   ->  Infinity
mxgx099 maxmag -Inf   Inf   ->  Infinity
mxgx100 maxmag -1     Inf   ->  Infinity
mxgx101 maxmag -0     Inf   ->  Infinity
mxgx102 maxmag  0     Inf   ->  Infinity
mxgx103 maxmag  1     Inf   ->  Infinity
mxgx104 maxmag  1000  Inf   ->  Infinity
mxgx105 maxmag  Inf   Inf   ->  Infinity

mxgx120 maxmag -Inf  -Inf   -> -Infinity
mxgx121 maxmag -Inf  -1000  -> -Infinity
mxgx122 maxmag -Inf  -1     -> -Infinity
mxgx123 maxmag -Inf  -0     -> -Infinity
mxgx124 maxmag -Inf   0     -> -Infinity
mxgx125 maxmag -Inf   1     -> -Infinity
mxgx126 maxmag -Inf   1000  -> -Infinity
mxgx127 maxmag -Inf   Inf   ->  Infinity
mxgx128 maxmag -Inf  -Inf   -> -Infinity
mxgx129 maxmag -1000 -Inf   -> -Infinity
mxgx130 maxmag -1    -Inf   -> -Infinity
mxgx131 maxmag -0    -Inf   -> -Infinity
mxgx132 maxmag  0    -Inf   -> -Infinity
mxgx133 maxmag  1    -Inf   -> -Infinity
mxgx134 maxmag  1000 -Inf   -> -Infinity
mxgx135 maxmag  Inf  -Inf   ->  Infinity

-- 2004.08.02 754r chooses number over NaN in mixed cases
mxgx141 maxmag  NaN -Inf    -> -Infinity
mxgx142 maxmag  NaN -1000   -> -1000
mxgx143 maxmag  NaN -1      -> -1
mxgx144 maxmag  NaN -0      -> -0
mxgx145 maxmag  NaN  0      ->  0
mxgx146 maxmag  NaN  1      ->  1
mxgx147 maxmag  NaN  1000   ->  1000
mxgx148 maxmag  NaN  Inf    ->  Infinity
mxgx149 maxmag  NaN  NaN    ->  NaN
mxgx150 maxmag -Inf  NaN    -> -Infinity
mxgx151 maxmag -1000 NaN    -> -1000
mxgx152 maxmag -1    NaN    -> -1
mxgx153 maxmag -0    NaN    -> -0
mxgx154 maxmag  0    NaN    ->  0
mxgx155 maxmag  1    NaN    ->  1
mxgx156 maxmag  1000 NaN    ->  1000
mxgx157 maxmag  Inf  NaN    ->  Infinity

mxgx161 maxmag  sNaN -Inf   ->  NaN  Invalid_operation
mxgx162 maxmag  sNaN -1000  ->  NaN  Invalid_operation
mxgx163 maxmag  sNaN -1     ->  NaN  Invalid_operation
mxgx164 maxmag  sNaN -0     ->  NaN  Invalid_operation
mxgx165 maxmag  sNaN  0     ->  NaN  Invalid_operation
mxgx166 maxmag  sNaN  1     ->  NaN  Invalid_operation
mxgx167 maxmag  sNaN  1000  ->  NaN  Invalid_operation
mxgx168 maxmag  sNaN  NaN   ->  NaN  Invalid_operation
mxgx169 maxmag  sNaN sNaN   ->  NaN  Invalid_operation
mxgx170 maxmag  NaN  sNaN   ->  NaN  Invalid_operation
mxgx171 maxmag -Inf  sNaN   ->  NaN  Invalid_operation
mxgx172 maxmag -1000 sNaN   ->  NaN  Invalid_operation
mxgx173 maxmag -1    sNaN   ->  NaN  Invalid_operation
mxgx174 maxmag -0    sNaN   ->  NaN  Invalid_operation
mxgx175 maxmag  0    sNaN   ->  NaN  Invalid_operation
mxgx176 maxmag  1    sNaN   ->  NaN  Invalid_operation
mxgx177 maxmag  1000 sNaN   ->  NaN  Invalid_operation
mxgx178 maxmag  Inf  sNaN   ->  NaN  Invalid_operation
mxgx179 maxmag  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
mxgx181 maxmag  NaN9  -Inf   -> -Infinity
mxgx182 maxmag  NaN8     9   ->  9
mxgx183 maxmag -NaN7   Inf   ->  Infinity

mxgx184 maxmag -NaN1   NaN11 -> -NaN1
mxgx185 maxmag  NaN2   NaN12 ->  NaN2
mxgx186 maxmag -NaN13 -NaN7  -> -NaN13
mxgx187 maxmag  NaN14 -NaN5  ->  NaN14

mxgx188 maxmag -Inf    NaN4  -> -Infinity
mxgx189 maxmag -9     -NaN3  -> -9
mxgx190 maxmag  Inf    NaN2  ->  Infinity

mxgx191 maxmag  sNaN99 -Inf    ->  NaN99 Invalid_operation
mxgx192 maxmag  sNaN98 -1      ->  NaN98 Invalid_operation
mxgx193 maxmag -sNaN97  NaN    -> -NaN97 Invalid_operation
mxgx194 maxmag  sNaN96 sNaN94  ->  NaN96 Invalid_operation
mxgx195 maxmag  NaN95  sNaN93  ->  NaN93 Invalid_operation
mxgx196 maxmag -Inf    sNaN92  ->  NaN92 Invalid_operation
mxgx197 maxmag  0      sNaN91  ->  NaN91 Invalid_operation
mxgx198 maxmag  Inf   -sNaN90  -> -NaN90 Invalid_operation
mxgx199 maxmag  NaN    sNaN89  ->  NaN89 Invalid_operation

-- rounding checks
maxexponent: 999
minexponent: -999
precision: 9
mxgx201 maxmag 12345678000 1  -> 1.23456780E+10 Rounded
mxgx202 maxmag 1 12345678000  -> 1.23456780E+10 Rounded
mxgx203 maxmag 1234567800  1  -> 1.23456780E+9 Rounded
mxgx204 maxmag 1 1234567800   -> 1.23456780E+9 Rounded
mxgx205 maxmag 1234567890  1  -> 1.23456789E+9 Rounded
mxgx206 maxmag 1 1234567890   -> 1.23456789E+9 Rounded
mxgx207 maxmag 1234567891  1  -> 1.23456789E+9 Inexact Rounded
mxgx208 maxmag 1 1234567891   -> 1.23456789E+9 Inexact Rounded
mxgx209 maxmag 12345678901 1  -> 1.23456789E+10 Inexact Rounded
mxgx210 maxmag 1 12345678901  -> 1.23456789E+10 Inexact Rounded
mxgx211 maxmag 1234567896  1  -> 1.23456790E+9 Inexact Rounded
mxgx212 maxmag 1 1234567896   -> 1.23456790E+9 Inexact Rounded
mxgx213 maxmag -1234567891  1 -> -1.23456789E+9   Inexact Rounded
mxgx214 maxmag 1 -1234567891  -> -1.23456789E+9   Inexact Rounded
mxgx215 maxmag -12345678901 1 -> -1.23456789E+10  Inexact Rounded
mxgx216 maxmag 1 -12345678901 -> -1.23456789E+10  Inexact Rounded
mxgx217 maxmag -1234567896  1 -> -1.23456790E+9   Inexact Rounded
mxgx218 maxmag 1 -1234567896  -> -1.23456790E+9   Inexact Rounded

precision: 15
mxgx221 maxmag 12345678000 1  -> 12345678000
mxgx222 maxmag 1 12345678000  -> 12345678000
mxgx223 maxmag 1234567800  1  -> 1234567800
mxgx224 maxmag 1 1234567800   -> 1234567800
mxgx225 maxmag 1234567890  1  -> 1234567890
mxgx226 maxmag 1 1234567890   -> 1234567890
mxgx227 maxmag 1234567891  1  -> 1234567891
mxgx228 maxmag 1 1234567891   -> 1234567891
mxgx229 maxmag 12345678901 1  -> 12345678901
mxgx230 maxmag 1 12345678901  -> 12345678901
mxgx231 maxmag 1234567896  1  -> 1234567896
mxgx232 maxmag 1 1234567896   -> 1234567896
mxgx233 maxmag -1234567891  1 -> -1234567891
mxgx234 maxmag 1 -1234567891  -> -1234567891
mxgx235 maxmag -12345678901 1 -> -12345678901
mxgx236 maxmag 1 -12345678901 -> -12345678901
mxgx237 maxmag -1234567896  1 -> -1234567896
mxgx238 maxmag 1 -1234567896  -> -1234567896

-- from examples
mxgx280 maxmag '3'   '2'  ->  '3'
mxgx281 maxmag '-10' '3'  ->  '-10'
mxgx282 maxmag '1.0' '1'  ->  '1'
mxgx283 maxmag '1' '1.0'  ->  '1'
mxgx284 maxmag '7' 'NaN'  ->  '7'

-- overflow and underflow tests ...
maxExponent: 999999999
minexponent: -999999999
mxgx330 maxmag +1.23456789012345E-0 9E+999999999 ->  9E+999999999
mxgx331 maxmag 9E+999999999 +1.23456789012345E-0 ->  9E+999999999
mxgx332 maxmag +0.100 9E-999999999               ->  0.100
mxgx333 maxmag 9E-999999999 +0.100               ->  0.100
mxgx335 maxmag -1.23456789012345E-0 9E+999999999 ->  9E+999999999
mxgx336 maxmag 9E+999999999 -1.23456789012345E-0 ->  9E+999999999
mxgx337 maxmag -0.100 9E-999999999               ->  -0.100
mxgx338 maxmag 9E-999999999 -0.100               ->  -0.100

mxgx339 maxmag 1e-599999999 1e-400000001   ->  1E-400000001
mxgx340 maxmag 1e-599999999 1e-400000000   ->  1E-400000000
mxgx341 maxmag 1e-600000000 1e-400000000   ->  1E-400000000
mxgx342 maxmag 9e-999999998 0.01           ->  0.01
mxgx343 maxmag 9e-999999998 0.1            ->  0.1
mxgx344 maxmag 0.01 9e-999999998           ->  0.01
mxgx345 maxmag 1e599999999 1e400000001     ->  1E+599999999
mxgx346 maxmag 1e599999999 1e400000000     ->  1E+599999999
mxgx347 maxmag 1e600000000 1e400000000     ->  1E+600000000
mxgx348 maxmag 9e999999998 100             ->  9E+999999998
mxgx349 maxmag 9e999999998 10              ->  9E+999999998
mxgx350 maxmag 100  9e999999998            ->  9E+999999998
-- signs
mxgx351 maxmag  1e+777777777  1e+411111111 ->  1E+777777777
mxgx352 maxmag  1e+777777777 -1e+411111111 ->  1E+777777777
mxgx353 maxmag -1e+777777777  1e+411111111 -> -1E+777777777
mxgx354 maxmag -1e+777777777 -1e+411111111 -> -1E+777777777
mxgx355 maxmag  1e-777777777  1e-411111111 ->  1E-411111111
mxgx356 maxmag  1e-777777777 -1e-411111111 -> -1E-411111111
mxgx357 maxmag -1e-777777777  1e-411111111 ->  1E-411111111
mxgx358 maxmag -1e-777777777 -1e-411111111 -> -1E-411111111

-- expanded list from min/max 754r purple prose
-- [explicit tests for exponent ordering]
mxgx401 maxmag  Inf    1.1     ->  Infinity
mxgx402 maxmag  1.1    1       ->  1.1
mxgx403 maxmag  1      1.0     ->  1
mxgx404 maxmag  1.0    0.1     ->  1.0
mxgx405 maxmag  0.1    0.10    ->  0.1
mxgx406 maxmag  0.10   0.100   ->  0.10
mxgx407 maxmag  0.10   0       ->  0.10
mxgx408 maxmag  0      0.0     ->  0
mxgx409 maxmag  0.0   -0       ->  0.0
mxgx410 maxmag  0.0   -0.0     ->  0.0
mxgx411 maxmag  0.00  -0.0     ->  0.00
mxgx412 maxmag  0.0   -0.00    ->  0.0
mxgx413 maxmag  0     -0.0     ->  0
mxgx414 maxmag  0     -0       ->  0
mxgx415 maxmag -0.0   -0       -> -0.0
mxgx416 maxmag -0     -0.100   -> -0.100
mxgx417 maxmag -0.100 -0.10    -> -0.100
mxgx418 maxmag -0.10  -0.1     -> -0.10
mxgx419 maxmag -0.1   -1.0     -> -1.0
mxgx420 maxmag -1.0   -1       -> -1.0
mxgx421 maxmag -1     -1.1     -> -1.1
mxgx423 maxmag -1.1   -Inf     -> -Infinity
-- same with operands reversed
mxgx431 maxmag  1.1    Inf     ->  Infinity
mxgx432 maxmag  1      1.1     ->  1.1
mxgx433 maxmag  1.0    1       ->  1
mxgx434 maxmag  0.1    1.0     ->  1.0
mxgx435 maxmag  0.10   0.1     ->  0.1
mxgx436 maxmag  0.100  0.10    ->  0.10
mxgx437 maxmag  0      0.10    ->  0.10
mxgx438 maxmag  0.0    0       ->  0
mxgx439 maxmag -0      0.0     ->  0.0
mxgx440 maxmag -0.0    0.0     ->  0.0
mxgx441 maxmag -0.0    0.00    ->  0.00
mxgx442 maxmag -0.00   0.0     ->  0.0
mxgx443 maxmag -0.0    0       ->  0
mxgx444 maxmag -0      0       ->  0
mxgx445 maxmag -0     -0.0     -> -0.0
mxgx446 maxmag -0.100 -0       -> -0.100
mxgx447 maxmag -0.10  -0.100   -> -0.100
mxgx448 maxmag -0.1   -0.10    -> -0.10
mxgx449 maxmag -1.0   -0.1     -> -1.0
mxgx450 maxmag -1     -1.0     -> -1.0
mxgx451 maxmag -1.1   -1       -> -1.1
mxgx453 maxmag -Inf   -1.1     -> -Infinity
-- largies
mxgx460 maxmag  1000   1E+3    ->  1E+3
mxgx461 maxmag  1E+3   1000    ->  1E+3
mxgx462 maxmag  1000  -1E+3    ->  1000
mxgx463 maxmag  1E+3  -1000    ->  1E+3
mxgx464 maxmag -1000   1E+3    ->  1E+3
mxgx465 maxmag -1E+3   1000    ->  1000
mxgx466 maxmag -1000  -1E+3    -> -1000
mxgx467 maxmag -1E+3  -1000    -> -1000

-- rounding (results treated as though plus)
maxexponent: 999999999
minexponent: -999999999
precision: 3

mxgx470 maxmag  1      .5     ->  1
mxgx471 maxmag  10     5      ->  10
mxgx472 maxmag  100    50     ->  100
mxgx473 maxmag  1000   500    ->  1.00E+3 Rounded
mxgx474 maxmag  10000  5000   ->  1.00E+4 Rounded
mxgx475 maxmag  6      .5     ->  6
mxgx476 maxmag  66     5      ->  66
mxgx477 maxmag  666    50     ->  666
mxgx478 maxmag  6666   500    ->  6.67E+3 Rounded Inexact
mxgx479 maxmag  66666  5000   ->  6.67E+4 Rounded Inexact
mxgx480 maxmag  33333  5000   ->  3.33E+4 Rounded Inexact
mxgx481 maxmag  .5     1      ->  1
mxgx482 maxmag  .5     10     ->  10
mxgx483 maxmag  .5     100    ->  100
mxgx484 maxmag  .5     1000   ->  1.00E+3 Rounded
mxgx485 maxmag  .5     10000  ->  1.00E+4 Rounded
mxgx486 maxmag  .5     6      ->  6
mxgx487 maxmag  .5     66     ->  66
mxgx488 maxmag  .5     666    ->  666
mxgx489 maxmag  .5     6666   ->  6.67E+3 Rounded Inexact
mxgx490 maxmag  .5     66666  ->  6.67E+4 Rounded Inexact
mxgx491 maxmag  .5     33333  ->  3.33E+4 Rounded Inexact

-- overflow tests
maxexponent: 999999999
minexponent: -999999999
precision: 3
mxgx500 maxmag 9.999E+999999999  0 ->  Infinity Inexact Overflow Rounded
mxgx501 maxmag -9.999E+999999999 0 -> -Infinity Inexact Overflow Rounded

-- subnormals and underflow
precision: 3
maxexponent: 999
minexponent: -999
mxgx510 maxmag  1.00E-999       0  ->   1.00E-999
mxgx511 maxmag  0.1E-999        0  ->   1E-1000   Subnormal
mxgx512 maxmag  0.10E-999       0  ->   1.0E-1000 Subnormal
mxgx513 maxmag  0.100E-999      0  ->   1.0E-1000 Subnormal Rounded
mxgx514 maxmag  0.01E-999       0  ->   1E-1001   Subnormal
-- next is rounded to Nmin
mxgx515 maxmag  0.999E-999      0  ->   1.00E-999 Inexact Rounded Subnormal Underflow
mxgx516 maxmag  0.099E-999      0  ->   1.0E-1000 Inexact Rounded Subnormal Underflow
mxgx517 maxmag  0.009E-999      0  ->   1E-1001   Inexact Rounded Subnormal Underflow
mxgx518 maxmag  0.001E-999      0  ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
mxgx519 maxmag  0.0009E-999     0  ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped
mxgx520 maxmag  0.0001E-999     0  ->   0E-1001   Inexact Rounded Subnormal Underflow Clamped

mxgx530 maxmag -1.00E-999       0  ->  -1.00E-999
mxgx531 maxmag -0.1E-999        0  ->  -1E-1000   Subnormal
mxgx532 maxmag -0.10E-999       0  ->  -1.0E-1000 Subnormal
mxgx533 maxmag -0.100E-999      0  ->  -1.0E-1000 Subnormal Rounded
mxgx534 maxmag -0.01E-999       0  ->  -1E-1001   Subnormal
-- next is rounded to -Nmin
mxgx535 maxmag -0.999E-999      0  ->  -1.00E-999 Inexact Rounded Subnormal Underflow
mxgx536 maxmag -0.099E-999      0  ->  -1.0E-1000 Inexact Rounded Subnormal Underflow
mxgx537 maxmag -0.009E-999      0  ->  -1E-1001   Inexact Rounded Subnormal Underflow
mxgx538 maxmag -0.001E-999      0  ->  -0E-1001   Inexact Rounded Subnormal Underflow Clamped
mxgx539 maxmag -0.0009E-999     0  ->  -0E-1001   Inexact Rounded Subnormal Underflow Clamped
mxgx540 maxmag -0.0001E-999     0  ->  -0E-1001   Inexact Rounded Subnormal Underflow Clamped

-- Null tests
mxgx900 maxmag 10  #  -> NaN Invalid_operation
mxgx901 maxmag  # 10  -> NaN Invalid_operation



Changes to test/dectest/min.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- min.decTest -- decimal minimum                                     --
-- Copyright (c) IBM Corporation, 1981, 2004.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding

extended:    1
precision:   9
rounding:    half_up


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- min.decTest -- decimal minimum                                     --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding

extended:    1
precision:   9
rounding:    half_up
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
















388
389
390
391
mnmx520 min  0.0001E-999     0  ->   0

mnmx530 min -1.00E-999       0  ->  -1.00E-999
mnmx531 min -0.1E-999        0  ->  -1E-1000   Subnormal
mnmx532 min -0.10E-999       0  ->  -1.0E-1000 Subnormal
mnmx533 min -0.100E-999      0  ->  -1.0E-1000 Subnormal Rounded
mnmx534 min -0.01E-999       0  ->  -1E-1001   Subnormal
-- next is rounded to Emin
mnmx535 min -0.999E-999      0  ->  -1.00E-999 Inexact Rounded Subnormal Underflow
mnmx536 min -0.099E-999      0  ->  -1.0E-1000 Inexact Rounded Subnormal Underflow
mnmx537 min -0.009E-999      0  ->  -1E-1001   Inexact Rounded Subnormal Underflow
mnmx538 min -0.001E-999      0  ->  -0E-1001   Inexact Rounded Subnormal Underflow Clamped
mnmx539 min -0.0009E-999     0  ->  -0E-1001   Inexact Rounded Subnormal Underflow Clamped
mnmx540 min -0.0001E-999     0  ->  -0E-1001   Inexact Rounded Subnormal Underflow Clamped


















-- Null tests
mnm900 min 10  # -> NaN Invalid_operation
mnm901 min  # 10 -> NaN Invalid_operation







|







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
mnmx520 min  0.0001E-999     0  ->   0

mnmx530 min -1.00E-999       0  ->  -1.00E-999
mnmx531 min -0.1E-999        0  ->  -1E-1000   Subnormal
mnmx532 min -0.10E-999       0  ->  -1.0E-1000 Subnormal
mnmx533 min -0.100E-999      0  ->  -1.0E-1000 Subnormal Rounded
mnmx534 min -0.01E-999       0  ->  -1E-1001   Subnormal
-- next is rounded to Nmin
mnmx535 min -0.999E-999      0  ->  -1.00E-999 Inexact Rounded Subnormal Underflow
mnmx536 min -0.099E-999      0  ->  -1.0E-1000 Inexact Rounded Subnormal Underflow
mnmx537 min -0.009E-999      0  ->  -1E-1001   Inexact Rounded Subnormal Underflow
mnmx538 min -0.001E-999      0  ->  -0E-1001   Inexact Rounded Subnormal Underflow Clamped
mnmx539 min -0.0009E-999     0  ->  -0E-1001   Inexact Rounded Subnormal Underflow Clamped
mnmx540 min -0.0001E-999     0  ->  -0E-1001   Inexact Rounded Subnormal Underflow Clamped

-- misalignment traps for little-endian
precision: 9
mnmx551 min      1.0       0.1  -> 0.1
mnmx552 min      0.1       1.0  -> 0.1
mnmx553 min     10.0       0.1  -> 0.1
mnmx554 min      0.1      10.0  -> 0.1
mnmx555 min      100       1.0  -> 1.0
mnmx556 min      1.0       100  -> 1.0
mnmx557 min     1000      10.0  -> 10.0
mnmx558 min     10.0      1000  -> 10.0
mnmx559 min    10000     100.0  -> 100.0
mnmx560 min    100.0     10000  -> 100.0
mnmx561 min   100000    1000.0  -> 1000.0
mnmx562 min   1000.0    100000  -> 1000.0
mnmx563 min  1000000   10000.0  -> 10000.0
mnmx564 min  10000.0   1000000  -> 10000.0

-- Null tests
mnm900 min 10  # -> NaN Invalid_operation
mnm901 min  # 10 -> NaN Invalid_operation

Added test/dectest/minmag.decTest.













































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
------------------------------------------------------------------------
-- minmag.decTest -- decimal minimum by magnitude                     --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- we assume that base comparison is tested in compare.decTest, so
-- these mainly cover special cases and rounding

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

-- sanity checks
mngx001 minmag  -2  -2  -> -2
mngx002 minmag  -2  -1  -> -1
mngx003 minmag  -2   0  ->  0
mngx004 minmag  -2   1  ->  1
mngx005 minmag  -2   2  -> -2
mngx006 minmag  -1  -2  -> -1
mngx007 minmag  -1  -1  -> -1
mngx008 minmag  -1   0  ->  0
mngx009 minmag  -1   1  -> -1
mngx010 minmag  -1   2  -> -1
mngx011 minmag   0  -2  ->  0
mngx012 minmag   0  -1  ->  0
mngx013 minmag   0   0  ->  0
mngx014 minmag   0   1  ->  0
mngx015 minmag   0   2  ->  0
mngx016 minmag   1  -2  ->  1
mngx017 minmag   1  -1  -> -1
mngx018 minmag   1   0  ->  0
mngx019 minmag   1   1  ->  1
mngx020 minmag   1   2  ->  1
mngx021 minmag   2  -2  -> -2
mngx022 minmag   2  -1  -> -1
mngx023 minmag   2   0  ->  0
mngx025 minmag   2   1  ->  1
mngx026 minmag   2   2  ->  2

-- extended zeros
mngx030 minmag   0     0   ->  0
mngx031 minmag   0    -0   -> -0
mngx032 minmag   0    -0.0 -> -0.0
mngx033 minmag   0     0.0 ->  0.0
mngx034 minmag  -0     0   -> -0
mngx035 minmag  -0    -0   -> -0
mngx036 minmag  -0    -0.0 -> -0
mngx037 minmag  -0     0.0 -> -0
mngx038 minmag   0.0   0   ->  0.0
mngx039 minmag   0.0  -0   -> -0
mngx040 minmag   0.0  -0.0 -> -0.0
mngx041 minmag   0.0   0.0 ->  0.0
mngx042 minmag  -0.0   0   -> -0.0
mngx043 minmag  -0.0  -0   -> -0
mngx044 minmag  -0.0  -0.0 -> -0.0
mngx045 minmag  -0.0   0.0 -> -0.0

mngx046 minmag   0E1  -0E1 -> -0E+1
mngx047 minmag  -0E1   0E2 -> -0E+1
mngx048 minmag   0E2   0E1 ->  0E+1
mngx049 minmag   0E1   0E2 ->  0E+1
mngx050 minmag  -0E3  -0E2 -> -0E+3
mngx051 minmag  -0E2  -0E3 -> -0E+3

-- Specials
precision: 9
mngx090 minmag  Inf  -Inf   -> -Infinity
mngx091 minmag  Inf  -1000  -> -1000
mngx092 minmag  Inf  -1     -> -1
mngx093 minmag  Inf  -0     -> -0
mngx094 minmag  Inf   0     ->  0
mngx095 minmag  Inf   1     ->  1
mngx096 minmag  Inf   1000  ->  1000
mngx097 minmag  Inf   Inf   ->  Infinity
mngx098 minmag -1000  Inf   -> -1000
mngx099 minmag -Inf   Inf   -> -Infinity
mngx100 minmag -1     Inf   -> -1
mngx101 minmag -0     Inf   -> -0
mngx102 minmag  0     Inf   ->  0
mngx103 minmag  1     Inf   ->  1
mngx104 minmag  1000  Inf   ->  1000
mngx105 minmag  Inf   Inf   ->  Infinity

mngx120 minmag -Inf  -Inf   -> -Infinity
mngx121 minmag -Inf  -1000  -> -1000
mngx122 minmag -Inf  -1     -> -1
mngx123 minmag -Inf  -0     -> -0
mngx124 minmag -Inf   0     ->  0
mngx125 minmag -Inf   1     ->  1
mngx126 minmag -Inf   1000  ->  1000
mngx127 minmag -Inf   Inf   -> -Infinity
mngx128 minmag -Inf  -Inf   -> -Infinity
mngx129 minmag -1000 -Inf   -> -1000
mngx130 minmag -1    -Inf   -> -1
mngx131 minmag -0    -Inf   -> -0
mngx132 minmag  0    -Inf   ->  0
mngx133 minmag  1    -Inf   ->  1
mngx134 minmag  1000 -Inf   ->  1000
mngx135 minmag  Inf  -Inf   -> -Infinity

-- 2004.08.02 754r chooses number over NaN in mixed cases
mngx141 minmag  NaN -Inf    ->  -Infinity
mngx142 minmag  NaN -1000   ->  -1000
mngx143 minmag  NaN -1      ->  -1
mngx144 minmag  NaN -0      ->  -0
mngx145 minmag  NaN  0      ->  0
mngx146 minmag  NaN  1      ->  1
mngx147 minmag  NaN  1000   ->  1000
mngx148 minmag  NaN  Inf    ->  Infinity
mngx149 minmag  NaN  NaN    ->  NaN
mngx150 minmag -Inf  NaN    -> -Infinity
mngx151 minmag -1000 NaN    -> -1000
mngx152 minmag -1   -NaN    -> -1
mngx153 minmag -0    NaN    -> -0
mngx154 minmag  0   -NaN    ->  0
mngx155 minmag  1    NaN    ->  1
mngx156 minmag  1000 NaN    ->  1000
mngx157 minmag  Inf  NaN    ->  Infinity

mngx161 minmag  sNaN -Inf   ->  NaN  Invalid_operation
mngx162 minmag  sNaN -1000  ->  NaN  Invalid_operation
mngx163 minmag  sNaN -1     ->  NaN  Invalid_operation
mngx164 minmag  sNaN -0     ->  NaN  Invalid_operation
mngx165 minmag -sNaN  0     -> -NaN  Invalid_operation
mngx166 minmag -sNaN  1     -> -NaN  Invalid_operation
mngx167 minmag  sNaN  1000  ->  NaN  Invalid_operation
mngx168 minmag  sNaN  NaN   ->  NaN  Invalid_operation
mngx169 minmag  sNaN sNaN   ->  NaN  Invalid_operation
mngx170 minmag  NaN  sNaN   ->  NaN  Invalid_operation
mngx171 minmag -Inf  sNaN   ->  NaN  Invalid_operation
mngx172 minmag -1000 sNaN   ->  NaN  Invalid_operation
mngx173 minmag -1    sNaN   ->  NaN  Invalid_operation
mngx174 minmag -0    sNaN   ->  NaN  Invalid_operation
mngx175 minmag  0    sNaN   ->  NaN  Invalid_operation
mngx176 minmag  1    sNaN   ->  NaN  Invalid_operation
mngx177 minmag  1000 sNaN   ->  NaN  Invalid_operation
mngx178 minmag  Inf  sNaN   ->  NaN  Invalid_operation
mngx179 minmag  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
mngx181 minmag  NaN9   -Inf   -> -Infinity
mngx182 minmag -NaN8    9990  ->  9990
mngx183 minmag  NaN71   Inf   ->  Infinity

mngx184 minmag  NaN1    NaN54 ->  NaN1
mngx185 minmag  NaN22  -NaN53 ->  NaN22
mngx186 minmag -NaN3    NaN6  -> -NaN3
mngx187 minmag -NaN44   NaN7  -> -NaN44

mngx188 minmag -Inf     NaN41 -> -Infinity
mngx189 minmag -9999   -NaN33 -> -9999
mngx190 minmag  Inf     NaN2  ->  Infinity

mngx191 minmag  sNaN99 -Inf    ->  NaN99 Invalid_operation
mngx192 minmag  sNaN98 -11     ->  NaN98 Invalid_operation
mngx193 minmag -sNaN97  NaN8   -> -NaN97 Invalid_operation
mngx194 minmag  sNaN69 sNaN94  ->  NaN69 Invalid_operation
mngx195 minmag  NaN95  sNaN93  ->  NaN93 Invalid_operation
mngx196 minmag -Inf    sNaN92  ->  NaN92 Invalid_operation
mngx197 minmag  088    sNaN91  ->  NaN91 Invalid_operation
mngx198 minmag  Inf   -sNaN90  -> -NaN90 Invalid_operation
mngx199 minmag  NaN    sNaN86  ->  NaN86 Invalid_operation

-- rounding checks -- chosen is rounded, or not
maxExponent: 999
minexponent: -999
precision: 9
mngx201 minmag -12345678000 1  -> 1
mngx202 minmag 1 -12345678000  -> 1
mngx203 minmag -1234567800  1  -> 1
mngx204 minmag 1 -1234567800   -> 1
mngx205 minmag -1234567890  1  -> 1
mngx206 minmag 1 -1234567890   -> 1
mngx207 minmag -1234567891  1  -> 1
mngx208 minmag 1 -1234567891   -> 1
mngx209 minmag -12345678901 1  -> 1
mngx210 minmag 1 -12345678901  -> 1
mngx211 minmag -1234567896  1  -> 1
mngx212 minmag 1 -1234567896   -> 1
mngx213 minmag 1234567891  1   -> 1
mngx214 minmag 1 1234567891    -> 1
mngx215 minmag 12345678901 1   -> 1
mngx216 minmag 1 12345678901   -> 1
mngx217 minmag 1234567896  1   -> 1
mngx218 minmag 1 1234567896    -> 1

precision: 15
mngx221 minmag -12345678000 1  -> 1
mngx222 minmag 1 -12345678000  -> 1
mngx223 minmag -1234567800  1  -> 1
mngx224 minmag 1 -1234567800   -> 1
mngx225 minmag -1234567890  1  -> 1
mngx226 minmag 1 -1234567890   -> 1
mngx227 minmag -1234567891  1  -> 1
mngx228 minmag 1 -1234567891   -> 1
mngx229 minmag -12345678901 1  -> 1
mngx230 minmag 1 -12345678901  -> 1
mngx231 minmag -1234567896  1  -> 1
mngx232 minmag 1 -1234567896   -> 1
mngx233 minmag 1234567891  1   -> 1
mngx234 minmag 1 1234567891    -> 1
mngx235 minmag 12345678901 1   -> 1
mngx236 minmag 1 12345678901   -> 1
mngx237 minmag 1234567896  1   -> 1
mngx238 minmag 1 1234567896    -> 1

-- from examples
mngx280 minmag '3'   '2'  ->  '2'
mngx281 minmag '-10' '3'  ->  '3'
mngx282 minmag '1.0' '1'  ->  '1.0'
mngx283 minmag '1' '1.0'  ->  '1.0'
mngx284 minmag '7' 'NaN'  ->  '7'

-- overflow and underflow tests .. subnormal results [inputs] now allowed
maxExponent: 999999999
minexponent: -999999999
mngx330 minmag -1.23456789012345E-0 -9E+999999999 -> -1.23456789012345
mngx331 minmag -9E+999999999 -1.23456789012345E-0 -> -1.23456789012345
mngx332 minmag -0.100 -9E-999999999               -> -9E-999999999
mngx333 minmag -9E-999999999 -0.100               -> -9E-999999999
mngx335 minmag +1.23456789012345E-0 -9E+999999999 ->  1.23456789012345
mngx336 minmag -9E+999999999 1.23456789012345E-0  ->  1.23456789012345
mngx337 minmag +0.100 -9E-999999999               -> -9E-999999999
mngx338 minmag -9E-999999999 0.100                -> -9E-999999999

mngx339 minmag -1e-599999999 -1e-400000001   ->  -1E-599999999
mngx340 minmag -1e-599999999 -1e-400000000   ->  -1E-599999999
mngx341 minmag -1e-600000000 -1e-400000000   ->  -1E-600000000
mngx342 minmag -9e-999999998 -0.01           ->  -9E-999999998
mngx343 minmag -9e-999999998 -0.1            ->  -9E-999999998
mngx344 minmag -0.01         -9e-999999998   ->  -9E-999999998
mngx345 minmag -1e599999999  -1e400000001    ->  -1E+400000001
mngx346 minmag -1e599999999  -1e400000000    ->  -1E+400000000
mngx347 minmag -1e600000000  -1e400000000    ->  -1E+400000000
mngx348 minmag -9e999999998  -100            ->  -100
mngx349 minmag -9e999999998  -10             ->  -10
mngx350 minmag -100          -9e999999998    ->  -100
-- signs
mngx351 minmag -1e+777777777 -1e+411111111 -> -1E+411111111
mngx352 minmag -1e+777777777 +1e+411111111 ->  1E+411111111
mngx353 minmag +1e+777777777 -1e+411111111 -> -1E+411111111
mngx354 minmag +1e+777777777 +1e+411111111 ->  1E+411111111
mngx355 minmag -1e-777777777 -1e-411111111 -> -1E-777777777
mngx356 minmag -1e-777777777 +1e-411111111 -> -1E-777777777
mngx357 minmag +1e-777777777 -1e-411111111 ->  1E-777777777
mngx358 minmag +1e-777777777 +1e-411111111 ->  1E-777777777

-- expanded list from min/max 754r purple prose
-- [explicit tests for exponent ordering]
mngx401 minmag  Inf    1.1     ->  1.1
mngx402 minmag  1.1    1       ->  1
mngx403 minmag  1      1.0     ->  1.0
mngx404 minmag  1.0    0.1     ->  0.1
mngx405 minmag  0.1    0.10    ->  0.10
mngx406 minmag  0.10   0.100   ->  0.100
mngx407 minmag  0.10   0       ->  0
mngx408 minmag  0      0.0     ->  0.0
mngx409 minmag  0.0   -0       -> -0
mngx410 minmag  0.0   -0.0     -> -0.0
mngx411 minmag  0.00  -0.0     -> -0.0
mngx412 minmag  0.0   -0.00    -> -0.00
mngx413 minmag  0     -0.0     -> -0.0
mngx414 minmag  0     -0       -> -0
mngx415 minmag -0.0   -0       -> -0
mngx416 minmag -0     -0.100   -> -0
mngx417 minmag -0.100 -0.10    -> -0.10
mngx418 minmag -0.10  -0.1     -> -0.1
mngx419 minmag -0.1   -1.0     -> -0.1
mngx420 minmag -1.0   -1       -> -1
mngx421 minmag -1     -1.1     -> -1
mngx423 minmag -1.1   -Inf     -> -1.1
-- same with operands reversed
mngx431 minmag  1.1    Inf     ->  1.1
mngx432 minmag  1      1.1     ->  1
mngx433 minmag  1.0    1       ->  1.0
mngx434 minmag  0.1    1.0     ->  0.1
mngx435 minmag  0.10   0.1     ->  0.10
mngx436 minmag  0.100  0.10    ->  0.100
mngx437 minmag  0      0.10    ->  0
mngx438 minmag  0.0    0       ->  0.0
mngx439 minmag -0      0.0     -> -0
mngx440 minmag -0.0    0.0     -> -0.0
mngx441 minmag -0.0    0.00    -> -0.0
mngx442 minmag -0.00   0.0     -> -0.00
mngx443 minmag -0.0    0       -> -0.0
mngx444 minmag -0      0       -> -0
mngx445 minmag -0     -0.0     -> -0
mngx446 minmag -0.100 -0       -> -0
mngx447 minmag -0.10  -0.100   -> -0.10
mngx448 minmag -0.1   -0.10    -> -0.1
mngx449 minmag -1.0   -0.1     -> -0.1
mngx450 minmag -1     -1.0     -> -1
mngx451 minmag -1.1   -1       -> -1
mngx453 minmag -Inf   -1.1     -> -1.1
-- largies
mngx460 minmag  1000   1E+3    ->  1000
mngx461 minmag  1E+3   1000    ->  1000
mngx462 minmag  1000  -1E+3    -> -1E+3
mngx463 minmag  1E+3  -1000    -> -1000
mngx464 minmag -1000   1E+3    -> -1000
mngx465 minmag -1E+3   1000    -> -1E+3
mngx466 minmag -1000  -1E+3    -> -1E+3
mngx467 minmag -1E+3  -1000    -> -1E+3

-- rounding (results treated as though plus)
maxexponent: 999999999
minexponent: -999999999
precision: 3

mngx470 minmag  1      5      ->  1
mngx471 minmag  10     50     ->  10
mngx472 minmag  100    500    ->  100
mngx473 minmag  1000   5000   ->  1.00E+3 Rounded
mngx474 minmag  10000  50000  ->  1.00E+4 Rounded
mngx475 minmag  6      50     ->  6
mngx476 minmag  66     500    ->  66
mngx477 minmag  666    5000   ->  666
mngx478 minmag  6666   50000  ->  6.67E+3 Rounded Inexact
mngx479 minmag  66666  500000 ->  6.67E+4 Rounded Inexact
mngx480 minmag  33333  500000 ->  3.33E+4 Rounded Inexact
mngx481 minmag  75401  1      ->  1
mngx482 minmag  75402  10     ->  10
mngx483 minmag  75403  100    ->  100
mngx484 minmag  75404  1000   ->  1.00E+3 Rounded
mngx485 minmag  75405  10000  ->  1.00E+4 Rounded
mngx486 minmag  75406  6      ->  6
mngx487 minmag  75407  66     ->  66
mngx488 minmag  75408  666    ->  666
mngx489 minmag  75409  6666   ->  6.67E+3 Rounded Inexact
mngx490 minmag  75410  66666  ->  6.67E+4 Rounded Inexact
mngx491 minmag  75411  33333  ->  3.33E+4 Rounded Inexact


-- overflow tests
maxexponent: 999999999
minexponent: -999999999
precision: 3
mngx500 minmag 9.999E+999999999  0 ->  0
mngx501 minmag -9.999E+999999999 0 ->  0

-- subnormals and underflow
precision: 3
maxexponent: 999
minexponent: -999
mngx510 minmag  1.00E-999       0  ->   0
mngx511 minmag  0.1E-999        0  ->   0
mngx512 minmag  0.10E-999       0  ->   0
mngx513 minmag  0.100E-999      0  ->   0
mngx514 minmag  0.01E-999       0  ->   0
mngx515 minmag  0.999E-999      0  ->   0
mngx516 minmag  0.099E-999      0  ->   0
mngx517 minmag  0.009E-999      0  ->   0
mngx518 minmag  0.001E-999      0  ->   0
mngx519 minmag  0.0009E-999     0  ->   0
mngx520 minmag  0.0001E-999     0  ->   0

mngx530 minmag -1.00E-999       0  ->   0
mngx531 minmag -0.1E-999        0  ->   0
mngx532 minmag -0.10E-999       0  ->   0
mngx533 minmag -0.100E-999      0  ->   0
mngx534 minmag -0.01E-999       0  ->   0
mngx535 minmag -0.999E-999      0  ->   0
mngx536 minmag -0.099E-999      0  ->   0
mngx537 minmag -0.009E-999      0  ->   0
mngx538 minmag -0.001E-999      0  ->   0
mngx539 minmag -0.0009E-999     0  ->   0
mngx540 minmag -0.0001E-999     0  ->   0


-- Null tests
mng900 minmag 10  # -> NaN Invalid_operation
mng901 minmag  # 10 -> NaN Invalid_operation

Changes to test/dectest/minus.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- minus.decTest -- decimal negation                                  --
-- Copyright (c) IBM Corporation, 1981, 2004.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- This set of tests primarily tests the existence of the operator.
-- Subtraction, rounding, and more overflows are tested elsewhere.

extended:    1
precision:   9
rounding:    half_up


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- minus.decTest -- decimal negation                                  --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests primarily tests the existence of the operator.
-- Subtraction, rounding, and more overflows are tested elsewhere.

extended:    1
precision:   9
rounding:    half_up

Changes to test/dectest/multiply.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- multiply.decTest -- decimal multiplication                         --
-- Copyright (c) IBM Corporation, 1981, 2005.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- multiply.decTest -- decimal multiplication                         --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
mulx851 multiply  1E-668     1e-334 -> 1E-1002    Subnormal
mulx852 multiply  4E-668     2e-334 -> 8E-1002    Subnormal
mulx853 multiply  9E-668     3e-334 -> 2.7E-1001  Subnormal
mulx854 multiply 16E-668     4e-334 -> 6.4E-1001  Subnormal
mulx855 multiply 25E-668     5e-334 -> 1.25E-1000 Subnormal
mulx856 multiply 10E-668   100e-334 -> 1.000E-999

-- test from 0.099 ** 999 at 15 digits
precision: 19
mulx860 multiply  6636851557994578716E-520 6636851557994578716E-520 -> 4.40477986028551E-1003 Underflow Subnormal Inexact Rounded

-- Long operand overflow may be a different path
precision: 3
maxExponent: 999999999
minexponent: -999999999







|







650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
mulx851 multiply  1E-668     1e-334 -> 1E-1002    Subnormal
mulx852 multiply  4E-668     2e-334 -> 8E-1002    Subnormal
mulx853 multiply  9E-668     3e-334 -> 2.7E-1001  Subnormal
mulx854 multiply 16E-668     4e-334 -> 6.4E-1001  Subnormal
mulx855 multiply 25E-668     5e-334 -> 1.25E-1000 Subnormal
mulx856 multiply 10E-668   100e-334 -> 1.000E-999

-- test derived from result of 0.099 ** 999 at 15 digits with unlimited exponent
precision: 19
mulx860 multiply  6636851557994578716E-520 6636851557994578716E-520 -> 4.40477986028551E-1003 Underflow Subnormal Inexact Rounded

-- Long operand overflow may be a different path
precision: 3
maxExponent: 999999999
minexponent: -999999999
717
718
719
720
721
722
723




724
725
726
727
maxExponent: 6144
minExponent: -6143
mulx1001  multiply 130E-2  120E-2 -> 1.5600
mulx1002  multiply 130E-2  12E-1  -> 1.560
mulx1003  multiply 130E-2  1E0    -> 1.30
mulx1004  multiply 1E2     1E4    -> 1E+6





-- Null tests
mulx990 multiply 10  # -> NaN Invalid_operation
mulx991 multiply  # 10 -> NaN Invalid_operation








>
>
>
>




717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
maxExponent: 6144
minExponent: -6143
mulx1001  multiply 130E-2  120E-2 -> 1.5600
mulx1002  multiply 130E-2  12E-1  -> 1.560
mulx1003  multiply 130E-2  1E0    -> 1.30
mulx1004  multiply 1E2     1E4    -> 1E+6

-- payload decapitate
precision: 5
mulx1010  multiply 11 -sNaN1234567890 -> -NaN67890  Invalid_operation

-- Null tests
mulx990 multiply 10  # -> NaN Invalid_operation
mulx991 multiply  # 10 -> NaN Invalid_operation

Added test/dectest/nextminus.decTest.









































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
------------------------------------------------------------------------
-- nextminus.decTest -- decimal next that is less [754r nextdown]     --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

nextm001 nextminus  0.999999995 ->   0.999999994
nextm002 nextminus  0.999999996 ->   0.999999995
nextm003 nextminus  0.999999997 ->   0.999999996
nextm004 nextminus  0.999999998 ->   0.999999997
nextm005 nextminus  0.999999999 ->   0.999999998
nextm006 nextminus  1.00000000  ->   0.999999999
nextm007 nextminus  1.0         ->   0.999999999
nextm008 nextminus  1           ->   0.999999999
nextm009 nextminus  1.00000001  ->   1.00000000
nextm010 nextminus  1.00000002  ->   1.00000001
nextm011 nextminus  1.00000003  ->   1.00000002
nextm012 nextminus  1.00000004  ->   1.00000003
nextm013 nextminus  1.00000005  ->   1.00000004
nextm014 nextminus  1.00000006  ->   1.00000005
nextm015 nextminus  1.00000007  ->   1.00000006
nextm016 nextminus  1.00000008  ->   1.00000007
nextm017 nextminus  1.00000009  ->   1.00000008
nextm018 nextminus  1.00000010  ->   1.00000009
nextm019 nextminus  1.00000011  ->   1.00000010
nextm020 nextminus  1.00000012  ->   1.00000011

nextm021 nextminus -0.999999995 ->  -0.999999996
nextm022 nextminus -0.999999996 ->  -0.999999997
nextm023 nextminus -0.999999997 ->  -0.999999998
nextm024 nextminus -0.999999998 ->  -0.999999999
nextm025 nextminus -0.999999999 ->  -1.00000000
nextm026 nextminus -1.00000000  ->  -1.00000001
nextm027 nextminus -1.0         ->  -1.00000001
nextm028 nextminus -1           ->  -1.00000001
nextm029 nextminus -1.00000001  ->  -1.00000002
nextm030 nextminus -1.00000002  ->  -1.00000003
nextm031 nextminus -1.00000003  ->  -1.00000004
nextm032 nextminus -1.00000004  ->  -1.00000005
nextm033 nextminus -1.00000005  ->  -1.00000006
nextm034 nextminus -1.00000006  ->  -1.00000007
nextm035 nextminus -1.00000007  ->  -1.00000008
nextm036 nextminus -1.00000008  ->  -1.00000009
nextm037 nextminus -1.00000009  ->  -1.00000010
nextm038 nextminus -1.00000010  ->  -1.00000011
nextm039 nextminus -1.00000011  ->  -1.00000012

-- input operand is >precision
nextm041 nextminus  1.00000010998  ->   1.00000010
nextm042 nextminus  1.00000010999  ->   1.00000010
nextm043 nextminus  1.00000011000  ->   1.00000010
nextm044 nextminus  1.00000011001  ->   1.00000011
nextm045 nextminus  1.00000011002  ->   1.00000011
nextm046 nextminus  1.00000011002  ->   1.00000011
nextm047 nextminus  1.00000011052  ->   1.00000011
nextm048 nextminus  1.00000011552  ->   1.00000011
nextm049 nextminus -1.00000010998  ->  -1.00000011
nextm050 nextminus -1.00000010999  ->  -1.00000011
nextm051 nextminus -1.00000011000  ->  -1.00000012
nextm052 nextminus -1.00000011001  ->  -1.00000012
nextm053 nextminus -1.00000011002  ->  -1.00000012
nextm054 nextminus -1.00000011002  ->  -1.00000012
nextm055 nextminus -1.00000011052  ->  -1.00000012
nextm056 nextminus -1.00000011552  ->  -1.00000012
-- ultra-tiny inputs
nextm060 nextminus  1E-99999       ->   0E-391
nextm061 nextminus  1E-999999999   ->   0E-391
nextm062 nextminus  1E-391         ->   0E-391
nextm063 nextminus -1E-99999       ->  -1E-391
nextm064 nextminus -1E-999999999   ->  -1E-391
nextm065 nextminus -1E-391         ->  -2E-391

-- Zeros
nextm100 nextminus -0           -> -1E-391
nextm101 nextminus  0           -> -1E-391
nextm102 nextminus  0.00        -> -1E-391
nextm103 nextminus -0.00        -> -1E-391
nextm104 nextminus  0E-300      -> -1E-391
nextm105 nextminus  0E+300      -> -1E-391
nextm106 nextminus  0E+30000    -> -1E-391
nextm107 nextminus -0E+30000    -> -1E-391

precision: 9
maxExponent: 999
minexponent: -999
-- specials
nextm150 nextminus   Inf    ->  9.99999999E+999
nextm151 nextminus  -Inf    -> -Infinity
nextm152 nextminus   NaN    ->  NaN
nextm153 nextminus  sNaN    ->  NaN   Invalid_operation
nextm154 nextminus   NaN77  ->  NaN77
nextm155 nextminus  sNaN88  ->  NaN88 Invalid_operation
nextm156 nextminus  -NaN    -> -NaN
nextm157 nextminus -sNaN    -> -NaN   Invalid_operation
nextm158 nextminus  -NaN77  -> -NaN77
nextm159 nextminus -sNaN88  -> -NaN88 Invalid_operation

-- Nmax, Nmin, Ntiny, subnormals
nextm170 nextminus  9.99999999E+999   -> 9.99999998E+999
nextm171 nextminus  9.99999998E+999   -> 9.99999997E+999
nextm172 nextminus  1E-999            -> 9.9999999E-1000
nextm173 nextminus  1.00000000E-999   -> 9.9999999E-1000
nextm174 nextminus  9E-1007           -> 8E-1007
nextm175 nextminus  9.9E-1006         -> 9.8E-1006
nextm176 nextminus  9.9999E-1003      -> 9.9998E-1003
nextm177 nextminus  9.9999999E-1000   -> 9.9999998E-1000
nextm178 nextminus  9.9999998E-1000   -> 9.9999997E-1000
nextm179 nextminus  9.9999997E-1000   -> 9.9999996E-1000
nextm180 nextminus  0E-1007           -> -1E-1007
nextm181 nextminus  1E-1007           -> 0E-1007
nextm182 nextminus  2E-1007           -> 1E-1007

nextm183 nextminus  -0E-1007          -> -1E-1007
nextm184 nextminus  -1E-1007          -> -2E-1007
nextm185 nextminus  -2E-1007          -> -3E-1007
nextm186 nextminus  -10E-1007         -> -1.1E-1006
nextm187 nextminus  -100E-1007        -> -1.01E-1005
nextm188 nextminus  -100000E-1007     -> -1.00001E-1002
nextm189 nextminus  -1.0000E-999      -> -1.00000001E-999
nextm190 nextminus  -1.00000000E-999  -> -1.00000001E-999
nextm191 nextminus  -1E-999           -> -1.00000001E-999
nextm192 nextminus  -9.99999998E+999  -> -9.99999999E+999
nextm193 nextminus  -9.99999999E+999  -> -Infinity

-- Null tests
nextm900 nextminus  # -> NaN Invalid_operation

Added test/dectest/nextplus.decTest.













































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
------------------------------------------------------------------------
-- nextplus.decTest -- decimal next that is greater [754r nextup]     --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

nextp001 nextplus  0.999999995 ->   0.999999996
nextp002 nextplus  0.999999996 ->   0.999999997
nextp003 nextplus  0.999999997 ->   0.999999998
nextp004 nextplus  0.999999998 ->   0.999999999
nextp005 nextplus  0.999999999 ->   1.00000000
nextp006 nextplus  1.00000000  ->   1.00000001
nextp007 nextplus  1.0         ->   1.00000001
nextp008 nextplus  1           ->   1.00000001
nextp009 nextplus  1.00000001  ->   1.00000002
nextp010 nextplus  1.00000002  ->   1.00000003
nextp011 nextplus  1.00000003  ->   1.00000004
nextp012 nextplus  1.00000004  ->   1.00000005
nextp013 nextplus  1.00000005  ->   1.00000006
nextp014 nextplus  1.00000006  ->   1.00000007
nextp015 nextplus  1.00000007  ->   1.00000008
nextp016 nextplus  1.00000008  ->   1.00000009
nextp017 nextplus  1.00000009  ->   1.00000010
nextp018 nextplus  1.00000010  ->   1.00000011
nextp019 nextplus  1.00000011  ->   1.00000012

nextp021 nextplus -0.999999995 ->  -0.999999994
nextp022 nextplus -0.999999996 ->  -0.999999995
nextp023 nextplus -0.999999997 ->  -0.999999996
nextp024 nextplus -0.999999998 ->  -0.999999997
nextp025 nextplus -0.999999999 ->  -0.999999998
nextp026 nextplus -1.00000000  ->  -0.999999999
nextp027 nextplus -1.0         ->  -0.999999999
nextp028 nextplus -1           ->  -0.999999999
nextp029 nextplus -1.00000001  ->  -1.00000000
nextp030 nextplus -1.00000002  ->  -1.00000001
nextp031 nextplus -1.00000003  ->  -1.00000002
nextp032 nextplus -1.00000004  ->  -1.00000003
nextp033 nextplus -1.00000005  ->  -1.00000004
nextp034 nextplus -1.00000006  ->  -1.00000005
nextp035 nextplus -1.00000007  ->  -1.00000006
nextp036 nextplus -1.00000008  ->  -1.00000007
nextp037 nextplus -1.00000009  ->  -1.00000008
nextp038 nextplus -1.00000010  ->  -1.00000009
nextp039 nextplus -1.00000011  ->  -1.00000010
nextp040 nextplus -1.00000012  ->  -1.00000011

-- input operand is >precision
nextp041 nextplus  1.00000010998  ->   1.00000011
nextp042 nextplus  1.00000010999  ->   1.00000011
nextp043 nextplus  1.00000011000  ->   1.00000012
nextp044 nextplus  1.00000011001  ->   1.00000012
nextp045 nextplus  1.00000011002  ->   1.00000012
nextp046 nextplus  1.00000011002  ->   1.00000012
nextp047 nextplus  1.00000011052  ->   1.00000012
nextp048 nextplus  1.00000011552  ->   1.00000012
nextp049 nextplus -1.00000010998  ->  -1.00000010
nextp050 nextplus -1.00000010999  ->  -1.00000010
nextp051 nextplus -1.00000011000  ->  -1.00000010
nextp052 nextplus -1.00000011001  ->  -1.00000011
nextp053 nextplus -1.00000011002  ->  -1.00000011
nextp054 nextplus -1.00000011002  ->  -1.00000011
nextp055 nextplus -1.00000011052  ->  -1.00000011
nextp056 nextplus -1.00000011552  ->  -1.00000011
-- ultra-tiny inputs
nextp060 nextplus  1E-99999       ->   1E-391
nextp061 nextplus  1E-999999999   ->   1E-391
nextp062 nextplus  1E-391         ->   2E-391
nextp063 nextplus -1E-99999       ->  -0E-391
nextp064 nextplus -1E-999999999   ->  -0E-391
nextp065 nextplus -1E-391         ->  -0E-391

-- Zeros
nextp100 nextplus  0           ->  1E-391
nextp101 nextplus  0.00        ->  1E-391
nextp102 nextplus  0E-300      ->  1E-391
nextp103 nextplus  0E+300      ->  1E-391
nextp104 nextplus  0E+30000    ->  1E-391
nextp105 nextplus -0           ->  1E-391
nextp106 nextplus -0.00        ->  1E-391
nextp107 nextplus -0E-300      ->  1E-391
nextp108 nextplus -0E+300      ->  1E-391
nextp109 nextplus -0E+30000    ->  1E-391

maxExponent: 999
minexponent: -999
precision: 9
-- specials
nextp150 nextplus   Inf    ->  Infinity
nextp151 nextplus  -Inf    -> -9.99999999E+999
nextp152 nextplus   NaN    ->  NaN
nextp153 nextplus  sNaN    ->  NaN   Invalid_operation
nextp154 nextplus   NaN77  ->  NaN77
nextp155 nextplus  sNaN88  ->  NaN88 Invalid_operation
nextp156 nextplus  -NaN    -> -NaN
nextp157 nextplus -sNaN    -> -NaN   Invalid_operation
nextp158 nextplus  -NaN77  -> -NaN77
nextp159 nextplus -sNaN88  -> -NaN88 Invalid_operation

-- Nmax, Nmin, Ntiny, subnormals
nextp170 nextplus  9.99999999E+999   -> Infinity
nextp171 nextplus  9.99999998E+999   -> 9.99999999E+999
nextp172 nextplus  1E-999            -> 1.00000001E-999
nextp173 nextplus  1.00000000E-999   -> 1.00000001E-999
nextp174 nextplus  9E-1007           -> 1.0E-1006
nextp175 nextplus  9.9E-1006         -> 1.00E-1005
nextp176 nextplus  9.9999E-1003      -> 1.00000E-1002
nextp177 nextplus  9.9999999E-1000   -> 1.00000000E-999
nextp178 nextplus  9.9999998E-1000   -> 9.9999999E-1000
nextp179 nextplus  9.9999997E-1000   -> 9.9999998E-1000
nextp180 nextplus  0E-1007           -> 1E-1007
nextp181 nextplus  1E-1007           -> 2E-1007
nextp182 nextplus  2E-1007           -> 3E-1007

nextp183 nextplus  -0E-1007          ->  1E-1007
nextp184 nextplus  -1E-1007          -> -0E-1007
nextp185 nextplus  -2E-1007          -> -1E-1007
nextp186 nextplus  -10E-1007         -> -9E-1007
nextp187 nextplus  -100E-1007        -> -9.9E-1006
nextp188 nextplus  -100000E-1007     -> -9.9999E-1003
nextp189 nextplus  -1.0000E-999      -> -9.9999999E-1000
nextp190 nextplus  -1.00000000E-999  -> -9.9999999E-1000
nextp191 nextplus  -1E-999           -> -9.9999999E-1000
nextp192 nextplus  -9.99999998E+999  -> -9.99999997E+999
nextp193 nextplus  -9.99999999E+999  -> -9.99999998E+999

-- Null tests
nextp900 nextplus  # -> NaN Invalid_operation

Added test/dectest/nexttoward.decTest.





















































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
------------------------------------------------------------------------
-- nexttoward.decTest -- decimal next toward rhs [754r nextafter]     --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

-- Sanity check with a scattering of numerics
nextt001 nexttoward   10    10   ->  10
nextt002 nexttoward  -10   -10   -> -10
nextt003 nexttoward   1     10   ->  1.00000001
nextt004 nexttoward   1    -10   ->  0.999999999
nextt005 nexttoward  -1     10   -> -0.999999999
nextt006 nexttoward  -1    -10   -> -1.00000001
nextt007 nexttoward   0     10   ->  1E-391       Underflow Subnormal Inexact Rounded
nextt008 nexttoward   0    -10   -> -1E-391       Underflow Subnormal Inexact Rounded
nextt009 nexttoward   9.99999999E+384 +Infinity ->  Infinity Overflow Inexact Rounded
nextt010 nexttoward  -9.99999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded

------- lhs=rhs
-- finites
nextt101 nexttoward          7       7 ->  7
nextt102 nexttoward         -7      -7 -> -7
nextt103 nexttoward         75      75 ->  75
nextt104 nexttoward        -75     -75 -> -75
nextt105 nexttoward       7.50     7.5 ->  7.50
nextt106 nexttoward      -7.50   -7.50 -> -7.50
nextt107 nexttoward       7.500 7.5000 ->  7.500
nextt108 nexttoward      -7.500   -7.5 -> -7.500

-- zeros
nextt111 nexttoward          0       0 ->  0
nextt112 nexttoward         -0      -0 -> -0
nextt113 nexttoward       0E+4       0 ->  0E+4
nextt114 nexttoward      -0E+4      -0 -> -0E+4
nextt115 nexttoward     0.0000 0.00000 ->  0.0000
nextt116 nexttoward    -0.0000   -0.00 -> -0.0000
nextt117 nexttoward      0E-141      0 ->  0E-141
nextt118 nexttoward     -0E-141   -000 -> -0E-141

-- full coefficients, alternating bits
nextt121 nexttoward   268268268    268268268 ->   268268268
nextt122 nexttoward  -268268268   -268268268 ->  -268268268
nextt123 nexttoward   134134134    134134134 ->   134134134
nextt124 nexttoward  -134134134   -134134134 ->  -134134134

-- Nmax, Nmin, Ntiny
nextt131 nexttoward  9.99999999E+384  9.99999999E+384   ->   9.99999999E+384
nextt132 nexttoward  1E-383           1E-383            ->   1E-383
nextt133 nexttoward  1.00000000E-383  1.00000000E-383   ->   1.00000000E-383
nextt134 nexttoward  1E-391           1E-391            ->   1E-391

nextt135 nexttoward  -1E-391          -1E-391           ->  -1E-391
nextt136 nexttoward  -1.00000000E-383 -1.00000000E-383  ->  -1.00000000E-383
nextt137 nexttoward  -1E-383          -1E-383           ->  -1E-383
nextt138 nexttoward  -9.99999999E+384 -9.99999999E+384  ->  -9.99999999E+384

------- lhs<rhs
nextt201 nexttoward  0.999999995 Infinity ->   0.999999996
nextt202 nexttoward  0.999999996 Infinity ->   0.999999997
nextt203 nexttoward  0.999999997 Infinity ->   0.999999998
nextt204 nexttoward  0.999999998 Infinity ->   0.999999999
nextt205 nexttoward  0.999999999 Infinity ->   1.00000000
nextt206 nexttoward  1.00000000  Infinity ->   1.00000001
nextt207 nexttoward  1.0         Infinity ->   1.00000001
nextt208 nexttoward  1           Infinity ->   1.00000001
nextt209 nexttoward  1.00000001  Infinity ->   1.00000002
nextt210 nexttoward  1.00000002  Infinity ->   1.00000003
nextt211 nexttoward  1.00000003  Infinity ->   1.00000004
nextt212 nexttoward  1.00000004  Infinity ->   1.00000005
nextt213 nexttoward  1.00000005  Infinity ->   1.00000006
nextt214 nexttoward  1.00000006  Infinity ->   1.00000007
nextt215 nexttoward  1.00000007  Infinity ->   1.00000008
nextt216 nexttoward  1.00000008  Infinity ->   1.00000009
nextt217 nexttoward  1.00000009  Infinity ->   1.00000010
nextt218 nexttoward  1.00000010  Infinity ->   1.00000011
nextt219 nexttoward  1.00000011  Infinity ->   1.00000012

nextt221 nexttoward -0.999999995 Infinity ->  -0.999999994
nextt222 nexttoward -0.999999996 Infinity ->  -0.999999995
nextt223 nexttoward -0.999999997 Infinity ->  -0.999999996
nextt224 nexttoward -0.999999998 Infinity ->  -0.999999997
nextt225 nexttoward -0.999999999 Infinity ->  -0.999999998
nextt226 nexttoward -1.00000000  Infinity ->  -0.999999999
nextt227 nexttoward -1.0         Infinity ->  -0.999999999
nextt228 nexttoward -1           Infinity ->  -0.999999999
nextt229 nexttoward -1.00000001  Infinity ->  -1.00000000
nextt230 nexttoward -1.00000002  Infinity ->  -1.00000001
nextt231 nexttoward -1.00000003  Infinity ->  -1.00000002
nextt232 nexttoward -1.00000004  Infinity ->  -1.00000003
nextt233 nexttoward -1.00000005  Infinity ->  -1.00000004
nextt234 nexttoward -1.00000006  Infinity ->  -1.00000005
nextt235 nexttoward -1.00000007  Infinity ->  -1.00000006
nextt236 nexttoward -1.00000008  Infinity ->  -1.00000007
nextt237 nexttoward -1.00000009  Infinity ->  -1.00000008
nextt238 nexttoward -1.00000010  Infinity ->  -1.00000009
nextt239 nexttoward -1.00000011  Infinity ->  -1.00000010
nextt240 nexttoward -1.00000012  Infinity ->  -1.00000011

-- input operand is >precision
nextt241 nexttoward  1.00000010998  Infinity ->   1.00000011
nextt242 nexttoward  1.00000010999  Infinity ->   1.00000011
nextt243 nexttoward  1.00000011000  Infinity ->   1.00000012
nextt244 nexttoward  1.00000011001  Infinity ->   1.00000012
nextt245 nexttoward  1.00000011002  Infinity ->   1.00000012
nextt246 nexttoward  1.00000011002  Infinity ->   1.00000012
nextt247 nexttoward  1.00000011052  Infinity ->   1.00000012
nextt248 nexttoward  1.00000011552  Infinity ->   1.00000012
nextt249 nexttoward -1.00000010998  Infinity ->  -1.00000010
nextt250 nexttoward -1.00000010999  Infinity ->  -1.00000010
nextt251 nexttoward -1.00000011000  Infinity ->  -1.00000010
nextt252 nexttoward -1.00000011001  Infinity ->  -1.00000011
nextt253 nexttoward -1.00000011002  Infinity ->  -1.00000011
nextt254 nexttoward -1.00000011002  Infinity ->  -1.00000011
nextt255 nexttoward -1.00000011052  Infinity ->  -1.00000011
nextt256 nexttoward -1.00000011552  Infinity ->  -1.00000011
-- ultra-tiny inputs
nextt260 nexttoward  1E-99999       Infinity ->   1E-391          Underflow Subnormal Inexact Rounded
nextt261 nexttoward  1E-999999999   Infinity ->   1E-391          Underflow Subnormal Inexact Rounded
nextt262 nexttoward  1E-391         Infinity ->   2E-391          Underflow Subnormal Inexact Rounded
nextt263 nexttoward -1E-99999       Infinity ->  -0E-391          Underflow Subnormal Inexact Rounded Clamped
nextt264 nexttoward -1E-999999999   Infinity ->  -0E-391          Underflow Subnormal Inexact Rounded Clamped
nextt265 nexttoward -1E-391         Infinity ->  -0E-391          Underflow Subnormal Inexact Rounded Clamped

-- Zeros
nextt300 nexttoward  0           Infinity ->  1E-391              Underflow Subnormal Inexact Rounded
nextt301 nexttoward  0.00        Infinity ->  1E-391              Underflow Subnormal Inexact Rounded
nextt302 nexttoward  0E-300      Infinity ->  1E-391              Underflow Subnormal Inexact Rounded
nextt303 nexttoward  0E+300      Infinity ->  1E-391              Underflow Subnormal Inexact Rounded
nextt304 nexttoward  0E+30000    Infinity ->  1E-391              Underflow Subnormal Inexact Rounded
nextt305 nexttoward -0           Infinity ->  1E-391              Underflow Subnormal Inexact Rounded
nextt306 nexttoward -0.00        Infinity ->  1E-391              Underflow Subnormal Inexact Rounded
nextt307 nexttoward -0E-300      Infinity ->  1E-391              Underflow Subnormal Inexact Rounded
nextt308 nexttoward -0E+300      Infinity ->  1E-391              Underflow Subnormal Inexact Rounded
nextt309 nexttoward -0E+30000    Infinity ->  1E-391              Underflow Subnormal Inexact Rounded

-- specials
nextt350 nexttoward   Inf    Infinity ->  Infinity
nextt351 nexttoward  -Inf    Infinity -> -9.99999999E+384
nextt352 nexttoward   NaN    Infinity ->  NaN
nextt353 nexttoward  sNaN    Infinity ->  NaN   Invalid_operation
nextt354 nexttoward   NaN77  Infinity ->  NaN77
nextt355 nexttoward  sNaN88  Infinity ->  NaN88 Invalid_operation
nextt356 nexttoward  -NaN    Infinity -> -NaN
nextt357 nexttoward -sNaN    Infinity -> -NaN   Invalid_operation
nextt358 nexttoward  -NaN77  Infinity -> -NaN77
nextt359 nexttoward -sNaN88  Infinity -> -NaN88 Invalid_operation

-- Nmax, Nmin, Ntiny, subnormals
maxExponent: 999
minexponent: -999
nextt370 nexttoward  9.99999999E+999   Infinity -> Infinity        Overflow Inexact Rounded
nextt371 nexttoward  9.99999998E+999   Infinity -> 9.99999999E+999
nextt372 nexttoward  1E-999            Infinity -> 1.00000001E-999
nextt373 nexttoward  1.00000000E-999   Infinity -> 1.00000001E-999
nextt374 nexttoward  0.999999999E-999  Infinity -> 1.00000000E-999
nextt375 nexttoward  0.99999999E-999   Infinity -> 1.00000000E-999
nextt376 nexttoward  9E-1007           Infinity -> 1.0E-1006       Underflow Subnormal Inexact Rounded
nextt377 nexttoward  9.9E-1006         Infinity -> 1.00E-1005      Underflow Subnormal Inexact Rounded
nextt378 nexttoward  9.9999E-1003      Infinity -> 1.00000E-1002   Underflow Subnormal Inexact Rounded
nextt379 nexttoward  9.9999998E-1000   Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
nextt380 nexttoward  9.9999997E-1000   Infinity -> 9.9999998E-1000 Underflow Subnormal Inexact Rounded
nextt381 nexttoward  0E-1007           Infinity -> 1E-1007         Underflow Subnormal Inexact Rounded
nextt382 nexttoward  1E-1007           Infinity -> 2E-1007         Underflow Subnormal Inexact Rounded
nextt383 nexttoward  2E-1007           Infinity -> 3E-1007         Underflow Subnormal Inexact Rounded

nextt385 nexttoward  -0E-1007          Infinity ->  1E-1007        Underflow Subnormal Inexact Rounded
nextt386 nexttoward  -1E-1007          Infinity -> -0E-1007        Underflow Subnormal Inexact Rounded Clamped
nextt387 nexttoward  -2E-1007          Infinity -> -1E-1007        Underflow Subnormal Inexact Rounded
nextt388 nexttoward  -10E-1007         Infinity -> -9E-1007        Underflow Subnormal Inexact Rounded
nextt389 nexttoward  -100E-1007        Infinity -> -9.9E-1006      Underflow Subnormal Inexact Rounded
nextt390 nexttoward  -100000E-1007     Infinity -> -9.9999E-1003   Underflow Subnormal Inexact Rounded
nextt391 nexttoward  -1.0000E-999      Infinity -> -9.9999999E-1000  Underflow Subnormal Inexact Rounded
nextt392 nexttoward  -1.00000000E-999  Infinity -> -9.9999999E-1000  Underflow Subnormal Inexact Rounded
nextt393 nexttoward  -1E-999           Infinity -> -9.9999999E-1000  Underflow Subnormal Inexact Rounded
nextt394 nexttoward  -9.99999998E+999  Infinity -> -9.99999997E+999
nextt395 nexttoward  -9.99999999E+999  Infinity -> -9.99999998E+999

------- lhs>rhs
maxExponent: 384
minexponent: -383
nextt401 nexttoward  0.999999995  -Infinity ->   0.999999994
nextt402 nexttoward  0.999999996  -Infinity ->   0.999999995
nextt403 nexttoward  0.999999997  -Infinity ->   0.999999996
nextt404 nexttoward  0.999999998  -Infinity ->   0.999999997
nextt405 nexttoward  0.999999999  -Infinity ->   0.999999998
nextt406 nexttoward  1.00000000   -Infinity ->   0.999999999
nextt407 nexttoward  1.0          -Infinity ->   0.999999999
nextt408 nexttoward  1            -Infinity ->   0.999999999
nextt409 nexttoward  1.00000001   -Infinity ->   1.00000000
nextt410 nexttoward  1.00000002   -Infinity ->   1.00000001
nextt411 nexttoward  1.00000003   -Infinity ->   1.00000002
nextt412 nexttoward  1.00000004   -Infinity ->   1.00000003
nextt413 nexttoward  1.00000005   -Infinity ->   1.00000004
nextt414 nexttoward  1.00000006   -Infinity ->   1.00000005
nextt415 nexttoward  1.00000007   -Infinity ->   1.00000006
nextt416 nexttoward  1.00000008   -Infinity ->   1.00000007
nextt417 nexttoward  1.00000009   -Infinity ->   1.00000008
nextt418 nexttoward  1.00000010   -Infinity ->   1.00000009
nextt419 nexttoward  1.00000011   -Infinity ->   1.00000010
nextt420 nexttoward  1.00000012   -Infinity ->   1.00000011

nextt421 nexttoward -0.999999995  -Infinity ->  -0.999999996
nextt422 nexttoward -0.999999996  -Infinity ->  -0.999999997
nextt423 nexttoward -0.999999997  -Infinity ->  -0.999999998
nextt424 nexttoward -0.999999998  -Infinity ->  -0.999999999
nextt425 nexttoward -0.999999999  -Infinity ->  -1.00000000
nextt426 nexttoward -1.00000000   -Infinity ->  -1.00000001
nextt427 nexttoward -1.0          -Infinity ->  -1.00000001
nextt428 nexttoward -1            -Infinity ->  -1.00000001
nextt429 nexttoward -1.00000001   -Infinity ->  -1.00000002
nextt430 nexttoward -1.00000002   -Infinity ->  -1.00000003
nextt431 nexttoward -1.00000003   -Infinity ->  -1.00000004
nextt432 nexttoward -1.00000004   -Infinity ->  -1.00000005
nextt433 nexttoward -1.00000005   -Infinity ->  -1.00000006
nextt434 nexttoward -1.00000006   -Infinity ->  -1.00000007
nextt435 nexttoward -1.00000007   -Infinity ->  -1.00000008
nextt436 nexttoward -1.00000008   -Infinity ->  -1.00000009
nextt437 nexttoward -1.00000009   -Infinity ->  -1.00000010
nextt438 nexttoward -1.00000010   -Infinity ->  -1.00000011
nextt439 nexttoward -1.00000011   -Infinity ->  -1.00000012

-- input operand is >precision
nextt441 nexttoward  1.00000010998   -Infinity ->   1.00000010
nextt442 nexttoward  1.00000010999   -Infinity ->   1.00000010
nextt443 nexttoward  1.00000011000   -Infinity ->   1.00000010
nextt444 nexttoward  1.00000011001   -Infinity ->   1.00000011
nextt445 nexttoward  1.00000011002   -Infinity ->   1.00000011
nextt446 nexttoward  1.00000011002   -Infinity ->   1.00000011
nextt447 nexttoward  1.00000011052   -Infinity ->   1.00000011
nextt448 nexttoward  1.00000011552   -Infinity ->   1.00000011
nextt449 nexttoward -1.00000010998   -Infinity ->  -1.00000011
nextt450 nexttoward -1.00000010999   -Infinity ->  -1.00000011
nextt451 nexttoward -1.00000011000   -Infinity ->  -1.00000012
nextt452 nexttoward -1.00000011001   -Infinity ->  -1.00000012
nextt453 nexttoward -1.00000011002   -Infinity ->  -1.00000012
nextt454 nexttoward -1.00000011002   -Infinity ->  -1.00000012
nextt455 nexttoward -1.00000011052   -Infinity ->  -1.00000012
nextt456 nexttoward -1.00000011552   -Infinity ->  -1.00000012
-- ultra-tiny inputs
nextt460 nexttoward  1E-99999        -Infinity ->   0E-391     Underflow Subnormal Inexact Rounded Clamped
nextt461 nexttoward  1E-999999999    -Infinity ->   0E-391     Underflow Subnormal Inexact Rounded Clamped
nextt462 nexttoward  1E-391          -Infinity ->   0E-391     Underflow Subnormal Inexact Rounded Clamped
nextt463 nexttoward -1E-99999        -Infinity ->  -1E-391     Underflow Subnormal Inexact Rounded
nextt464 nexttoward -1E-999999999    -Infinity ->  -1E-391     Underflow Subnormal Inexact Rounded
nextt465 nexttoward -1E-391          -Infinity ->  -2E-391     Underflow Subnormal Inexact Rounded

-- Zeros
nextt500 nexttoward -0            -Infinity -> -1E-391         Underflow Subnormal Inexact Rounded
nextt501 nexttoward  0            -Infinity -> -1E-391         Underflow Subnormal Inexact Rounded
nextt502 nexttoward  0.00         -Infinity -> -1E-391         Underflow Subnormal Inexact Rounded
nextt503 nexttoward -0.00         -Infinity -> -1E-391         Underflow Subnormal Inexact Rounded
nextt504 nexttoward  0E-300       -Infinity -> -1E-391         Underflow Subnormal Inexact Rounded
nextt505 nexttoward  0E+300       -Infinity -> -1E-391         Underflow Subnormal Inexact Rounded
nextt506 nexttoward  0E+30000     -Infinity -> -1E-391         Underflow Subnormal Inexact Rounded
nextt507 nexttoward -0E+30000     -Infinity -> -1E-391         Underflow Subnormal Inexact Rounded
nextt508 nexttoward  0.00         -0.0000   -> -0.00

-- specials
nextt550 nexttoward   Inf     -Infinity ->  9.99999999E+384
nextt551 nexttoward  -Inf     -Infinity -> -Infinity
nextt552 nexttoward   NaN     -Infinity ->  NaN
nextt553 nexttoward  sNaN     -Infinity ->  NaN   Invalid_operation
nextt554 nexttoward   NaN77   -Infinity ->  NaN77
nextt555 nexttoward  sNaN88   -Infinity ->  NaN88 Invalid_operation
nextt556 nexttoward  -NaN     -Infinity -> -NaN
nextt557 nexttoward -sNaN     -Infinity -> -NaN   Invalid_operation
nextt558 nexttoward  -NaN77   -Infinity -> -NaN77
nextt559 nexttoward -sNaN88   -Infinity -> -NaN88 Invalid_operation

-- Nmax, Nmin, Ntiny, subnormals
maxExponent: 999
minexponent: -999
nextt570 nexttoward  9.99999999E+999    -Infinity -> 9.99999998E+999
nextt571 nexttoward  9.99999998E+999    -Infinity -> 9.99999997E+999
nextt572 nexttoward  1E-999             -Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
nextt573 nexttoward  1.00000000E-999    -Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
nextt574 nexttoward  9E-1007            -Infinity -> 8E-1007         Underflow Subnormal Inexact Rounded
nextt575 nexttoward  9.9E-1006          -Infinity -> 9.8E-1006       Underflow Subnormal Inexact Rounded
nextt576 nexttoward  9.9999E-1003       -Infinity -> 9.9998E-1003    Underflow Subnormal Inexact Rounded
nextt577 nexttoward  9.9999999E-1000    -Infinity -> 9.9999998E-1000 Underflow Subnormal Inexact Rounded
nextt578 nexttoward  9.9999998E-1000    -Infinity -> 9.9999997E-1000 Underflow Subnormal Inexact Rounded
nextt579 nexttoward  9.9999997E-1000    -Infinity -> 9.9999996E-1000 Underflow Subnormal Inexact Rounded
nextt580 nexttoward  0E-1007            -Infinity -> -1E-1007        Underflow Subnormal Inexact Rounded
nextt581 nexttoward  1E-1007            -Infinity -> 0E-1007         Underflow Subnormal Inexact Rounded Clamped
nextt582 nexttoward  2E-1007            -Infinity -> 1E-1007         Underflow Subnormal Inexact Rounded

nextt583 nexttoward  -0E-1007           -Infinity -> -1E-1007        Underflow Subnormal Inexact Rounded
nextt584 nexttoward  -1E-1007           -Infinity -> -2E-1007        Underflow Subnormal Inexact Rounded
nextt585 nexttoward  -2E-1007           -Infinity -> -3E-1007        Underflow Subnormal Inexact Rounded
nextt586 nexttoward  -10E-1007          -Infinity -> -1.1E-1006      Underflow Subnormal Inexact Rounded
nextt587 nexttoward  -100E-1007         -Infinity -> -1.01E-1005     Underflow Subnormal Inexact Rounded
nextt588 nexttoward  -100000E-1007      -Infinity -> -1.00001E-1002  Underflow Subnormal Inexact Rounded
nextt589 nexttoward  -1.0000E-999       -Infinity -> -1.00000001E-999
nextt590 nexttoward  -1.00000000E-999   -Infinity -> -1.00000001E-999
nextt591 nexttoward  -1E-999            -Infinity -> -1.00000001E-999
nextt592 nexttoward  -9.99999998E+999   -Infinity -> -9.99999999E+999
nextt593 nexttoward  -9.99999999E+999   -Infinity -> -Infinity Overflow Inexact Rounded




------- Specials
maxExponent: 384
minexponent: -383
nextt780 nexttoward -Inf  -Inf   -> -Infinity
nextt781 nexttoward -Inf  -1000  -> -9.99999999E+384
nextt782 nexttoward -Inf  -1     -> -9.99999999E+384
nextt783 nexttoward -Inf  -0     -> -9.99999999E+384
nextt784 nexttoward -Inf   0     -> -9.99999999E+384
nextt785 nexttoward -Inf   1     -> -9.99999999E+384
nextt786 nexttoward -Inf   1000  -> -9.99999999E+384
nextt787 nexttoward -1000 -Inf   -> -1000.00001
nextt788 nexttoward -Inf  -Inf   -> -Infinity
nextt789 nexttoward -1    -Inf   -> -1.00000001
nextt790 nexttoward -0    -Inf   -> -1E-391           Underflow Subnormal Inexact Rounded
nextt791 nexttoward  0    -Inf   -> -1E-391           Underflow Subnormal Inexact Rounded
nextt792 nexttoward  1    -Inf   ->  0.999999999
nextt793 nexttoward  1000 -Inf   ->  999.999999
nextt794 nexttoward  Inf  -Inf   ->  9.99999999E+384

nextt800 nexttoward  Inf  -Inf   ->  9.99999999E+384
nextt801 nexttoward  Inf  -1000  ->  9.99999999E+384
nextt802 nexttoward  Inf  -1     ->  9.99999999E+384
nextt803 nexttoward  Inf  -0     ->  9.99999999E+384
nextt804 nexttoward  Inf   0     ->  9.99999999E+384
nextt805 nexttoward  Inf   1     ->  9.99999999E+384
nextt806 nexttoward  Inf   1000  ->  9.99999999E+384
nextt807 nexttoward  Inf   Inf   ->  Infinity
nextt808 nexttoward -1000  Inf   -> -999.999999
nextt809 nexttoward -Inf   Inf   -> -9.99999999E+384
nextt810 nexttoward -1     Inf   -> -0.999999999
nextt811 nexttoward -0     Inf   ->  1E-391           Underflow Subnormal Inexact Rounded
nextt812 nexttoward  0     Inf   ->  1E-391           Underflow Subnormal Inexact Rounded
nextt813 nexttoward  1     Inf   ->  1.00000001
nextt814 nexttoward  1000  Inf   ->  1000.00001
nextt815 nexttoward  Inf   Inf   ->  Infinity

nextt821 nexttoward  NaN -Inf    ->  NaN
nextt822 nexttoward  NaN -1000   ->  NaN
nextt823 nexttoward  NaN -1      ->  NaN
nextt824 nexttoward  NaN -0      ->  NaN
nextt825 nexttoward  NaN  0      ->  NaN
nextt826 nexttoward  NaN  1      ->  NaN
nextt827 nexttoward  NaN  1000   ->  NaN
nextt828 nexttoward  NaN  Inf    ->  NaN
nextt829 nexttoward  NaN  NaN    ->  NaN
nextt830 nexttoward -Inf  NaN    ->  NaN
nextt831 nexttoward -1000 NaN    ->  NaN
nextt832 nexttoward -1    NaN    ->  NaN
nextt833 nexttoward -0    NaN    ->  NaN
nextt834 nexttoward  0    NaN    ->  NaN
nextt835 nexttoward  1    NaN    ->  NaN
nextt836 nexttoward  1000 NaN    ->  NaN
nextt837 nexttoward  Inf  NaN    ->  NaN

nextt841 nexttoward  sNaN -Inf   ->  NaN  Invalid_operation
nextt842 nexttoward  sNaN -1000  ->  NaN  Invalid_operation
nextt843 nexttoward  sNaN -1     ->  NaN  Invalid_operation
nextt844 nexttoward  sNaN -0     ->  NaN  Invalid_operation
nextt845 nexttoward  sNaN  0     ->  NaN  Invalid_operation
nextt846 nexttoward  sNaN  1     ->  NaN  Invalid_operation
nextt847 nexttoward  sNaN  1000  ->  NaN  Invalid_operation
nextt848 nexttoward  sNaN  NaN   ->  NaN  Invalid_operation
nextt849 nexttoward  sNaN sNaN   ->  NaN  Invalid_operation
nextt850 nexttoward  NaN  sNaN   ->  NaN  Invalid_operation
nextt851 nexttoward -Inf  sNaN   ->  NaN  Invalid_operation
nextt852 nexttoward -1000 sNaN   ->  NaN  Invalid_operation
nextt853 nexttoward -1    sNaN   ->  NaN  Invalid_operation
nextt854 nexttoward -0    sNaN   ->  NaN  Invalid_operation
nextt855 nexttoward  0    sNaN   ->  NaN  Invalid_operation
nextt856 nexttoward  1    sNaN   ->  NaN  Invalid_operation
nextt857 nexttoward  1000 sNaN   ->  NaN  Invalid_operation
nextt858 nexttoward  Inf  sNaN   ->  NaN  Invalid_operation
nextt859 nexttoward  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
nextt861 nexttoward  NaN1   -Inf    ->  NaN1
nextt862 nexttoward +NaN2   -1000   ->  NaN2
nextt863 nexttoward  NaN3    1000   ->  NaN3
nextt864 nexttoward  NaN4    Inf    ->  NaN4
nextt865 nexttoward  NaN5   +NaN6   ->  NaN5
nextt866 nexttoward -Inf     NaN7   ->  NaN7
nextt867 nexttoward -1000    NaN8   ->  NaN8
nextt868 nexttoward  1000    NaN9   ->  NaN9
nextt869 nexttoward  Inf    +NaN10  ->  NaN10
nextt871 nexttoward  sNaN11  -Inf   ->  NaN11  Invalid_operation
nextt872 nexttoward  sNaN12  -1000  ->  NaN12  Invalid_operation
nextt873 nexttoward  sNaN13   1000  ->  NaN13  Invalid_operation
nextt874 nexttoward  sNaN14   NaN17 ->  NaN14  Invalid_operation
nextt875 nexttoward  sNaN15  sNaN18 ->  NaN15  Invalid_operation
nextt876 nexttoward  NaN16   sNaN19 ->  NaN19  Invalid_operation
nextt877 nexttoward -Inf    +sNaN20 ->  NaN20  Invalid_operation
nextt878 nexttoward -1000    sNaN21 ->  NaN21  Invalid_operation
nextt879 nexttoward  1000    sNaN22 ->  NaN22  Invalid_operation
nextt880 nexttoward  Inf     sNaN23 ->  NaN23  Invalid_operation
nextt881 nexttoward +NaN25  +sNaN24 ->  NaN24  Invalid_operation
nextt882 nexttoward -NaN26    NaN28 -> -NaN26
nextt883 nexttoward -sNaN27  sNaN29 -> -NaN27  Invalid_operation
nextt884 nexttoward  1000    -NaN30 -> -NaN30
nextt885 nexttoward  1000   -sNaN31 -> -NaN31  Invalid_operation

-- Null tests
nextt900 nexttoward 1  # -> NaN Invalid_operation
nextt901 nexttoward #  1 -> NaN Invalid_operation

Deleted test/dectest/normalize.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
------------------------------------------------------------------------
-- normalize.decTest -- remove trailing zeros                         --
-- Copyright (c) IBM Corporation, 2003.  All rights reserved.         --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minexponent: -999

nrmx001 normalize '1'      -> '1'
nrmx002 normalize '-1'     -> '-1'
nrmx003 normalize '1.00'   -> '1'
nrmx004 normalize '-1.00'  -> '-1'
nrmx005 normalize '0'      -> '0'
nrmx006 normalize '0.00'   -> '0'
nrmx007 normalize '00.0'   -> '0'
nrmx008 normalize '00.00'  -> '0'
nrmx009 normalize '00'     -> '0'
nrmx010 normalize '0E+1'   -> '0'
nrmx011 normalize '0E+5'   -> '0'

nrmx012 normalize '-2'     -> '-2'
nrmx013 normalize '2'      -> '2'
nrmx014 normalize '-2.00'  -> '-2'
nrmx015 normalize '2.00'   -> '2'
nrmx016 normalize '-0'     -> '-0'
nrmx017 normalize '-0.00'  -> '-0'
nrmx018 normalize '-00.0'  -> '-0'
nrmx019 normalize '-00.00' -> '-0'
nrmx020 normalize '-00'    -> '-0'
nrmx021 normalize '-0E+5'   -> '-0'
nrmx022 normalize '-0E+1'  -> '-0'

nrmx030 normalize '+0.1'            -> '0.1'
nrmx031 normalize '-0.1'            -> '-0.1'
nrmx032 normalize '+0.01'           -> '0.01'
nrmx033 normalize '-0.01'           -> '-0.01'
nrmx034 normalize '+0.001'          -> '0.001'
nrmx035 normalize '-0.001'          -> '-0.001'
nrmx036 normalize '+0.000001'       -> '0.000001'
nrmx037 normalize '-0.000001'       -> '-0.000001'
nrmx038 normalize '+0.000000000001' -> '1E-12'
nrmx039 normalize '-0.000000000001' -> '-1E-12'

nrmx041 normalize 1.1        -> 1.1
nrmx042 normalize 1.10       -> 1.1
nrmx043 normalize 1.100      -> 1.1
nrmx044 normalize 1.110      -> 1.11
nrmx045 normalize -1.1       -> -1.1
nrmx046 normalize -1.10      -> -1.1
nrmx047 normalize -1.100     -> -1.1
nrmx048 normalize -1.110     -> -1.11
nrmx049 normalize 9.9        -> 9.9
nrmx050 normalize 9.90       -> 9.9
nrmx051 normalize 9.900      -> 9.9
nrmx052 normalize 9.990      -> 9.99
nrmx053 normalize -9.9       -> -9.9
nrmx054 normalize -9.90      -> -9.9
nrmx055 normalize -9.900     -> -9.9
nrmx056 normalize -9.990     -> -9.99

-- some trailing fractional zeros with zeros in units
nrmx060 normalize  10.0        -> 1E+1
nrmx061 normalize  10.00       -> 1E+1
nrmx062 normalize  100.0       -> 1E+2
nrmx063 normalize  100.00      -> 1E+2
nrmx064 normalize  1.1000E+3   -> 1.1E+3
nrmx065 normalize  1.10000E+3  -> 1.1E+3
nrmx066 normalize -10.0        -> -1E+1
nrmx067 normalize -10.00       -> -1E+1
nrmx068 normalize -100.0       -> -1E+2
nrmx069 normalize -100.00      -> -1E+2
nrmx070 normalize -1.1000E+3   -> -1.1E+3
nrmx071 normalize -1.10000E+3  -> -1.1E+3

-- some insignificant trailing zeros with positive exponent
nrmx080 normalize  10E+1       -> 1E+2
nrmx081 normalize  100E+1      -> 1E+3
nrmx082 normalize  1.0E+2      -> 1E+2
nrmx083 normalize  1.0E+3      -> 1E+3
nrmx084 normalize  1.1E+3      -> 1.1E+3
nrmx085 normalize  1.00E+3     -> 1E+3
nrmx086 normalize  1.10E+3     -> 1.1E+3
nrmx087 normalize -10E+1       -> -1E+2
nrmx088 normalize -100E+1      -> -1E+3
nrmx089 normalize -1.0E+2      -> -1E+2
nrmx090 normalize -1.0E+3      -> -1E+3
nrmx091 normalize -1.1E+3      -> -1.1E+3
nrmx092 normalize -1.00E+3     -> -1E+3
nrmx093 normalize -1.10E+3     -> -1.1E+3

-- some significant trailing zeros, were we to be trimming
nrmx100 normalize  11          -> 11
nrmx101 normalize  10          -> 1E+1
nrmx102 normalize  10.         -> 1E+1
nrmx103 normalize  1.1E+1      -> 11
nrmx104 normalize  1.0E+1      -> 1E+1
nrmx105 normalize  1.10E+2     -> 1.1E+2
nrmx106 normalize  1.00E+2     -> 1E+2
nrmx107 normalize  1.100E+3    -> 1.1E+3
nrmx108 normalize  1.000E+3    -> 1E+3
nrmx109 normalize  1.000000E+6 -> 1E+6
nrmx110 normalize -11          -> -11
nrmx111 normalize -10          -> -1E+1
nrmx112 normalize -10.         -> -1E+1
nrmx113 normalize -1.1E+1      -> -11
nrmx114 normalize -1.0E+1      -> -1E+1
nrmx115 normalize -1.10E+2     -> -1.1E+2
nrmx116 normalize -1.00E+2     -> -1E+2
nrmx117 normalize -1.100E+3    -> -1.1E+3
nrmx118 normalize -1.000E+3    -> -1E+3
nrmx119 normalize -1.00000E+5  -> -1E+5
nrmx120 normalize -1.000000E+6 -> -1E+6
nrmx121 normalize -10.00000E+6 -> -1E+7
nrmx122 normalize -100.0000E+6 -> -1E+8
nrmx123 normalize -1000.000E+6 -> -1E+9
nrmx124 normalize -10000.00E+6 -> -1E+10
nrmx125 normalize -100000.0E+6 -> -1E+11
nrmx126 normalize -1000000.E+6 -> -1E+12

-- examples from decArith
nrmx140 normalize '2.1'     ->  '2.1'
nrmx141 normalize '-2.0'    ->  '-2'
nrmx142 normalize '1.200'   ->  '1.2'
nrmx143 normalize '-120'    ->  '-1.2E+2'
nrmx144 normalize '120.00'  ->  '1.2E+2'
nrmx145 normalize '0.00'    ->  '0'

-- overflow tests
maxexponent: 999999999
minexponent: -999999999
precision: 3
nrmx160 normalize 9.999E+999999999  ->  Infinity Inexact Overflow Rounded
nrmx161 normalize -9.999E+999999999 -> -Infinity Inexact Overflow Rounded

-- subnormals and underflow
precision: 3
maxexponent: 999
minexponent: -999
nrmx210 normalize  1.00E-999        ->   1E-999
nrmx211 normalize  0.1E-999         ->   1E-1000   Subnormal
nrmx212 normalize  0.10E-999        ->   1E-1000   Subnormal
nrmx213 normalize  0.100E-999       ->   1E-1000   Subnormal Rounded
nrmx214 normalize  0.01E-999        ->   1E-1001   Subnormal
-- next is rounded to Emin
nrmx215 normalize  0.999E-999       ->   1E-999    Inexact Rounded Subnormal Underflow
nrmx216 normalize  0.099E-999       ->   1E-1000   Inexact Rounded Subnormal Underflow
nrmx217 normalize  0.009E-999       ->   1E-1001   Inexact Rounded Subnormal Underflow
nrmx218 normalize  0.001E-999       ->   0         Inexact Rounded Subnormal Underflow Clamped
nrmx219 normalize  0.0009E-999      ->   0         Inexact Rounded Subnormal Underflow Clamped
nrmx220 normalize  0.0001E-999      ->   0         Inexact Rounded Subnormal Underflow Clamped

nrmx230 normalize -1.00E-999        ->  -1E-999
nrmx231 normalize -0.1E-999         ->  -1E-1000   Subnormal
nrmx232 normalize -0.10E-999        ->  -1E-1000   Subnormal
nrmx233 normalize -0.100E-999       ->  -1E-1000   Subnormal Rounded
nrmx234 normalize -0.01E-999        ->  -1E-1001   Subnormal
-- next is rounded to Emin
nrmx235 normalize -0.999E-999       ->  -1E-999    Inexact Rounded Subnormal Underflow
nrmx236 normalize -0.099E-999       ->  -1E-1000   Inexact Rounded Subnormal Underflow
nrmx237 normalize -0.009E-999       ->  -1E-1001   Inexact Rounded Subnormal Underflow
nrmx238 normalize -0.001E-999       ->  -0         Inexact Rounded Subnormal Underflow Clamped
nrmx239 normalize -0.0009E-999      ->  -0         Inexact Rounded Subnormal Underflow Clamped
nrmx240 normalize -0.0001E-999      ->  -0         Inexact Rounded Subnormal Underflow Clamped

-- more reshaping
precision: 9
nrmx260 normalize '56260E-10'   -> '0.000005626'
nrmx261 normalize '56260E-5'    -> '0.5626'
nrmx262 normalize '56260E-2'    -> '562.6'
nrmx263 normalize '56260E-1'    -> '5626'
nrmx265 normalize '56260E-0'    -> '5.626E+4'
nrmx266 normalize '56260E+0'    -> '5.626E+4'
nrmx267 normalize '56260E+1'    -> '5.626E+5'
nrmx268 normalize '56260E+2'    -> '5.626E+6'
nrmx269 normalize '56260E+3'    -> '5.626E+7'
nrmx270 normalize '56260E+4'    -> '5.626E+8'
nrmx271 normalize '56260E+5'    -> '5.626E+9'
nrmx272 normalize '56260E+6'    -> '5.626E+10'
nrmx280 normalize '-56260E-10'  -> '-0.000005626'
nrmx281 normalize '-56260E-5'   -> '-0.5626'
nrmx282 normalize '-56260E-2'   -> '-562.6'
nrmx283 normalize '-56260E-1'   -> '-5626'
nrmx285 normalize '-56260E-0'   -> '-5.626E+4'
nrmx286 normalize '-56260E+0'   -> '-5.626E+4'
nrmx287 normalize '-56260E+1'   -> '-5.626E+5'
nrmx288 normalize '-56260E+2'   -> '-5.626E+6'
nrmx289 normalize '-56260E+3'   -> '-5.626E+7'
nrmx290 normalize '-56260E+4'   -> '-5.626E+8'
nrmx291 normalize '-56260E+5'   -> '-5.626E+9'
nrmx292 normalize '-56260E+6'   -> '-5.626E+10'

-- FL test
precision: 40
nrmx295 normalize 9892345673.0123456780000000000 -> 9892345673.012345678

-- specials
nrmx820 normalize 'Inf'    -> 'Infinity'
nrmx821 normalize '-Inf'   -> '-Infinity'
nrmx822 normalize   NaN    ->  NaN
nrmx823 normalize  sNaN    ->  NaN    Invalid_operation
nrmx824 normalize   NaN101 ->  NaN101
nrmx825 normalize  sNaN010 ->  NaN10  Invalid_operation
nrmx827 normalize  -NaN    -> -NaN
nrmx828 normalize -sNaN    -> -NaN    Invalid_operation
nrmx829 normalize  -NaN101 -> -NaN101
nrmx830 normalize -sNaN010 -> -NaN10  Invalid_operation

-- Null test
nrmx900 normalize  # -> NaN Invalid_operation
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































































































































































































































































































Added test/dectest/or.decTest.





























































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
------------------------------------------------------------------------
-- or.decTest -- digitwise logical OR                                 --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

-- Sanity check (truth table)
orx001 or             0    0 ->    0
orx002 or             0    1 ->    1
orx003 or             1    0 ->    1
orx004 or             1    1 ->    1
orx005 or          1100 1010 -> 1110
-- and at msd and msd-1
orx006 or 000000000 000000000 ->           0
orx007 or 000000000 100000000 ->   100000000
orx008 or 100000000 000000000 ->   100000000
orx009 or 100000000 100000000 ->   100000000
orx010 or 000000000 000000000 ->           0
orx011 or 000000000 010000000 ->    10000000
orx012 or 010000000 000000000 ->    10000000
orx013 or 010000000 010000000 ->    10000000

-- Various lengths
--        123456789     123456789      123456789
orx021 or 111111111     111111111  ->  111111111
orx022 or 111111111111  111111111  ->  111111111
orx023 or  11111111      11111111  ->   11111111
orx025 or   1111111       1111111  ->    1111111
orx026 or    111111        111111  ->     111111
orx027 or     11111         11111  ->      11111
orx028 or      1111          1111  ->       1111
orx029 or       111           111  ->        111
orx031 or        11            11  ->         11
orx032 or         1             1  ->          1
orx033 or 111111111111 1111111111  ->  111111111
orx034 or 11111111111 11111111111  ->  111111111
orx035 or 1111111111 111111111111  ->  111111111
orx036 or 111111111 1111111111111  ->  111111111

orx040 or 111111111  111111111111  ->  111111111
orx041 or  11111111  111111111111  ->  111111111
orx042 or  11111111     111111111  ->  111111111
orx043 or   1111111     100000010  ->  101111111
orx044 or    111111     100000100  ->  100111111
orx045 or     11111     100001000  ->  100011111
orx046 or      1111     100010000  ->  100011111
orx047 or       111     100100000  ->  100100111
orx048 or        11     101000000  ->  101000011
orx049 or         1     110000000  ->  110000001

orx050 or 1111111111  1  ->  111111111
orx051 or  111111111  1  ->  111111111
orx052 or   11111111  1  ->  11111111
orx053 or    1111111  1  ->  1111111
orx054 or     111111  1  ->  111111
orx055 or      11111  1  ->  11111
orx056 or       1111  1  ->  1111
orx057 or        111  1  ->  111
orx058 or         11  1  ->  11
orx059 or          1  1  ->  1

orx060 or 1111111111  0  ->  111111111
orx061 or  111111111  0  ->  111111111
orx062 or   11111111  0  ->  11111111
orx063 or    1111111  0  ->  1111111
orx064 or     111111  0  ->  111111
orx065 or      11111  0  ->  11111
orx066 or       1111  0  ->  1111
orx067 or        111  0  ->  111
orx068 or         11  0  ->  11
orx069 or          1  0  ->  1

orx070 or 1  1111111111  ->  111111111
orx071 or 1   111111111  ->  111111111
orx072 or 1    11111111  ->  11111111
orx073 or 1     1111111  ->  1111111
orx074 or 1      111111  ->  111111
orx075 or 1       11111  ->  11111
orx076 or 1        1111  ->  1111
orx077 or 1         111  ->  111
orx078 or 1          11  ->  11
orx079 or 1           1  ->  1

orx080 or 0  1111111111  ->  111111111
orx081 or 0   111111111  ->  111111111
orx082 or 0    11111111  ->  11111111
orx083 or 0     1111111  ->  1111111
orx084 or 0      111111  ->  111111
orx085 or 0       11111  ->  11111
orx086 or 0        1111  ->  1111
orx087 or 0         111  ->  111
orx088 or 0          11  ->  11
orx089 or 0           1  ->  1

orx090 or 011111111  111101111  ->  111111111
orx091 or 101111111  111101111  ->  111111111
orx092 or 110111111  111101111  ->  111111111
orx093 or 111011111  111101111  ->  111111111
orx094 or 111101111  111101111  ->  111101111
orx095 or 111110111  111101111  ->  111111111
orx096 or 111111011  111101111  ->  111111111
orx097 or 111111101  111101111  ->  111111111
orx098 or 111111110  111101111  ->  111111111

orx100 or 111101111  011111111  ->  111111111
orx101 or 111101111  101111111  ->  111111111
orx102 or 111101111  110111111  ->  111111111
orx103 or 111101111  111011111  ->  111111111
orx104 or 111101111  111101111  ->  111101111
orx105 or 111101111  111110111  ->  111111111
orx106 or 111101111  111111011  ->  111111111
orx107 or 111101111  111111101  ->  111111111
orx108 or 111101111  111111110  ->  111111111

-- non-0/1 should not be accepted, nor should signs
orx220 or 111111112  111111111  ->  NaN Invalid_operation
orx221 or 333333333  333333333  ->  NaN Invalid_operation
orx222 or 555555555  555555555  ->  NaN Invalid_operation
orx223 or 777777777  777777777  ->  NaN Invalid_operation
orx224 or 999999999  999999999  ->  NaN Invalid_operation
orx225 or 222222222  999999999  ->  NaN Invalid_operation
orx226 or 444444444  999999999  ->  NaN Invalid_operation
orx227 or 666666666  999999999  ->  NaN Invalid_operation
orx228 or 888888888  999999999  ->  NaN Invalid_operation
orx229 or 999999999  222222222  ->  NaN Invalid_operation
orx230 or 999999999  444444444  ->  NaN Invalid_operation
orx231 or 999999999  666666666  ->  NaN Invalid_operation
orx232 or 999999999  888888888  ->  NaN Invalid_operation
-- a few randoms
orx240 or  567468689 -934981942 ->  NaN Invalid_operation
orx241 or  567367689  934981942 ->  NaN Invalid_operation
orx242 or -631917772 -706014634 ->  NaN Invalid_operation
orx243 or -756253257  138579234 ->  NaN Invalid_operation
orx244 or  835590149  567435400 ->  NaN Invalid_operation
-- test MSD
orx250 or  200000000 100000000 ->  NaN Invalid_operation
orx251 or  700000000 100000000 ->  NaN Invalid_operation
orx252 or  800000000 100000000 ->  NaN Invalid_operation
orx253 or  900000000 100000000 ->  NaN Invalid_operation
orx254 or  200000000 000000000 ->  NaN Invalid_operation
orx255 or  700000000 000000000 ->  NaN Invalid_operation
orx256 or  800000000 000000000 ->  NaN Invalid_operation
orx257 or  900000000 000000000 ->  NaN Invalid_operation
orx258 or  100000000 200000000 ->  NaN Invalid_operation
orx259 or  100000000 700000000 ->  NaN Invalid_operation
orx260 or  100000000 800000000 ->  NaN Invalid_operation
orx261 or  100000000 900000000 ->  NaN Invalid_operation
orx262 or  000000000 200000000 ->  NaN Invalid_operation
orx263 or  000000000 700000000 ->  NaN Invalid_operation
orx264 or  000000000 800000000 ->  NaN Invalid_operation
orx265 or  000000000 900000000 ->  NaN Invalid_operation
-- test MSD-1
orx270 or  020000000 100000000 ->  NaN Invalid_operation
orx271 or  070100000 100000000 ->  NaN Invalid_operation
orx272 or  080010000 100000001 ->  NaN Invalid_operation
orx273 or  090001000 100000010 ->  NaN Invalid_operation
orx274 or  100000100 020010100 ->  NaN Invalid_operation
orx275 or  100000000 070001000 ->  NaN Invalid_operation
orx276 or  100000010 080010100 ->  NaN Invalid_operation
orx277 or  100000000 090000010 ->  NaN Invalid_operation
-- test LSD
orx280 or  001000002 100000000 ->  NaN Invalid_operation
orx281 or  000000007 100000000 ->  NaN Invalid_operation
orx282 or  000000008 100000000 ->  NaN Invalid_operation
orx283 or  000000009 100000000 ->  NaN Invalid_operation
orx284 or  100000000 000100002 ->  NaN Invalid_operation
orx285 or  100100000 001000007 ->  NaN Invalid_operation
orx286 or  100010000 010000008 ->  NaN Invalid_operation
orx287 or  100001000 100000009 ->  NaN Invalid_operation
-- test Middie
orx288 or  001020000 100000000 ->  NaN Invalid_operation
orx289 or  000070001 100000000 ->  NaN Invalid_operation
orx290 or  000080000 100010000 ->  NaN Invalid_operation
orx291 or  000090000 100001000 ->  NaN Invalid_operation
orx292 or  100000010 000020100 ->  NaN Invalid_operation
orx293 or  100100000 000070010 ->  NaN Invalid_operation
orx294 or  100010100 000080001 ->  NaN Invalid_operation
orx295 or  100001000 000090000 ->  NaN Invalid_operation
-- signs
orx296 or -100001000 -000000000 ->  NaN Invalid_operation
orx297 or -100001000  000010000 ->  NaN Invalid_operation
orx298 or  100001000 -000000000 ->  NaN Invalid_operation
orx299 or  100001000  000011000 ->  100011000

-- Nmax, Nmin, Ntiny
orx331 or  2   9.99999999E+999     -> NaN Invalid_operation
orx332 or  3   1E-999              -> NaN Invalid_operation
orx333 or  4   1.00000000E-999     -> NaN Invalid_operation
orx334 or  5   1E-1007             -> NaN Invalid_operation
orx335 or  6   -1E-1007            -> NaN Invalid_operation
orx336 or  7   -1.00000000E-999    -> NaN Invalid_operation
orx337 or  8   -1E-999             -> NaN Invalid_operation
orx338 or  9   -9.99999999E+999    -> NaN Invalid_operation
orx341 or  9.99999999E+999     -18 -> NaN Invalid_operation
orx342 or  1E-999               01 -> NaN Invalid_operation
orx343 or  1.00000000E-999     -18 -> NaN Invalid_operation
orx344 or  1E-1007              18 -> NaN Invalid_operation
orx345 or  -1E-1007            -10 -> NaN Invalid_operation
orx346 or  -1.00000000E-999     18 -> NaN Invalid_operation
orx347 or  -1E-999              10 -> NaN Invalid_operation
orx348 or  -9.99999999E+999    -18 -> NaN Invalid_operation

-- A few other non-integers
orx361 or  1.0                  1  -> NaN Invalid_operation
orx362 or  1E+1                 1  -> NaN Invalid_operation
orx363 or  0.0                  1  -> NaN Invalid_operation
orx364 or  0E+1                 1  -> NaN Invalid_operation
orx365 or  9.9                  1  -> NaN Invalid_operation
orx366 or  9E+1                 1  -> NaN Invalid_operation
orx371 or  0 1.0                   -> NaN Invalid_operation
orx372 or  0 1E+1                  -> NaN Invalid_operation
orx373 or  0 0.0                   -> NaN Invalid_operation
orx374 or  0 0E+1                  -> NaN Invalid_operation
orx375 or  0 9.9                   -> NaN Invalid_operation
orx376 or  0 9E+1                  -> NaN Invalid_operation

-- All Specials are in error
orx780 or -Inf  -Inf   -> NaN Invalid_operation
orx781 or -Inf  -1000  -> NaN Invalid_operation
orx782 or -Inf  -1     -> NaN Invalid_operation
orx783 or -Inf  -0     -> NaN Invalid_operation
orx784 or -Inf   0     -> NaN Invalid_operation
orx785 or -Inf   1     -> NaN Invalid_operation
orx786 or -Inf   1000  -> NaN Invalid_operation
orx787 or -1000 -Inf   -> NaN Invalid_operation
orx788 or -Inf  -Inf   -> NaN Invalid_operation
orx789 or -1    -Inf   -> NaN Invalid_operation
orx790 or -0    -Inf   -> NaN Invalid_operation
orx791 or  0    -Inf   -> NaN Invalid_operation
orx792 or  1    -Inf   -> NaN Invalid_operation
orx793 or  1000 -Inf   -> NaN Invalid_operation
orx794 or  Inf  -Inf   -> NaN Invalid_operation

orx800 or  Inf  -Inf   -> NaN Invalid_operation
orx801 or  Inf  -1000  -> NaN Invalid_operation
orx802 or  Inf  -1     -> NaN Invalid_operation
orx803 or  Inf  -0     -> NaN Invalid_operation
orx804 or  Inf   0     -> NaN Invalid_operation
orx805 or  Inf   1     -> NaN Invalid_operation
orx806 or  Inf   1000  -> NaN Invalid_operation
orx807 or  Inf   Inf   -> NaN Invalid_operation
orx808 or -1000  Inf   -> NaN Invalid_operation
orx809 or -Inf   Inf   -> NaN Invalid_operation
orx810 or -1     Inf   -> NaN Invalid_operation
orx811 or -0     Inf   -> NaN Invalid_operation
orx812 or  0     Inf   -> NaN Invalid_operation
orx813 or  1     Inf   -> NaN Invalid_operation
orx814 or  1000  Inf   -> NaN Invalid_operation
orx815 or  Inf   Inf   -> NaN Invalid_operation

orx821 or  NaN -Inf    -> NaN Invalid_operation
orx822 or  NaN -1000   -> NaN Invalid_operation
orx823 or  NaN -1      -> NaN Invalid_operation
orx824 or  NaN -0      -> NaN Invalid_operation
orx825 or  NaN  0      -> NaN Invalid_operation
orx826 or  NaN  1      -> NaN Invalid_operation
orx827 or  NaN  1000   -> NaN Invalid_operation
orx828 or  NaN  Inf    -> NaN Invalid_operation
orx829 or  NaN  NaN    -> NaN Invalid_operation
orx830 or -Inf  NaN    -> NaN Invalid_operation
orx831 or -1000 NaN    -> NaN Invalid_operation
orx832 or -1    NaN    -> NaN Invalid_operation
orx833 or -0    NaN    -> NaN Invalid_operation
orx834 or  0    NaN    -> NaN Invalid_operation
orx835 or  1    NaN    -> NaN Invalid_operation
orx836 or  1000 NaN    -> NaN Invalid_operation
orx837 or  Inf  NaN    -> NaN Invalid_operation

orx841 or  sNaN -Inf   ->  NaN  Invalid_operation
orx842 or  sNaN -1000  ->  NaN  Invalid_operation
orx843 or  sNaN -1     ->  NaN  Invalid_operation
orx844 or  sNaN -0     ->  NaN  Invalid_operation
orx845 or  sNaN  0     ->  NaN  Invalid_operation
orx846 or  sNaN  1     ->  NaN  Invalid_operation
orx847 or  sNaN  1000  ->  NaN  Invalid_operation
orx848 or  sNaN  NaN   ->  NaN  Invalid_operation
orx849 or  sNaN sNaN   ->  NaN  Invalid_operation
orx850 or  NaN  sNaN   ->  NaN  Invalid_operation
orx851 or -Inf  sNaN   ->  NaN  Invalid_operation
orx852 or -1000 sNaN   ->  NaN  Invalid_operation
orx853 or -1    sNaN   ->  NaN  Invalid_operation
orx854 or -0    sNaN   ->  NaN  Invalid_operation
orx855 or  0    sNaN   ->  NaN  Invalid_operation
orx856 or  1    sNaN   ->  NaN  Invalid_operation
orx857 or  1000 sNaN   ->  NaN  Invalid_operation
orx858 or  Inf  sNaN   ->  NaN  Invalid_operation
orx859 or  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
orx861 or  NaN1   -Inf    -> NaN Invalid_operation
orx862 or +NaN2   -1000   -> NaN Invalid_operation
orx863 or  NaN3    1000   -> NaN Invalid_operation
orx864 or  NaN4    Inf    -> NaN Invalid_operation
orx865 or  NaN5   +NaN6   -> NaN Invalid_operation
orx866 or -Inf     NaN7   -> NaN Invalid_operation
orx867 or -1000    NaN8   -> NaN Invalid_operation
orx868 or  1000    NaN9   -> NaN Invalid_operation
orx869 or  Inf    +NaN10  -> NaN Invalid_operation
orx871 or  sNaN11  -Inf   -> NaN Invalid_operation
orx872 or  sNaN12  -1000  -> NaN Invalid_operation
orx873 or  sNaN13   1000  -> NaN Invalid_operation
orx874 or  sNaN14   NaN17 -> NaN Invalid_operation
orx875 or  sNaN15  sNaN18 -> NaN Invalid_operation
orx876 or  NaN16   sNaN19 -> NaN Invalid_operation
orx877 or -Inf    +sNaN20 -> NaN Invalid_operation
orx878 or -1000    sNaN21 -> NaN Invalid_operation
orx879 or  1000    sNaN22 -> NaN Invalid_operation
orx880 or  Inf     sNaN23 -> NaN Invalid_operation
orx881 or +NaN25  +sNaN24 -> NaN Invalid_operation
orx882 or -NaN26    NaN28 -> NaN Invalid_operation
orx883 or -sNaN27  sNaN29 -> NaN Invalid_operation
orx884 or  1000    -NaN30 -> NaN Invalid_operation
orx885 or  1000   -sNaN31 -> NaN Invalid_operation

Changes to test/dectest/plus.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- plus.decTest -- decimal monadic addition                           --
-- Copyright (c) IBM Corporation, 1981, 2004.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- This set of tests primarily tests the existence of the operator.
-- Addition and rounding, and most overflows, are tested elsewhere.

extended:    1
precision:   9
rounding:    half_up


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- plus.decTest -- decimal monadic addition                           --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests primarily tests the existence of the operator.
-- Addition and rounding, and most overflows, are tested elsewhere.

extended:    1
precision:   9
rounding:    half_up

Changes to test/dectest/power.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- power.decTest -- decimal exponentiation [power(x, y)]              --
-- Copyright (c) IBM Corporation, 1981, 2005.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- In addition to the power operator testcases here, see also the file
-- powersqrt.decTest which includes all the tests from
-- squareroot.decTest implemented using power(x, 0.5)

extended:    1
precision:   16


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- power.decTest -- decimal exponentiation [power(x, y)]              --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- In addition to the power operator testcases here, see also the file
-- powersqrt.decTest which includes all the tests from
-- squareroot.decTest implemented using power(x, 0.5)

extended:    1
precision:   16
1168
1169
1170
1171
1172
1173
1174



1175
1176
1177
1178
1179
1180
1181
precision:   34
powx2500 power 10 0.4342944819032518276511289189166048     -> 2.718281828459045235360287471352661  Inexact Rounded
powx2501 power 10 0.4342944819032518276511289189166049     -> 2.718281828459045235360287471352661  Inexact Rounded
powx2502 power 10 0.4342944819032518276511289189166050     -> 2.718281828459045235360287471352662  Inexact Rounded
powx2503 power 10 0.4342944819032518276511289189166051     -> 2.718281828459045235360287471352663  Inexact Rounded
powx2504 power 10 0.4342944819032518276511289189166052     -> 2.718281828459045235360287471352663  Inexact Rounded




-- Sequence around an integer
powx2512 power 10 2.9999999999999999999999999999999997     -> 999.9999999999999999999999999999993  Inexact Rounded
powx2513 power 10 2.9999999999999999999999999999999998     -> 999.9999999999999999999999999999995  Inexact Rounded
powx2514 power 10 2.9999999999999999999999999999999999     -> 999.9999999999999999999999999999998  Inexact Rounded
powx2515 power 10 3.0000000000000000000000000000000000     -> 1000
powx2516 power 10 3.0000000000000000000000000000000001     -> 1000.000000000000000000000000000000  Inexact Rounded
powx2517 power 10 3.0000000000000000000000000000000002     -> 1000.000000000000000000000000000000  Inexact Rounded







>
>
>







1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
precision:   34
powx2500 power 10 0.4342944819032518276511289189166048     -> 2.718281828459045235360287471352661  Inexact Rounded
powx2501 power 10 0.4342944819032518276511289189166049     -> 2.718281828459045235360287471352661  Inexact Rounded
powx2502 power 10 0.4342944819032518276511289189166050     -> 2.718281828459045235360287471352662  Inexact Rounded
powx2503 power 10 0.4342944819032518276511289189166051     -> 2.718281828459045235360287471352663  Inexact Rounded
powx2504 power 10 0.4342944819032518276511289189166052     -> 2.718281828459045235360287471352663  Inexact Rounded

-- e**e, 16->34
powx2505 power 2.718281828459045 2.718281828459045 -> '15.15426224147925705633739513098219' Inexact Rounded

-- Sequence around an integer
powx2512 power 10 2.9999999999999999999999999999999997     -> 999.9999999999999999999999999999993  Inexact Rounded
powx2513 power 10 2.9999999999999999999999999999999998     -> 999.9999999999999999999999999999995  Inexact Rounded
powx2514 power 10 2.9999999999999999999999999999999999     -> 999.9999999999999999999999999999998  Inexact Rounded
powx2515 power 10 3.0000000000000000000000000000000000     -> 1000
powx2516 power 10 3.0000000000000000000000000000000001     -> 1000.000000000000000000000000000000  Inexact Rounded
powx2517 power 10 3.0000000000000000000000000000000002     -> 1000.000000000000000000000000000000  Inexact Rounded
1558
1559
1560
1561
1562
1563
1564

1565

1566
1567
1568
1569
1570
1571
1572
minExponent: -95

-- For x=nextfp(1)=1.00..001 (where the number of 0s is precision-2)
--   power(x,y)=x when the rounding is up (e.g., toward_pos_inf or
--   ceil) for any y in (0,1].
rounding: ceiling
powx4301  power  1.000001 0          -> 1

powx4302  power  1.000001 1e-101     -> 1.000001   Inexact Rounded

powx4303  power  1.000001 1e-95      -> 1.000001   Inexact Rounded
powx4304  power  1.000001 1e-10      -> 1.000001   Inexact Rounded
powx4305  power  1.000001 0.1        -> 1.000001   Inexact Rounded
powx4306  power  1.000001 0.1234567  -> 1.000001   Inexact Rounded
powx4307  power  1.000001 0.7        -> 1.000001   Inexact Rounded
powx4308  power  1.000001 0.9999999  -> 1.000001   Inexact Rounded
powx4309  power  1.000001 1.000000   -> 1.000001







>

>







1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
minExponent: -95

-- For x=nextfp(1)=1.00..001 (where the number of 0s is precision-2)
--   power(x,y)=x when the rounding is up (e.g., toward_pos_inf or
--   ceil) for any y in (0,1].
rounding: ceiling
powx4301  power  1.000001 0          -> 1
-- The next test should be skipped for decNumber
powx4302  power  1.000001 1e-101     -> 1.000001   Inexact Rounded
-- The next test should be skipped for decNumber
powx4303  power  1.000001 1e-95      -> 1.000001   Inexact Rounded
powx4304  power  1.000001 1e-10      -> 1.000001   Inexact Rounded
powx4305  power  1.000001 0.1        -> 1.000001   Inexact Rounded
powx4306  power  1.000001 0.1234567  -> 1.000001   Inexact Rounded
powx4307  power  1.000001 0.7        -> 1.000001   Inexact Rounded
powx4308  power  1.000001 0.9999999  -> 1.000001   Inexact Rounded
powx4309  power  1.000001 1.000000   -> 1.000001
1583
1584
1585
1586
1587
1588
1589

1590

1591
1592
1593
1594
1595
1596
1597
powx4328  power  1.000001 0.9999999  -> 1.000000   Inexact Rounded
powx4329  power  1.000001 1.000000   -> 1.000001

-- For x=prevfp(1)=0.99..99 (where the number of 9s is precision)
--   power(x,y)=x when the rounding is down for any y in (0,1].
rounding: floor
powx4341  power  0.9999999 0          -> 1

powx4342  power  0.9999999 1e-101     -> 0.9999999   Inexact Rounded

powx4343  power  0.9999999 1e-95      -> 0.9999999   Inexact Rounded
powx4344  power  0.9999999 1e-10      -> 0.9999999   Inexact Rounded
powx4345  power  0.9999999 0.1        -> 0.9999999   Inexact Rounded
powx4346  power  0.9999999 0.1234567  -> 0.9999999   Inexact Rounded
powx4347  power  0.9999999 0.7        -> 0.9999999   Inexact Rounded
powx4348  power  0.9999999 0.9999999  -> 0.9999999   Inexact Rounded
powx4349  power  0.9999999 1.000000   -> 0.9999999







>

>







1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
powx4328  power  1.000001 0.9999999  -> 1.000000   Inexact Rounded
powx4329  power  1.000001 1.000000   -> 1.000001

-- For x=prevfp(1)=0.99..99 (where the number of 9s is precision)
--   power(x,y)=x when the rounding is down for any y in (0,1].
rounding: floor
powx4341  power  0.9999999 0          -> 1
-- The next test should be skipped for decNumber
powx4342  power  0.9999999 1e-101     -> 0.9999999   Inexact Rounded
-- The next test should be skipped for decNumber
powx4343  power  0.9999999 1e-95      -> 0.9999999   Inexact Rounded
powx4344  power  0.9999999 1e-10      -> 0.9999999   Inexact Rounded
powx4345  power  0.9999999 0.1        -> 0.9999999   Inexact Rounded
powx4346  power  0.9999999 0.1234567  -> 0.9999999   Inexact Rounded
powx4347  power  0.9999999 0.7        -> 0.9999999   Inexact Rounded
powx4348  power  0.9999999 0.9999999  -> 0.9999999   Inexact Rounded
powx4349  power  0.9999999 1.000000   -> 0.9999999

Changes to test/dectest/powersqrt.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- powersqrt.decTest -- decimal square root, using power              --
-- Copyright (c) IBM Corporation, 2004.  All rights reserved.         --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- These testcases are taken from squareroot.decTest but are
-- evaluated using the power operator.  The differences in results
-- (153 out of 2856) fall into the following categories:
--
--    x    ** 0.5 (x>0) has no preferred exponent, and is Inexact
--                (and hence full precision); almost all differences are


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- powersqrt.decTest -- decimal square root, using power              --
-- Copyright (c) IBM Corporation, 2004, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- These testcases are taken from squareroot.decTest but are
-- evaluated using the power operator.  The differences in results
-- (153 out of 2856) fall into the following categories:
--
--    x    ** 0.5 (x>0) has no preferred exponent, and is Inexact
--                (and hence full precision); almost all differences are
2933
2934
2935
2936
2937
2938
2939

2940
2941
2942
2943
2944
2945
2946
pwsx801  power 10E-17    0.5 -> 1.00000000E-8 Inexact Rounded
precision: 10               -- Etiny=-18
pwsx802  power 10E-18    0.5 -> 3.162277660E-9 Inexact Rounded
pwsx803  power  1E-18    0.5 -> 1.000000000E-9 Inexact Rounded

precision: 11               -- Etiny=-19
pwsx804  power  1E-19    0.5 -> 3.162277660E-10 Underflow Subnormal Inexact Rounded

pwsx805  power 10E-19    0.5 -> 1.0000000000E-9 Inexact Rounded
precision: 12               -- Etiny=-20
pwsx806  power 10E-20    0.5 -> 3.1622776602E-10 Underflow Subnormal Inexact Rounded
pwsx807  power  1E-20    0.5 -> 1.0000000000E-10 Underflow Subnormal Inexact Rounded

precision: 13               -- Etiny=-21
pwsx808  power  1E-21    0.5 -> 3.1622776602E-11 Underflow Subnormal Inexact Rounded







>







2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
pwsx801  power 10E-17    0.5 -> 1.00000000E-8 Inexact Rounded
precision: 10               -- Etiny=-18
pwsx802  power 10E-18    0.5 -> 3.162277660E-9 Inexact Rounded
pwsx803  power  1E-18    0.5 -> 1.000000000E-9 Inexact Rounded

precision: 11               -- Etiny=-19
pwsx804  power  1E-19    0.5 -> 3.162277660E-10 Underflow Subnormal Inexact Rounded
-- The next test should be skipped for decNumber
pwsx805  power 10E-19    0.5 -> 1.0000000000E-9 Inexact Rounded
precision: 12               -- Etiny=-20
pwsx806  power 10E-20    0.5 -> 3.1622776602E-10 Underflow Subnormal Inexact Rounded
pwsx807  power  1E-20    0.5 -> 1.0000000000E-10 Underflow Subnormal Inexact Rounded

precision: 13               -- Etiny=-21
pwsx808  power  1E-21    0.5 -> 3.1622776602E-11 Underflow Subnormal Inexact Rounded

Changes to test/dectest/quantize.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- quantize.decTest -- decimal quantize operation                     --
-- Copyright (c) IBM Corporation, 1981, 2005.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- Most of the tests here assume a "regular pattern", where the
-- sign and coefficient are +1.
-- 2004.03.15 Underflow for quantize is suppressed
-- 2005.06.08 More extensive tests for 'does not fit'

extended:    1


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- quantize.decTest -- decimal quantize operation                     --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- Most of the tests here assume a "regular pattern", where the
-- sign and coefficient are +1.
-- 2004.03.15 Underflow for quantize is suppressed
-- 2005.06.08 More extensive tests for 'does not fit'

extended:    1
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
quax120 quantize   1.04  1e-3 ->  1.040
quax121 quantize   1.04  1e-2 ->  1.04
quax122 quantize   1.04  1e-1 ->  1.0 Inexact Rounded
quax123 quantize   1.04   1e0 ->  1 Inexact Rounded
quax124 quantize   1.05  1e-3 ->  1.050
quax125 quantize   1.05  1e-2 ->  1.05
quax126 quantize   1.05  1e-1 ->  1.1 Inexact Rounded
quax127 quantize   1.05   1e0 ->  1 Inexact Rounded
quax128 quantize   1.05  1e-3 ->  1.050
quax129 quantize   1.05  1e-2 ->  1.05
quax130 quantize   1.05  1e-1 ->  1.1 Inexact Rounded
quax131 quantize   1.05   1e0 ->  1 Inexact Rounded
quax132 quantize   1.06  1e-3 ->  1.060
quax133 quantize   1.06  1e-2 ->  1.06
quax134 quantize   1.06  1e-1 ->  1.1 Inexact Rounded
quax135 quantize   1.06   1e0 ->  1 Inexact Rounded

quax140 quantize   -10    1e-2  ->  -10.00







<
<
<
<







120
121
122
123
124
125
126




127
128
129
130
131
132
133
quax120 quantize   1.04  1e-3 ->  1.040
quax121 quantize   1.04  1e-2 ->  1.04
quax122 quantize   1.04  1e-1 ->  1.0 Inexact Rounded
quax123 quantize   1.04   1e0 ->  1 Inexact Rounded
quax124 quantize   1.05  1e-3 ->  1.050
quax125 quantize   1.05  1e-2 ->  1.05
quax126 quantize   1.05  1e-1 ->  1.1 Inexact Rounded




quax131 quantize   1.05   1e0 ->  1 Inexact Rounded
quax132 quantize   1.06  1e-3 ->  1.060
quax133 quantize   1.06  1e-2 ->  1.06
quax134 quantize   1.06  1e-1 ->  1.1 Inexact Rounded
quax135 quantize   1.06   1e0 ->  1 Inexact Rounded

quax140 quantize   -10    1e-2  ->  -10.00
884
885
886
887
888
889
890













































891
892
893
894
895
896
897
898
899
900




901
902
903
quax1025 quantize 64#8.666666666666000E+384  64#1E+384   -> 64#8.666666666666000E+384
quax1026 quantize 64#8.666666666666000E+384 128#1E+384   -> 64#9E+384 Inexact Rounded Clamped
quax1027 quantize 64#8.666666666666000E+323  64#1E+31    -> NaN Invalid_operation
quax1028 quantize 64#8.666666666666000E+323 128#1E+31    -> NaN Invalid_operation
quax1029 quantize 64#8.66666666E+3          128#1E+10    -> 64#0E10 Inexact Rounded
quax1030 quantize    8.66666666E+3              1E+3     -> 9E+3 Inexact Rounded














































precision:   34
rounding:    half_up
maxExponent: 6144
minExponent: -6143
--                             1         2         3
--                   1 234567890123456789012345678901234
quax0a1 quantize     8.555555555555555555555555555555555E+6143  1E+6143      -> 9E+6143   Inexact Rounded
quax0a2 quantize 128#8.555555555555555555555555555555555E+6143  128#1E+6143  -> 8.55555555555555555555555555555556E+6143   Rounded Inexact
quax0a3 quantize 128#8.555555555555555555555555555555555E+6144  128#1E+6144  -> 8.555555555555555555555555555555555E+6144





-- Null tests
quax998 quantize 10    # -> NaN Invalid_operation
quax999 quantize  # 1e10 -> NaN Invalid_operation







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










>
>
>
>



880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
quax1025 quantize 64#8.666666666666000E+384  64#1E+384   -> 64#8.666666666666000E+384
quax1026 quantize 64#8.666666666666000E+384 128#1E+384   -> 64#9E+384 Inexact Rounded Clamped
quax1027 quantize 64#8.666666666666000E+323  64#1E+31    -> NaN Invalid_operation
quax1028 quantize 64#8.666666666666000E+323 128#1E+31    -> NaN Invalid_operation
quax1029 quantize 64#8.66666666E+3          128#1E+10    -> 64#0E10 Inexact Rounded
quax1030 quantize    8.66666666E+3              1E+3     -> 9E+3 Inexact Rounded

-- Int and uInt32 edge values for testing conversions
quax1040 quantize -2147483646     0 -> -2147483646
quax1041 quantize -2147483647     0 -> -2147483647
quax1042 quantize -2147483648     0 -> -2147483648
quax1043 quantize -2147483649     0 -> -2147483649
quax1044 quantize  2147483646     0 ->  2147483646
quax1045 quantize  2147483647     0 ->  2147483647
quax1046 quantize  2147483648     0 ->  2147483648
quax1047 quantize  2147483649     0 ->  2147483649
quax1048 quantize  4294967294     0 ->  4294967294
quax1049 quantize  4294967295     0 ->  4294967295
quax1050 quantize  4294967296     0 ->  4294967296
quax1051 quantize  4294967297     0 ->  4294967297
-- and powers of ten for same
quax1101 quantize  5000000000     0 ->  5000000000
quax1102 quantize  4000000000     0 ->  4000000000
quax1103 quantize  2000000000     0 ->  2000000000
quax1104 quantize  1000000000     0 ->  1000000000
quax1105 quantize  0100000000     0 ->  100000000
quax1106 quantize  0010000000     0 ->  10000000
quax1107 quantize  0001000000     0 ->  1000000
quax1108 quantize  0000100000     0 ->  100000
quax1109 quantize  0000010000     0 ->  10000
quax1110 quantize  0000001000     0 ->  1000
quax1111 quantize  0000000100     0 ->  100
quax1112 quantize  0000000010     0 ->  10
quax1113 quantize  0000000001     0 ->  1
quax1114 quantize  0000000000     0 ->  0
-- and powers of ten for same
quax1121 quantize -5000000000     0 -> -5000000000
quax1122 quantize -4000000000     0 -> -4000000000
quax1123 quantize -2000000000     0 -> -2000000000
quax1124 quantize -1000000000     0 -> -1000000000
quax1125 quantize -0100000000     0 -> -100000000
quax1126 quantize -0010000000     0 -> -10000000
quax1127 quantize -0001000000     0 -> -1000000
quax1128 quantize -0000100000     0 -> -100000
quax1129 quantize -0000010000     0 -> -10000
quax1130 quantize -0000001000     0 -> -1000
quax1131 quantize -0000000100     0 -> -100
quax1132 quantize -0000000010     0 -> -10
quax1133 quantize -0000000001     0 -> -1
quax1134 quantize -0000000000     0 -> -0

-- Some miscellany
precision:   34
rounding:    half_up
maxExponent: 6144
minExponent: -6143
--                             1         2         3
--                   1 234567890123456789012345678901234
quax0a1 quantize     8.555555555555555555555555555555555E+6143  1E+6143      -> 9E+6143   Inexact Rounded
quax0a2 quantize 128#8.555555555555555555555555555555555E+6143  128#1E+6143  -> 8.55555555555555555555555555555556E+6143   Rounded Inexact
quax0a3 quantize 128#8.555555555555555555555555555555555E+6144  128#1E+6144  -> 8.555555555555555555555555555555555E+6144

-- payload decapitate
precision: 5
quax62100 quantize 11 -sNaN1234567890 -> -NaN67890  Invalid_operation

-- Null tests
quax998 quantize 10    # -> NaN Invalid_operation
quax999 quantize  # 1e10 -> NaN Invalid_operation

Changes to test/dectest/randombound32.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- randomBound32.decTest -- decimal testcases -- boundaries near 32   --
-- Copyright (c) IBM Corporation, 1981, 2003.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- These testcases test calculations at precisions 31, 32, and 33, to
-- exercise the boundaries around 2**5

-- randomly generated testcases [26 Sep 2001]
extended:    1
precision:   31


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- randomBound32.decTest -- decimal testcases -- boundaries near 32   --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- These testcases test calculations at precisions 31, 32, and 33, to
-- exercise the boundaries around 2**5

-- randomly generated testcases [26 Sep 2001]
extended:    1
precision:   31

Changes to test/dectest/randoms.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- randoms.decTest -- decimal random testcases                        --
-- Copyright (c) IBM Corporation, 1981, 2003.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
maxexponent: 999999999
minexponent: -999999999
precision:   9
rounding:    half_up



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- randoms.decTest -- decimal random testcases                        --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
maxexponent: 999999999
minexponent: -999999999
precision:   9
rounding:    half_up

Added test/dectest/reduce.decTest.





















































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
------------------------------------------------------------------------
-- reduce.decTest -- remove trailing zeros                            --
-- Copyright (c) IBM Corporation, 2003, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
-- [This used to be called normalize.]

version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minexponent: -999

redx001 reduce '1'      -> '1'
redx002 reduce '-1'     -> '-1'
redx003 reduce '1.00'   -> '1'
redx004 reduce '-1.00'  -> '-1'
redx005 reduce '0'      -> '0'
redx006 reduce '0.00'   -> '0'
redx007 reduce '00.0'   -> '0'
redx008 reduce '00.00'  -> '0'
redx009 reduce '00'     -> '0'
redx010 reduce '0E+1'   -> '0'
redx011 reduce '0E+5'   -> '0'

redx012 reduce '-2'     -> '-2'
redx013 reduce '2'      -> '2'
redx014 reduce '-2.00'  -> '-2'
redx015 reduce '2.00'   -> '2'
redx016 reduce '-0'     -> '-0'
redx017 reduce '-0.00'  -> '-0'
redx018 reduce '-00.0'  -> '-0'
redx019 reduce '-00.00' -> '-0'
redx020 reduce '-00'    -> '-0'
redx021 reduce '-0E+5'   -> '-0'
redx022 reduce '-0E+1'  -> '-0'

redx030 reduce '+0.1'            -> '0.1'
redx031 reduce '-0.1'            -> '-0.1'
redx032 reduce '+0.01'           -> '0.01'
redx033 reduce '-0.01'           -> '-0.01'
redx034 reduce '+0.001'          -> '0.001'
redx035 reduce '-0.001'          -> '-0.001'
redx036 reduce '+0.000001'       -> '0.000001'
redx037 reduce '-0.000001'       -> '-0.000001'
redx038 reduce '+0.000000000001' -> '1E-12'
redx039 reduce '-0.000000000001' -> '-1E-12'

redx041 reduce 1.1        -> 1.1
redx042 reduce 1.10       -> 1.1
redx043 reduce 1.100      -> 1.1
redx044 reduce 1.110      -> 1.11
redx045 reduce -1.1       -> -1.1
redx046 reduce -1.10      -> -1.1
redx047 reduce -1.100     -> -1.1
redx048 reduce -1.110     -> -1.11
redx049 reduce 9.9        -> 9.9
redx050 reduce 9.90       -> 9.9
redx051 reduce 9.900      -> 9.9
redx052 reduce 9.990      -> 9.99
redx053 reduce -9.9       -> -9.9
redx054 reduce -9.90      -> -9.9
redx055 reduce -9.900     -> -9.9
redx056 reduce -9.990     -> -9.99

-- some trailing fractional zeros with zeros in units
redx060 reduce  10.0        -> 1E+1
redx061 reduce  10.00       -> 1E+1
redx062 reduce  100.0       -> 1E+2
redx063 reduce  100.00      -> 1E+2
redx064 reduce  1.1000E+3   -> 1.1E+3
redx065 reduce  1.10000E+3  -> 1.1E+3
redx066 reduce -10.0        -> -1E+1
redx067 reduce -10.00       -> -1E+1
redx068 reduce -100.0       -> -1E+2
redx069 reduce -100.00      -> -1E+2
redx070 reduce -1.1000E+3   -> -1.1E+3
redx071 reduce -1.10000E+3  -> -1.1E+3

-- some insignificant trailing zeros with positive exponent
redx080 reduce  10E+1       -> 1E+2
redx081 reduce  100E+1      -> 1E+3
redx082 reduce  1.0E+2      -> 1E+2
redx083 reduce  1.0E+3      -> 1E+3
redx084 reduce  1.1E+3      -> 1.1E+3
redx085 reduce  1.00E+3     -> 1E+3
redx086 reduce  1.10E+3     -> 1.1E+3
redx087 reduce -10E+1       -> -1E+2
redx088 reduce -100E+1      -> -1E+3
redx089 reduce -1.0E+2      -> -1E+2
redx090 reduce -1.0E+3      -> -1E+3
redx091 reduce -1.1E+3      -> -1.1E+3
redx092 reduce -1.00E+3     -> -1E+3
redx093 reduce -1.10E+3     -> -1.1E+3

-- some significant trailing zeros, were we to be trimming
redx100 reduce  11          -> 11
redx101 reduce  10          -> 1E+1
redx102 reduce  10.         -> 1E+1
redx103 reduce  1.1E+1      -> 11
redx104 reduce  1.0E+1      -> 1E+1
redx105 reduce  1.10E+2     -> 1.1E+2
redx106 reduce  1.00E+2     -> 1E+2
redx107 reduce  1.100E+3    -> 1.1E+3
redx108 reduce  1.000E+3    -> 1E+3
redx109 reduce  1.000000E+6 -> 1E+6
redx110 reduce -11          -> -11
redx111 reduce -10          -> -1E+1
redx112 reduce -10.         -> -1E+1
redx113 reduce -1.1E+1      -> -11
redx114 reduce -1.0E+1      -> -1E+1
redx115 reduce -1.10E+2     -> -1.1E+2
redx116 reduce -1.00E+2     -> -1E+2
redx117 reduce -1.100E+3    -> -1.1E+3
redx118 reduce -1.000E+3    -> -1E+3
redx119 reduce -1.00000E+5  -> -1E+5
redx120 reduce -1.000000E+6 -> -1E+6
redx121 reduce -10.00000E+6 -> -1E+7
redx122 reduce -100.0000E+6 -> -1E+8
redx123 reduce -1000.000E+6 -> -1E+9
redx124 reduce -10000.00E+6 -> -1E+10
redx125 reduce -100000.0E+6 -> -1E+11
redx126 reduce -1000000.E+6 -> -1E+12

-- examples from decArith
redx140 reduce '2.1'     ->  '2.1'
redx141 reduce '-2.0'    ->  '-2'
redx142 reduce '1.200'   ->  '1.2'
redx143 reduce '-120'    ->  '-1.2E+2'
redx144 reduce '120.00'  ->  '1.2E+2'
redx145 reduce '0.00'    ->  '0'

-- overflow tests
maxexponent: 999999999
minexponent: -999999999
precision: 3
redx160 reduce 9.999E+999999999  ->  Infinity Inexact Overflow Rounded
redx161 reduce -9.999E+999999999 -> -Infinity Inexact Overflow Rounded

-- subnormals and underflow
precision: 3
maxexponent: 999
minexponent: -999
redx210 reduce  1.00E-999        ->   1E-999
redx211 reduce  0.1E-999         ->   1E-1000   Subnormal
redx212 reduce  0.10E-999        ->   1E-1000   Subnormal
redx213 reduce  0.100E-999       ->   1E-1000   Subnormal Rounded
redx214 reduce  0.01E-999        ->   1E-1001   Subnormal
-- next is rounded to Emin
redx215 reduce  0.999E-999       ->   1E-999    Inexact Rounded Subnormal Underflow
redx216 reduce  0.099E-999       ->   1E-1000   Inexact Rounded Subnormal Underflow
redx217 reduce  0.009E-999       ->   1E-1001   Inexact Rounded Subnormal Underflow
redx218 reduce  0.001E-999       ->   0         Inexact Rounded Subnormal Underflow Clamped
redx219 reduce  0.0009E-999      ->   0         Inexact Rounded Subnormal Underflow Clamped
redx220 reduce  0.0001E-999      ->   0         Inexact Rounded Subnormal Underflow Clamped

redx230 reduce -1.00E-999        ->  -1E-999
redx231 reduce -0.1E-999         ->  -1E-1000   Subnormal
redx232 reduce -0.10E-999        ->  -1E-1000   Subnormal
redx233 reduce -0.100E-999       ->  -1E-1000   Subnormal Rounded
redx234 reduce -0.01E-999        ->  -1E-1001   Subnormal
-- next is rounded to Emin
redx235 reduce -0.999E-999       ->  -1E-999    Inexact Rounded Subnormal Underflow
redx236 reduce -0.099E-999       ->  -1E-1000   Inexact Rounded Subnormal Underflow
redx237 reduce -0.009E-999       ->  -1E-1001   Inexact Rounded Subnormal Underflow
redx238 reduce -0.001E-999       ->  -0         Inexact Rounded Subnormal Underflow Clamped
redx239 reduce -0.0009E-999      ->  -0         Inexact Rounded Subnormal Underflow Clamped
redx240 reduce -0.0001E-999      ->  -0         Inexact Rounded Subnormal Underflow Clamped

-- more reshaping
precision: 9
redx260 reduce '56260E-10'   -> '0.000005626'
redx261 reduce '56260E-5'    -> '0.5626'
redx262 reduce '56260E-2'    -> '562.6'
redx263 reduce '56260E-1'    -> '5626'
redx265 reduce '56260E-0'    -> '5.626E+4'
redx266 reduce '56260E+0'    -> '5.626E+4'
redx267 reduce '56260E+1'    -> '5.626E+5'
redx268 reduce '56260E+2'    -> '5.626E+6'
redx269 reduce '56260E+3'    -> '5.626E+7'
redx270 reduce '56260E+4'    -> '5.626E+8'
redx271 reduce '56260E+5'    -> '5.626E+9'
redx272 reduce '56260E+6'    -> '5.626E+10'
redx280 reduce '-56260E-10'  -> '-0.000005626'
redx281 reduce '-56260E-5'   -> '-0.5626'
redx282 reduce '-56260E-2'   -> '-562.6'
redx283 reduce '-56260E-1'   -> '-5626'
redx285 reduce '-56260E-0'   -> '-5.626E+4'
redx286 reduce '-56260E+0'   -> '-5.626E+4'
redx287 reduce '-56260E+1'   -> '-5.626E+5'
redx288 reduce '-56260E+2'   -> '-5.626E+6'
redx289 reduce '-56260E+3'   -> '-5.626E+7'
redx290 reduce '-56260E+4'   -> '-5.626E+8'
redx291 reduce '-56260E+5'   -> '-5.626E+9'
redx292 reduce '-56260E+6'   -> '-5.626E+10'

-- FL test
precision: 40
redx295 reduce 9892345673.0123456780000000000 -> 9892345673.012345678

-- specials
redx820 reduce 'Inf'    -> 'Infinity'
redx821 reduce '-Inf'   -> '-Infinity'
redx822 reduce   NaN    ->  NaN
redx823 reduce  sNaN    ->  NaN    Invalid_operation
redx824 reduce   NaN101 ->  NaN101
redx825 reduce  sNaN010 ->  NaN10  Invalid_operation
redx827 reduce  -NaN    -> -NaN
redx828 reduce -sNaN    -> -NaN    Invalid_operation
redx829 reduce  -NaN101 -> -NaN101
redx830 reduce -sNaN010 -> -NaN10  Invalid_operation

-- payload decapitate
precision: 5
redx62100 reduce  sNaN1234567890 -> NaN67890  Invalid_operation

-- Null test
redx900 reduce  # -> NaN Invalid_operation

Changes to test/dectest/remainder.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- remainder.decTest -- decimal remainder                             --
-- Copyright (c) IBM Corporation, 1981, 2004.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- remainder.decTest -- decimal remainder                             --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

Changes to test/dectest/remaindernear.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- remainderNear.decTest -- decimal remainder-near (IEEE remainder)   --
-- Copyright (c) IBM Corporation, 1981, 2004.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- remainderNear.decTest -- decimal remainder-near (IEEE remainder)   --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

Changes to test/dectest/rescale.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- rescale.decTest -- decimal rescale operation                       --
-- Copyright (c) IBM Corporation, 1981, 2005.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- [obsolete]   Quantize.decTest has the improved version

-- 2004.03.15 Underflow for quantize is suppressed

extended:    1
precision:   9


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- rescale.decTest -- decimal rescale operation                       --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- [obsolete]   Quantize.decTest has the improved version

-- 2004.03.15 Underflow for quantize is suppressed

extended:    1
precision:   9

Added test/dectest/rotate.decTest.















































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
------------------------------------------------------------------------
-- rotate.decTest -- rotate coefficient left or right                 --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

-- Sanity check
rotx001 rotate          0    0  ->  0
rotx002 rotate          0    2  ->  0
rotx003 rotate          1    2  ->  100
rotx004 rotate         34    8  ->  400000003
rotx005 rotate          1    9  ->  1
rotx006 rotate          1   -1  ->  100000000
rotx007 rotate  123456789   -1  ->  912345678
rotx008 rotate  123456789   -8  ->  234567891
rotx009 rotate  123456789   -9  ->  123456789
rotx010 rotate          0   -2  ->  0

-- rhs must be an integer
rotx011 rotate        1    1.5    -> NaN Invalid_operation
rotx012 rotate        1    1.0    -> NaN Invalid_operation
rotx013 rotate        1    0.1    -> NaN Invalid_operation
rotx014 rotate        1    0.0    -> NaN Invalid_operation
rotx015 rotate        1    1E+1   -> NaN Invalid_operation
rotx016 rotate        1    1E+99  -> NaN Invalid_operation
rotx017 rotate        1    Inf    -> NaN Invalid_operation
rotx018 rotate        1    -Inf   -> NaN Invalid_operation
-- and |rhs| <= precision
rotx020 rotate        1    -1000  -> NaN Invalid_operation
rotx021 rotate        1    -10    -> NaN Invalid_operation
rotx022 rotate        1     10    -> NaN Invalid_operation
rotx023 rotate        1     1000  -> NaN Invalid_operation

-- full pattern
rotx030 rotate  123456789          -9   -> 123456789
rotx031 rotate  123456789          -8   -> 234567891
rotx032 rotate  123456789          -7   -> 345678912
rotx033 rotate  123456789          -6   -> 456789123
rotx034 rotate  123456789          -5   -> 567891234
rotx035 rotate  123456789          -4   -> 678912345
rotx036 rotate  123456789          -3   -> 789123456
rotx037 rotate  123456789          -2   -> 891234567
rotx038 rotate  123456789          -1   -> 912345678
rotx039 rotate  123456789          -0   -> 123456789
rotx040 rotate  123456789          +0   -> 123456789
rotx041 rotate  123456789          +1   -> 234567891
rotx042 rotate  123456789          +2   -> 345678912
rotx043 rotate  123456789          +3   -> 456789123
rotx044 rotate  123456789          +4   -> 567891234
rotx045 rotate  123456789          +5   -> 678912345
rotx046 rotate  123456789          +6   -> 789123456
rotx047 rotate  123456789          +7   -> 891234567
rotx048 rotate  123456789          +8   -> 912345678
rotx049 rotate  123456789          +9   -> 123456789

-- zeros
rotx060 rotate  0E-10              +9   ->   0E-10
rotx061 rotate  0E-10              -9   ->   0E-10
rotx062 rotate  0.000              +9   ->   0.000
rotx063 rotate  0.000              -9   ->   0.000
rotx064 rotate  0E+10              +9   ->   0E+10
rotx065 rotate  0E+10              -9   ->   0E+10
rotx066 rotate -0E-10              +9   ->  -0E-10
rotx067 rotate -0E-10              -9   ->  -0E-10
rotx068 rotate -0.000              +9   ->  -0.000
rotx069 rotate -0.000              -9   ->  -0.000
rotx070 rotate -0E+10              +9   ->  -0E+10
rotx071 rotate -0E+10              -9   ->  -0E+10

-- Nmax, Nmin, Ntiny
rotx141 rotate  9.99999999E+999     -1  -> 9.99999999E+999
rotx142 rotate  9.99999999E+999     -8  -> 9.99999999E+999
rotx143 rotate  9.99999999E+999      1  -> 9.99999999E+999
rotx144 rotate  9.99999999E+999      8  -> 9.99999999E+999
rotx145 rotate  1E-999              -1  -> 1.00000000E-991
rotx146 rotate  1E-999              -8  -> 1.0E-998
rotx147 rotate  1E-999               1  -> 1.0E-998
rotx148 rotate  1E-999               8  -> 1.00000000E-991
rotx151 rotate  1.00000000E-999     -1  -> 1.0000000E-1000
rotx152 rotate  1.00000000E-999     -8  -> 1E-1007
rotx153 rotate  1.00000000E-999      1  -> 1E-1007
rotx154 rotate  1.00000000E-999      8  -> 1.0000000E-1000
rotx155 rotate  9.00000000E-999     -1  -> 9.0000000E-1000
rotx156 rotate  9.00000000E-999     -8  -> 9E-1007
rotx157 rotate  9.00000000E-999      1  -> 9E-1007
rotx158 rotate  9.00000000E-999      8  -> 9.0000000E-1000
rotx160 rotate  1E-1007             -1  -> 1.00000000E-999
rotx161 rotate  1E-1007             -8  -> 1.0E-1006
rotx162 rotate  1E-1007              1  -> 1.0E-1006
rotx163 rotate  1E-1007              8  -> 1.00000000E-999
--  negatives
rotx171 rotate -9.99999999E+999     -1  -> -9.99999999E+999
rotx172 rotate -9.99999999E+999     -8  -> -9.99999999E+999
rotx173 rotate -9.99999999E+999      1  -> -9.99999999E+999
rotx174 rotate -9.99999999E+999      8  -> -9.99999999E+999
rotx175 rotate -1E-999              -1  -> -1.00000000E-991
rotx176 rotate -1E-999              -8  -> -1.0E-998
rotx177 rotate -1E-999               1  -> -1.0E-998
rotx178 rotate -1E-999               8  -> -1.00000000E-991
rotx181 rotate -1.00000000E-999     -1  -> -1.0000000E-1000
rotx182 rotate -1.00000000E-999     -8  -> -1E-1007
rotx183 rotate -1.00000000E-999      1  -> -1E-1007
rotx184 rotate -1.00000000E-999      8  -> -1.0000000E-1000
rotx185 rotate -9.00000000E-999     -1  -> -9.0000000E-1000
rotx186 rotate -9.00000000E-999     -8  -> -9E-1007
rotx187 rotate -9.00000000E-999      1  -> -9E-1007
rotx188 rotate -9.00000000E-999      8  -> -9.0000000E-1000
rotx190 rotate -1E-1007             -1  -> -1.00000000E-999
rotx191 rotate -1E-1007             -8  -> -1.0E-1006
rotx192 rotate -1E-1007              1  -> -1.0E-1006
rotx193 rotate -1E-1007              8  -> -1.00000000E-999

-- more negatives (of sanities)
rotx201 rotate         -0    0  ->  -0
rotx202 rotate         -0    2  ->  -0
rotx203 rotate         -1    2  ->  -100
rotx204 rotate         -1    8  ->  -100000000
rotx205 rotate         -1    9  ->  -1
rotx206 rotate         -1   -1  ->  -100000000
rotx207 rotate -123456789   -1  ->  -912345678
rotx208 rotate -123456789   -8  ->  -234567891
rotx209 rotate -123456789   -9  ->  -123456789
rotx210 rotate         -0   -2  ->  -0

-- Specials; NaNs are handled as usual
rotx781 rotate -Inf  -8     -> -Infinity
rotx782 rotate -Inf  -1     -> -Infinity
rotx783 rotate -Inf  -0     -> -Infinity
rotx784 rotate -Inf   0     -> -Infinity
rotx785 rotate -Inf   1     -> -Infinity
rotx786 rotate -Inf   8     -> -Infinity
rotx787 rotate -1000 -Inf   -> NaN Invalid_operation
rotx788 rotate -Inf  -Inf   -> NaN Invalid_operation
rotx789 rotate -1    -Inf   -> NaN Invalid_operation
rotx790 rotate -0    -Inf   -> NaN Invalid_operation
rotx791 rotate  0    -Inf   -> NaN Invalid_operation
rotx792 rotate  1    -Inf   -> NaN Invalid_operation
rotx793 rotate  1000 -Inf   -> NaN Invalid_operation
rotx794 rotate  Inf  -Inf   -> NaN Invalid_operation

rotx800 rotate  Inf  -Inf   -> NaN Invalid_operation
rotx801 rotate  Inf  -8     -> Infinity
rotx802 rotate  Inf  -1     -> Infinity
rotx803 rotate  Inf  -0     -> Infinity
rotx804 rotate  Inf   0     -> Infinity
rotx805 rotate  Inf   1     -> Infinity
rotx806 rotate  Inf   8     -> Infinity
rotx807 rotate  Inf   Inf   -> NaN Invalid_operation
rotx808 rotate -1000  Inf   -> NaN Invalid_operation
rotx809 rotate -Inf   Inf   -> NaN Invalid_operation
rotx810 rotate -1     Inf   -> NaN Invalid_operation
rotx811 rotate -0     Inf   -> NaN Invalid_operation
rotx812 rotate  0     Inf   -> NaN Invalid_operation
rotx813 rotate  1     Inf   -> NaN Invalid_operation
rotx814 rotate  1000  Inf   -> NaN Invalid_operation
rotx815 rotate  Inf   Inf   -> NaN Invalid_operation

rotx821 rotate  NaN -Inf    ->  NaN
rotx822 rotate  NaN -1000   ->  NaN
rotx823 rotate  NaN -1      ->  NaN
rotx824 rotate  NaN -0      ->  NaN
rotx825 rotate  NaN  0      ->  NaN
rotx826 rotate  NaN  1      ->  NaN
rotx827 rotate  NaN  1000   ->  NaN
rotx828 rotate  NaN  Inf    ->  NaN
rotx829 rotate  NaN  NaN    ->  NaN
rotx830 rotate -Inf  NaN    ->  NaN
rotx831 rotate -1000 NaN    ->  NaN
rotx832 rotate -1    NaN    ->  NaN
rotx833 rotate -0    NaN    ->  NaN
rotx834 rotate  0    NaN    ->  NaN
rotx835 rotate  1    NaN    ->  NaN
rotx836 rotate  1000 NaN    ->  NaN
rotx837 rotate  Inf  NaN    ->  NaN



rotx841 rotate  sNaN -Inf   ->  NaN  Invalid_operation
rotx842 rotate  sNaN -1000  ->  NaN  Invalid_operation
rotx843 rotate  sNaN -1     ->  NaN  Invalid_operation
rotx844 rotate  sNaN -0     ->  NaN  Invalid_operation
rotx845 rotate  sNaN  0     ->  NaN  Invalid_operation
rotx846 rotate  sNaN  1     ->  NaN  Invalid_operation
rotx847 rotate  sNaN  1000  ->  NaN  Invalid_operation
rotx848 rotate  sNaN  NaN   ->  NaN  Invalid_operation
rotx849 rotate  sNaN sNaN   ->  NaN  Invalid_operation
rotx850 rotate  NaN  sNaN   ->  NaN  Invalid_operation
rotx851 rotate -Inf  sNaN   ->  NaN  Invalid_operation
rotx852 rotate -1000 sNaN   ->  NaN  Invalid_operation
rotx853 rotate -1    sNaN   ->  NaN  Invalid_operation
rotx854 rotate -0    sNaN   ->  NaN  Invalid_operation
rotx855 rotate  0    sNaN   ->  NaN  Invalid_operation
rotx856 rotate  1    sNaN   ->  NaN  Invalid_operation
rotx857 rotate  1000 sNaN   ->  NaN  Invalid_operation
rotx858 rotate  Inf  sNaN   ->  NaN  Invalid_operation
rotx859 rotate  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
rotx861 rotate  NaN1   -Inf    ->  NaN1
rotx862 rotate +NaN2   -1000   ->  NaN2
rotx863 rotate  NaN3    1000   ->  NaN3
rotx864 rotate  NaN4    Inf    ->  NaN4
rotx865 rotate  NaN5   +NaN6   ->  NaN5
rotx866 rotate -Inf     NaN7   ->  NaN7
rotx867 rotate -1000    NaN8   ->  NaN8
rotx868 rotate  1000    NaN9   ->  NaN9
rotx869 rotate  Inf    +NaN10  ->  NaN10
rotx871 rotate  sNaN11  -Inf   ->  NaN11  Invalid_operation
rotx872 rotate  sNaN12  -1000  ->  NaN12  Invalid_operation
rotx873 rotate  sNaN13   1000  ->  NaN13  Invalid_operation
rotx874 rotate  sNaN14   NaN17 ->  NaN14  Invalid_operation
rotx875 rotate  sNaN15  sNaN18 ->  NaN15  Invalid_operation
rotx876 rotate  NaN16   sNaN19 ->  NaN19  Invalid_operation
rotx877 rotate -Inf    +sNaN20 ->  NaN20  Invalid_operation
rotx878 rotate -1000    sNaN21 ->  NaN21  Invalid_operation
rotx879 rotate  1000    sNaN22 ->  NaN22  Invalid_operation
rotx880 rotate  Inf     sNaN23 ->  NaN23  Invalid_operation
rotx881 rotate +NaN25  +sNaN24 ->  NaN24  Invalid_operation
rotx882 rotate -NaN26    NaN28 -> -NaN26
rotx883 rotate -sNaN27  sNaN29 -> -NaN27  Invalid_operation
rotx884 rotate  1000    -NaN30 -> -NaN30
rotx885 rotate  1000   -sNaN31 -> -NaN31  Invalid_operation

-- payload decapitate
precision: 5
rotx886 rotate  11 -sNaN1234567890 -> -NaN67890  Invalid_operation

Changes to test/dectest/rounding.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28



29
30
31
32
33
34
35
36
37
------------------------------------------------------------------------
-- rounding.decTest -- decimal rounding modes testcases               --
-- Copyright (c) IBM Corporation, 1981, 2003.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- These tests require that implementations take account of residues in
-- order to get correct results for some rounding modes.  Rather than
-- single rounding tests we therefore need tests for most operators.
-- [We do assume add/minus/plus/subtract are common paths, however, as
-- is rounding of negatives (if the latter works for addition, assume it
-- works for the others, too).]
--



-- Underflow Subnormal and overflow behaviours are tested under the individual
-- operators.

extended:    1
precision:   5           -- for easier visual inspection
maxExponent: 999
minexponent: -999

-- Addition operators -------------------------------------------------


|
















|








>
>
>
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
------------------------------------------------------------------------
-- rounding.decTest -- decimal rounding modes testcases               --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- These tests require that implementations take account of residues in
-- order to get correct results for some rounding modes.  Rather than
-- single rounding tests we therefore need tests for most operators.
-- [We do assume add/minus/plus/subtract are common paths, however, as
-- is rounding of negatives (if the latter works for addition, assume it
-- works for the others, too).]
--
-- Round-for-reround (05UP) is tested as a separate block, mostly for
-- 'historical' reasons.
--
-- Underflow Subnormal and overflow behaviours are tested under the
-- individual operators.

extended:    1
precision:   5           -- for easier visual inspection
maxExponent: 999
minexponent: -999

-- Addition operators -------------------------------------------------
1073
1074
1075
1076
1077
1078
1079





























































































































































































































rounding: up
rmex410 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded
rmex411 multiply  9.999E+999999999 10 ->  Infinity Overflow Inexact Rounded
rounding: down
rmex412 multiply -9.999E+999999999 10 -> -9.99999999E+999999999 Overflow Inexact Rounded
rmex413 multiply  9.999E+999999999 10 ->  9.99999999E+999999999 Overflow Inexact Rounded





































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
rounding: up
rmex410 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded
rmex411 multiply  9.999E+999999999 10 ->  Infinity Overflow Inexact Rounded
rounding: down
rmex412 multiply -9.999E+999999999 10 -> -9.99999999E+999999999 Overflow Inexact Rounded
rmex413 multiply  9.999E+999999999 10 ->  9.99999999E+999999999 Overflow Inexact Rounded

----- Round-for-reround -----
rounding:    05up
precision:   5           -- for easier visual inspection
maxExponent: 999
minexponent: -999

-- basic rounding; really is just 0 and 5 up
r05up001 add 12340  0.001     -> 12341 Inexact Rounded
r05up002 add 12341  0.001     -> 12341 Inexact Rounded
r05up003 add 12342  0.001     -> 12342 Inexact Rounded
r05up004 add 12343  0.001     -> 12343 Inexact Rounded
r05up005 add 12344  0.001     -> 12344 Inexact Rounded
r05up006 add 12345  0.001     -> 12346 Inexact Rounded
r05up007 add 12346  0.001     -> 12346 Inexact Rounded
r05up008 add 12347  0.001     -> 12347 Inexact Rounded
r05up009 add 12348  0.001     -> 12348 Inexact Rounded
r05up010 add 12349  0.001     -> 12349 Inexact Rounded

r05up011 add 12340  0.000     -> 12340 Rounded
r05up012 add 12341  0.000     -> 12341 Rounded
r05up013 add 12342  0.000     -> 12342 Rounded
r05up014 add 12343  0.000     -> 12343 Rounded
r05up015 add 12344  0.000     -> 12344 Rounded
r05up016 add 12345  0.000     -> 12345 Rounded
r05up017 add 12346  0.000     -> 12346 Rounded
r05up018 add 12347  0.000     -> 12347 Rounded
r05up019 add 12348  0.000     -> 12348 Rounded
r05up020 add 12349  0.000     -> 12349 Rounded

r05up021 add 12340  0.901     -> 12341 Inexact Rounded
r05up022 add 12341  0.901     -> 12341 Inexact Rounded
r05up023 add 12342  0.901     -> 12342 Inexact Rounded
r05up024 add 12343  0.901     -> 12343 Inexact Rounded
r05up025 add 12344  0.901     -> 12344 Inexact Rounded
r05up026 add 12345  0.901     -> 12346 Inexact Rounded
r05up027 add 12346  0.901     -> 12346 Inexact Rounded
r05up028 add 12347  0.901     -> 12347 Inexact Rounded
r05up029 add 12348  0.901     -> 12348 Inexact Rounded
r05up030 add 12349  0.901     -> 12349 Inexact Rounded

r05up031 add -12340  -0.001     -> -12341 Inexact Rounded
r05up032 add -12341  -0.001     -> -12341 Inexact Rounded
r05up033 add -12342  -0.001     -> -12342 Inexact Rounded
r05up034 add -12343  -0.001     -> -12343 Inexact Rounded
r05up035 add -12344  -0.001     -> -12344 Inexact Rounded
r05up036 add -12345  -0.001     -> -12346 Inexact Rounded
r05up037 add -12346  -0.001     -> -12346 Inexact Rounded
r05up038 add -12347  -0.001     -> -12347 Inexact Rounded
r05up039 add -12348  -0.001     -> -12348 Inexact Rounded
r05up040 add -12349  -0.001     -> -12349 Inexact Rounded

r05up041 add -12340   0.001     -> -12339 Inexact Rounded
r05up042 add -12341   0.001     -> -12341 Inexact Rounded
r05up043 add -12342   0.001     -> -12341 Inexact Rounded
r05up044 add -12343   0.001     -> -12342 Inexact Rounded
r05up045 add -12344   0.001     -> -12343 Inexact Rounded
r05up046 add -12345   0.001     -> -12344 Inexact Rounded
r05up047 add -12346   0.001     -> -12346 Inexact Rounded
r05up048 add -12347   0.001     -> -12346 Inexact Rounded
r05up049 add -12348   0.001     -> -12347 Inexact Rounded
r05up050 add -12349   0.001     -> -12348 Inexact Rounded

-- Addition operators -------------------------------------------------
-- [The first few of these check negative residue possibilities; these
-- cases may be implemented as a negative residue in fastpaths]

r0adx100  add 12345 -0.1       -> 12344 Inexact Rounded
r0adx101  add 12345 -0.01      -> 12344 Inexact Rounded
r0adx102  add 12345 -0.001     -> 12344 Inexact Rounded
r0adx103  add 12345 -0.00001   -> 12344 Inexact Rounded
r0adx104  add 12345 -0.000001  -> 12344 Inexact Rounded
r0adx105  add 12345 -0.0000001 -> 12344 Inexact Rounded
r0adx106  add 12345  0         -> 12345
r0adx107  add 12345  0.0000001 -> 12346 Inexact Rounded
r0adx108  add 12345  0.000001  -> 12346 Inexact Rounded
r0adx109  add 12345  0.00001   -> 12346 Inexact Rounded
r0adx110  add 12345  0.0001    -> 12346 Inexact Rounded
r0adx111  add 12345  0.001     -> 12346 Inexact Rounded
r0adx112  add 12345  0.01      -> 12346 Inexact Rounded
r0adx113  add 12345  0.1       -> 12346 Inexact Rounded

r0adx115  add 12346  0.49999   -> 12346 Inexact Rounded
r0adx116  add 12346  0.5       -> 12346 Inexact Rounded
r0adx117  add 12346  0.50001   -> 12346 Inexact Rounded

r0adx120  add 12345  0.4       -> 12346 Inexact Rounded
r0adx121  add 12345  0.49      -> 12346 Inexact Rounded
r0adx122  add 12345  0.499     -> 12346 Inexact Rounded
r0adx123  add 12345  0.49999   -> 12346 Inexact Rounded
r0adx124  add 12345  0.5       -> 12346 Inexact Rounded
r0adx125  add 12345  0.50001   -> 12346 Inexact Rounded
r0adx126  add 12345  0.5001    -> 12346 Inexact Rounded
r0adx127  add 12345  0.501     -> 12346 Inexact Rounded
r0adx128  add 12345  0.51      -> 12346 Inexact Rounded
r0adx129  add 12345  0.6       -> 12346 Inexact Rounded

-- negatives...

r0sux100  add -12345 -0.1       -> -12346 Inexact Rounded
r0sux101  add -12345 -0.01      -> -12346 Inexact Rounded
r0sux102  add -12345 -0.001     -> -12346 Inexact Rounded
r0sux103  add -12345 -0.00001   -> -12346 Inexact Rounded
r0sux104  add -12345 -0.000001  -> -12346 Inexact Rounded
r0sux105  add -12345 -0.0000001 -> -12346 Inexact Rounded
r0sux106  add -12345  0         -> -12345
r0sux107  add -12345  0.0000001 -> -12344 Inexact Rounded
r0sux108  add -12345  0.000001  -> -12344 Inexact Rounded
r0sux109  add -12345  0.00001   -> -12344 Inexact Rounded
r0sux110  add -12345  0.0001    -> -12344 Inexact Rounded
r0sux111  add -12345  0.001     -> -12344 Inexact Rounded
r0sux112  add -12345  0.01      -> -12344 Inexact Rounded
r0sux113  add -12345  0.1       -> -12344 Inexact Rounded

r0sux115  add -12346  0.49999   -> -12346 Inexact Rounded
r0sux116  add -12346  0.5       -> -12346 Inexact Rounded
r0sux117  add -12346  0.50001   -> -12346 Inexact Rounded

r0sux120  add -12345  0.4       -> -12344 Inexact Rounded
r0sux121  add -12345  0.49      -> -12344 Inexact Rounded
r0sux122  add -12345  0.499     -> -12344 Inexact Rounded
r0sux123  add -12345  0.49999   -> -12344 Inexact Rounded
r0sux124  add -12345  0.5       -> -12344 Inexact Rounded
r0sux125  add -12345  0.50001   -> -12344 Inexact Rounded
r0sux126  add -12345  0.5001    -> -12344 Inexact Rounded
r0sux127  add -12345  0.501     -> -12344 Inexact Rounded
r0sux128  add -12345  0.51      -> -12344 Inexact Rounded
r0sux129  add -12345  0.6       -> -12344 Inexact Rounded

-- Check cancellation subtractions
-- (The IEEE 854 'curious rule' in $6.3)

r0zex001  add  0    0    ->  0
r0zex002  add  0   -0    ->  0
r0zex003  add -0    0    ->  0
r0zex004  add -0   -0    -> -0
r0zex005  add  1   -1    ->  0
r0zex006  add -1    1    ->  0
r0zex007  add  1.5 -1.5  ->  0.0
r0zex008  add -1.5  1.5  ->  0.0
r0zex009  add  2   -2    ->  0
r0zex010  add -2    2    ->  0


-- Division operators -------------------------------------------------

r0dvx101  divide 12345  1         ->  12345
r0dvx102  divide 12345  1.0001    ->  12343 Inexact Rounded
r0dvx103  divide 12345  1.001     ->  12332 Inexact Rounded
r0dvx104  divide 12345  1.01      ->  12222 Inexact Rounded
r0dvx105  divide 12345  1.1       ->  11222 Inexact Rounded
r0dvx106  divide 12355  4         ->   3088.7 Inexact Rounded
r0dvx107  divide 12345  4         ->   3086.2 Inexact Rounded
r0dvx108  divide 12355  4.0001    ->   3088.6 Inexact Rounded
r0dvx109  divide 12345  4.0001    ->   3086.1 Inexact Rounded
r0dvx110  divide 12345  4.9       ->   2519.3 Inexact Rounded
r0dvx111  divide 12345  4.99      ->   2473.9 Inexact Rounded
r0dvx112  divide 12345  4.999     ->   2469.4 Inexact Rounded
r0dvx113  divide 12345  4.9999    ->   2469.1 Inexact Rounded
r0dvx114  divide 12345  5         ->   2469
r0dvx115  divide 12345  5.0001    ->  2468.9 Inexact Rounded
r0dvx116  divide 12345  5.001     ->  2468.6 Inexact Rounded
r0dvx117  divide 12345  5.01      ->  2464.1 Inexact Rounded
r0dvx118  divide 12345  5.1       ->  2420.6 Inexact Rounded

-- [divideInteger and remainder unaffected]

-- Multiplication operator --------------------------------------------

r0mux101  multiply 12345  1         ->  12345
r0mux102  multiply 12345  1.0001    ->  12346 Inexact Rounded
r0mux103  multiply 12345  1.001     ->  12357 Inexact Rounded
r0mux104  multiply 12345  1.01      ->  12468 Inexact Rounded
r0mux105  multiply 12345  1.1       ->  13579 Inexact Rounded
r0mux106  multiply 12345  4         ->  49380
r0mux107  multiply 12345  4.0001    ->  49381 Inexact Rounded
r0mux108  multiply 12345  4.9       ->  60491 Inexact Rounded
r0mux109  multiply 12345  4.99      ->  61601 Inexact Rounded
r0mux110  multiply 12345  4.999     ->  61712 Inexact Rounded
r0mux111  multiply 12345  4.9999    ->  61723 Inexact Rounded
r0mux112  multiply 12345  5         ->  61725
r0mux113  multiply 12345  5.0001    ->  61726 Inexact Rounded
r0mux114  multiply 12345  5.001     ->  61737 Inexact Rounded
r0mux115  multiply 12345  5.01      ->  61848 Inexact Rounded
r0mux116  multiply 12345  12        ->  1.4814E+5 Rounded
r0mux117  multiply 12345  13        ->  1.6048E+5 Inexact Rounded
r0mux118  multiply 12355  12        ->  1.4826E+5 Rounded
r0mux119  multiply 12355  13        ->  1.6061E+5 Inexact Rounded


-- Power operator -----------------------------------------------------

r0pox101  power 12345  -5        ->  3.4877E-21 Inexact Rounded
r0pox102  power 12345  -4        ->  4.3056E-17 Inexact Rounded
r0pox103  power 12345  -3        ->  5.3152E-13 Inexact Rounded
r0pox104  power 12345  -2        ->  6.5617E-9 Inexact Rounded
r0pox105  power 12345  -1        ->  0.000081004 Inexact Rounded
r0pox106  power 12345  0         ->  1
r0pox107  power 12345  1         ->  12345
r0pox108  power 12345  2         ->  1.5239E+8 Inexact Rounded
r0pox109  power 12345  3         ->  1.8813E+12 Inexact Rounded
r0pox110  power 12345  4         ->  2.3226E+16 Inexact Rounded
r0pox111  power 12345  5         ->  2.8671E+20 Inexact Rounded
r0pox112  power   415  2         ->  1.7222E+5 Inexact Rounded
r0pox113  power    75  3         ->  4.2187E+5 Inexact Rounded


-- Underflow Subnormal and overflow values vary with rounding mode and sign
maxexponent: 999999999
minexponent: -999999999
-- [round down gives Nmax on first two and .0E... on the next two]
r0ovx100  multiply   10    9E+999999999 ->  Infinity Overflow Inexact Rounded
r0ovx101  multiply  -10    9E+999999999 -> -Infinity Overflow Inexact Rounded
r0ovx102  divide     1E-9  9E+999999999 ->  1E-1000000003 Underflow Subnormal Inexact Rounded
r0ovx104  divide    -1E-9  9E+999999999 -> -1E-1000000003 Underflow Subnormal Inexact Rounded

-- reprise rounding mode effect (using multiplies so precision directive used)
precision: 9
maxexponent: 999999999
r0mex412 multiply -9.999E+999999999 10 -> -Infinity Overflow Inexact Rounded
r0mex413 multiply  9.999E+999999999 10 ->  Infinity Overflow Inexact Rounded

Changes to test/dectest/samequantum.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- samequantum.decTest -- check quantums match                        --
-- Copyright (c) IBM Corporation, 2001, 2003.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- samequantum.decTest -- check quantums match                        --
-- Copyright (c) IBM Corporation, 2001, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

60
61
62
63
64
65
66









67








68



















69
70
71
72
73
74
75
samq044 samequantum -0E-17  0.0E-16 -> 1
samq045 samequantum  0E-17 -0.0E-17 -> 0
samq046 samequantum  0E-17 -0.0E-16 -> 1
samq047 samequantum -0E-17  0.0E-17 -> 0
samq048 samequantum -0E-17 -0.0E-16 -> 1
samq049 samequantum -0E-17 -0.0E-17 -> 0










-- specials & combinations




























samq0110 samequantum  -Inf    -Inf   -> 1
samq0111 samequantum  -Inf     Inf   -> 1
samq0112 samequantum  -Inf     NaN   -> 0
samq0113 samequantum  -Inf    -7E+3  -> 0
samq0114 samequantum  -Inf    -7     -> 0
samq0115 samequantum  -Inf    -7E-3  -> 0
samq0116 samequantum  -Inf    -0E-3  -> 0







>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
samq044 samequantum -0E-17  0.0E-16 -> 1
samq045 samequantum  0E-17 -0.0E-17 -> 0
samq046 samequantum  0E-17 -0.0E-16 -> 1
samq047 samequantum -0E-17  0.0E-17 -> 0
samq048 samequantum -0E-17 -0.0E-16 -> 1
samq049 samequantum -0E-17 -0.0E-17 -> 0

-- Nmax, Nmin, Ntiny
samq051 samequantum  9.99999999E+999    9.99999999E+999  -> 1
samq052 samequantum  1E-999             1E-999           -> 1
samq053 samequantum  1.00000000E-999    1.00000000E-999  -> 1
samq054 samequantum  1E-1007            1E-1007          -> 1
samq055 samequantum  9.99999999E+999    9.99999999E+999  -> 1
samq056 samequantum  1E-999             1E-999           -> 1
samq057 samequantum  1.00000000E-999    1.00000000E-999  -> 1
samq058 samequantum  1E-1007            1E-1007          -> 1

samq061 samequantum  -1E-1007           -1E-1007         -> 1
samq062 samequantum  -1.00000000E-999   -1.00000000E-999 -> 1
samq063 samequantum  -1E-999            -1E-999          -> 1
samq064 samequantum  -9.99999999E+999   -9.99999999E+999 -> 1
samq065 samequantum  -1E-1007           -1E-1007         -> 1
samq066 samequantum  -1.00000000E-999   -1.00000000E-999 -> 1
samq067 samequantum  -1E-999            -1E-999          -> 1
samq068 samequantum  -9.99999999E+999   -9.99999999E+999 -> 1

samq071 samequantum  -4E-1007           -1E-1007         -> 1
samq072 samequantum  -4.00000000E-999   -1.00004000E-999 -> 1
samq073 samequantum  -4E-999            -1E-999          -> 1
samq074 samequantum  -4.99999999E+999   -9.99949999E+999 -> 1
samq075 samequantum  -4E-1007           -1E-1007         -> 1
samq076 samequantum  -4.00000000E-999   -1.00400000E-999 -> 1
samq077 samequantum  -4E-999            -1E-999          -> 1
samq078 samequantum  -4.99999999E+999   -9.94999999E+999 -> 1

samq081 samequantum  -4E-1006           -1E-1007         -> 0
samq082 samequantum  -4.00000000E-999   -1.00004000E-996 -> 0
samq083 samequantum  -4E-996            -1E-999          -> 0
samq084 samequantum  -4.99999999E+999   -9.99949999E+996 -> 0
samq085 samequantum  -4E-1006           -1E-1007         -> 0
samq086 samequantum  -4.00000000E-999   -1.00400000E-996 -> 0
samq087 samequantum  -4E-996            -1E-999          -> 0
samq088 samequantum  -4.99999999E+999   -9.94999999E+996 -> 0

-- specials & combinations
samq0110 samequantum  -Inf    -Inf   -> 1
samq0111 samequantum  -Inf     Inf   -> 1
samq0112 samequantum  -Inf     NaN   -> 0
samq0113 samequantum  -Inf    -7E+3  -> 0
samq0114 samequantum  -Inf    -7     -> 0
samq0115 samequantum  -Inf    -7E-3  -> 0
samq0116 samequantum  -Inf    -0E-3  -> 0

Added test/dectest/scaleb.decTest.

















































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
------------------------------------------------------------------------
-- scaleb.decTest -- scale a number by powers of 10                   --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

-- Max |rhs| is 2*(999+9) = 2016

-- Sanity checks
scbx001 scaleb       7.50   10 -> 7.50E+10
scbx002 scaleb       7.50    3 -> 7.50E+3
scbx003 scaleb       7.50    2 -> 750
scbx004 scaleb       7.50    1 -> 75.0
scbx005 scaleb       7.50    0 -> 7.50
scbx006 scaleb       7.50   -1 -> 0.750
scbx007 scaleb       7.50   -2 -> 0.0750
scbx008 scaleb       7.50  -10 -> 7.50E-10
scbx009 scaleb      -7.50    3 -> -7.50E+3
scbx010 scaleb      -7.50    2 -> -750
scbx011 scaleb      -7.50    1 -> -75.0
scbx012 scaleb      -7.50    0 -> -7.50
scbx013 scaleb      -7.50   -1 -> -0.750

-- Infinities
scbx014 scaleb  Infinity   1 -> Infinity
scbx015 scaleb  -Infinity  2 -> -Infinity
scbx016 scaleb  Infinity  -1 -> Infinity
scbx017 scaleb  -Infinity -2 -> -Infinity

-- Next two are somewhat undefined in 754r; treat as non-integer
scbx018 scaleb  10  Infinity -> NaN Invalid_operation
scbx019 scaleb  10 -Infinity -> NaN Invalid_operation

-- NaNs are undefined in 754r; assume usual processing
-- NaNs, 0 payload
scbx021 scaleb         NaN  1 -> NaN
scbx022 scaleb        -NaN -1 -> -NaN
scbx023 scaleb        sNaN  1 -> NaN Invalid_operation
scbx024 scaleb       -sNaN  1 -> -NaN Invalid_operation
scbx025 scaleb    4    NaN    -> NaN
scbx026 scaleb -Inf   -NaN    -> -NaN
scbx027 scaleb    4   sNaN    -> NaN Invalid_operation
scbx028 scaleb  Inf  -sNaN    -> -NaN Invalid_operation

-- non-integer RHS
scbx030 scaleb  1.23    1    ->  12.3
scbx031 scaleb  1.23    1.00 ->  NaN Invalid_operation
scbx032 scaleb  1.23    1.1  ->  NaN Invalid_operation
scbx033 scaleb  1.23    1.01 ->  NaN Invalid_operation
scbx034 scaleb  1.23    0.01 ->  NaN Invalid_operation
scbx035 scaleb  1.23    0.11 ->  NaN Invalid_operation
scbx036 scaleb  1.23    0.999999999 ->  NaN Invalid_operation
scbx037 scaleb  1.23   -1    ->  0.123
scbx038 scaleb  1.23   -1.00 ->  NaN Invalid_operation
scbx039 scaleb  1.23   -1.1  ->  NaN Invalid_operation
scbx040 scaleb  1.23   -1.01 ->  NaN Invalid_operation
scbx041 scaleb  1.23   -0.01 ->  NaN Invalid_operation
scbx042 scaleb  1.23   -0.11 ->  NaN Invalid_operation
scbx043 scaleb  1.23   -0.999999999 ->  NaN Invalid_operation
scbx044 scaleb  1.23    0.1         ->  NaN Invalid_operation
scbx045 scaleb  1.23    1E+1        ->  NaN Invalid_operation
scbx046 scaleb  1.23    1.1234E+6   ->  NaN Invalid_operation
scbx047 scaleb  1.23    1.123E+4    ->  NaN Invalid_operation


scbx120 scaleb  1.23    2015        ->  Infinity Overflow Inexact Rounded
scbx121 scaleb  1.23    2016        ->  Infinity Overflow Inexact Rounded
scbx122 scaleb  1.23    2017        ->  NaN Invalid_operation
scbx123 scaleb  1.23    2018        ->  NaN Invalid_operation
scbx124 scaleb  1.23   -2015        ->  0E-1007 Underflow Subnormal Inexact Rounded Clamped
scbx125 scaleb  1.23   -2016        ->  0E-1007 Underflow Subnormal Inexact Rounded Clamped
scbx126 scaleb  1.23   -2017        ->  NaN Invalid_operation
scbx127 scaleb  1.23   -2018        ->  NaN Invalid_operation

-- NaNs, non-0 payload
-- propagating NaNs
scbx861 scaleb  NaN01   -Inf     ->  NaN1
scbx862 scaleb -NaN02   -1000    -> -NaN2
scbx863 scaleb  NaN03    1000    ->  NaN3
scbx864 scaleb  NaN04    Inf     ->  NaN4
scbx865 scaleb  NaN05    NaN61   ->  NaN5
scbx866 scaleb -Inf     -NaN71   -> -NaN71
scbx867 scaleb -1000     NaN81   ->  NaN81
scbx868 scaleb  1000     NaN91   ->  NaN91
scbx869 scaleb  Inf      NaN101  ->  NaN101
scbx871 scaleb  sNaN011  -Inf    ->  NaN11  Invalid_operation
scbx872 scaleb  sNaN012  -1000   ->  NaN12  Invalid_operation
scbx873 scaleb -sNaN013   1000   -> -NaN13  Invalid_operation
scbx874 scaleb  sNaN014   NaN171 ->  NaN14  Invalid_operation
scbx875 scaleb  sNaN015  sNaN181 ->  NaN15  Invalid_operation
scbx876 scaleb  NaN016   sNaN191 ->  NaN191 Invalid_operation
scbx877 scaleb -Inf      sNaN201 ->  NaN201 Invalid_operation
scbx878 scaleb -1000     sNaN211 ->  NaN211 Invalid_operation
scbx879 scaleb  1000    -sNaN221 -> -NaN221 Invalid_operation
scbx880 scaleb  Inf      sNaN231 ->  NaN231 Invalid_operation
scbx881 scaleb  NaN025   sNaN241 ->  NaN241 Invalid_operation

-- finites
scbx051 scaleb          7   -2  -> 0.07
scbx052 scaleb         -7   -2  -> -0.07
scbx053 scaleb         75   -2  -> 0.75
scbx054 scaleb        -75   -2  -> -0.75
scbx055 scaleb       7.50   -2  -> 0.0750
scbx056 scaleb      -7.50   -2  -> -0.0750
scbx057 scaleb       7.500  -2  -> 0.07500
scbx058 scaleb      -7.500  -2  -> -0.07500
scbx061 scaleb          7   -1  -> 0.7
scbx062 scaleb         -7   -1  -> -0.7
scbx063 scaleb         75   -1  -> 7.5
scbx064 scaleb        -75   -1  -> -7.5
scbx065 scaleb       7.50   -1  -> 0.750
scbx066 scaleb      -7.50   -1  -> -0.750
scbx067 scaleb       7.500  -1  -> 0.7500
scbx068 scaleb      -7.500  -1  -> -0.7500
scbx071 scaleb          7    0  -> 7
scbx072 scaleb         -7    0  -> -7
scbx073 scaleb         75    0  -> 75
scbx074 scaleb        -75    0  -> -75
scbx075 scaleb       7.50    0  -> 7.50
scbx076 scaleb      -7.50    0  -> -7.50
scbx077 scaleb       7.500   0  -> 7.500
scbx078 scaleb      -7.500   0  -> -7.500
scbx081 scaleb          7    1  -> 7E+1
scbx082 scaleb         -7    1  -> -7E+1
scbx083 scaleb         75    1  -> 7.5E+2
scbx084 scaleb        -75    1  -> -7.5E+2
scbx085 scaleb       7.50    1  -> 75.0
scbx086 scaleb      -7.50    1  -> -75.0
scbx087 scaleb       7.500   1  -> 75.00
scbx088 scaleb      -7.500   1  -> -75.00
scbx091 scaleb          7    2  -> 7E+2
scbx092 scaleb         -7    2  -> -7E+2
scbx093 scaleb         75    2  -> 7.5E+3
scbx094 scaleb        -75    2  -> -7.5E+3
scbx095 scaleb       7.50    2  -> 750
scbx096 scaleb      -7.50    2  -> -750
scbx097 scaleb       7.500   2  -> 750.0
scbx098 scaleb      -7.500   2  -> -750.0

-- zeros
scbx111 scaleb          0  1 -> 0E+1
scbx112 scaleb         -0  2 -> -0E+2
scbx113 scaleb       0E+4  3 -> 0E+7
scbx114 scaleb      -0E+4  4 -> -0E+8
scbx115 scaleb     0.0000  5 -> 0E+1
scbx116 scaleb    -0.0000  6 -> -0E+2
scbx117 scaleb      0E-141 7 -> 0E-134
scbx118 scaleb     -0E-141 8 -> -0E-133

-- Nmax, Nmin, Ntiny
scbx132 scaleb  9.99999999E+999 +999 -> Infinity    Overflow Inexact Rounded
scbx133 scaleb  9.99999999E+999  +10 -> Infinity     Overflow Inexact Rounded
scbx134 scaleb  9.99999999E+999  +1  -> Infinity     Overflow Inexact Rounded
scbx135 scaleb  9.99999999E+999   0  -> 9.99999999E+999
scbx136 scaleb  9.99999999E+999  -1  -> 9.99999999E+998
scbx137 scaleb  1E-999           +1  -> 1E-998
scbx138 scaleb  1E-999           -0  -> 1E-999
scbx139 scaleb  1E-999           -1  -> 1E-1000         Subnormal
scbx140 scaleb  1.00000000E-999  +1  -> 1.00000000E-998
scbx141 scaleb  1.00000000E-999   0  -> 1.00000000E-999
scbx142 scaleb  1.00000000E-999  -1  -> 1.0000000E-1000 Subnormal Rounded
scbx143 scaleb  1E-1007          +1  -> 1E-1006         Subnormal
scbx144 scaleb  1E-1007          -0  -> 1E-1007         Subnormal
scbx145 scaleb  1E-1007          -1  -> 0E-1007         Underflow Subnormal Inexact Rounded Clamped

scbx150 scaleb  -1E-1007         +1  -> -1E-1006        Subnormal
scbx151 scaleb  -1E-1007         -0  -> -1E-1007        Subnormal
scbx152 scaleb  -1E-1007         -1  -> -0E-1007        Underflow Subnormal Inexact Rounded Clamped
scbx153 scaleb  -1.00000000E-999 +1  -> -1.00000000E-998
scbx154 scaleb  -1.00000000E-999 +0  -> -1.00000000E-999
scbx155 scaleb  -1.00000000E-999 -1  -> -1.0000000E-1000 Subnormal Rounded
scbx156 scaleb  -1E-999          +1  -> -1E-998
scbx157 scaleb  -1E-999          -0  -> -1E-999
scbx158 scaleb  -1E-999          -1  -> -1E-1000         Subnormal
scbx159 scaleb  -9.99999999E+999 +1  -> -Infinity        Overflow Inexact Rounded
scbx160 scaleb  -9.99999999E+999 +0  -> -9.99999999E+999
scbx161 scaleb  -9.99999999E+999 -1  -> -9.99999999E+998
scbx162 scaleb  -9E+999          +1  -> -Infinity        Overflow Inexact Rounded
scbx163 scaleb  -1E+999          +1  -> -Infinity        Overflow Inexact Rounded

Added test/dectest/shift.decTest.





















































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
------------------------------------------------------------------------
-- shift.decTest -- shift coefficient left or right                   --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

-- Sanity check
shix001 shift          0    0  ->  0
shix002 shift          0    2  ->  0
shix003 shift          1    2  ->  100
shix004 shift          1    8  ->  100000000
shix005 shift          1    9  ->  0
shix006 shift          1   -1  ->  0
shix007 shift  123456789   -1  ->  12345678
shix008 shift  123456789   -8  ->  1
shix009 shift  123456789   -9  ->  0
shix010 shift          0   -2  ->  0

-- rhs must be an integer
shix011 shift        1    1.5    -> NaN Invalid_operation
shix012 shift        1    1.0    -> NaN Invalid_operation
shix013 shift        1    0.1    -> NaN Invalid_operation
shix014 shift        1    0.0    -> NaN Invalid_operation
shix015 shift        1    1E+1   -> NaN Invalid_operation
shix016 shift        1    1E+99  -> NaN Invalid_operation
shix017 shift        1    Inf    -> NaN Invalid_operation
shix018 shift        1    -Inf   -> NaN Invalid_operation
-- and |rhs| <= precision
shix020 shift        1    -1000  -> NaN Invalid_operation
shix021 shift        1    -10    -> NaN Invalid_operation
shix022 shift        1     10    -> NaN Invalid_operation
shix023 shift        1     1000  -> NaN Invalid_operation

-- full shifting pattern
shix030 shift  123456789          -9   -> 0
shix031 shift  123456789          -8   -> 1
shix032 shift  123456789          -7   -> 12
shix033 shift  123456789          -6   -> 123
shix034 shift  123456789          -5   -> 1234
shix035 shift  123456789          -4   -> 12345
shix036 shift  123456789          -3   -> 123456
shix037 shift  123456789          -2   -> 1234567
shix038 shift  123456789          -1   -> 12345678
shix039 shift  123456789          -0   -> 123456789
shix040 shift  123456789          +0   -> 123456789
shix041 shift  123456789          +1   -> 234567890
shix042 shift  123456789          +2   -> 345678900
shix043 shift  123456789          +3   -> 456789000
shix044 shift  123456789          +4   -> 567890000
shix045 shift  123456789          +5   -> 678900000
shix046 shift  123456789          +6   -> 789000000
shix047 shift  123456789          +7   -> 890000000
shix048 shift  123456789          +8   -> 900000000
shix049 shift  123456789          +9   -> 0

-- from examples
shix051 shift 34        8   ->  '400000000'
shix052 shift 12        9   ->  '0'
shix053 shift 123456789 -2  ->  '1234567'
shix054 shift 123456789 0   ->  '123456789'
shix055 shift 123456789 +2  ->  '345678900'

-- zeros
shix060 shift  0E-10              +9   ->   0E-10
shix061 shift  0E-10              -9   ->   0E-10
shix062 shift  0.000              +9   ->   0.000
shix063 shift  0.000              -9   ->   0.000
shix064 shift  0E+10              +9   ->   0E+10
shix065 shift  0E+10              -9   ->   0E+10
shix066 shift -0E-10              +9   ->  -0E-10
shix067 shift -0E-10              -9   ->  -0E-10
shix068 shift -0.000              +9   ->  -0.000
shix069 shift -0.000              -9   ->  -0.000
shix070 shift -0E+10              +9   ->  -0E+10
shix071 shift -0E+10              -9   ->  -0E+10

-- Nmax, Nmin, Ntiny
shix141 shift  9.99999999E+999     -1  -> 9.9999999E+998
shix142 shift  9.99999999E+999     -8  -> 9E+991
shix143 shift  9.99999999E+999      1  -> 9.99999990E+999
shix144 shift  9.99999999E+999      8  -> 9.00000000E+999
shix145 shift  1E-999              -1  -> 0E-999
shix146 shift  1E-999              -8  -> 0E-999
shix147 shift  1E-999               1  -> 1.0E-998
shix148 shift  1E-999               8  -> 1.00000000E-991
shix151 shift  1.00000000E-999     -1  -> 1.0000000E-1000
shix152 shift  1.00000000E-999     -8  -> 1E-1007
shix153 shift  1.00000000E-999      1  -> 0E-1007
shix154 shift  1.00000000E-999      8  -> 0E-1007
shix155 shift  9.00000000E-999     -1  -> 9.0000000E-1000
shix156 shift  9.00000000E-999     -8  -> 9E-1007
shix157 shift  9.00000000E-999      1  -> 0E-1007
shix158 shift  9.00000000E-999      8  -> 0E-1007
shix160 shift  1E-1007             -1  -> 0E-1007
shix161 shift  1E-1007             -8  -> 0E-1007
shix162 shift  1E-1007              1  -> 1.0E-1006
shix163 shift  1E-1007              8  -> 1.00000000E-999
--  negatives
shix171 shift -9.99999999E+999     -1  -> -9.9999999E+998
shix172 shift -9.99999999E+999     -8  -> -9E+991
shix173 shift -9.99999999E+999      1  -> -9.99999990E+999
shix174 shift -9.99999999E+999      8  -> -9.00000000E+999
shix175 shift -1E-999              -1  -> -0E-999
shix176 shift -1E-999              -8  -> -0E-999
shix177 shift -1E-999               1  -> -1.0E-998
shix178 shift -1E-999               8  -> -1.00000000E-991
shix181 shift -1.00000000E-999     -1  -> -1.0000000E-1000
shix182 shift -1.00000000E-999     -8  -> -1E-1007
shix183 shift -1.00000000E-999      1  -> -0E-1007
shix184 shift -1.00000000E-999      8  -> -0E-1007
shix185 shift -9.00000000E-999     -1  -> -9.0000000E-1000
shix186 shift -9.00000000E-999     -8  -> -9E-1007
shix187 shift -9.00000000E-999      1  -> -0E-1007
shix188 shift -9.00000000E-999      8  -> -0E-1007
shix190 shift -1E-1007             -1  -> -0E-1007
shix191 shift -1E-1007             -8  -> -0E-1007
shix192 shift -1E-1007              1  -> -1.0E-1006
shix193 shift -1E-1007              8  -> -1.00000000E-999

-- more negatives (of sanities)
shix201 shift         -0    0  ->  -0
shix202 shift         -0    2  ->  -0
shix203 shift         -1    2  ->  -100
shix204 shift         -1    8  ->  -100000000
shix205 shift         -1    9  ->  -0
shix206 shift         -1   -1  ->  -0
shix207 shift -123456789   -1  ->  -12345678
shix208 shift -123456789   -8  ->  -1
shix209 shift -123456789   -9  ->  -0
shix210 shift         -0   -2  ->  -0
shix211 shift         -0   -0  ->  -0


-- Specials; NaNs are handled as usual
shix781 shift -Inf  -8     -> -Infinity
shix782 shift -Inf  -1     -> -Infinity
shix783 shift -Inf  -0     -> -Infinity
shix784 shift -Inf   0     -> -Infinity
shix785 shift -Inf   1     -> -Infinity
shix786 shift -Inf   8     -> -Infinity
shix787 shift -1000 -Inf   -> NaN Invalid_operation
shix788 shift -Inf  -Inf   -> NaN Invalid_operation
shix789 shift -1    -Inf   -> NaN Invalid_operation
shix790 shift -0    -Inf   -> NaN Invalid_operation
shix791 shift  0    -Inf   -> NaN Invalid_operation
shix792 shift  1    -Inf   -> NaN Invalid_operation
shix793 shift  1000 -Inf   -> NaN Invalid_operation
shix794 shift  Inf  -Inf   -> NaN Invalid_operation

shix800 shift  Inf  -Inf   -> NaN Invalid_operation
shix801 shift  Inf  -8     -> Infinity
shix802 shift  Inf  -1     -> Infinity
shix803 shift  Inf  -0     -> Infinity
shix804 shift  Inf   0     -> Infinity
shix805 shift  Inf   1     -> Infinity
shix806 shift  Inf   8     -> Infinity
shix807 shift  Inf   Inf   -> NaN Invalid_operation
shix808 shift -1000  Inf   -> NaN Invalid_operation
shix809 shift -Inf   Inf   -> NaN Invalid_operation
shix810 shift -1     Inf   -> NaN Invalid_operation
shix811 shift -0     Inf   -> NaN Invalid_operation
shix812 shift  0     Inf   -> NaN Invalid_operation
shix813 shift  1     Inf   -> NaN Invalid_operation
shix814 shift  1000  Inf   -> NaN Invalid_operation
shix815 shift  Inf   Inf   -> NaN Invalid_operation

shix821 shift  NaN -Inf    ->  NaN
shix822 shift  NaN -1000   ->  NaN
shix823 shift  NaN -1      ->  NaN
shix824 shift  NaN -0      ->  NaN
shix825 shift  NaN  0      ->  NaN
shix826 shift  NaN  1      ->  NaN
shix827 shift  NaN  1000   ->  NaN
shix828 shift  NaN  Inf    ->  NaN
shix829 shift  NaN  NaN    ->  NaN
shix830 shift -Inf  NaN    ->  NaN
shix831 shift -1000 NaN    ->  NaN
shix832 shift -1    NaN    ->  NaN
shix833 shift -0    NaN    ->  NaN
shix834 shift  0    NaN    ->  NaN
shix835 shift  1    NaN    ->  NaN
shix836 shift  1000 NaN    ->  NaN
shix837 shift  Inf  NaN    ->  NaN

shix841 shift  sNaN -Inf   ->  NaN  Invalid_operation
shix842 shift  sNaN -1000  ->  NaN  Invalid_operation
shix843 shift  sNaN -1     ->  NaN  Invalid_operation
shix844 shift  sNaN -0     ->  NaN  Invalid_operation
shix845 shift  sNaN  0     ->  NaN  Invalid_operation
shix846 shift  sNaN  1     ->  NaN  Invalid_operation
shix847 shift  sNaN  1000  ->  NaN  Invalid_operation
shix848 shift  sNaN  NaN   ->  NaN  Invalid_operation
shix849 shift  sNaN sNaN   ->  NaN  Invalid_operation
shix850 shift  NaN  sNaN   ->  NaN  Invalid_operation
shix851 shift -Inf  sNaN   ->  NaN  Invalid_operation
shix852 shift -1000 sNaN   ->  NaN  Invalid_operation
shix853 shift -1    sNaN   ->  NaN  Invalid_operation
shix854 shift -0    sNaN   ->  NaN  Invalid_operation
shix855 shift  0    sNaN   ->  NaN  Invalid_operation
shix856 shift  1    sNaN   ->  NaN  Invalid_operation
shix857 shift  1000 sNaN   ->  NaN  Invalid_operation
shix858 shift  Inf  sNaN   ->  NaN  Invalid_operation
shix859 shift  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
shix861 shift  NaN1   -Inf    ->  NaN1
shix862 shift +NaN2   -1000   ->  NaN2
shix863 shift  NaN3    1000   ->  NaN3
shix864 shift  NaN4    Inf    ->  NaN4
shix865 shift  NaN5   +NaN6   ->  NaN5
shix866 shift -Inf     NaN7   ->  NaN7
shix867 shift -1000    NaN8   ->  NaN8
shix868 shift  1000    NaN9   ->  NaN9
shix869 shift  Inf    +NaN10  ->  NaN10
shix871 shift  sNaN11  -Inf   ->  NaN11  Invalid_operation
shix872 shift  sNaN12  -1000  ->  NaN12  Invalid_operation
shix873 shift  sNaN13   1000  ->  NaN13  Invalid_operation
shix874 shift  sNaN14   NaN17 ->  NaN14  Invalid_operation
shix875 shift  sNaN15  sNaN18 ->  NaN15  Invalid_operation
shix876 shift  NaN16   sNaN19 ->  NaN19  Invalid_operation
shix877 shift -Inf    +sNaN20 ->  NaN20  Invalid_operation
shix878 shift -1000    sNaN21 ->  NaN21  Invalid_operation
shix879 shift  1000    sNaN22 ->  NaN22  Invalid_operation
shix880 shift  Inf     sNaN23 ->  NaN23  Invalid_operation
shix881 shift +NaN25  +sNaN24 ->  NaN24  Invalid_operation
shix882 shift -NaN26    NaN28 -> -NaN26
shix883 shift -sNaN27  sNaN29 -> -NaN27  Invalid_operation
shix884 shift  1000    -NaN30 -> -NaN30
shix885 shift  1000   -sNaN31 -> -NaN31  Invalid_operation

Changes to test/dectest/squareroot.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- squareroot.decTest -- decimal square root                          --
-- Copyright (c) IBM Corporation, 2004.  All rights reserved.         --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- squareroot.decTest -- decimal square root                          --
-- Copyright (c) IBM Corporation, 2003, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

2937
2938
2939
2940
2941
2942
2943







2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958




2959
2960
sqtx808 squareroot  1E-21   -> 3.1622776602E-11 Underflow Subnormal Inexact Rounded
sqtx809 squareroot 10E-21   -> 1.0E-10 Subnormal -- exact Subnormal case
precision: 14               -- Etiny=-22
sqtx810 squareroot  1E-21   -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded
sqtx811 squareroot 10E-22   -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded
sqtx812 squareroot  1E-22   -> 1E-11 Subnormal   -- exact Subnormal case









-- special values
maxexponent: 999
minexponent: -999
sqtx820 squareroot   Inf    -> Infinity
sqtx821 squareroot  -Inf    -> NaN Invalid_operation
sqtx822 squareroot   NaN    -> NaN
sqtx823 squareroot  sNaN    -> NaN Invalid_operation
-- propagating NaNs
sqtx824 squareroot  sNaN123 ->  NaN123 Invalid_operation
sqtx825 squareroot -sNaN321 -> -NaN321 Invalid_operation
sqtx826 squareroot   NaN456 ->  NaN456
sqtx827 squareroot  -NaN654 -> -NaN654
sqtx828 squareroot   NaN1   ->  NaN1





-- Null test
sqtx900 squareroot  # -> NaN Invalid_operation







>
>
>
>
>
>
>















>
>
>
>


2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
sqtx808 squareroot  1E-21   -> 3.1622776602E-11 Underflow Subnormal Inexact Rounded
sqtx809 squareroot 10E-21   -> 1.0E-10 Subnormal -- exact Subnormal case
precision: 14               -- Etiny=-22
sqtx810 squareroot  1E-21   -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded
sqtx811 squareroot 10E-22   -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded
sqtx812 squareroot  1E-22   -> 1E-11 Subnormal   -- exact Subnormal case

-- Not enough digits?
precision:   16
maxExponent: 384
minExponent: -383
rounding:    half_even
sqtx815 squareroot 1.0000000001000000E-78  -> 1.000000000050000E-39 Inexact Rounded
--                                            1 234567890123456

-- special values
maxexponent: 999
minexponent: -999
sqtx820 squareroot   Inf    -> Infinity
sqtx821 squareroot  -Inf    -> NaN Invalid_operation
sqtx822 squareroot   NaN    -> NaN
sqtx823 squareroot  sNaN    -> NaN Invalid_operation
-- propagating NaNs
sqtx824 squareroot  sNaN123 ->  NaN123 Invalid_operation
sqtx825 squareroot -sNaN321 -> -NaN321 Invalid_operation
sqtx826 squareroot   NaN456 ->  NaN456
sqtx827 squareroot  -NaN654 -> -NaN654
sqtx828 squareroot   NaN1   ->  NaN1

-- payload decapitate
precision: 5
sqtx840 squareroot -sNaN1234567890 -> -NaN67890  Invalid_operation

-- Null test
sqtx900 squareroot  # -> NaN Invalid_operation

Changes to test/dectest/subtract.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- subtract.decTest -- decimal subtraction                            --
-- Copyright (c) IBM Corporation, 1981, 2004.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- subtract.decTest -- decimal subtraction                            --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 384
minexponent: -383

Changes to test/dectest/testall.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

24
25

26

27

28





29
30
31

32

33

34
35

36

37
38

39


40
41
42
43
44

45
46
47

48
49


50
51
52

53

54
55


56
57
58
59
60
61
62
63
------------------------------------------------------------------------
-- testall.decTest -- run all general decimal arithmetic testcases    --
-- Copyright (c) IBM Corporation, 1981, 2004.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- core tests (using Extended: 1) --------------------------------------
dectest: base

dectest: abs
dectest: add

dectest: clamp

dectest: compare

dectest: comparetotal





dectest: divide
dectest: divideint
dectest: exp

dectest: inexact

dectest: ln

dectest: log10
dectest: max

dectest: min

dectest: minus
dectest: multiply

dectest: normalize


dectest: plus
dectest: power
dectest: powersqrt
dectest: quantize
dectest: randoms

dectest: remainder
dectest: remaindernear
dectest: rescale              -- [obsolete]

dectest: rounding
dectest: samequantum


dectest: squareroot
dectest: subtract
dectest: tointegral

dectest: trim


-- The next are for the Strawman 4d concrete representations


dectest: decimal32
dectest: decimal64
dectest: decimal128


-- General 31->33-digit boundary tests
dectest: randombound32



|
















|



>


>

>

>

>
>
>
>
>



>

>

>


>

>


>
|
>
>





>



>


>
>



>

>

|
>
>
|
|
|
<




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

84
85
86
87
------------------------------------------------------------------------
-- testall.decTest -- run all general decimal arithmetic testcases    --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- core tests (using Extended: 1) --------------------------------------
dectest: base

dectest: abs
dectest: add
dectest: and
dectest: clamp
dectest: class
dectest: compare
dectest: comparesig
dectest: comparetotal
dectest: comparetotmag
dectest: copy
dectest: copyabs
dectest: copynegate
dectest: copysign
dectest: divide
dectest: divideint
dectest: exp
dectest: fma
dectest: inexact
dectest: invert
dectest: ln
dectest: logb
dectest: log10
dectest: max
dectest: maxmag
dectest: min
dectest: minmag
dectest: minus
dectest: multiply
dectest: nextminus
dectest: nextplus
dectest: nexttoward
dectest: or
dectest: plus
dectest: power
dectest: powersqrt
dectest: quantize
dectest: randoms
dectest: reduce               -- [was called normalize]
dectest: remainder
dectest: remaindernear
dectest: rescale              -- [obsolete]
dectest: rotate
dectest: rounding
dectest: samequantum
dectest: scaleb
dectest: shift
dectest: squareroot
dectest: subtract
dectest: tointegral
dectest: tointegralx
dectest: trim
dectest: xor

-- The next are for the Strawman 4d concrete representations and
-- tests at those sizes [including dsEncode, ddEncode, and dqEncode,
-- which replace decimal32, decimal64, and decimal128]
dectest: decSingle
dectest: decDouble
dectest: decQuad


-- General 31->33-digit boundary tests
dectest: randombound32

Changes to test/dectest/tointegral.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- tointegral.decTest -- round decimal to integral value              --
-- Copyright (c) IBM Corporation, 2001, 2003.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

-- This set of tests tests the extended specification 'round-to-integral
-- value' operation (from IEEE 854, later modified in 754r).
-- All non-zero results are defined as being those from either copy or
-- quantize, so those are assumed to have been tested.
-- Note that 754r requires that Inexact not be set, and we similarly
-- assume Rounded is not set.


|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- tointegral.decTest -- round decimal to integral value              --
-- Copyright (c) IBM Corporation, 2001, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests tests the extended specification 'round-to-integral
-- value' operation (from IEEE 854, later modified in 754r).
-- All non-zero results are defined as being those from either copy or
-- quantize, so those are assumed to have been tested.
-- Note that 754r requires that Inexact not be set, and we similarly
-- assume Rounded is not set.
170
171
172
173
174
175
176

































































intx202 tointegral   100.0    -> 100
intx203 tointegral   101.5    -> 102
intx204 tointegral  -101.5    -> -102
intx205 tointegral   10E+5    -> 1.0E+6
intx206 tointegral  7.89E+77  -> 7.89E+77
intx207 tointegral   -Inf     -> -Infinity









































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
intx202 tointegral   100.0    -> 100
intx203 tointegral   101.5    -> 102
intx204 tointegral  -101.5    -> -102
intx205 tointegral   10E+5    -> 1.0E+6
intx206 tointegral  7.89E+77  -> 7.89E+77
intx207 tointegral   -Inf     -> -Infinity


-- all rounding modes
rounding:    half_even

intx210 tointegral     55.5   ->  56
intx211 tointegral     56.5   ->  56
intx212 tointegral     57.5   ->  58
intx213 tointegral    -55.5   -> -56
intx214 tointegral    -56.5   -> -56
intx215 tointegral    -57.5   -> -58

rounding:    half_up

intx220 tointegral     55.5   ->  56
intx221 tointegral     56.5   ->  57
intx222 tointegral     57.5   ->  58
intx223 tointegral    -55.5   -> -56
intx224 tointegral    -56.5   -> -57
intx225 tointegral    -57.5   -> -58

rounding:    half_down

intx230 tointegral     55.5   ->  55
intx231 tointegral     56.5   ->  56
intx232 tointegral     57.5   ->  57
intx233 tointegral    -55.5   -> -55
intx234 tointegral    -56.5   -> -56
intx235 tointegral    -57.5   -> -57

rounding:    up

intx240 tointegral     55.3   ->  56
intx241 tointegral     56.3   ->  57
intx242 tointegral     57.3   ->  58
intx243 tointegral    -55.3   -> -56
intx244 tointegral    -56.3   -> -57
intx245 tointegral    -57.3   -> -58

rounding:    down

intx250 tointegral     55.7   ->  55
intx251 tointegral     56.7   ->  56
intx252 tointegral     57.7   ->  57
intx253 tointegral    -55.7   -> -55
intx254 tointegral    -56.7   -> -56
intx255 tointegral    -57.7   -> -57

rounding:    ceiling

intx260 tointegral     55.3   ->  56
intx261 tointegral     56.3   ->  57
intx262 tointegral     57.3   ->  58
intx263 tointegral    -55.3   -> -55
intx264 tointegral    -56.3   -> -56
intx265 tointegral    -57.3   -> -57

rounding:    floor

intx270 tointegral     55.7   ->  55
intx271 tointegral     56.7   ->  56
intx272 tointegral     57.7   ->  57
intx273 tointegral    -55.7   -> -56
intx274 tointegral    -56.7   -> -57
intx275 tointegral    -57.7   -> -58

Added test/dectest/tointegralx.decTest.































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
------------------------------------------------------------------------
-- tointegralx.decTest -- round decimal to integral value, exact      --
-- Copyright (c) IBM Corporation, 2001, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

-- This set of tests tests the extended specification 'round-to-integral
-- value' operation (from IEEE 854, later modified in 754r).
-- All non-zero results are defined as being those from either copy or
-- quantize, so those are assumed to have been tested.

-- This tests toIntegraExact, which may set Inexact

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

intxx001 tointegralx      0     ->  0
intxx002 tointegralx      0.0   ->  0
intxx003 tointegralx      0.1   ->  0 Inexact Rounded
intxx004 tointegralx      0.2   ->  0 Inexact Rounded
intxx005 tointegralx      0.3   ->  0 Inexact Rounded
intxx006 tointegralx      0.4   ->  0 Inexact Rounded
intxx007 tointegralx      0.5   ->  1 Inexact Rounded
intxx008 tointegralx      0.6   ->  1 Inexact Rounded
intxx009 tointegralx      0.7   ->  1 Inexact Rounded
intxx010 tointegralx      0.8   ->  1 Inexact Rounded
intxx011 tointegralx      0.9   ->  1 Inexact Rounded
intxx012 tointegralx      1     ->  1
intxx013 tointegralx      1.0   ->  1 Rounded
intxx014 tointegralx      1.1   ->  1 Inexact Rounded
intxx015 tointegralx      1.2   ->  1 Inexact Rounded
intxx016 tointegralx      1.3   ->  1 Inexact Rounded
intxx017 tointegralx      1.4   ->  1 Inexact Rounded
intxx018 tointegralx      1.5   ->  2 Inexact Rounded
intxx019 tointegralx      1.6   ->  2 Inexact Rounded
intxx020 tointegralx      1.7   ->  2 Inexact Rounded
intxx021 tointegralx      1.8   ->  2 Inexact Rounded
intxx022 tointegralx      1.9   ->  2 Inexact Rounded
-- negatives
intxx031 tointegralx     -0     -> -0
intxx032 tointegralx     -0.0   -> -0
intxx033 tointegralx     -0.1   -> -0 Inexact Rounded
intxx034 tointegralx     -0.2   -> -0 Inexact Rounded
intxx035 tointegralx     -0.3   -> -0 Inexact Rounded
intxx036 tointegralx     -0.4   -> -0 Inexact Rounded
intxx037 tointegralx     -0.5   -> -1 Inexact Rounded
intxx038 tointegralx     -0.6   -> -1 Inexact Rounded
intxx039 tointegralx     -0.7   -> -1 Inexact Rounded
intxx040 tointegralx     -0.8   -> -1 Inexact Rounded
intxx041 tointegralx     -0.9   -> -1 Inexact Rounded
intxx042 tointegralx     -1     -> -1
intxx043 tointegralx     -1.0   -> -1 Rounded
intxx044 tointegralx     -1.1   -> -1 Inexact Rounded
intxx045 tointegralx     -1.2   -> -1 Inexact Rounded
intxx046 tointegralx     -1.3   -> -1 Inexact Rounded
intxx047 tointegralx     -1.4   -> -1 Inexact Rounded
intxx048 tointegralx     -1.5   -> -2 Inexact Rounded
intxx049 tointegralx     -1.6   -> -2 Inexact Rounded
intxx050 tointegralx     -1.7   -> -2 Inexact Rounded
intxx051 tointegralx     -1.8   -> -2 Inexact Rounded
intxx052 tointegralx     -1.9   -> -2 Inexact Rounded
-- next two would be NaN using quantize(x, 0)
intxx053 tointegralx    10E+30  -> 1.0E+31
intxx054 tointegralx   -10E+30  -> -1.0E+31

-- numbers around precision
precision: 9
intxx060 tointegralx '56267E-10'   -> '0'               Inexact Rounded
intxx061 tointegralx '56267E-5'    -> '1'               Inexact Rounded
intxx062 tointegralx '56267E-2'    -> '563'             Inexact Rounded
intxx063 tointegralx '56267E-1'    -> '5627'            Inexact Rounded
intxx065 tointegralx '56267E-0'    -> '56267'
intxx066 tointegralx '56267E+0'    -> '56267'
intxx067 tointegralx '56267E+1'    -> '5.6267E+5'
intxx068 tointegralx '56267E+2'    -> '5.6267E+6'
intxx069 tointegralx '56267E+3'    -> '5.6267E+7'
intxx070 tointegralx '56267E+4'    -> '5.6267E+8'
intxx071 tointegralx '56267E+5'    -> '5.6267E+9'
intxx072 tointegralx '56267E+6'    -> '5.6267E+10'
intxx073 tointegralx '1.23E+96'    -> '1.23E+96'
intxx074 tointegralx '1.23E+384'   -> '1.23E+384'
intxx075 tointegralx '1.23E+999'   -> '1.23E+999'

intxx080 tointegralx '-56267E-10'  -> '-0'              Inexact Rounded
intxx081 tointegralx '-56267E-5'   -> '-1'              Inexact Rounded
intxx082 tointegralx '-56267E-2'   -> '-563'            Inexact Rounded
intxx083 tointegralx '-56267E-1'   -> '-5627'           Inexact Rounded
intxx085 tointegralx '-56267E-0'   -> '-56267'
intxx086 tointegralx '-56267E+0'   -> '-56267'
intxx087 tointegralx '-56267E+1'   -> '-5.6267E+5'
intxx088 tointegralx '-56267E+2'   -> '-5.6267E+6'
intxx089 tointegralx '-56267E+3'   -> '-5.6267E+7'
intxx090 tointegralx '-56267E+4'   -> '-5.6267E+8'
intxx091 tointegralx '-56267E+5'   -> '-5.6267E+9'
intxx092 tointegralx '-56267E+6'   -> '-5.6267E+10'
intxx093 tointegralx '-1.23E+96'   -> '-1.23E+96'
intxx094 tointegralx '-1.23E+384'  -> '-1.23E+384'
intxx095 tointegralx '-1.23E+999'  -> '-1.23E+999'

-- subnormal inputs
intxx100 tointegralx        1E-999 -> 0                 Inexact Rounded
intxx101 tointegralx      0.1E-999 -> 0                 Inexact Rounded
intxx102 tointegralx     0.01E-999 -> 0                 Inexact Rounded
intxx103 tointegralx        0E-999 -> 0

-- specials and zeros
intxx120 tointegralx 'Inf'       ->  Infinity
intxx121 tointegralx '-Inf'      -> -Infinity
intxx122 tointegralx   NaN       ->  NaN
intxx123 tointegralx  sNaN       ->  NaN  Invalid_operation
intxx124 tointegralx     0       ->  0
intxx125 tointegralx    -0       -> -0
intxx126 tointegralx     0.000   ->  0
intxx127 tointegralx     0.00    ->  0
intxx128 tointegralx     0.0     ->  0
intxx129 tointegralx     0       ->  0
intxx130 tointegralx     0E-3    ->  0
intxx131 tointegralx     0E-2    ->  0
intxx132 tointegralx     0E-1    ->  0
intxx133 tointegralx     0E-0    ->  0
intxx134 tointegralx     0E+1    ->  0E+1
intxx135 tointegralx     0E+2    ->  0E+2
intxx136 tointegralx     0E+3    ->  0E+3
intxx137 tointegralx     0E+4    ->  0E+4
intxx138 tointegralx     0E+5    ->  0E+5
intxx139 tointegralx    -0.000   -> -0
intxx140 tointegralx    -0.00    -> -0
intxx141 tointegralx    -0.0     -> -0
intxx142 tointegralx    -0       -> -0
intxx143 tointegralx    -0E-3    -> -0
intxx144 tointegralx    -0E-2    -> -0
intxx145 tointegralx    -0E-1    -> -0
intxx146 tointegralx    -0E-0    -> -0
intxx147 tointegralx    -0E+1    -> -0E+1
intxx148 tointegralx    -0E+2    -> -0E+2
intxx149 tointegralx    -0E+3    -> -0E+3
intxx150 tointegralx    -0E+4    -> -0E+4
intxx151 tointegralx    -0E+5    -> -0E+5
-- propagating NaNs
intxx152 tointegralx   NaN808    ->  NaN808
intxx153 tointegralx  sNaN080    ->  NaN80  Invalid_operation
intxx154 tointegralx  -NaN808    -> -NaN808
intxx155 tointegralx -sNaN080    -> -NaN80  Invalid_operation
intxx156 tointegralx  -NaN       -> -NaN
intxx157 tointegralx -sNaN       -> -NaN    Invalid_operation

-- examples
rounding:    half_up
precision:   9
intxx200 tointegralx     2.1    -> 2                    Inexact Rounded
intxx201 tointegralx   100      -> 100
intxx202 tointegralx   100.0    -> 100                  Rounded
intxx203 tointegralx   101.5    -> 102                  Inexact Rounded
intxx204 tointegralx  -101.5    -> -102                 Inexact Rounded
intxx205 tointegralx   10E+5    -> 1.0E+6
intxx206 tointegralx  7.89E+77  -> 7.89E+77
intxx207 tointegralx   -Inf     -> -Infinity


-- all rounding modes
rounding:    half_even

intxx210 tointegralx     55.5   ->  56   Inexact Rounded
intxx211 tointegralx     56.5   ->  56   Inexact Rounded
intxx212 tointegralx     57.5   ->  58   Inexact Rounded
intxx213 tointegralx    -55.5   -> -56   Inexact Rounded
intxx214 tointegralx    -56.5   -> -56   Inexact Rounded
intxx215 tointegralx    -57.5   -> -58   Inexact Rounded

rounding:    half_up

intxx220 tointegralx     55.5   ->  56   Inexact Rounded
intxx221 tointegralx     56.5   ->  57   Inexact Rounded
intxx222 tointegralx     57.5   ->  58   Inexact Rounded
intxx223 tointegralx    -55.5   -> -56   Inexact Rounded
intxx224 tointegralx    -56.5   -> -57   Inexact Rounded
intxx225 tointegralx    -57.5   -> -58   Inexact Rounded

rounding:    half_down

intxx230 tointegralx     55.5   ->  55   Inexact Rounded
intxx231 tointegralx     56.5   ->  56   Inexact Rounded
intxx232 tointegralx     57.5   ->  57   Inexact Rounded
intxx233 tointegralx    -55.5   -> -55   Inexact Rounded
intxx234 tointegralx    -56.5   -> -56   Inexact Rounded
intxx235 tointegralx    -57.5   -> -57   Inexact Rounded

rounding:    up

intxx240 tointegralx     55.3   ->  56   Inexact Rounded
intxx241 tointegralx     56.3   ->  57   Inexact Rounded
intxx242 tointegralx     57.3   ->  58   Inexact Rounded
intxx243 tointegralx    -55.3   -> -56   Inexact Rounded
intxx244 tointegralx    -56.3   -> -57   Inexact Rounded
intxx245 tointegralx    -57.3   -> -58   Inexact Rounded

rounding:    down

intxx250 tointegralx     55.7   ->  55   Inexact Rounded
intxx251 tointegralx     56.7   ->  56   Inexact Rounded
intxx252 tointegralx     57.7   ->  57   Inexact Rounded
intxx253 tointegralx    -55.7   -> -55   Inexact Rounded
intxx254 tointegralx    -56.7   -> -56   Inexact Rounded
intxx255 tointegralx    -57.7   -> -57   Inexact Rounded

rounding:    ceiling

intxx260 tointegralx     55.3   ->  56   Inexact Rounded
intxx261 tointegralx     56.3   ->  57   Inexact Rounded
intxx262 tointegralx     57.3   ->  58   Inexact Rounded
intxx263 tointegralx    -55.3   -> -55   Inexact Rounded
intxx264 tointegralx    -56.3   -> -56   Inexact Rounded
intxx265 tointegralx    -57.3   -> -57   Inexact Rounded

rounding:    floor

intxx270 tointegralx     55.7   ->  55   Inexact Rounded
intxx271 tointegralx     56.7   ->  56   Inexact Rounded
intxx272 tointegralx     57.7   ->  57   Inexact Rounded
intxx273 tointegralx    -55.7   -> -56   Inexact Rounded
intxx274 tointegralx    -56.7   -> -57   Inexact Rounded
intxx275 tointegralx    -57.7   -> -58   Inexact Rounded

-- Int and uInt32 edge values for testing conversions
precision: 16
intxx300 tointegralx -2147483646  -> -2147483646
intxx301 tointegralx -2147483647  -> -2147483647
intxx302 tointegralx -2147483648  -> -2147483648
intxx303 tointegralx -2147483649  -> -2147483649
intxx304 tointegralx  2147483646  ->  2147483646
intxx305 tointegralx  2147483647  ->  2147483647
intxx306 tointegralx  2147483648  ->  2147483648
intxx307 tointegralx  2147483649  ->  2147483649
intxx308 tointegralx  4294967294  ->  4294967294
intxx309 tointegralx  4294967295  ->  4294967295
intxx310 tointegralx  4294967296  ->  4294967296
intxx311 tointegralx  4294967297  ->  4294967297

Changes to test/dectest/trim.decTest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- trim.decTest -- remove insignificant trailing zeros                --
-- Copyright (c) IBM Corporation, 2003.  All rights reserved.         --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.52

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minexponent: -999



|
















|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
------------------------------------------------------------------------
-- trim.decTest -- remove insignificant trailing zeros                --
-- Copyright (c) IBM Corporation, 2003, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minexponent: -999

Added test/dectest/xor.decTest.































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
------------------------------------------------------------------------
-- xor.decTest -- digitwise logical XOR                               --
-- Copyright (c) IBM Corporation, 1981, 2007.  All rights reserved.   --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases"     --
-- at http://www2.hursley.ibm.com/decimal for the description of      --
-- these testcases.                                                   --
--                                                                    --
-- These testcases are experimental ('beta' versions), and they       --
-- may contain errors.  They are offered on an as-is basis.  In       --
-- particular, achieving the same results as the tests here is not    --
-- a guarantee that an implementation complies with any Standard      --
-- or specification.  The tests are not exhaustive.                   --
--                                                                    --
-- Please send comments, suggestions, and corrections to the author:  --
--   Mike Cowlishaw, IBM Fellow                                       --
--   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         --
--   mfc@uk.ibm.com                                                   --
------------------------------------------------------------------------
version: 2.55

extended:    1
precision:   9
rounding:    half_up
maxExponent: 999
minExponent: -999

-- Sanity check (truth table)
xorx001 xor             0    0 ->    0
xorx002 xor             0    1 ->    1
xorx003 xor             1    0 ->    1
xorx004 xor             1    1 ->    0
xorx005 xor          1100 1010 ->  110
xorx006 xor          1111   10 -> 1101
-- and at msd and msd-1
xorx010 xor 000000000 000000000 ->           0
xorx011 xor 000000000 100000000 ->   100000000
xorx012 xor 100000000 000000000 ->   100000000
xorx013 xor 100000000 100000000 ->           0
xorx014 xor 000000000 000000000 ->           0
xorx015 xor 000000000 010000000 ->    10000000
xorx016 xor 010000000 000000000 ->    10000000
xorx017 xor 010000000 010000000 ->           0

-- Various lengths
--        123456789     123456789      123456789
xorx021 xor 111111111     111111111  ->  0
xorx022 xor 111111111111  111111111  ->  0
xorx023 xor  11111111      11111111  ->  0
xorx025 xor   1111111       1111111  ->  0
xorx026 xor    111111        111111  ->  0
xorx027 xor     11111         11111  ->  0
xorx028 xor      1111          1111  ->  0
xorx029 xor       111           111  ->  0
xorx031 xor        11            11  ->  0
xorx032 xor         1             1  ->  0
xorx033 xor 111111111111 1111111111  ->  0
xorx034 xor 11111111111 11111111111  ->  0
xorx035 xor 1111111111 111111111111  ->  0
xorx036 xor 111111111 1111111111111  ->  0

xorx040 xor 111111111  111111111111  ->  0
xorx041 xor  11111111  111111111111  ->  100000000
xorx042 xor  11111111     111111111  ->  100000000
xorx043 xor   1111111     100000010  ->  101111101
xorx044 xor    111111     100000100  ->  100111011
xorx045 xor     11111     100001000  ->  100010111
xorx046 xor      1111     100010000  ->  100011111
xorx047 xor       111     100100000  ->  100100111
xorx048 xor        11     101000000  ->  101000011
xorx049 xor         1     110000000  ->  110000001

xorx050 xor 1111111111  1  ->  111111110
xorx051 xor  111111111  1  ->  111111110
xorx052 xor   11111111  1  ->  11111110
xorx053 xor    1111111  1  ->  1111110
xorx054 xor     111111  1  ->  111110
xorx055 xor      11111  1  ->  11110
xorx056 xor       1111  1  ->  1110
xorx057 xor        111  1  ->  110
xorx058 xor         11  1  ->  10
xorx059 xor          1  1  ->  0

xorx060 xor 1111111111  0  ->  111111111
xorx061 xor  111111111  0  ->  111111111
xorx062 xor   11111111  0  ->  11111111
xorx063 xor    1111111  0  ->  1111111
xorx064 xor     111111  0  ->  111111
xorx065 xor      11111  0  ->  11111
xorx066 xor       1111  0  ->  1111
xorx067 xor        111  0  ->  111
xorx068 xor         11  0  ->  11
xorx069 xor          1  0  ->  1

xorx070 xor 1  1111111111  ->  111111110
xorx071 xor 1   111111111  ->  111111110
xorx072 xor 1    11111111  ->  11111110
xorx073 xor 1     1111111  ->  1111110
xorx074 xor 1      111111  ->  111110
xorx075 xor 1       11111  ->  11110
xorx076 xor 1        1111  ->  1110
xorx077 xor 1         111  ->  110
xorx078 xor 1          11  ->  10
xorx079 xor 1           1  ->  0

xorx080 xor 0  1111111111  ->  111111111
xorx081 xor 0   111111111  ->  111111111
xorx082 xor 0    11111111  ->  11111111
xorx083 xor 0     1111111  ->  1111111
xorx084 xor 0      111111  ->  111111
xorx085 xor 0       11111  ->  11111
xorx086 xor 0        1111  ->  1111
xorx087 xor 0         111  ->  111
xorx088 xor 0          11  ->  11
xorx089 xor 0           1  ->  1

xorx090 xor 011111111  111101111  ->  100010000
xorx091 xor 101111111  111101111  ->   10010000
xorx092 xor 110111111  111101111  ->    1010000
xorx093 xor 111011111  111101111  ->     110000
xorx094 xor 111101111  111101111  ->          0
xorx095 xor 111110111  111101111  ->      11000
xorx096 xor 111111011  111101111  ->      10100
xorx097 xor 111111101  111101111  ->      10010
xorx098 xor 111111110  111101111  ->      10001

xorx100 xor 111101111  011111111  ->  100010000
xorx101 xor 111101111  101111111  ->   10010000
xorx102 xor 111101111  110111111  ->    1010000
xorx103 xor 111101111  111011111  ->     110000
xorx104 xor 111101111  111101111  ->          0
xorx105 xor 111101111  111110111  ->      11000
xorx106 xor 111101111  111111011  ->      10100
xorx107 xor 111101111  111111101  ->      10010
xorx108 xor 111101111  111111110  ->      10001

-- non-0/1 should not be accepted, nor should signs
xorx220 xor 111111112  111111111  ->  NaN Invalid_operation
xorx221 xor 333333333  333333333  ->  NaN Invalid_operation
xorx222 xor 555555555  555555555  ->  NaN Invalid_operation
xorx223 xor 777777777  777777777  ->  NaN Invalid_operation
xorx224 xor 999999999  999999999  ->  NaN Invalid_operation
xorx225 xor 222222222  999999999  ->  NaN Invalid_operation
xorx226 xor 444444444  999999999  ->  NaN Invalid_operation
xorx227 xor 666666666  999999999  ->  NaN Invalid_operation
xorx228 xor 888888888  999999999  ->  NaN Invalid_operation
xorx229 xor 999999999  222222222  ->  NaN Invalid_operation
xorx230 xor 999999999  444444444  ->  NaN Invalid_operation
xorx231 xor 999999999  666666666  ->  NaN Invalid_operation
xorx232 xor 999999999  888888888  ->  NaN Invalid_operation
-- a few randoms
xorx240 xor  567468689 -934981942 ->  NaN Invalid_operation
xorx241 xor  567367689  934981942 ->  NaN Invalid_operation
xorx242 xor -631917772 -706014634 ->  NaN Invalid_operation
xorx243 xor -756253257  138579234 ->  NaN Invalid_operation
xorx244 xor  835590149  567435400 ->  NaN Invalid_operation
-- test MSD
xorx250 xor  200000000 100000000 ->  NaN Invalid_operation
xorx251 xor  700000000 100000000 ->  NaN Invalid_operation
xorx252 xor  800000000 100000000 ->  NaN Invalid_operation
xorx253 xor  900000000 100000000 ->  NaN Invalid_operation
xorx254 xor  200000000 000000000 ->  NaN Invalid_operation
xorx255 xor  700000000 000000000 ->  NaN Invalid_operation
xorx256 xor  800000000 000000000 ->  NaN Invalid_operation
xorx257 xor  900000000 000000000 ->  NaN Invalid_operation
xorx258 xor  100000000 200000000 ->  NaN Invalid_operation
xorx259 xor  100000000 700000000 ->  NaN Invalid_operation
xorx260 xor  100000000 800000000 ->  NaN Invalid_operation
xorx261 xor  100000000 900000000 ->  NaN Invalid_operation
xorx262 xor  000000000 200000000 ->  NaN Invalid_operation
xorx263 xor  000000000 700000000 ->  NaN Invalid_operation
xorx264 xor  000000000 800000000 ->  NaN Invalid_operation
xorx265 xor  000000000 900000000 ->  NaN Invalid_operation
-- test MSD-1
xorx270 xor  020000000 100000000 ->  NaN Invalid_operation
xorx271 xor  070100000 100000000 ->  NaN Invalid_operation
xorx272 xor  080010000 100000001 ->  NaN Invalid_operation
xorx273 xor  090001000 100000010 ->  NaN Invalid_operation
xorx274 xor  100000100 020010100 ->  NaN Invalid_operation
xorx275 xor  100000000 070001000 ->  NaN Invalid_operation
xorx276 xor  100000010 080010100 ->  NaN Invalid_operation
xorx277 xor  100000000 090000010 ->  NaN Invalid_operation
-- test LSD
xorx280 xor  001000002 100000000 ->  NaN Invalid_operation
xorx281 xor  000000007 100000000 ->  NaN Invalid_operation
xorx282 xor  000000008 100000000 ->  NaN Invalid_operation
xorx283 xor  000000009 100000000 ->  NaN Invalid_operation
xorx284 xor  100000000 000100002 ->  NaN Invalid_operation
xorx285 xor  100100000 001000007 ->  NaN Invalid_operation
xorx286 xor  100010000 010000008 ->  NaN Invalid_operation
xorx287 xor  100001000 100000009 ->  NaN Invalid_operation
-- test Middie
xorx288 xor  001020000 100000000 ->  NaN Invalid_operation
xorx289 xor  000070001 100000000 ->  NaN Invalid_operation
xorx290 xor  000080000 100010000 ->  NaN Invalid_operation
xorx291 xor  000090000 100001000 ->  NaN Invalid_operation
xorx292 xor  100000010 000020100 ->  NaN Invalid_operation
xorx293 xor  100100000 000070010 ->  NaN Invalid_operation
xorx294 xor  100010100 000080001 ->  NaN Invalid_operation
xorx295 xor  100001000 000090000 ->  NaN Invalid_operation
-- signs
xorx296 xor -100001000 -000000000 ->  NaN Invalid_operation
xorx297 xor -100001000  000010000 ->  NaN Invalid_operation
xorx298 xor  100001000 -000000000 ->  NaN Invalid_operation
xorx299 xor  100001000  000011000 ->  100010000

-- Nmax, Nmin, Ntiny
xorx331 xor  2   9.99999999E+999     -> NaN Invalid_operation
xorx332 xor  3   1E-999              -> NaN Invalid_operation
xorx333 xor  4   1.00000000E-999     -> NaN Invalid_operation
xorx334 xor  5   1E-1007             -> NaN Invalid_operation
xorx335 xor  6   -1E-1007            -> NaN Invalid_operation
xorx336 xor  7   -1.00000000E-999    -> NaN Invalid_operation
xorx337 xor  8   -1E-999             -> NaN Invalid_operation
xorx338 xor  9   -9.99999999E+999    -> NaN Invalid_operation
xorx341 xor  9.99999999E+999     -18 -> NaN Invalid_operation
xorx342 xor  1E-999               01 -> NaN Invalid_operation
xorx343 xor  1.00000000E-999     -18 -> NaN Invalid_operation
xorx344 xor  1E-1007              18 -> NaN Invalid_operation
xorx345 xor  -1E-1007            -10 -> NaN Invalid_operation
xorx346 xor  -1.00000000E-999     18 -> NaN Invalid_operation
xorx347 xor  -1E-999              10 -> NaN Invalid_operation
xorx348 xor  -9.99999999E+999    -18 -> NaN Invalid_operation

-- A few other non-integers
xorx361 xor  1.0                  1  -> NaN Invalid_operation
xorx362 xor  1E+1                 1  -> NaN Invalid_operation
xorx363 xor  0.0                  1  -> NaN Invalid_operation
xorx364 xor  0E+1                 1  -> NaN Invalid_operation
xorx365 xor  9.9                  1  -> NaN Invalid_operation
xorx366 xor  9E+1                 1  -> NaN Invalid_operation
xorx371 xor  0 1.0                   -> NaN Invalid_operation
xorx372 xor  0 1E+1                  -> NaN Invalid_operation
xorx373 xor  0 0.0                   -> NaN Invalid_operation
xorx374 xor  0 0E+1                  -> NaN Invalid_operation
xorx375 xor  0 9.9                   -> NaN Invalid_operation
xorx376 xor  0 9E+1                  -> NaN Invalid_operation

-- All Specials are in error
xorx780 xor -Inf  -Inf   -> NaN Invalid_operation
xorx781 xor -Inf  -1000  -> NaN Invalid_operation
xorx782 xor -Inf  -1     -> NaN Invalid_operation
xorx783 xor -Inf  -0     -> NaN Invalid_operation
xorx784 xor -Inf   0     -> NaN Invalid_operation
xorx785 xor -Inf   1     -> NaN Invalid_operation
xorx786 xor -Inf   1000  -> NaN Invalid_operation
xorx787 xor -1000 -Inf   -> NaN Invalid_operation
xorx788 xor -Inf  -Inf   -> NaN Invalid_operation
xorx789 xor -1    -Inf   -> NaN Invalid_operation
xorx790 xor -0    -Inf   -> NaN Invalid_operation
xorx791 xor  0    -Inf   -> NaN Invalid_operation
xorx792 xor  1    -Inf   -> NaN Invalid_operation
xorx793 xor  1000 -Inf   -> NaN Invalid_operation
xorx794 xor  Inf  -Inf   -> NaN Invalid_operation

xorx800 xor  Inf  -Inf   -> NaN Invalid_operation
xorx801 xor  Inf  -1000  -> NaN Invalid_operation
xorx802 xor  Inf  -1     -> NaN Invalid_operation
xorx803 xor  Inf  -0     -> NaN Invalid_operation
xorx804 xor  Inf   0     -> NaN Invalid_operation
xorx805 xor  Inf   1     -> NaN Invalid_operation
xorx806 xor  Inf   1000  -> NaN Invalid_operation
xorx807 xor  Inf   Inf   -> NaN Invalid_operation
xorx808 xor -1000  Inf   -> NaN Invalid_operation
xorx809 xor -Inf   Inf   -> NaN Invalid_operation
xorx810 xor -1     Inf   -> NaN Invalid_operation
xorx811 xor -0     Inf   -> NaN Invalid_operation
xorx812 xor  0     Inf   -> NaN Invalid_operation
xorx813 xor  1     Inf   -> NaN Invalid_operation
xorx814 xor  1000  Inf   -> NaN Invalid_operation
xorx815 xor  Inf   Inf   -> NaN Invalid_operation

xorx821 xor  NaN -Inf    -> NaN Invalid_operation
xorx822 xor  NaN -1000   -> NaN Invalid_operation
xorx823 xor  NaN -1      -> NaN Invalid_operation
xorx824 xor  NaN -0      -> NaN Invalid_operation
xorx825 xor  NaN  0      -> NaN Invalid_operation
xorx826 xor  NaN  1      -> NaN Invalid_operation
xorx827 xor  NaN  1000   -> NaN Invalid_operation
xorx828 xor  NaN  Inf    -> NaN Invalid_operation
xorx829 xor  NaN  NaN    -> NaN Invalid_operation
xorx830 xor -Inf  NaN    -> NaN Invalid_operation
xorx831 xor -1000 NaN    -> NaN Invalid_operation
xorx832 xor -1    NaN    -> NaN Invalid_operation
xorx833 xor -0    NaN    -> NaN Invalid_operation
xorx834 xor  0    NaN    -> NaN Invalid_operation
xorx835 xor  1    NaN    -> NaN Invalid_operation
xorx836 xor  1000 NaN    -> NaN Invalid_operation
xorx837 xor  Inf  NaN    -> NaN Invalid_operation

xorx841 xor  sNaN -Inf   ->  NaN  Invalid_operation
xorx842 xor  sNaN -1000  ->  NaN  Invalid_operation
xorx843 xor  sNaN -1     ->  NaN  Invalid_operation
xorx844 xor  sNaN -0     ->  NaN  Invalid_operation
xorx845 xor  sNaN  0     ->  NaN  Invalid_operation
xorx846 xor  sNaN  1     ->  NaN  Invalid_operation
xorx847 xor  sNaN  1000  ->  NaN  Invalid_operation
xorx848 xor  sNaN  NaN   ->  NaN  Invalid_operation
xorx849 xor  sNaN sNaN   ->  NaN  Invalid_operation
xorx850 xor  NaN  sNaN   ->  NaN  Invalid_operation
xorx851 xor -Inf  sNaN   ->  NaN  Invalid_operation
xorx852 xor -1000 sNaN   ->  NaN  Invalid_operation
xorx853 xor -1    sNaN   ->  NaN  Invalid_operation
xorx854 xor -0    sNaN   ->  NaN  Invalid_operation
xorx855 xor  0    sNaN   ->  NaN  Invalid_operation
xorx856 xor  1    sNaN   ->  NaN  Invalid_operation
xorx857 xor  1000 sNaN   ->  NaN  Invalid_operation
xorx858 xor  Inf  sNaN   ->  NaN  Invalid_operation
xorx859 xor  NaN  sNaN   ->  NaN  Invalid_operation

-- propagating NaNs
xorx861 xor  NaN1   -Inf    -> NaN Invalid_operation
xorx862 xor +NaN2   -1000   -> NaN Invalid_operation
xorx863 xor  NaN3    1000   -> NaN Invalid_operation
xorx864 xor  NaN4    Inf    -> NaN Invalid_operation
xorx865 xor  NaN5   +NaN6   -> NaN Invalid_operation
xorx866 xor -Inf     NaN7   -> NaN Invalid_operation
xorx867 xor -1000    NaN8   -> NaN Invalid_operation
xorx868 xor  1000    NaN9   -> NaN Invalid_operation
xorx869 xor  Inf    +NaN10  -> NaN Invalid_operation
xorx871 xor  sNaN11  -Inf   -> NaN Invalid_operation
xorx872 xor  sNaN12  -1000  -> NaN Invalid_operation
xorx873 xor  sNaN13   1000  -> NaN Invalid_operation
xorx874 xor  sNaN14   NaN17 -> NaN Invalid_operation
xorx875 xor  sNaN15  sNaN18 -> NaN Invalid_operation
xorx876 xor  NaN16   sNaN19 -> NaN Invalid_operation
xorx877 xor -Inf    +sNaN20 -> NaN Invalid_operation
xorx878 xor -1000    sNaN21 -> NaN Invalid_operation
xorx879 xor  1000    sNaN22 -> NaN Invalid_operation
xorx880 xor  Inf     sNaN23 -> NaN Invalid_operation
xorx881 xor +NaN25  +sNaN24 -> NaN Invalid_operation
xorx882 xor -NaN26    NaN28 -> NaN Invalid_operation
xorx883 xor -sNaN27  sNaN29 -> NaN Invalid_operation
xorx884 xor  1000    -NaN30 -> NaN Invalid_operation
xorx885 xor  1000   -sNaN31 -> NaN Invalid_operation

Changes to test/ldecNumberTestDriver.lua.

191
192
193
194
195
196
197
198

199
200
201
202
203
204
205
{
    ceiling    = decNumber.ROUND_CEILING,
    down       = decNumber.ROUND_DOWN,
    floor      = decNumber.ROUND_FLOOR,
    half_down  = decNumber.ROUND_HALF_DOWN,
    half_even  = decNumber.ROUND_HALF_EVEN,
    half_up    = decNumber.ROUND_HALF_UP,
    up         = decNumber.ROUND_UP

}

function directive_rounding (v)
    local r = assert( rounding[string.lower(v)], "unknown directive rounding ", v)
    decNumber.getcontext():setround (r)
end








|
>







191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
{
    ceiling    = decNumber.ROUND_CEILING,
    down       = decNumber.ROUND_DOWN,
    floor      = decNumber.ROUND_FLOOR,
    half_down  = decNumber.ROUND_HALF_DOWN,
    half_even  = decNumber.ROUND_HALF_EVEN,
    half_up    = decNumber.ROUND_HALF_UP,
    up         = decNumber.ROUND_UP,
    ["05up"]   = decNumber.ROUND_05UP
}

function directive_rounding (v)
    local r = assert( rounding[string.lower(v)], "unknown directive rounding ", v)
    decNumber.getcontext():setround (r)
end

244
245
246
247
248
249
250

251

252
253





254
255
256


257
258

259

260

261
262



263
264
265
266

267
268
269

270
271


272
273
274

275
276

277
278
279
280
281
282
283
--apply_function = decNumber.plus
apply_function = decNumber.tonumber

operations = 
{
    abs = assert( decNumber.abs ),
    add = assert( decNumber.add ),

    apply = assert( apply_function ),

    compare = assert( decNumber.compare ),
    comparetotal = assert( decNumber.comparetotal ),





    divide = assert( decNumber.divide ),
    divideint = assert( decNumber.divideinteger ),
    exp = assert( decNumber.exp ),


    ln = assert( decNumber.ln ),
    log10 = assert( decNumber.log10 ),

    max = assert( decNumber.max ),

    min = assert( decNumber.min ),

    minus = assert( decNumber.minus ),
    multiply = assert( decNumber.multiply ),



    normalize = assert( decNumber.normalize ),
    plus = assert( decNumber.plus ),
    power = assert( decNumber.power ),
    quantize = assert( decNumber.quantize ),

    remainder = assert( decNumber.remainder ),
    remaindernear = assert( decNumber.remaindernear ),
    rescale = assert( decNumber.rescale ),

    samequantum = assert( decNumber.samequantum ),
    squareroot = assert( decNumber.squareroot ),


    subtract = assert( decNumber.subtract ),
    toeng = assert( decNumber.toengstring ),
    tointegral = assert( decNumber.tointegralvalue ),

    tosci = assert( decNumber.tostring ),
    trim = assert( decNumber.trim )

}

conditions = 
{
    clamped = assert( decNumber.Clamped ),
    conversion_syntax = assert( decNumber.Conversion_syntax ),
    division_by_zero = assert( decNumber.Division_by_zero ),







>

>


>
>
>
>
>



>
>


>

>

>


>
>
>
|



>



>


>
>



>

|
>







245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
--apply_function = decNumber.plus
apply_function = decNumber.tonumber

operations = 
{
    abs = assert( decNumber.abs ),
    add = assert( decNumber.add ),
    ["and"] = assert( decNumber.land ),
    apply = assert( apply_function ),
    class = assert( decNumber.classasstring ),
    compare = assert( decNumber.compare ),
    comparetotal = assert( decNumber.comparetotal ),
    comparetotmag = assert( decNumber.comparetotalmag ),
    copy = assert( decNumber.copy ),
    copyabs = assert( decNumber.copyabs ),
    copynegate = assert( decNumber.copynegate ),
    copysign = assert( decNumber.copysign ),
    divide = assert( decNumber.divide ),
    divideint = assert( decNumber.divideinteger ),
    exp = assert( decNumber.exp ),
    fma = assert( decNumber.fma ),
    invert = assert( decNumber.invert ),
    ln = assert( decNumber.ln ),
    log10 = assert( decNumber.log10 ),
    logb = assert( decNumber.logb ),
    max = assert( decNumber.max ),
    maxmag = assert( decNumber.maxmag ),
    min = assert( decNumber.min ),
    minmag = assert( decNumber.minmag ),
    minus = assert( decNumber.minus ),
    multiply = assert( decNumber.multiply ),
    nextminus = assert( decNumber.nextminus ),
    nextplus = assert( decNumber.nextplus ),
    nexttoward = assert( decNumber.nexttoward ),
    ["or"] = assert( decNumber.lor ),
    plus = assert( decNumber.plus ),
    power = assert( decNumber.power ),
    quantize = assert( decNumber.quantize ),
    reduce = assert( decNumber.normalize ),
    remainder = assert( decNumber.remainder ),
    remaindernear = assert( decNumber.remaindernear ),
    rescale = assert( decNumber.rescale ),
    rotate = assert( decNumber.rotate ),
    samequantum = assert( decNumber.samequantum ),
    squareroot = assert( decNumber.squareroot ),
    scaleb = assert( decNumber.scaleb ),
    shift = assert( decNumber.shift ),
    subtract = assert( decNumber.subtract ),
    toeng = assert( decNumber.toengstring ),
    tointegral = assert( decNumber.tointegralvalue ),
    tointegralx = assert( decNumber.tointegralexact ),
    tosci = assert( decNumber.tostring ),
    trim = assert( decNumber.trim ),
    xor = assert( decNumber.xor )
}

conditions = 
{
    clamped = assert( decNumber.Clamped ),
    conversion_syntax = assert( decNumber.Conversion_syntax ),
    division_by_zero = assert( decNumber.Division_by_zero ),
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346

347
348
349



350
351
352
353
354
355
356
357
358
359
360
361
362

363
364
365



366
367
368
369
370
371
372
373
    if bit.band(c,decNumber.Overflow) ~= 0 then s = s..sep.."Overflow" sep = "," end
    if bit.band(c,decNumber.Rounded) ~= 0 then s = s..sep.."Rounded" sep = "," end
    if bit.band(c,decNumber.Subnormal) ~= 0 then s = s..sep.."Subnormal" sep = "," end
    if bit.band(c,decNumber.Underflow) ~= 0 then s = s..sep.."Underflow" sep = "," end
    return s
end

evaltest = function (id, op_, d1_, d2_, rt_, t, first_cond)
    testsrun = testsrun + 1
    if skip_tests_precision
    then
        print (string.format ("%s xp skipped: precision unavailable", id))
        testspuntedp = testspuntedp + 1
        return
    end
    --if string.sub(d1_,1,1) == "#" or string.sub(d2_,1,1) == "#" or string.sub(rt_,1,1) == "#"
    if string.find(d1_,"#") or string.find(d2_,"#") or string.find(rt_,"#")
    then
        print (string.format ("%s x# skipped: no # tests implemented", id))
        testspuntedo = testspuntedo + 1
        return
    end
    --
    local ctx = decNumber.getcontext()
    ctx:setstatus(0)
    local failed = false
    local rounded = false
    local ss = ""
    --
    local op = assert(operations[string.lower(op_)], string.format ("unknown op %s", op_))
    local d1, d2
    if op ~= decNumber.tostring and op ~= decNumber.toengstring and op ~= apply_function
    then
        -- use full precision for converting operands
        local prec = ctx:getdigits()
        ctx:setdigits(MAX_DIGITS)
        d1 = decNumber.tonumber (d1_)
        if d2_ ~= "" then d2 = decNumber.tonumber (d2_) else d2 = d2_ end

        if ctx:getstatus() ~= 0
        then
            ss = make_status_str(ctx:getstatus())



            if bit.band(ctx:getstatus(),decNumber.Rounded) ~= 0 -- bit.bor(decNumber.Rounded,decNumber.Inexact)
            then
                rounded = true
            end
        end
        ctx:setdigits(prec)
        ctx:setstatus(0)
    else
        --d1 = decNumber.tonumber (d1_)
        --if d2_ ~= "" then d2 = decNumber.tonumber (d2_) else d2 = d2_ end
        -- let ldn_get do it
        d1 = d1_
        d2 = d2_

    end
    --
    local rg



    if d2_ ~= ""
    then
        rg = op (d1, d2)
    else
        rg = op (d1)
    end
    if rg == nil
    then







|








|













|







>



>
>
>
|












>



>
>
>
|







331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
    if bit.band(c,decNumber.Overflow) ~= 0 then s = s..sep.."Overflow" sep = "," end
    if bit.band(c,decNumber.Rounded) ~= 0 then s = s..sep.."Rounded" sep = "," end
    if bit.band(c,decNumber.Subnormal) ~= 0 then s = s..sep.."Subnormal" sep = "," end
    if bit.band(c,decNumber.Underflow) ~= 0 then s = s..sep.."Underflow" sep = "," end
    return s
end

evaltest = function (id, op_, d1_, d2_, d3_, rt_, t, first_cond)
    testsrun = testsrun + 1
    if skip_tests_precision
    then
        print (string.format ("%s xp skipped: precision unavailable", id))
        testspuntedp = testspuntedp + 1
        return
    end
    --if string.sub(d1_,1,1) == "#" or string.sub(d2_,1,1) == "#" or string.sub(rt_,1,1) == "#"
    if string.find(d1_,"#") or string.find(d2_,"#") or string.find(d3_,"#") or string.find(rt_,"#")
    then
        print (string.format ("%s x# skipped: no # tests implemented", id))
        testspuntedo = testspuntedo + 1
        return
    end
    --
    local ctx = decNumber.getcontext()
    ctx:setstatus(0)
    local failed = false
    local rounded = false
    local ss = ""
    --
    local op = assert(operations[string.lower(op_)], string.format ("unknown op %s", op_))
    local d1, d2, d3
    if op ~= decNumber.tostring and op ~= decNumber.toengstring and op ~= apply_function
    then
        -- use full precision for converting operands
        local prec = ctx:getdigits()
        ctx:setdigits(MAX_DIGITS)
        d1 = decNumber.tonumber (d1_)
        if d2_ ~= "" then d2 = decNumber.tonumber (d2_) else d2 = d2_ end
        if d3_ ~= "" then d3 = decNumber.tonumber (d3_) else d3 = d3_ end
        if ctx:getstatus() ~= 0
        then
            ss = make_status_str(ctx:getstatus())
            --local convngmask = decNumber.Rounded
            --local convngmask = bit.bor(decNumber.Rounded,decNumber.Inexact)
            local convngmask = bit.bor(decNumber.Rounded,decNumber.Clamped) -- good
            if bit.band(ctx:getstatus(),convngmask) ~= 0
            then
                rounded = true
            end
        end
        ctx:setdigits(prec)
        ctx:setstatus(0)
    else
        --d1 = decNumber.tonumber (d1_)
        --if d2_ ~= "" then d2 = decNumber.tonumber (d2_) else d2 = d2_ end
        -- let ldn_get do it
        d1 = d1_
        d2 = d2_
        d3 = d3_
    end
    --
    local rg
    if d3_ ~= ""
    then
        rg = op (d1, d2, d3)
    elseif d2_ ~= ""
    then
        rg = op (d1, d2)
    else
        rg = op (d1)
    end
    if rg == nil
    then
442
443
444
445
446
447
448
449
450
451
452

453
454
455
456
457
458





459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476

477
478

479
480





481
482
483

484

485
486

487

488

489
490



491
492
493
494
495
496
497

498
499
500
501

502


503
504
505

506












507








508
509









































510

























511
512
513
514
515
516
517
    local id = t[1]
    if id == nil then return end -- comment line
    if string.sub(id,-1,-1) == ":"
    then
        assert (t[3] == nil, string.format("malformed line %d -- extra directive args",lnum))
        evaldirective ( string.lower( string.sub(id,1,-2) ), t[2] )
    else
        -- id operation operand1 [operand2] –> result [conditions...]
        local op = t[2]
        local d1 = t[3]
        local d2 = t[4]

        local first_cond = 7
        if d2 == "->"
        then
            d2 = ""
            rt = t[5]
            first_cond = 6





        else
            if t[5] ~= "->"
            then
                print (string.format("**** malformed line %d -- misplaced ->",lnum))
                return
            end
            rt = t[6]
        end
        -- print (string.format ("test (%s): %s (%s) (%s) = (%s)", id, op, d1, d2, rt))
        -- for i = first_cond, #t do print (string.format ("cond %s", t[i])) end
        evaltest (id, op, d1, d2, rt, t, first_cond)
    end
end

--dotestfile ("dectest/abs.decTest", showtoks)

dotestfile ("dectest/abs.decTest", evalline)
dotestfile ("dectest/add.decTest", evalline)

dotestfile ("dectest/base.decTest", evalline)
dotestfile ("dectest/clamp.decTest", evalline)

dotestfile ("dectest/compare.decTest", evalline)
dotestfile ("dectest/comparetotal.decTest", evalline)





dotestfile ("dectest/divide.decTest", evalline)
dotestfile ("dectest/divideint.decTest", evalline)
dotestfile ("dectest/exp.decTest", evalline)

dotestfile ("dectest/inexact.decTest", evalline)

dotestfile ("dectest/ln.decTest", evalline)
dotestfile ("dectest/log10.decTest", evalline)

dotestfile ("dectest/max.decTest", evalline)

dotestfile ("dectest/min.decTest", evalline)

dotestfile ("dectest/minus.decTest", evalline)
dotestfile ("dectest/multiply.decTest", evalline)



dotestfile ("dectest/normalize.decTest", evalline)
dotestfile ("dectest/plus.decTest", evalline)
dotestfile ("dectest/power.decTest", evalline)
dotestfile ("dectest/powersqrt.decTest", evalline)
dotestfile ("dectest/quantize.decTest", evalline)
dotestfile ("dectest/randombound32.decTest", evalline)
dotestfile ("dectest/randoms.decTest", evalline)

dotestfile ("dectest/remainder.decTest", evalline)
dotestfile ("dectest/remaindernear.decTest", evalline)
dotestfile ("dectest/rescale.decTest", evalline)
dotestfile ("dectest/rounding.decTest", evalline)

dotestfile ("dectest/samequantum.decTest", evalline)


dotestfile ("dectest/squareroot.decTest", evalline)
dotestfile ("dectest/subtract.decTest", evalline)
dotestfile ("dectest/tointegral.decTest", evalline)

dotestfile ("dectest/trim.decTest", evalline)












--dotestfile ("dectest/decimal32.decTest", evalline)








--dotestfile ("dectest/decimal64decTest", evalline)
--dotestfile ("dectest/decimal128.decTest", evalline)









































--dotestfile ("dectest/testall.decTest", evalline)


























do
    local s = ""
    local r = ""
    if total_halffailures ~= 0
    then
        s = string.format (" (%d of these semi-succeeded)", total_halffailures )







|



>
|





>
>
>
>
>

|




|



|



|



>


>


>
>
>
>
>



>

>


>

>

>


>
>
>
|






>




>

>
>



>

>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
    local id = t[1]
    if id == nil then return end -- comment line
    if string.sub(id,-1,-1) == ":"
    then
        assert (t[3] == nil, string.format("malformed line %d -- extra directive args",lnum))
        evaldirective ( string.lower( string.sub(id,1,-2) ), t[2] )
    else
        -- id operation operand1 [operand2 [operand3]] –> result [conditions...]
        local op = t[2]
        local d1 = t[3]
        local d2 = t[4]
        local d3 = t[5]
        local first_cond = 8
        if d2 == "->"
        then
            d2 = ""
            rt = t[5]
            first_cond = 6
        elseif d3 == "->"
        then
            d3 = ""
            rt = t[6]
            first_cond = 7
        else
            if t[6] ~= "->"
            then
                print (string.format("**** malformed line %d -- misplaced ->",lnum))
                return
            end
            rt = t[7]
        end
        -- print (string.format ("test (%s): %s (%s) (%s) = (%s)", id, op, d1, d2, rt))
        -- for i = first_cond, #t do print (string.format ("cond %s", t[i])) end
        evaltest (id, op, d1, d2, d3, rt, t, first_cond)
    end
end

-- dotestfile ("dectest/rounding.decTest", showtoks)

dotestfile ("dectest/abs.decTest", evalline)
dotestfile ("dectest/add.decTest", evalline)
dotestfile ("dectest/and.decTest", evalline)
dotestfile ("dectest/base.decTest", evalline)
dotestfile ("dectest/clamp.decTest", evalline)
dotestfile ("dectest/class.decTest", evalline)
dotestfile ("dectest/compare.decTest", evalline)
dotestfile ("dectest/comparetotal.decTest", evalline)
dotestfile ("dectest/comparetotmag.decTest", evalline)
dotestfile ("dectest/copy.decTest", evalline)
dotestfile ("dectest/copyabs.decTest", evalline)
dotestfile ("dectest/copynegate.decTest", evalline)
dotestfile ("dectest/copysign.decTest", evalline)
dotestfile ("dectest/divide.decTest", evalline)
dotestfile ("dectest/divideint.decTest", evalline)
dotestfile ("dectest/exp.decTest", evalline)
dotestfile ("dectest/fma.decTest", evalline)
dotestfile ("dectest/inexact.decTest", evalline)
dotestfile ("dectest/invert.decTest", evalline)
dotestfile ("dectest/ln.decTest", evalline)
dotestfile ("dectest/log10.decTest", evalline)
dotestfile ("dectest/logb.decTest", evalline)
dotestfile ("dectest/max.decTest", evalline)
dotestfile ("dectest/maxmag.decTest", evalline)
dotestfile ("dectest/min.decTest", evalline)
dotestfile ("dectest/minmag.decTest", evalline)
dotestfile ("dectest/minus.decTest", evalline)
dotestfile ("dectest/multiply.decTest", evalline)
dotestfile ("dectest/nextminus.decTest", evalline)
dotestfile ("dectest/nextplus.decTest", evalline)
dotestfile ("dectest/nexttoward.decTest", evalline)
dotestfile ("dectest/or.decTest", evalline)
dotestfile ("dectest/plus.decTest", evalline)
dotestfile ("dectest/power.decTest", evalline)
dotestfile ("dectest/powersqrt.decTest", evalline)
dotestfile ("dectest/quantize.decTest", evalline)
dotestfile ("dectest/randombound32.decTest", evalline)
dotestfile ("dectest/randoms.decTest", evalline)
dotestfile ("dectest/reduce.decTest", evalline)
dotestfile ("dectest/remainder.decTest", evalline)
dotestfile ("dectest/remaindernear.decTest", evalline)
dotestfile ("dectest/rescale.decTest", evalline)
dotestfile ("dectest/rounding.decTest", evalline)
dotestfile ("dectest/rotate.decTest", evalline)
dotestfile ("dectest/samequantum.decTest", evalline)
dotestfile ("dectest/scaleb.decTest", evalline)
dotestfile ("dectest/shift.decTest", evalline)
dotestfile ("dectest/squareroot.decTest", evalline)
dotestfile ("dectest/subtract.decTest", evalline)
dotestfile ("dectest/tointegral.decTest", evalline)
dotestfile ("dectest/tointegralx.decTest", evalline)
dotestfile ("dectest/trim.decTest", evalline)
dotestfile ("dectest/xor.decTest", evalline)
--dotestfile ("dectest/testall.decTest", evalline)
-- no: decSingle.decTest dsEncode.decTest (no format encoders)
dotestfile ("dectest/dsBase.decTest", evalline)
-- no: decDouble.decTest ddEncode.decTest (no format encoders. no signal)
dotestfile ("dectest/ddAbs.decTest", evalline)
dotestfile ("dectest/ddAdd.decTest", evalline)
dotestfile ("dectest/ddAnd.decTest", evalline)
dotestfile ("dectest/ddBase.decTest", evalline)
dotestfile ("dectest/ddCanonical.decTest", evalline)
dotestfile ("dectest/ddClass.decTest", evalline)
dotestfile ("dectest/ddCompare.decTest", evalline)
--dotestfile ("dectest/ddCompareSig.decTest", evalline)
dotestfile ("dectest/ddCompareTotal.decTest", evalline)
dotestfile ("dectest/ddCompareTotalMag.decTest", evalline)
dotestfile ("dectest/ddCopy.decTest", evalline)
dotestfile ("dectest/ddCopyAbs.decTest", evalline)
dotestfile ("dectest/ddCopyNegate.decTest", evalline)
dotestfile ("dectest/ddCopySign.decTest", evalline)
dotestfile ("dectest/ddDivide.decTest", evalline)
dotestfile ("dectest/ddDivideInt.decTest", evalline)
--dotestfile ("dectest/ddEncode.decTest", evalline)
dotestfile ("dectest/ddFMA.decTest", evalline)
dotestfile ("dectest/ddInvert.decTest", evalline)
dotestfile ("dectest/ddLogB.decTest", evalline)
dotestfile ("dectest/ddMax.decTest", evalline)
dotestfile ("dectest/ddMaxMag.decTest", evalline)
dotestfile ("dectest/ddMin.decTest", evalline)
dotestfile ("dectest/ddMinMag.decTest", evalline)
dotestfile ("dectest/ddMinus.decTest", evalline)
dotestfile ("dectest/ddMultiply.decTest", evalline)
dotestfile ("dectest/ddNextMinus.decTest", evalline)
dotestfile ("dectest/ddNextPlus.decTest", evalline)
dotestfile ("dectest/ddNextToward.decTest", evalline)
dotestfile ("dectest/ddOr.decTest", evalline)
dotestfile ("dectest/ddPlus.decTest", evalline)
dotestfile ("dectest/ddQuantize.decTest", evalline)
dotestfile ("dectest/ddReduce.decTest", evalline)
dotestfile ("dectest/ddRemainder.decTest", evalline)
dotestfile ("dectest/ddRemainderNear.decTest", evalline)
dotestfile ("dectest/ddRotate.decTest", evalline)
dotestfile ("dectest/ddSameQuantum.decTest", evalline)
dotestfile ("dectest/ddScaleB.decTest", evalline)
dotestfile ("dectest/ddShift.decTest", evalline)
dotestfile ("dectest/ddSubtract.decTest", evalline)
dotestfile ("dectest/ddToIntegral.decTest", evalline)
dotestfile ("dectest/ddXor.decTest", evalline)
-- no: decQuad.decTest dqEncode.decTest (no format encoders. no signal)
dotestfile ("dectest/dqAbs.decTest", evalline)
dotestfile ("dectest/dqAdd.decTest", evalline)
dotestfile ("dectest/dqAnd.decTest", evalline)
dotestfile ("dectest/dqBase.decTest", evalline)
dotestfile ("dectest/dqCanonical.decTest", evalline)
dotestfile ("dectest/dqClass.decTest", evalline)
dotestfile ("dectest/dqCompare.decTest", evalline)
--dotestfile ("dectest/dqCompareSig.decTest", evalline)
dotestfile ("dectest/dqCompareTotal.decTest", evalline)
dotestfile ("dectest/dqCompareTotalMag.decTest", evalline)
dotestfile ("dectest/dqCopy.decTest", evalline)
dotestfile ("dectest/dqCopyAbs.decTest", evalline)
dotestfile ("dectest/dqCopyNegate.decTest", evalline)
dotestfile ("dectest/dqCopySign.decTest", evalline)
dotestfile ("dectest/dqDivide.decTest", evalline)
dotestfile ("dectest/dqDivideInt.decTest", evalline)
--dotestfile ("dectest/dqEncode.decTest", evalline)
dotestfile ("dectest/dqFMA.decTest", evalline)
dotestfile ("dectest/dqInvert.decTest", evalline)
dotestfile ("dectest/dqLogB.decTest", evalline)
dotestfile ("dectest/dqMax.decTest", evalline)
dotestfile ("dectest/dqMaxMag.decTest", evalline)
dotestfile ("dectest/dqMin.decTest", evalline)
dotestfile ("dectest/dqMinMag.decTest", evalline)
dotestfile ("dectest/dqMinus.decTest", evalline)
dotestfile ("dectest/dqMultiply.decTest", evalline)
dotestfile ("dectest/dqNextMinus.decTest", evalline)
dotestfile ("dectest/dqNextPlus.decTest", evalline)
dotestfile ("dectest/dqNextToward.decTest", evalline)
dotestfile ("dectest/dqOr.decTest", evalline)
dotestfile ("dectest/dqPlus.decTest", evalline)
dotestfile ("dectest/dqQuantize.decTest", evalline)
dotestfile ("dectest/dqReduce.decTest", evalline)
dotestfile ("dectest/dqRemainder.decTest", evalline)
dotestfile ("dectest/dqRemainderNear.decTest", evalline)
dotestfile ("dectest/dqRotate.decTest", evalline)
dotestfile ("dectest/dqSameQuantum.decTest", evalline)
dotestfile ("dectest/dqScaleB.decTest", evalline)
dotestfile ("dectest/dqShift.decTest", evalline)
dotestfile ("dectest/dqSubtract.decTest", evalline)
dotestfile ("dectest/dqToIntegral.decTest", evalline)
dotestfile ("dectest/dqXor.decTest", evalline)

do
    local s = ""
    local r = ""
    if total_halffailures ~= 0
    then
        s = string.format (" (%d of these semi-succeeded)", total_halffailures )

Changes to test/ldecNumberUnitTest.lua.

525
526
527
528
529
530
531






































































































532
533
534
    assert_not_equal (r1,t1)
    assert_equal (r2, s2)
    assert_not_equal (r1,r2)
    assert_not_equal (r2,t2)
    assert_true(r(12,-12) < r(12,1))
    assert_true(t(12,-12) < decNumber.tonumber "1")
    assert_true(t(12,1) > decNumber.tonumber "1")






































































































end

lunit.run()







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
    assert_not_equal (r1,t1)
    assert_equal (r2, s2)
    assert_not_equal (r1,r2)
    assert_not_equal (r2,t2)
    assert_true(r(12,-12) < r(12,1))
    assert_true(t(12,-12) < decNumber.tonumber "1")
    assert_true(t(12,1) > decNumber.tonumber "1")
end

local cls_funcs = lunit.TestCase("Classifier Functions")

function cls_funcs:test()
    local ctx = decNumber.getcontext()
    ctx:setdefault(decNumber.INIT_DECIMAL128)
    local pi = (decNumber.tonumber "1") / 0
    local ni = -pi
    local pn = decNumber.tonumber "12.347"
    local nn = -pn
    local ps = decNumber.tonumber "1e-6144"
    local ns = -ps
    local nz = decNumber.tonumber "-0"
    local pz = -nz
    local nan = decNumber.tonumber "NaN"
    local inv = (decNumber.tonumber "2"):invert()
    assert_equal (pi:classasstring(), "+Infinity")
    assert_equal (ni:classasstring(), "-Infinity")
    assert_equal (pn:classasstring(), "+Normal")
    assert_equal (nn:classasstring(), "-Normal")
    assert_equal (ps:classasstring(), "+Subnormal")
    assert_equal (ns:classasstring(), "-Subnormal")
    assert_equal (pz:classasstring(), "+Zero")
    assert_equal (nz:classasstring(), "-Zero")
    assert_equal (nan:classasstring(), "NaN")
    --assert_equal (inv:classasstring(), "Invalid") -- NaN
    assert_equal (pi:class(), decNumber.CLASS_POS_INF)
    assert_equal (ni:class(), decNumber.CLASS_NEG_INF)
    assert_equal (pn:class(), decNumber.CLASS_POS_NORMAL)
    assert_equal (nn:class(), decNumber.CLASS_NEG_NORMAL)
    assert_equal (ps:class(), decNumber.CLASS_POS_SUBNORMAL)
    assert_equal (ns:class(), decNumber.CLASS_NEG_SUBNORMAL)
    assert_equal (pz:class(), decNumber.CLASS_POS_ZERO)
    assert_equal (nz:class(), decNumber.CLASS_NEG_ZERO)
    assert_equal (nan:class(), decNumber.CLASS_QNAN)
    assert_equal (decNumber.classtostring(pi:class()), "+Infinity")
    assert_equal (decNumber.classtostring(ni:class()), "-Infinity")
    assert_equal (decNumber.classtostring(pn:class()), "+Normal")
    assert_equal (decNumber.classtostring(nn:class()), "-Normal")
    assert_equal (decNumber.classtostring(ps:class()), "+Subnormal")
    assert_equal (decNumber.classtostring(ns:class()), "-Subnormal")
    assert_equal (decNumber.classtostring(pz:class()), "+Zero")
    assert_equal (decNumber.classtostring(nz:class()), "-Zero")
    assert_equal (decNumber.classtostring(nan:class()), "NaN")
    -- predicates
    assert_false (pi:isnormal())
    assert_false (ni:isnormal())
    assert_true  (pn:isnormal())
    assert_true  (nn:isnormal())
    assert_false (pz:isnormal())
    assert_false (nz:isnormal())
    assert_false (ns:isnormal())
    assert_false (ps:isnormal())
    assert_false (nan:isnormal())
    assert_false (pi:issubnormal())
    assert_false (ni:issubnormal())
    assert_false (pn:issubnormal())
    assert_false (nn:issubnormal())
    assert_false (pz:issubnormal())
    assert_false (nz:issubnormal())
    assert_true  (ns:issubnormal())
    assert_true  (ps:issubnormal())
    assert_false (nan:issubnormal())
    assert_false (pi:isfinite())
    assert_false (ni:isfinite())
    assert_true  (pn:isfinite())
    assert_true  (nn:isfinite())
    assert_true  (pz:isfinite())
    assert_true  (nz:isfinite())
    assert_true  (ns:isfinite())
    assert_true  (ps:isfinite())
    assert_false (nan:isfinite())
    assert_true  (pi:isspecial())
    assert_true  (ni:isspecial())
    assert_false (pn:isspecial())
    assert_false (nn:isspecial())
    assert_false (pz:isspecial())
    assert_false (nz:isspecial())
    assert_false (ns:isspecial())
    assert_false (ps:isspecial())
    assert_true  (nan:isspecial())
    assert_true (pi:iscanonical())
    assert_true (ni:iscanonical())
    assert_true (pn:iscanonical())
    assert_true (nn:iscanonical())
    assert_true (pz:iscanonical())
    assert_true (nz:iscanonical())
    assert_true (ns:iscanonical())
    assert_true (ps:iscanonical())
    assert_true (nan:iscanonical())
    -- misc
    assert_equal (pi:radix(), 10)
    assert_equal (ni:radix(), 10)
    assert_equal (pn:radix(), 10)
    assert_equal (nn:radix(), 10)
    assert_equal (ps:radix(), 10)
    assert_equal (ns:radix(), 10)
    assert_equal (pz:radix(), 10)
    assert_equal (nz:radix(), 10)
    assert_equal (nan:radix(), 10)

end

lunit.run()