1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.hipparchus.dfp;
24
25 import org.junit.After;
26 import org.junit.Assert;
27 import org.junit.Before;
28 import org.junit.Test;
29
30 public class DfpDecTest {
31
32 private DfpField field;
33 private Dfp pinf;
34 private Dfp ninf;
35
36 @Before
37 public void setUp() {
38
39 field = new DfpField(20);
40 pinf = new DfpDec(field, 1).divide(new DfpDec(field, 0));
41 ninf = new DfpDec(field, -1).divide(new DfpDec(field, 0));
42 ninf.getField().clearIEEEFlags();
43 }
44
45 @After
46 public void tearDown() {
47 field = null;
48 pinf = null;
49 ninf = null;
50 }
51
52
53
54
55 private void test(Dfp x, Dfp y, int flags, String desc) {
56 boolean b = x.equals(y);
57
58 if (!x.equals(y) && !x.unequal(y))
59 b = (x.toString().equals(y.toString()));
60
61 if (x.equals(new DfpDec(field, 0)))
62 b = (b && (x.toString().equals(y.toString())));
63
64 b = (b && x.getField().getIEEEFlags() == flags);
65
66 if (!b)
67 Assert.assertTrue("assersion failed "+desc+" x = "+x.toString()+" flags = "+x.getField().getIEEEFlags(), b);
68
69 x.getField().clearIEEEFlags();
70 }
71
72 @Test
73 public void testRound()
74 {
75 field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_EVEN);
76
77 test(new DfpDec(field, "12345678901234567890"),
78 new DfpDec(field, "12345678901234568000"),
79 DfpField.FLAG_INEXACT, "Round #1");
80
81 test(new DfpDec(field, "0.12345678901234567890"),
82 new DfpDec(field, "0.12345678901234568"),
83 DfpField.FLAG_INEXACT, "Round #2");
84
85 test(new DfpDec(field, "0.12345678901234567500"),
86 new DfpDec(field, "0.12345678901234568"),
87 DfpField.FLAG_INEXACT, "Round #3");
88
89 test(new DfpDec(field, "0.12345678901234568500"),
90 new DfpDec(field, "0.12345678901234568"),
91 DfpField.FLAG_INEXACT, "Round #4");
92
93 test(new DfpDec(field, "0.12345678901234568501"),
94 new DfpDec(field, "0.12345678901234569"),
95 DfpField.FLAG_INEXACT, "Round #5");
96
97 test(new DfpDec(field, "0.12345678901234568499"),
98 new DfpDec(field, "0.12345678901234568"),
99 DfpField.FLAG_INEXACT, "Round #6");
100
101 test(new DfpDec(field, "1.2345678901234567890"),
102 new DfpDec(field, "1.2345678901234568"),
103 DfpField.FLAG_INEXACT, "Round #7");
104
105 test(new DfpDec(field, "1.2345678901234567500"),
106 new DfpDec(field, "1.2345678901234568"),
107 DfpField.FLAG_INEXACT, "Round #8");
108
109 test(new DfpDec(field, "1.2345678901234568500"),
110 new DfpDec(field, "1.2345678901234568"),
111 DfpField.FLAG_INEXACT, "Round #9");
112
113 test(new DfpDec(field, "1.2345678901234568000").add(new DfpDec(field, ".0000000000000000501")),
114 new DfpDec(field, "1.2345678901234569"),
115 DfpField.FLAG_INEXACT, "Round #10");
116
117 test(new DfpDec(field, "1.2345678901234568499"),
118 new DfpDec(field, "1.2345678901234568"),
119 DfpField.FLAG_INEXACT, "Round #11");
120
121 test(new DfpDec(field, "12.345678901234567890"),
122 new DfpDec(field, "12.345678901234568"),
123 DfpField.FLAG_INEXACT, "Round #12");
124
125 test(new DfpDec(field, "12.345678901234567500"),
126 new DfpDec(field, "12.345678901234568"),
127 DfpField.FLAG_INEXACT, "Round #13");
128
129 test(new DfpDec(field, "12.345678901234568500"),
130 new DfpDec(field, "12.345678901234568"),
131 DfpField.FLAG_INEXACT, "Round #14");
132
133 test(new DfpDec(field, "12.345678901234568").add(new DfpDec(field, ".000000000000000501")),
134 new DfpDec(field, "12.345678901234569"),
135 DfpField.FLAG_INEXACT, "Round #15");
136
137 test(new DfpDec(field, "12.345678901234568499"),
138 new DfpDec(field, "12.345678901234568"),
139 DfpField.FLAG_INEXACT, "Round #16");
140
141 test(new DfpDec(field, "123.45678901234567890"),
142 new DfpDec(field, "123.45678901234568"),
143 DfpField.FLAG_INEXACT, "Round #17");
144
145 test(new DfpDec(field, "123.45678901234567500"),
146 new DfpDec(field, "123.45678901234568"),
147 DfpField.FLAG_INEXACT, "Round #18");
148
149 test(new DfpDec(field, "123.45678901234568500"),
150 new DfpDec(field, "123.45678901234568"),
151 DfpField.FLAG_INEXACT, "Round #19");
152
153 test(new DfpDec(field, "123.456789012345685").add(new DfpDec(field, ".00000000000000501")),
154 new DfpDec(field, "123.45678901234569"),
155 DfpField.FLAG_INEXACT, "Round #20");
156
157 test(new DfpDec(field, "123.45678901234568499"),
158 new DfpDec(field, "123.45678901234568"),
159 DfpField.FLAG_INEXACT, "Round #21");
160
161 field.setRoundingMode(DfpField.RoundingMode.ROUND_DOWN);
162
163
164 test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.9")),
165 new DfpDec(field, "12345678901234567"),
166 DfpField.FLAG_INEXACT, "Round #22");
167
168 test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.99999999")),
169 new DfpDec(field, "12345678901234567"),
170 DfpField.FLAG_INEXACT, "Round #23");
171
172 test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.99999999")),
173 new DfpDec(field, "-12345678901234567"),
174 DfpField.FLAG_INEXACT, "Round #24");
175
176 field.setRoundingMode(DfpField.RoundingMode.ROUND_UP);
177
178
179 test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.1")),
180 new DfpDec(field, "12345678901234568"),
181 DfpField.FLAG_INEXACT, "Round #25");
182
183 test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.0001")),
184 new DfpDec(field, "12345678901234568"),
185 DfpField.FLAG_INEXACT, "Round #26");
186
187 test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.1")),
188 new DfpDec(field, "-12345678901234568"),
189 DfpField.FLAG_INEXACT, "Round #27");
190
191 test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.0001")),
192 new DfpDec(field, "-12345678901234568"),
193 DfpField.FLAG_INEXACT, "Round #28");
194
195 test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "0")),
196 new DfpDec(field, "-12345678901234567"),
197 0, "Round #28.5");
198
199 field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_UP);
200
201
202 test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.499999999999")),
203 new DfpDec(field, "12345678901234567"),
204 DfpField.FLAG_INEXACT, "Round #29");
205
206 test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.50000001")),
207 new DfpDec(field, "12345678901234568"),
208 DfpField.FLAG_INEXACT, "Round #30");
209
210 test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.5")),
211 new DfpDec(field, "12345678901234568"),
212 DfpField.FLAG_INEXACT, "Round #30.5");
213
214 test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.499999999999")),
215 new DfpDec(field, "-12345678901234567"),
216 DfpField.FLAG_INEXACT, "Round #31");
217
218 test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.50000001")),
219 new DfpDec(field, "-12345678901234568"),
220 DfpField.FLAG_INEXACT, "Round #32");
221
222 field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_DOWN);
223
224
225 test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.5001")),
226 new DfpDec(field, "12345678901234568"),
227 DfpField.FLAG_INEXACT, "Round #33");
228
229 test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.5000")),
230 new DfpDec(field, "12345678901234567"),
231 DfpField.FLAG_INEXACT, "Round #34");
232
233 test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.5001")),
234 new DfpDec(field, "-12345678901234568"),
235 DfpField.FLAG_INEXACT, "Round #35");
236
237 test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.6")),
238 new DfpDec(field, "-12345678901234568"),
239 DfpField.FLAG_INEXACT, "Round #35.5");
240
241 test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.5000")),
242 new DfpDec(field, "-12345678901234567"),
243 DfpField.FLAG_INEXACT, "Round #36");
244
245 field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_ODD);
246
247
248 test(new DfpDec(field, "12345678901234568").add(new DfpDec(field, "0.5000")),
249 new DfpDec(field, "12345678901234569"),
250 DfpField.FLAG_INEXACT, "Round #37");
251
252 test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.5000")),
253 new DfpDec(field, "12345678901234567"),
254 DfpField.FLAG_INEXACT, "Round #38");
255
256 test(new DfpDec(field, "-12345678901234568").add(new DfpDec(field, "-0.5000")),
257 new DfpDec(field, "-12345678901234569"),
258 DfpField.FLAG_INEXACT, "Round #39");
259
260 test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.5000")),
261 new DfpDec(field, "-12345678901234567"),
262 DfpField.FLAG_INEXACT, "Round #40");
263
264 field.setRoundingMode(DfpField.RoundingMode.ROUND_CEIL);
265
266
267 test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.0001")),
268 new DfpDec(field, "12345678901234568"),
269 DfpField.FLAG_INEXACT, "Round #41");
270
271 test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.9999")),
272 new DfpDec(field, "-12345678901234567"),
273 DfpField.FLAG_INEXACT, "Round #42");
274
275 field.setRoundingMode(DfpField.RoundingMode.ROUND_FLOOR);
276
277
278 test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.9999")),
279 new DfpDec(field, "12345678901234567"),
280 DfpField.FLAG_INEXACT, "Round #43");
281
282 test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.0001")),
283 new DfpDec(field, "-12345678901234568"),
284 DfpField.FLAG_INEXACT, "Round #44");
285
286 field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_EVEN);
287 }
288
289 @Test
290 public void testRoundDecimal10()
291 {
292 field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_EVEN);
293
294 test(new Decimal10(field, "1234567891234567890"),
295 new Decimal10(field, "1234567891000000000"),
296 DfpField.FLAG_INEXACT, "RoundDecimal10 #1");
297
298 test(new Decimal10(field, "0.1234567891634567890"),
299 new Decimal10(field, "0.1234567892"),
300 DfpField.FLAG_INEXACT, "RoundDecimal10 #2");
301
302 test(new Decimal10(field, "0.1234567891500000000"),
303 new Decimal10(field, "0.1234567892"),
304 DfpField.FLAG_INEXACT, "RoundDecimal10 #3");
305
306 test(new Decimal10(field, "0.1234567890500"),
307 new Decimal10(field, "0.1234567890"),
308 DfpField.FLAG_INEXACT, "RoundDecimal10 #4");
309
310 test(new Decimal10(field, "0.1234567890501"),
311 new Decimal10(field, "0.1234567891"),
312 DfpField.FLAG_INEXACT, "RoundDecimal10 #5");
313
314 test(new Decimal10(field, "0.1234567890499"),
315 new Decimal10(field, "0.1234567890"),
316 DfpField.FLAG_INEXACT, "RoundDecimal10 #6");
317
318 test(new Decimal10(field, "1.234567890890"),
319 new Decimal10(field, "1.234567891"),
320 DfpField.FLAG_INEXACT, "RoundDecimal10 #7");
321
322 test(new Decimal10(field, "1.234567891500"),
323 new Decimal10(field, "1.234567892"),
324 DfpField.FLAG_INEXACT, "RoundDecimal10 #8");
325
326 test(new Decimal10(field, "1.234567890500"),
327 new Decimal10(field, "1.234567890"),
328 DfpField.FLAG_INEXACT, "RoundDecimal10 #9");
329
330 test(new Decimal10(field, "1.234567890000").add(new Decimal10(field, ".000000000501")),
331 new Decimal10(field, "1.234567891"),
332 DfpField.FLAG_INEXACT, "RoundDecimal10 #10");
333
334 test(new Decimal10(field, "1.234567890499"),
335 new Decimal10(field, "1.234567890"),
336 DfpField.FLAG_INEXACT, "RoundDecimal10 #11");
337
338 test(new Decimal10(field, "12.34567890890"),
339 new Decimal10(field, "12.34567891"),
340 DfpField.FLAG_INEXACT, "RoundDecimal10 #12");
341
342 test(new Decimal10(field, "12.34567891500"),
343 new Decimal10(field, "12.34567892"),
344 DfpField.FLAG_INEXACT, "RoundDecimal10 #13");
345
346 test(new Decimal10(field, "12.34567890500"),
347 new Decimal10(field, "12.34567890"),
348 DfpField.FLAG_INEXACT, "RoundDecimal10 #14");
349
350 test(new Decimal10(field, "12.34567890").add(new Decimal10(field, ".00000000501")),
351 new Decimal10(field, "12.34567891"),
352 DfpField.FLAG_INEXACT, "RoundDecimal10 #15");
353
354 test(new Decimal10(field, "12.34567890499"),
355 new Decimal10(field, "12.34567890"),
356 DfpField.FLAG_INEXACT, "RoundDecimal10 #16");
357
358 test(new Decimal10(field, "123.4567890890"),
359 new Decimal10(field, "123.4567891"),
360 DfpField.FLAG_INEXACT, "RoundDecimal10 #17");
361
362 test(new Decimal10(field, "123.4567891500"),
363 new Decimal10(field, "123.4567892"),
364 DfpField.FLAG_INEXACT, "RoundDecimal10 #18");
365
366 test(new Decimal10(field, "123.4567890500"),
367 new Decimal10(field, "123.4567890"),
368 DfpField.FLAG_INEXACT, "RoundDecimal10 #19");
369
370 test(new Decimal10(field, "123.4567890").add(new Decimal10(field, ".0000000501")),
371 new Decimal10(field, "123.4567891"),
372 DfpField.FLAG_INEXACT, "RoundDecimal10 #20");
373
374 test(new Decimal10(field, "123.4567890499"),
375 new Decimal10(field, "123.4567890"),
376 DfpField.FLAG_INEXACT, "RoundDecimal10 #21");
377
378 field.setRoundingMode(DfpField.RoundingMode.ROUND_DOWN);
379
380
381 test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.9")),
382 new Decimal10(field, "1234567890"),
383 DfpField.FLAG_INEXACT, "RoundDecimal10 #22");
384
385 test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.99999999")),
386 new Decimal10(field, "1234567890"),
387 DfpField.FLAG_INEXACT, "RoundDecimal10 #23");
388
389 test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.99999999")),
390 new Decimal10(field, "-1234567890"),
391 DfpField.FLAG_INEXACT, "RoundDecimal10 #24");
392
393 field.setRoundingMode(DfpField.RoundingMode.ROUND_UP);
394
395
396 test(new Decimal10(field, 1234567890).add(new Decimal10(field, "0.1")),
397 new Decimal10(field, 1234567891l),
398 DfpField.FLAG_INEXACT, "RoundDecimal10 #25");
399
400 test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.0001")),
401 new Decimal10(field, "1234567891"),
402 DfpField.FLAG_INEXACT, "RoundDecimal10 #26");
403
404 test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.1")),
405 new Decimal10(field, "-1234567891"),
406 DfpField.FLAG_INEXACT, "RoundDecimal10 #27");
407
408 test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.0001")),
409 new Decimal10(field, "-1234567891"),
410 DfpField.FLAG_INEXACT, "RoundDecimal10 #28");
411
412 test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "0")),
413 new Decimal10(field, "-1234567890"),
414 0, "RoundDecimal10 #28.5");
415
416 field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_UP);
417
418
419 test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.4999999999")),
420 new Decimal10(field, "1234567890"),
421 DfpField.FLAG_INEXACT, "RoundDecimal10 #29");
422
423 test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.50000001")),
424 new Decimal10(field, "1234567891"),
425 DfpField.FLAG_INEXACT, "RoundDecimal10 #30");
426
427 test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.5")),
428 new Decimal10(field, "1234567891"),
429 DfpField.FLAG_INEXACT, "RoundDecimal10 #30.5");
430
431 test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.4999999999")),
432 new Decimal10(field, "-1234567890"),
433 DfpField.FLAG_INEXACT, "RoundDecimal10 #31");
434
435 test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.50000001")),
436 new Decimal10(field, "-1234567891"),
437 DfpField.FLAG_INEXACT, "RoundDecimal10 #32");
438
439 field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_DOWN);
440
441
442 test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.5001")),
443 new Decimal10(field, "1234567890"),
444 DfpField.FLAG_INEXACT, "RoundDecimal10 #33");
445
446 test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.5000")),
447 new Decimal10(field, "1234567890"),
448 DfpField.FLAG_INEXACT, "RoundDecimal10 #34");
449
450 test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.5001")),
451 new Decimal10(field, "-1234567890"),
452 DfpField.FLAG_INEXACT, "RoundDecimal10 #35");
453
454 test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.6")),
455 new Decimal10(field, "-1234567891"),
456 DfpField.FLAG_INEXACT, "RoundDecimal10 #35.5");
457
458 test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.5000")),
459 new Decimal10(field, "-1234567890"),
460 DfpField.FLAG_INEXACT, "RoundDecimal10 #36");
461
462 field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_ODD);
463
464
465 test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.5000")),
466 new Decimal10(field, "1234567891"),
467 DfpField.FLAG_INEXACT, "RoundDecimal10 #37");
468
469 test(new Decimal10(field, "1234567891").add(new Decimal10(field, "0.5000")),
470 new Decimal10(field, "1234567891"),
471 DfpField.FLAG_INEXACT, "RoundDecimal10 #38");
472
473 test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.5000")),
474 new Decimal10(field, "-1234567891"),
475 DfpField.FLAG_INEXACT, "RoundDecimal10 #39");
476
477 test(new Decimal10(field, "-1234567891").add(new Decimal10(field, "-0.5000")),
478 new Decimal10(field, "-1234567891"),
479 DfpField.FLAG_INEXACT, "RoundDecimal10 #40");
480
481 field.setRoundingMode(DfpField.RoundingMode.ROUND_CEIL);
482
483
484 test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.0001")),
485 new Decimal10(field, "1234567891"),
486 DfpField.FLAG_INEXACT, "RoundDecimal10 #41");
487
488 test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.9999")),
489 new Decimal10(field, "-1234567890"),
490 DfpField.FLAG_INEXACT, "RoundDecimal10 #42");
491
492 field.setRoundingMode(DfpField.RoundingMode.ROUND_FLOOR);
493
494
495 test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.9999")),
496 new Decimal10(field, "1234567890"),
497 DfpField.FLAG_INEXACT, "RoundDecimal10 #43");
498
499 test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.0001")),
500 new Decimal10(field, "-1234567891"),
501 DfpField.FLAG_INEXACT, "RoundDecimal10 #44");
502
503 field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_EVEN);
504 }
505
506 @Test
507 public void testNextAfter()
508 {
509 test(new DfpDec(field, 1).nextAfter(pinf),
510 new DfpDec(field, "1.0000000000000001"),
511 0, "NextAfter #1");
512
513 test(new DfpDec(field, "1.0000000000000001").nextAfter(ninf),
514 new DfpDec(field, 1),
515 0, "NextAfter #1.5");
516
517 test(new DfpDec(field, 1).nextAfter(ninf),
518 new DfpDec(field, "0.99999999999999999"),
519 0, "NextAfter #2");
520
521 test(new DfpDec(field, "0.99999999999999999").nextAfter(new DfpDec(field, 2)),
522 new DfpDec(field, 1),
523 0, "NextAfter #3");
524
525 test(new DfpDec(field, -1).nextAfter(ninf),
526 new DfpDec(field, "-1.0000000000000001"),
527 0, "NextAfter #4");
528
529 test(new DfpDec(field, -1).nextAfter(pinf),
530 new DfpDec(field, "-0.99999999999999999"),
531 0, "NextAfter #5");
532
533 test(new DfpDec(field, "-0.99999999999999999").nextAfter(new DfpDec(field, -2)),
534 new DfpDec(field, (byte) -1),
535 0, "NextAfter #6");
536
537 test(new DfpDec(field, (byte) 2).nextAfter(new DfpDec(field, 2)),
538 new DfpDec(field, 2l),
539 0, "NextAfter #7");
540
541 test(new DfpDec(field, 0).nextAfter(new DfpDec(field, 0)),
542 new DfpDec(field, 0),
543 0, "NextAfter #8");
544
545 test(new DfpDec(field, -2).nextAfter(new DfpDec(field, -2)),
546 new DfpDec(field, -2),
547 0, "NextAfter #9");
548
549 test(new DfpDec(field, 0).nextAfter(new DfpDec(field, 1)),
550 new DfpDec(field, "1e-131092"),
551 DfpField.FLAG_UNDERFLOW, "NextAfter #10");
552
553 test(new DfpDec(field, 0).nextAfter(new DfpDec(field, -1)),
554 new DfpDec(field, "-1e-131092"),
555 DfpField.FLAG_UNDERFLOW, "NextAfter #11");
556
557 test(new DfpDec(field, "-1e-131092").nextAfter(pinf),
558 new DfpDec(field, "-0"),
559 DfpField.FLAG_UNDERFLOW|DfpField.FLAG_INEXACT, "Next After #12");
560
561 test(new DfpDec(field, "1e-131092").nextAfter(ninf),
562 new DfpDec(field, "0"),
563 DfpField.FLAG_UNDERFLOW|DfpField.FLAG_INEXACT, "Next After #13");
564
565 test(new DfpDec(field, "9.9999999999999999e131078").nextAfter(pinf),
566 pinf,
567 DfpField.FLAG_OVERFLOW|DfpField.FLAG_INEXACT, "Next After #14");
568 }
569
570 }