test: flpt2.c Source File

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# flpt2.c

Go to the documentation of this file.

    00001 /*++
    00002
    00003 Copyright (c) 1991  Microsoft Corporation
    00004
    00005 Module Name:
    00006
    00007     flpt2.c
    00008
    00009 Abstract:
    00010
    00011     This module implements user mode IEEE floating point tests.
    00012
    00013 Author:
    00014
    00015     David N. Cutler (davec) 1-Jul-1991
    00016
    00017 Environment:
    00018
    00019     User mode only.
    00020
    00021 Revision History:
    00022
    00023 --*/
    00024
    00025 #include "flpt.h"
    00026
    00027 VOID
    00028 Test20 (
    00029     VOID
    00030     )
    00031
    00032 {
    00033
    00034     ULONG Count;
    00035     FLOATING_STATUS Fsr;
    00036     ULARGE_INTEGER DoubleOperand;
    00037     ULARGE_INTEGER DoubleResult;
    00038     ULONG Subtest;
    00039
    00040     //
    00041     // Test 20 - Absolute, move, and negate double test.
    00042     //
    00043
    00044     Subtest = 0;
    00045     printf("    Test 20 - absolute, move, and negate double ...");
    00046     Subtest += 1;
    00047     DoubleOperand.LowPart = 0x0;
    00048     DoubleOperand.HighPart = 0x80000;
    00049     Fsr.Data = AbsoluteDouble(ROUND_TO_NEAREST,
    00050                               &DoubleOperand,
    00051                               &DoubleResult);
    00052
    00053     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00054         (DoubleResult.LowPart != 0x0) ||
    00055         (DoubleResult.HighPart != 0x80000)) {
    00056         goto TestFailed;
    00057     }
    00058
    00059     Subtest += 1;
    00060     DoubleOperand.LowPart = 0x0;
    00061     DoubleOperand.HighPart = SIGN | 0x80000;
    00062     Fsr.Data = AbsoluteDouble(ROUND_TO_NEAREST,
    00063                               &DoubleOperand,
    00064                               &DoubleResult);
    00065
    00066     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00067         (DoubleResult.LowPart != 0x0) ||
    00068         (DoubleResult.HighPart != 0x80000)) {
    00069         goto TestFailed;
    00070     }
    00071
    00072     Subtest += 1;
    00073     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    00074     DoubleOperand.HighPart = DOUBLE_QUIET_NAN;
    00075     Fsr.Data = AbsoluteDouble(ROUND_TO_NEAREST,
    00076                               &DoubleOperand,
    00077                               &DoubleResult);
    00078
    00079     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00080         (DoubleResult.LowPart != DOUBLE_NAN_LOW) ||
    00081         (DoubleResult.HighPart != DOUBLE_QUIET_NAN)) {
    00082         goto TestFailed;
    00083     }
    00084
    00085     Subtest += 1;
    00086     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    00087     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    00088     Fsr.Data = AbsoluteDouble(ROUND_TO_NEAREST,
    00089                               &DoubleOperand,
    00090                               &DoubleResult);
    00091
    00092     if ((Fsr.Data != (SV | XV | ROUND_TO_NEAREST)) ||
    00093         (DoubleResult.LowPart != DOUBLE_NAN_LOW) ||
    00094         (DoubleResult.HighPart != DOUBLE_QUIET_NAN)) {
    00095         goto TestFailed;
    00096     }
    00097
    00098     Subtest += 1;
    00099     Count = 0;
    00100     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    00101     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    00102     try {
    00103         Fsr.Data = AbsoluteDouble(EV | ROUND_TO_NEAREST,
    00104                                   &DoubleOperand,
    00105                                   &DoubleResult);
    00106
    00107     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    00108               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00109         Count += 1;
    00110     }
    00111
    00112     if (Count == 0) {
    00113         goto TestFailed;
    00114     }
    00115
    00116     Subtest += 1;
    00117     DoubleOperand.LowPart = 0x0;
    00118     DoubleOperand.HighPart = 0x80000;
    00119     Fsr.Data = MoveDouble(ROUND_TO_NEAREST,
    00120                           &DoubleOperand,
    00121                           &DoubleResult);
    00122
    00123     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00124         (DoubleResult.LowPart != 0x0) ||
    00125         (DoubleResult.HighPart != 0x80000)) {
    00126         goto TestFailed;
    00127     }
    00128
    00129     Subtest += 1;
    00130     DoubleOperand.LowPart = 0x0;
    00131     DoubleOperand.HighPart = SIGN | 0x80000;
    00132     Fsr.Data = MoveDouble(ROUND_TO_NEAREST,
    00133                           &DoubleOperand,
    00134                           &DoubleResult);
    00135
    00136     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00137         (DoubleResult.LowPart != 0x0) ||
    00138         (DoubleResult.HighPart != (SIGN | 0x80000))) {
    00139         goto TestFailed;
    00140     }
    00141
    00142     Subtest += 1;
    00143     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    00144     DoubleOperand.HighPart = DOUBLE_QUIET_NAN;
    00145     Fsr.Data = MoveDouble(ROUND_TO_NEAREST,
    00146                           &DoubleOperand,
    00147                           &DoubleResult);
    00148
    00149     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00150         (DoubleResult.LowPart != DOUBLE_NAN_LOW) ||
    00151         (DoubleResult.HighPart != DOUBLE_QUIET_NAN)) {
    00152         goto TestFailed;
    00153     }
    00154
    00155     Subtest += 1;
    00156     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    00157     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    00158     Fsr.Data = MoveDouble(ROUND_TO_NEAREST,
    00159                           &DoubleOperand,
    00160                           &DoubleResult);
    00161
    00162     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00163         (DoubleResult.LowPart != DOUBLE_NAN_LOW) ||
    00164         (DoubleResult.HighPart != DOUBLE_SIGNAL_NAN)) {
    00165         goto TestFailed;
    00166     }
    00167
    00168     Subtest += 1;
    00169     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    00170     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    00171     Fsr.Data = MoveDouble(EV | ROUND_TO_NEAREST,
    00172                           &DoubleOperand,
    00173                           &DoubleResult);
    00174
    00175     if ((Fsr.Data != (EV | ROUND_TO_NEAREST)) ||
    00176         (DoubleResult.LowPart != DOUBLE_NAN_LOW) ||
    00177         (DoubleResult.HighPart != DOUBLE_SIGNAL_NAN)) {
    00178         goto TestFailed;
    00179     }
    00180
    00181     Subtest += 1;
    00182     DoubleOperand.LowPart = 0x0;
    00183     DoubleOperand.HighPart = 0x80000;
    00184     Fsr.Data = NegateDouble(ROUND_TO_NEAREST,
    00185                             &DoubleOperand,
    00186                             &DoubleResult);
    00187
    00188     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00189         (DoubleResult.LowPart != 0x0) ||
    00190         (DoubleResult.HighPart != (SIGN | 0x80000))) {
    00191         goto TestFailed;
    00192     }
    00193
    00194     Subtest += 1;
    00195     DoubleOperand.LowPart = 0x0;
    00196     DoubleOperand.HighPart = SIGN | 0x80000;
    00197     Fsr.Data = NegateDouble(ROUND_TO_NEAREST,
    00198                             &DoubleOperand,
    00199                             &DoubleResult);
    00200
    00201     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00202         (DoubleResult.LowPart != 0x0) ||
    00203         (DoubleResult.HighPart != 0x80000)) {
    00204         goto TestFailed;
    00205     }
    00206
    00207     Subtest += 1;
    00208     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    00209     DoubleOperand.HighPart = DOUBLE_QUIET_NAN;
    00210     Fsr.Data = NegateDouble(ROUND_TO_NEAREST,
    00211                             &DoubleOperand,
    00212                             &DoubleResult);
    00213
    00214     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00215         (DoubleResult.LowPart != DOUBLE_NAN_LOW) ||
    00216         (DoubleResult.HighPart != DOUBLE_QUIET_NAN)) {
    00217         goto TestFailed;
    00218     }
    00219
    00220     Subtest += 1;
    00221     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    00222     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    00223     Fsr.Data = NegateDouble(ROUND_TO_NEAREST,
    00224                             &DoubleOperand,
    00225                             &DoubleResult);
    00226
    00227     if ((Fsr.Data != (SV | XV | ROUND_TO_NEAREST)) ||
    00228         (DoubleResult.LowPart != DOUBLE_NAN_LOW) ||
    00229         (DoubleResult.HighPart != DOUBLE_QUIET_NAN)) {
    00230         goto TestFailed;
    00231     }
    00232
    00233     Subtest += 1;
    00234     Count = 0;
    00235     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    00236     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    00237     try {
    00238         Fsr.Data = NegateDouble(EV | ROUND_TO_NEAREST,
    00239                                 &DoubleOperand,
    00240                                 &DoubleResult);
    00241
    00242     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    00243               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00244         Count += 1;
    00245     }
    00246
    00247     if (Count == 0) {
    00248         goto TestFailed;
    00249     }
    00250
    00251     //
    00252     // End of test 20.
    00253     //
    00254
    00255     printf("succeeded\n");
    00256     return;
    00257
    00258     //
    00259     // Test 20 failed.
    00260     //
    00261
    00262 TestFailed:
    00263     printf(" subtest %d failed, fsr = %lx, result = %lx, %lx\n",
    00264            Subtest,
    00265            Fsr.Data,
    00266            DoubleResult.LowPart,
    00267            DoubleResult.HighPart);
    00268
    00269     return;
    00270 }
    00271
    00272 VOID
    00273 Test21 (
    00274     VOID
    00275     )
    00276
    00277 {
    00278
    00279     ULONG Count;
    00280     FLOATING_STATUS Fsr;
    00281     ULARGE_INTEGER DoubleOperand;
    00282     ULONG SingleResult;
    00283     ULONG Subtest;
    00284
    00285     //
    00286     // Test 21 - Convert to single.
    00287     //
    00288
    00289     Subtest = 0;
    00290     printf("    Test 21 - convert to single ...");
    00291     Subtest += 1;
    00292     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    00293     DoubleOperand.HighPart = DOUBLE_QUIET_NAN;
    00294     Fsr.Data = ConvertToSingleFromDouble(ROUND_TO_NEAREST,
    00295                                          &DoubleOperand,
    00296                                          &SingleResult);
    00297
    00298     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00299         (SingleResult != SINGLE_QUIET_NAN)) {
    00300         goto TestFailed;
    00301     }
    00302
    00303     Subtest += 1;
    00304     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    00305     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    00306     Fsr.Data = ConvertToSingleFromDouble(ROUND_TO_NEAREST,
    00307                                          &DoubleOperand,
    00308                                          &SingleResult);
    00309
    00310     if ((Fsr.Data != (SV | XV | ROUND_TO_NEAREST)) ||
    00311         (SingleResult != SINGLE_QUIET_NAN)) {
    00312         goto TestFailed;
    00313     }
    00314
    00315     Subtest += 1;
    00316     DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    00317     DoubleOperand.HighPart = DOUBLE_INFINITY_VALUE_HIGH;
    00318     Fsr.Data = ConvertToSingleFromDouble(ROUND_TO_NEAREST,
    00319                                          &DoubleOperand,
    00320                                          &SingleResult);
    00321
    00322     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00323         (SingleResult != SINGLE_INFINITY_VALUE)) {
    00324         goto TestFailed;
    00325     }
    00326
    00327     Subtest += 1;
    00328     DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    00329     DoubleOperand.HighPart = MINUS_DOUBLE_INFINITY_VALUE;
    00330     Fsr.Data = ConvertToSingleFromDouble(ROUND_TO_NEAREST,
    00331                                          &DoubleOperand,
    00332                                          &SingleResult);
    00333
    00334     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00335         (SingleResult != MINUS_SINGLE_INFINITY_VALUE)) {
    00336         goto TestFailed;
    00337     }
    00338
    00339     Subtest += 1;
    00340     Count = 0;
    00341     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    00342     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    00343     try {
    00344         Fsr.Data = ConvertToSingleFromDouble(EV | ROUND_TO_NEAREST,
    00345                                              &DoubleOperand,
    00346                                              &SingleResult);
    00347
    00348     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    00349               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00350         Count += 1;
    00351     }
    00352
    00353     if (Count == 0) {
    00354         goto TestFailed;
    00355     }
    00356
    00357     Subtest += 1;
    00358     DoubleOperand.LowPart = 0x0;
    00359     DoubleOperand.HighPart =
    00360         ((DOUBLE_EXPONENT_BIAS - SINGLE_EXPONENT_BIAS) << (52 - 32)) | 0xfffff;
    00361     Fsr.Data = ConvertToSingleFromDouble(ROUND_TO_ZERO,
    00362                                          &DoubleOperand,
    00363                                          &SingleResult);
    00364
    00365     if ((Fsr.Data != ROUND_TO_ZERO) ||
    00366         (SingleResult != 0x7ffffc)) {
    00367         goto TestFailed;
    00368     }
    00369
    00370     Subtest += 1;
    00371     DoubleOperand.LowPart = 0x0;
    00372     DoubleOperand.HighPart = SIGN |
    00373         ((DOUBLE_EXPONENT_BIAS - SINGLE_EXPONENT_BIAS) << (52 - 32)) | 0xfffff;
    00374     Fsr.Data = ConvertToSingleFromDouble(ROUND_TO_ZERO,
    00375                                          &DoubleOperand,
    00376                                          &SingleResult);
    00377
    00378     if ((Fsr.Data != ROUND_TO_ZERO) ||
    00379         (SingleResult != (SIGN | 0x7ffffc))) {
    00380         goto TestFailed;
    00381     }
    00382
    00383     Subtest += 1;
    00384     DoubleOperand.LowPart = 0xf0000000;
    00385     DoubleOperand.HighPart =
    00386         ((DOUBLE_EXPONENT_BIAS - SINGLE_EXPONENT_BIAS) << (52 - 32)) | 0xfffff;
    00387     Fsr.Data = ConvertToSingleFromDouble(ROUND_TO_ZERO,
    00388                                          &DoubleOperand,
    00389                                          &SingleResult);
    00390
    00391     if ((Fsr.Data != (SI | SU | ROUND_TO_ZERO)) ||
    00392         (SingleResult != 0x7fffff)) {
    00393         goto TestFailed;
    00394     }
    00395
    00396     Subtest += 1;
    00397     DoubleOperand.LowPart = 0xf0000000;
    00398     DoubleOperand.HighPart = SIGN |
    00399         ((DOUBLE_EXPONENT_BIAS - SINGLE_EXPONENT_BIAS) << (52 - 32)) | 0xfffff;
    00400     Fsr.Data = ConvertToSingleFromDouble(ROUND_TO_ZERO,
    00401                                          &DoubleOperand,
    00402                                          &SingleResult);
    00403
    00404     if ((Fsr.Data != (SI | SU | ROUND_TO_ZERO)) ||
    00405         (SingleResult != (SIGN | 0x7fffff))) {
    00406         goto TestFailed;
    00407     }
    00408
    00409     Subtest += 1;
    00410     Count = 0;
    00411     DoubleOperand.LowPart = 0xf0000000;
    00412     DoubleOperand.HighPart = SIGN |
    00413         ((DOUBLE_EXPONENT_BIAS - SINGLE_EXPONENT_BIAS) << (52 - 32)) | 0xfffff;
    00414     try {
    00415         Fsr.Data = ConvertToSingleFromDouble(EU | ROUND_TO_ZERO,
    00416                                              &DoubleOperand,
    00417                                              &SingleResult);
    00418
    00419     } except ((GetExceptionCode() == STATUS_FLOAT_UNDERFLOW) ?
    00420               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00421         Count += 1;
    00422     }
    00423
    00424     if (Count == 0) {
    00425         goto TestFailed;
    00426     }
    00427
    00428     Subtest += 1;
    00429     Count = 0;
    00430     DoubleOperand.LowPart = 0xf0000000;
    00431     DoubleOperand.HighPart = SIGN |
    00432         ((DOUBLE_EXPONENT_BIAS - SINGLE_EXPONENT_BIAS) << (52 - 32)) | 0xfffff;
    00433     try {
    00434         Fsr.Data = ConvertToSingleFromDouble(EI | ROUND_TO_ZERO,
    00435                                              &DoubleOperand,
    00436                                              &SingleResult);
    00437
    00438     } except ((GetExceptionCode() == STATUS_FLOAT_INEXACT_RESULT) ?
    00439               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00440         Count += 1;
    00441     }
    00442
    00443     if (Count == 0) {
    00444         goto TestFailed;
    00445     }
    00446
    00447     Subtest += 1;
    00448     DoubleOperand.LowPart = 0x0;
    00449     DoubleOperand.HighPart = 0xfffff;
    00450     Fsr.Data = ConvertToSingleFromDouble(ROUND_TO_ZERO,
    00451                                          &DoubleOperand,
    00452                                          &SingleResult);
    00453
    00454     if ((Fsr.Data != (SI | SU | ROUND_TO_ZERO)) ||
    00455         (SingleResult != 0x0)) {
    00456         goto TestFailed;
    00457     }
    00458
    00459     Subtest += 1;
    00460     DoubleOperand.LowPart = 0x0;
    00461     DoubleOperand.HighPart = SIGN | 0xfffff;
    00462     Fsr.Data = ConvertToSingleFromDouble(ROUND_TO_ZERO,
    00463                                          &DoubleOperand,
    00464                                          &SingleResult);
    00465
    00466     if ((Fsr.Data != (SI | SU | ROUND_TO_ZERO)) ||
    00467         (SingleResult != (SIGN | 0x0))) {
    00468         goto TestFailed;
    00469     }
    00470
    00471     Subtest += 1;
    00472     Count = 0;
    00473     DoubleOperand.LowPart = 0x0;
    00474     DoubleOperand.HighPart = 0xfffff;
    00475     try {
    00476         Fsr.Data = ConvertToSingleFromDouble(EU | ROUND_TO_ZERO,
    00477                                              &DoubleOperand,
    00478                                              &SingleResult);
    00479
    00480     } except ((GetExceptionCode() == STATUS_FLOAT_UNDERFLOW) ?
    00481               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00482         Count += 1;
    00483     }
    00484
    00485     if (Count == 0) {
    00486         goto TestFailed;
    00487     }
    00488
    00489     Subtest += 1;
    00490     Count = 0;
    00491     DoubleOperand.LowPart = 0x0;
    00492     DoubleOperand.HighPart = 0xfffff;
    00493     try {
    00494         Fsr.Data = ConvertToSingleFromDouble(EI | ROUND_TO_ZERO,
    00495                                              &DoubleOperand,
    00496                                              &SingleResult);
    00497
    00498     } except ((GetExceptionCode() == STATUS_FLOAT_INEXACT_RESULT) ?
    00499               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00500         Count += 1;
    00501     }
    00502
    00503     if (Count == 0) {
    00504         goto TestFailed;
    00505     }
    00506
    00507     Subtest += 1;
    00508     DoubleOperand.LowPart = 0x0;
    00509     DoubleOperand.HighPart = ((DOUBLE_EXPONENT_BIAS +
    00510                             SINGLE_EXPONENT_BIAS + 1) << (52 - 32)) | 0xfffff;
    00511     Fsr.Data = ConvertToSingleFromDouble(ROUND_TO_ZERO,
    00512                                          &DoubleOperand,
    00513                                          &SingleResult);
    00514
    00515     if ((Fsr.Data != (SI | SO | XI | XO | ROUND_TO_ZERO)) ||
    00516         (SingleResult != SINGLE_MAXIMUM_VALUE)) {
    00517         goto TestFailed;
    00518     }
    00519
    00520     Subtest += 1;
    00521     DoubleOperand.LowPart = 0x0;
    00522     DoubleOperand.HighPart = SIGN | ((DOUBLE_EXPONENT_BIAS +
    00523                             SINGLE_EXPONENT_BIAS + 1) << (52 - 32)) | 0xfffff;
    00524     Fsr.Data = ConvertToSingleFromDouble(ROUND_TO_ZERO,
    00525                                          &DoubleOperand,
    00526                                          &SingleResult);
    00527
    00528     if ((Fsr.Data != (SI | SO | XI | XO | ROUND_TO_ZERO)) ||
    00529         (SingleResult != (SIGN | SINGLE_MAXIMUM_VALUE))) {
    00530         goto TestFailed;
    00531     }
    00532
    00533     Subtest += 1;
    00534     Count = 0;
    00535     DoubleOperand.LowPart = 0x0;
    00536     DoubleOperand.HighPart = ((DOUBLE_EXPONENT_BIAS +
    00537                             SINGLE_EXPONENT_BIAS + 1) << (52 - 32)) | 0xfffff;
    00538     try {
    00539         Fsr.Data = ConvertToSingleFromDouble(EO | ROUND_TO_ZERO,
    00540                                              &DoubleOperand,
    00541                                              &SingleResult);
    00542
    00543     } except ((GetExceptionCode() == STATUS_FLOAT_OVERFLOW) ?
    00544               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00545         Count += 1;
    00546     }
    00547
    00548     if (Count == 0) {
    00549         goto TestFailed;
    00550     }
    00551
    00552     Subtest += 1;
    00553     Count = 0;
    00554     DoubleOperand.LowPart = 0x0;
    00555     DoubleOperand.HighPart = ((DOUBLE_EXPONENT_BIAS +
    00556                             SINGLE_EXPONENT_BIAS + 1) << (52 - 32)) | 0xfffff;
    00557     try {
    00558         Fsr.Data = ConvertToSingleFromDouble(EI | ROUND_TO_ZERO,
    00559                                              &DoubleOperand,
    00560                                              &SingleResult);
    00561
    00562     } except ((GetExceptionCode() == STATUS_FLOAT_INEXACT_RESULT) ?
    00563               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00564         Count += 1;
    00565     }
    00566
    00567     if (Count == 0) {
    00568         goto TestFailed;
    00569     }
    00570
    00571     //
    00572     // End of test 21.
    00573     //
    00574
    00575     printf("succeeded\n");
    00576     return;
    00577
    00578     //
    00579     // Test 21 failed.
    00580     //
    00581
    00582 TestFailed:
    00583     printf(" subtest %d failed, fsr = %lx, result = %lx\n",
    00584            Subtest,
    00585            Fsr.Data,
    00586            SingleResult);
    00587
    00588     return;
    00589 }
    00590
    00591 VOID
    00592 Test22 (
    00593     VOID
    00594     )
    00595
    00596 {
    00597
    00598     ULONG Count;
    00599     FLOATING_STATUS Fsr;
    00600     ULARGE_INTEGER DoubleResult;
    00601     ULONG SingleOperand;
    00602     ULONG Subtest;
    00603
    00604     //
    00605     // Test 22 - Convert to double.
    00606     //
    00607
    00608     Subtest = 0;
    00609     printf("    Test 22 - convert to double ...");
    00610     Subtest += 1;
    00611     SingleOperand = SINGLE_QUIET_NAN;
    00612     Fsr.Data = ConvertToDoubleFromSingle(ROUND_TO_NEAREST,
    00613                                          SingleOperand,
    00614                                          &DoubleResult);
    00615
    00616     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00617         (DoubleResult.LowPart != DOUBLE_NAN_LOW) ||
    00618         (DoubleResult.HighPart != DOUBLE_QUIET_NAN)) {
    00619         goto TestFailed;
    00620     }
    00621
    00622     Subtest += 1;
    00623     SingleOperand = SINGLE_SIGNAL_NAN;
    00624     Fsr.Data = ConvertToDoubleFromSingle(ROUND_TO_NEAREST,
    00625                                          SingleOperand,
    00626                                          &DoubleResult);
    00627
    00628     if ((Fsr.Data != (SV | XV | ROUND_TO_NEAREST)) ||
    00629         (DoubleResult.LowPart != DOUBLE_NAN_LOW) ||
    00630         (DoubleResult.HighPart != DOUBLE_QUIET_NAN)) {
    00631         goto TestFailed;
    00632     }
    00633
    00634     Subtest += 1;
    00635     SingleOperand = SINGLE_INFINITY_VALUE;
    00636     Fsr.Data = ConvertToDoubleFromSingle(ROUND_TO_NEAREST,
    00637                                          SingleOperand,
    00638                                          &DoubleResult);
    00639
    00640     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00641         (DoubleResult.LowPart != DOUBLE_INFINITY_VALUE_LOW) ||
    00642         (DoubleResult.HighPart != DOUBLE_INFINITY_VALUE_HIGH)) {
    00643         goto TestFailed;
    00644     }
    00645
    00646     Subtest += 1;
    00647     SingleOperand = MINUS_SINGLE_INFINITY_VALUE;
    00648     Fsr.Data = ConvertToDoubleFromSingle(ROUND_TO_NEAREST,
    00649                                          SingleOperand,
    00650                                          &DoubleResult);
    00651
    00652     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00653         (DoubleResult.LowPart != DOUBLE_INFINITY_VALUE_LOW) ||
    00654         (DoubleResult.HighPart != MINUS_DOUBLE_INFINITY_VALUE)) {
    00655         goto TestFailed;
    00656     }
    00657
    00658     Subtest += 1;
    00659     Count = 0;
    00660     SingleOperand = SINGLE_SIGNAL_NAN;
    00661     try {
    00662         Fsr.Data = ConvertToDoubleFromSingle(EV | ROUND_TO_NEAREST,
    00663                                              SingleOperand,
    00664                                              &DoubleResult);
    00665
    00666     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    00667               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00668         Count += 1;
    00669     }
    00670
    00671     if (Count == 0) {
    00672         goto TestFailed;
    00673     }
    00674
    00675     Subtest += 1;
    00676     SingleOperand = 0x400000;
    00677     Fsr.Data = ConvertToDoubleFromSingle(ROUND_TO_ZERO,
    00678                                          SingleOperand,
    00679                                          &DoubleResult);
    00680
    00681     if ((Fsr.Data != ROUND_TO_ZERO) ||
    00682         (DoubleResult.LowPart != 0x0) ||
    00683         (DoubleResult.HighPart != 0x38000000)) {
    00684         goto TestFailed;
    00685     }
    00686
    00687     Subtest += 1;
    00688     SingleOperand = SIGN | 0x400000;
    00689     Fsr.Data = ConvertToDoubleFromSingle(ROUND_TO_ZERO,
    00690                                          SingleOperand,
    00691                                          &DoubleResult);
    00692
    00693     if ((Fsr.Data != ROUND_TO_ZERO) ||
    00694         (DoubleResult.LowPart != 0x0) ||
    00695         (DoubleResult.HighPart != (SIGN | 0x38000000))) {
    00696         goto TestFailed;
    00697     }
    00698
    00699     Subtest += 1;
    00700     SingleOperand = 0x440000;
    00701     Fsr.Data = ConvertToDoubleFromSingle(ROUND_TO_ZERO,
    00702                                          SingleOperand,
    00703                                          &DoubleResult);
    00704
    00705     if ((Fsr.Data != ROUND_TO_ZERO) ||
    00706         (DoubleResult.LowPart != 0x0) ||
    00707         (DoubleResult.HighPart != 0x38010000)) {
    00708         goto TestFailed;
    00709     }
    00710
    00711     Subtest += 1;
    00712     SingleOperand = SIGN | 0x440000;
    00713     Fsr.Data = ConvertToDoubleFromSingle(ROUND_TO_ZERO,
    00714                                          SingleOperand,
    00715                                          &DoubleResult);
    00716
    00717     if ((Fsr.Data != ROUND_TO_ZERO) ||
    00718         (DoubleResult.LowPart != 0x0) ||
    00719         (DoubleResult.HighPart != (SIGN | 0x38010000))) {
    00720         goto TestFailed;
    00721     }
    00722
    00723     //
    00724     // End of test 22.
    00725     //
    00726
    00727     printf("succeeded\n");
    00728     return;
    00729
    00730     //
    00731     // Test 22 failed.
    00732     //
    00733
    00734 TestFailed:
    00735     printf(" subtest %d failed, fsr = %lx, result = %lx, %lx\n",
    00736            Subtest,
    00737            Fsr.Data,
    00738            DoubleResult.LowPart,
    00739            DoubleResult.HighPart);
    00740
    00741     return;
    00742 }
    00743
    00744 VOID
    00745 Test23 (
    00746     VOID
    00747     )
    00748
    00749 {
    00750
    00751     ULONG Count;
    00752     FLOATING_STATUS Fsr;
    00753     ULONG LongwordResult;
    00754     ULONG SingleOperand;
    00755     ULONG Subtest;
    00756
    00757     //
    00758     // Test 23 - Convert to longword from single.
    00759     //
    00760
    00761     Subtest = 0;
    00762     printf("    Test 23 - convert to longword from single ...");
    00763     Subtest += 1;
    00764     SingleOperand = SINGLE_QUIET_NAN;
    00765     Fsr.Data = ConvertToLongwordFromSingle(ROUND_TO_NEAREST,
    00766                                            SingleOperand,
    00767                                            &LongwordResult);
    00768
    00769     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    00770         (LongwordResult != INTEGER_NAN)) {
    00771         goto TestFailed;
    00772     }
    00773
    00774     Subtest += 1;
    00775     SingleOperand = SINGLE_SIGNAL_NAN;
    00776     Fsr.Data = ConvertToLongwordFromSingle(ROUND_TO_NEAREST,
    00777                                            SingleOperand,
    00778                                            &LongwordResult);
    00779
    00780     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    00781         (LongwordResult != INTEGER_NAN)) {
    00782         goto TestFailed;
    00783     }
    00784
    00785     Subtest += 1;
    00786     SingleOperand = SINGLE_INFINITY_VALUE;
    00787     Fsr.Data = ConvertToLongwordFromSingle(ROUND_TO_NEAREST,
    00788                                            SingleOperand,
    00789                                            &LongwordResult);
    00790
    00791     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    00792         (LongwordResult != 0x7fffffff)) {
    00793         goto TestFailed;
    00794     }
    00795
    00796     Subtest += 1;
    00797     SingleOperand = MINUS_SINGLE_INFINITY_VALUE;
    00798     Fsr.Data = ConvertToLongwordFromSingle(ROUND_TO_NEAREST,
    00799                                            SingleOperand,
    00800                                            &LongwordResult);
    00801
    00802     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    00803         (LongwordResult != 0x80000000)) {
    00804         goto TestFailed;
    00805     }
    00806
    00807     Subtest += 1;
    00808     Count = 0;
    00809     SingleOperand = SINGLE_QUIET_NAN;
    00810     try {
    00811         Fsr.Data = ConvertToLongwordFromSingle(EV | ROUND_TO_NEAREST,
    00812                                                SingleOperand,
    00813                                                &LongwordResult);
    00814
    00815     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    00816               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00817         Count += 1;
    00818     }
    00819
    00820     if (Count == 0) {
    00821         goto TestFailed;
    00822     }
    00823
    00824     Subtest += 1;
    00825     Count = 0;
    00826     SingleOperand = SINGLE_SIGNAL_NAN;
    00827     try {
    00828         Fsr.Data = ConvertToLongwordFromSingle(EV | ROUND_TO_NEAREST,
    00829                                                SingleOperand,
    00830                                                &LongwordResult);
    00831
    00832     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    00833               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00834         Count += 1;
    00835     }
    00836
    00837     if (Count == 0) {
    00838         goto TestFailed;
    00839     }
    00840
    00841     Subtest += 1;
    00842     Count = 0;
    00843     SingleOperand = SINGLE_INFINITY_VALUE;
    00844     try {
    00845         Fsr.Data = ConvertToLongwordFromSingle(EV | ROUND_TO_NEAREST,
    00846                                                SingleOperand,
    00847                                                &LongwordResult);
    00848
    00849     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    00850               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00851         Count += 1;
    00852     }
    00853
    00854     if (Count == 0) {
    00855         goto TestFailed;
    00856     }
    00857
    00858     Subtest += 1;
    00859     Count = 0;
    00860     SingleOperand = MINUS_SINGLE_INFINITY_VALUE;
    00861     try {
    00862         Fsr.Data = ConvertToLongwordFromSingle(EV | ROUND_TO_NEAREST,
    00863                                                SingleOperand,
    00864                                                &LongwordResult);
    00865
    00866     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    00867               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00868         Count += 1;
    00869     }
    00870
    00871     if (Count == 0) {
    00872         goto TestFailed;
    00873     }
    00874
    00875     Subtest += 1;
    00876     SingleOperand = 0x400000;
    00877     Fsr.Data = ConvertToLongwordFromSingle(ROUND_TO_NEAREST,
    00878                                            SingleOperand,
    00879                                            &LongwordResult);
    00880
    00881     if ((Fsr.Data != (SI | ROUND_TO_NEAREST)) ||
    00882         (LongwordResult != 0x0)) {
    00883         goto TestFailed;
    00884     }
    00885
    00886     Subtest += 1;
    00887     SingleOperand = 0x1;
    00888     Fsr.Data = ConvertToLongwordFromSingle(ROUND_TO_NEAREST,
    00889                                            SingleOperand,
    00890                                            &LongwordResult);
    00891
    00892     if ((Fsr.Data != (SI | ROUND_TO_NEAREST)) ||
    00893         (LongwordResult != 0x0)) {
    00894         goto TestFailed;
    00895     }
    00896
    00897     Subtest += 1;
    00898     Count = 0;
    00899     SingleOperand = 0x400000;
    00900     try {
    00901         Fsr.Data = ConvertToLongwordFromSingle(EI | ROUND_TO_NEAREST,
    00902                                                SingleOperand,
    00903                                                &LongwordResult);
    00904
    00905     } except ((GetExceptionCode() == STATUS_FLOAT_INEXACT_RESULT) ?
    00906               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00907         Count += 1;
    00908     }
    00909
    00910     if (Count == 0) {
    00911         goto TestFailed;
    00912     }
    00913
    00914     Subtest += 1;
    00915     SingleOperand = ((SINGLE_EXPONENT_BIAS + 32) << 23);
    00916     Fsr.Data = ConvertToLongwordFromSingle(ROUND_TO_NEAREST,
    00917                                            SingleOperand,
    00918                                            &LongwordResult);
    00919
    00920     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    00921         (LongwordResult != INTEGER_NAN)) {
    00922         goto TestFailed;
    00923     }
    00924
    00925     Subtest += 1;
    00926     SingleOperand = ((SINGLE_EXPONENT_BIAS + 31) << 23);
    00927     Fsr.Data = ConvertToLongwordFromSingle(ROUND_TO_NEAREST,
    00928                                            SingleOperand,
    00929                                            &LongwordResult);
    00930
    00931     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    00932         (LongwordResult != INTEGER_NAN)) {
    00933         goto TestFailed;
    00934     }
    00935
    00936     Subtest += 1;
    00937     SingleOperand = SIGN | ((SINGLE_EXPONENT_BIAS + 31) << 23);
    00938     Fsr.Data = ConvertToLongwordFromSingle(ROUND_TO_NEAREST,
    00939                                            SingleOperand,
    00940                                            &LongwordResult);
    00941
    00942     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    00943         (LongwordResult != 0x80000000)) {
    00944         goto TestFailed;
    00945     }
    00946
    00947     Subtest += 1;
    00948     SingleOperand = SIGN | ((SINGLE_EXPONENT_BIAS + 31) << 23) | 0x1;
    00949     Fsr.Data = ConvertToLongwordFromSingle(ROUND_TO_NEAREST,
    00950                                            SingleOperand,
    00951                                            &LongwordResult);
    00952
    00953     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    00954         (LongwordResult != INTEGER_NAN)) {
    00955         goto TestFailed;
    00956     }
    00957
    00958     Subtest += 1;
    00959     Count = 0;
    00960     SingleOperand = ((SINGLE_EXPONENT_BIAS + 31) << 23);
    00961     try {
    00962         Fsr.Data = ConvertToLongwordFromSingle(EV | ROUND_TO_NEAREST,
    00963                                                SingleOperand,
    00964                                                &LongwordResult);
    00965
    00966     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    00967               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    00968         Count += 1;
    00969     }
    00970
    00971     if (Count == 0) {
    00972         goto TestFailed;
    00973     }
    00974
    00975     Subtest += 1;
    00976     SingleOperand = SINGLE_QUIET_NAN;
    00977     Fsr.Data = RoundToLongwordFromSingle(ROUND_TO_NEAREST,
    00978                                          SingleOperand,
    00979                                          &LongwordResult);
    00980
    00981     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    00982         (LongwordResult != INTEGER_NAN)) {
    00983         goto TestFailed;
    00984     }
    00985
    00986     Subtest += 1;
    00987     SingleOperand = SINGLE_SIGNAL_NAN;
    00988     Fsr.Data = RoundToLongwordFromSingle(ROUND_TO_NEAREST,
    00989                                          SingleOperand,
    00990                                          &LongwordResult);
    00991
    00992     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    00993         (LongwordResult != INTEGER_NAN)) {
    00994         goto TestFailed;
    00995     }
    00996
    00997     Subtest += 1;
    00998     SingleOperand = SINGLE_INFINITY_VALUE;
    00999     Fsr.Data = RoundToLongwordFromSingle(ROUND_TO_NEAREST,
    01000                                          SingleOperand,
    01001                                          &LongwordResult);
    01002
    01003     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01004         (LongwordResult != 0x7fffffff)) {
    01005         goto TestFailed;
    01006     }
    01007
    01008     Subtest += 1;
    01009     SingleOperand = MINUS_SINGLE_INFINITY_VALUE;
    01010     Fsr.Data = RoundToLongwordFromSingle(ROUND_TO_NEAREST,
    01011                                          SingleOperand,
    01012                                          &LongwordResult);
    01013
    01014     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01015         (LongwordResult != 0x80000000)) {
    01016         goto TestFailed;
    01017     }
    01018
    01019     Subtest += 1;
    01020     Count = 0;
    01021     SingleOperand = SINGLE_QUIET_NAN;
    01022     try {
    01023         Fsr.Data = RoundToLongwordFromSingle(EV | ROUND_TO_NEAREST,
    01024                                              SingleOperand,
    01025                                              &LongwordResult);
    01026
    01027     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01028               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01029         Count += 1;
    01030     }
    01031
    01032     if (Count == 0) {
    01033         goto TestFailed;
    01034     }
    01035
    01036     Subtest += 1;
    01037     Count = 0;
    01038     SingleOperand = SINGLE_SIGNAL_NAN;
    01039     try {
    01040         Fsr.Data = RoundToLongwordFromSingle(EV | ROUND_TO_NEAREST,
    01041                                              SingleOperand,
    01042                                              &LongwordResult);
    01043
    01044     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01045               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01046         Count += 1;
    01047     }
    01048
    01049     if (Count == 0) {
    01050         goto TestFailed;
    01051     }
    01052
    01053     Subtest += 1;
    01054     Count = 0;
    01055     SingleOperand = SINGLE_INFINITY_VALUE;
    01056     try {
    01057         Fsr.Data = RoundToLongwordFromSingle(EV | ROUND_TO_NEAREST,
    01058                                              SingleOperand,
    01059                                              &LongwordResult);
    01060
    01061     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01062               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01063         Count += 1;
    01064     }
    01065
    01066     if (Count == 0) {
    01067         goto TestFailed;
    01068     }
    01069
    01070     Subtest += 1;
    01071     Count = 0;
    01072     SingleOperand = MINUS_SINGLE_INFINITY_VALUE;
    01073     try {
    01074         Fsr.Data = RoundToLongwordFromSingle(EV | ROUND_TO_NEAREST,
    01075                                              SingleOperand,
    01076                                              &LongwordResult);
    01077
    01078     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01079               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01080         Count += 1;
    01081     }
    01082
    01083     if (Count == 0) {
    01084         goto TestFailed;
    01085     }
    01086
    01087     Subtest += 1;
    01088     SingleOperand = 0x400000;
    01089     Fsr.Data = RoundToLongwordFromSingle(ROUND_TO_NEAREST,
    01090                                          SingleOperand,
    01091                                          &LongwordResult);
    01092
    01093     if ((Fsr.Data != (SI | ROUND_TO_NEAREST)) ||
    01094         (LongwordResult != 0x0)) {
    01095         goto TestFailed;
    01096     }
    01097
    01098     Subtest += 1;
    01099     SingleOperand = 0x1;
    01100     Fsr.Data = RoundToLongwordFromSingle(ROUND_TO_NEAREST,
    01101                                          SingleOperand,
    01102                                          &LongwordResult);
    01103
    01104     if ((Fsr.Data != (SI | ROUND_TO_NEAREST)) ||
    01105         (LongwordResult != 0x0)) {
    01106         goto TestFailed;
    01107     }
    01108
    01109     Subtest += 1;
    01110     Count = 0;
    01111     SingleOperand = 0x400000;
    01112     try {
    01113         Fsr.Data = RoundToLongwordFromSingle(EI | ROUND_TO_NEAREST,
    01114                                              SingleOperand,
    01115                                              &LongwordResult);
    01116
    01117     } except ((GetExceptionCode() == STATUS_FLOAT_INEXACT_RESULT) ?
    01118               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01119         Count += 1;
    01120     }
    01121
    01122     if (Count == 0) {
    01123         goto TestFailed;
    01124     }
    01125
    01126     Subtest += 1;
    01127     SingleOperand = ((SINGLE_EXPONENT_BIAS + 32) << 23);
    01128     Fsr.Data = RoundToLongwordFromSingle(ROUND_TO_NEAREST,
    01129                                          SingleOperand,
    01130                                          &LongwordResult);
    01131
    01132     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01133         (LongwordResult != INTEGER_NAN)) {
    01134         goto TestFailed;
    01135     }
    01136
    01137     Subtest += 1;
    01138     SingleOperand = ((SINGLE_EXPONENT_BIAS + 31) << 23);
    01139     Fsr.Data = RoundToLongwordFromSingle(ROUND_TO_NEAREST,
    01140                                          SingleOperand,
    01141                                          &LongwordResult);
    01142
    01143     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01144         (LongwordResult != INTEGER_NAN)) {
    01145         goto TestFailed;
    01146     }
    01147
    01148     Subtest += 1;
    01149     SingleOperand = SIGN | ((SINGLE_EXPONENT_BIAS + 31) << 23);
    01150     Fsr.Data = RoundToLongwordFromSingle(ROUND_TO_NEAREST,
    01151                                          SingleOperand,
    01152                                          &LongwordResult);
    01153
    01154     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    01155         (LongwordResult != 0x80000000)) {
    01156         goto TestFailed;
    01157     }
    01158
    01159     Subtest += 1;
    01160     SingleOperand = SIGN | ((SINGLE_EXPONENT_BIAS + 31) << 23) | 0x1;
    01161     Fsr.Data = RoundToLongwordFromSingle(ROUND_TO_NEAREST,
    01162                                          SingleOperand,
    01163                                          &LongwordResult);
    01164
    01165     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01166         (LongwordResult != INTEGER_NAN)) {
    01167         goto TestFailed;
    01168     }
    01169
    01170     Subtest += 1;
    01171     Count = 0;
    01172     SingleOperand = ((SINGLE_EXPONENT_BIAS + 31) << 23);
    01173     try {
    01174         Fsr.Data = RoundToLongwordFromSingle(EV | ROUND_TO_NEAREST,
    01175                                              SingleOperand,
    01176                                              &LongwordResult);
    01177
    01178     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01179               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01180         Count += 1;
    01181     }
    01182
    01183     if (Count == 0) {
    01184         goto TestFailed;
    01185     }
    01186
    01187     //
    01188     // End of test 23.
    01189     //
    01190
    01191     printf("succeeded\n");
    01192     return;
    01193
    01194     //
    01195     // Test 23 failed.
    01196     //
    01197
    01198 TestFailed:
    01199     printf(" subtest %d failed, fsr = %lx, result = %lx\n",
    01200            Subtest,
    01201            Fsr.Data,
    01202            LongwordResult);
    01203
    01204     return;
    01205 }
    01206
    01207 VOID
    01208 Test24 (
    01209     VOID
    01210     )
    01211
    01212 {
    01213
    01214     ULONG Count;
    01215     FLOATING_STATUS Fsr;
    01216     ULARGE_INTEGER DoubleOperand;
    01217     ULONG LongwordResult;
    01218     ULONG Subtest;
    01219
    01220     //
    01221     // Test 24 - Convert to longword from double.
    01222     //
    01223
    01224     Subtest = 0;
    01225     printf("    Test 24 - convert to longword from double ...");
    01226     Subtest += 1;
    01227     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    01228     DoubleOperand.HighPart = DOUBLE_QUIET_NAN;
    01229     Fsr.Data = ConvertToLongwordFromDouble(ROUND_TO_NEAREST,
    01230                                            &DoubleOperand,
    01231                                            &LongwordResult);
    01232
    01233     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01234         (LongwordResult != INTEGER_NAN)) {
    01235         goto TestFailed;
    01236     }
    01237
    01238     Subtest += 1;
    01239     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    01240     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    01241     Fsr.Data = ConvertToLongwordFromDouble(ROUND_TO_NEAREST,
    01242                                            &DoubleOperand,
    01243                                            &LongwordResult);
    01244
    01245     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01246         (LongwordResult != INTEGER_NAN)) {
    01247         goto TestFailed;
    01248     }
    01249
    01250     Subtest += 1;
    01251     DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    01252     DoubleOperand.HighPart = DOUBLE_INFINITY_VALUE_HIGH;
    01253     Fsr.Data = ConvertToLongwordFromDouble(ROUND_TO_NEAREST,
    01254                                            &DoubleOperand,
    01255                                            &LongwordResult);
    01256
    01257     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01258         (LongwordResult != 0x7fffffff)) {
    01259         goto TestFailed;
    01260     }
    01261
    01262     Subtest += 1;
    01263     DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    01264     DoubleOperand.HighPart = MINUS_DOUBLE_INFINITY_VALUE;
    01265     Fsr.Data = ConvertToLongwordFromDouble(ROUND_TO_NEAREST,
    01266                                            &DoubleOperand,
    01267                                            &LongwordResult);
    01268
    01269     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01270         (LongwordResult != 0x80000000)) {
    01271         goto TestFailed;
    01272     }
    01273
    01274     Subtest += 1;
    01275     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    01276     DoubleOperand.HighPart = DOUBLE_QUIET_NAN;
    01277     Fsr.Data = RoundToLongwordFromDouble(ROUND_TO_NEAREST,
    01278                                          &DoubleOperand,
    01279                                          &LongwordResult);
    01280
    01281     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01282         (LongwordResult != INTEGER_NAN)) {
    01283         goto TestFailed;
    01284     }
    01285
    01286     Subtest += 1;
    01287     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    01288     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    01289     Fsr.Data = RoundToLongwordFromDouble(ROUND_TO_NEAREST,
    01290                                          &DoubleOperand,
    01291                                          &LongwordResult);
    01292
    01293     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01294         (LongwordResult != INTEGER_NAN)) {
    01295         goto TestFailed;
    01296     }
    01297
    01298     Subtest += 1;
    01299     DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    01300     DoubleOperand.HighPart = DOUBLE_INFINITY_VALUE_HIGH;
    01301     Fsr.Data = RoundToLongwordFromDouble(ROUND_TO_NEAREST,
    01302                                          &DoubleOperand,
    01303                                          &LongwordResult);
    01304
    01305     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01306         (LongwordResult != 0x7fffffff)) {
    01307         goto TestFailed;
    01308     }
    01309
    01310     Subtest += 1;
    01311     DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    01312     DoubleOperand.HighPart = MINUS_DOUBLE_INFINITY_VALUE;
    01313     Fsr.Data = RoundToLongwordFromDouble(ROUND_TO_NEAREST,
    01314                                          &DoubleOperand,
    01315                                          &LongwordResult);
    01316
    01317     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01318         (LongwordResult != 0x80000000)) {
    01319         goto TestFailed;
    01320     }
    01321
    01322     Subtest += 1;
    01323     Count = 0;
    01324     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    01325     DoubleOperand.HighPart = DOUBLE_QUIET_NAN;
    01326     try {
    01327         Fsr.Data = ConvertToLongwordFromDouble(EV | ROUND_TO_ZERO,
    01328                                                &DoubleOperand,
    01329                                                &LongwordResult);
    01330
    01331     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01332               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01333         Count += 1;
    01334     }
    01335
    01336     if (Count == 0) {
    01337         goto TestFailed;
    01338     }
    01339
    01340     Subtest += 1;
    01341     Count = 0;
    01342     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    01343     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    01344     try {
    01345         Fsr.Data = ConvertToLongwordFromDouble(EV | ROUND_TO_ZERO,
    01346                                                &DoubleOperand,
    01347                                                &LongwordResult);
    01348
    01349     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01350               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01351         Count += 1;
    01352     }
    01353
    01354     if (Count == 0) {
    01355         goto TestFailed;
    01356     }
    01357
    01358     Subtest += 1;
    01359     Count = 0;
    01360     DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    01361     DoubleOperand.HighPart = DOUBLE_INFINITY_VALUE_HIGH;
    01362     try {
    01363         Fsr.Data = ConvertToLongwordFromDouble(EV | ROUND_TO_ZERO,
    01364                                                &DoubleOperand,
    01365                                                &LongwordResult);
    01366
    01367     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01368               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01369         Count += 1;
    01370     }
    01371
    01372     if (Count == 0) {
    01373         goto TestFailed;
    01374     }
    01375
    01376     Subtest += 1;
    01377     Count = 0;
    01378     DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    01379     DoubleOperand.HighPart = MINUS_DOUBLE_INFINITY_VALUE;
    01380     try {
    01381         Fsr.Data = ConvertToLongwordFromDouble(EV | ROUND_TO_ZERO,
    01382                                                &DoubleOperand,
    01383                                                &LongwordResult);
    01384
    01385     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01386               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01387         Count += 1;
    01388     }
    01389
    01390     if (Count == 0) {
    01391         goto TestFailed;
    01392     }
    01393
    01394     Subtest += 1;
    01395     Count = 0;
    01396     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    01397     DoubleOperand.HighPart = DOUBLE_QUIET_NAN;
    01398     try {
    01399         Fsr.Data = TruncateToLongwordFromDouble(EV | ROUND_TO_ZERO,
    01400                                                 &DoubleOperand,
    01401                                                 &LongwordResult);
    01402
    01403     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01404               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01405         Count += 1;
    01406     }
    01407
    01408     if (Count == 0) {
    01409         goto TestFailed;
    01410     }
    01411
    01412     Subtest += 1;
    01413     Count = 0;
    01414     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    01415     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    01416     try {
    01417         Fsr.Data = TruncateToLongwordFromDouble(EV | ROUND_TO_ZERO,
    01418                                                 &DoubleOperand,
    01419                                                 &LongwordResult);
    01420
    01421     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01422               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01423         Count += 1;
    01424     }
    01425
    01426     if (Count == 0) {
    01427         goto TestFailed;
    01428     }
    01429
    01430     Subtest += 1;
    01431     Count = 0;
    01432     DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    01433     DoubleOperand.HighPart = DOUBLE_INFINITY_VALUE_HIGH;
    01434     try {
    01435         Fsr.Data = TruncateToLongwordFromDouble(EV | ROUND_TO_ZERO,
    01436                                                 &DoubleOperand,
    01437                                                 &LongwordResult);
    01438
    01439     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01440               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01441         Count += 1;
    01442     }
    01443
    01444     if (Count == 0) {
    01445         goto TestFailed;
    01446     }
    01447
    01448     Subtest += 1;
    01449     Count = 0;
    01450     DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    01451     DoubleOperand.HighPart = MINUS_DOUBLE_INFINITY_VALUE;
    01452     try {
    01453         Fsr.Data = TruncateToLongwordFromDouble(EV | ROUND_TO_ZERO,
    01454                                                 &DoubleOperand,
    01455                                                 &LongwordResult);
    01456
    01457     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01458               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01459         Count += 1;
    01460     }
    01461
    01462     if (Count == 0) {
    01463         goto TestFailed;
    01464     }
    01465
    01466     Subtest += 1;
    01467     DoubleOperand.LowPart = 0x0;
    01468     DoubleOperand.HighPart = 0x80000;
    01469     Fsr.Data = ConvertToLongwordFromDouble(ROUND_TO_NEAREST,
    01470                                            &DoubleOperand,
    01471                                            &LongwordResult);
    01472
    01473     if ((Fsr.Data != (SI | ROUND_TO_NEAREST)) ||
    01474         (LongwordResult != 0x0)) {
    01475         goto TestFailed;
    01476     }
    01477
    01478     Subtest += 1;
    01479     DoubleOperand.LowPart = 0x1;
    01480     DoubleOperand.HighPart = 0x0;
    01481     Fsr.Data = ConvertToLongwordFromDouble(ROUND_TO_NEAREST,
    01482                                            &DoubleOperand,
    01483                                            &LongwordResult);
    01484
    01485     if ((Fsr.Data != (SI | ROUND_TO_NEAREST)) ||
    01486         (LongwordResult != 0x0)) {
    01487         goto TestFailed;
    01488     }
    01489
    01490     Subtest += 1;
    01491     DoubleOperand.LowPart = 0x0;
    01492     DoubleOperand.HighPart = 0x80000;
    01493     Fsr.Data = RoundToLongwordFromDouble(ROUND_TO_NEAREST,
    01494                                          &DoubleOperand,
    01495                                          &LongwordResult);
    01496
    01497     if ((Fsr.Data != (SI | ROUND_TO_NEAREST)) ||
    01498         (LongwordResult != 0x0)) {
    01499         goto TestFailed;
    01500     }
    01501
    01502     Subtest += 1;
    01503     DoubleOperand.LowPart = 0x1;
    01504     DoubleOperand.HighPart = 0x0;
    01505     Fsr.Data = RoundToLongwordFromDouble(ROUND_TO_NEAREST,
    01506                                          &DoubleOperand,
    01507                                          &LongwordResult);
    01508
    01509     if ((Fsr.Data != (SI | ROUND_TO_NEAREST)) ||
    01510         (LongwordResult != 0x0)) {
    01511         goto TestFailed;
    01512     }
    01513
    01514     Subtest += 1;
    01515     Count = 0;
    01516     DoubleOperand.LowPart = 0x0;
    01517     DoubleOperand.HighPart = 0x80000;
    01518     try {
    01519         Fsr.Data = ConvertToLongwordFromDouble(EI | ROUND_TO_ZERO,
    01520                                                &DoubleOperand,
    01521                                                &LongwordResult);
    01522
    01523     } except ((GetExceptionCode() == STATUS_FLOAT_INEXACT_RESULT) ?
    01524               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01525         Count += 1;
    01526     }
    01527
    01528     if (Count == 0) {
    01529         goto TestFailed;
    01530     }
    01531
    01532     Subtest += 1;
    01533     Count = 0;
    01534     DoubleOperand.LowPart = 0x0;
    01535     DoubleOperand.HighPart = 0x80000;
    01536     try {
    01537         Fsr.Data = TruncateToLongwordFromDouble(EI | ROUND_TO_ZERO,
    01538                                                 &DoubleOperand,
    01539                                                 &LongwordResult);
    01540
    01541     } except ((GetExceptionCode() == STATUS_FLOAT_INEXACT_RESULT) ?
    01542               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01543         Count += 1;
    01544     }
    01545
    01546     if (Count == 0) {
    01547         goto TestFailed;
    01548     }
    01549
    01550     Subtest += 1;
    01551     DoubleOperand.LowPart = 0x0;
    01552     DoubleOperand.HighPart = ((DOUBLE_EXPONENT_BIAS + 32) << 20);
    01553     Fsr.Data = ConvertToLongwordFromDouble(ROUND_TO_NEAREST,
    01554                                            &DoubleOperand,
    01555                                            &LongwordResult);
    01556
    01557     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01558         (LongwordResult != INTEGER_NAN)) {
    01559         goto TestFailed;
    01560     }
    01561
    01562     Subtest += 1;
    01563     DoubleOperand.LowPart = 0x0;
    01564     DoubleOperand.HighPart = ((DOUBLE_EXPONENT_BIAS + 31) << 20);
    01565     Fsr.Data = ConvertToLongwordFromDouble(ROUND_TO_NEAREST,
    01566                                            &DoubleOperand,
    01567                                            &LongwordResult);
    01568
    01569     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01570         (LongwordResult != INTEGER_NAN)) {
    01571         goto TestFailed;
    01572     }
    01573
    01574     Subtest += 1;
    01575     DoubleOperand.LowPart = 0x0;
    01576     DoubleOperand.HighPart = SIGN | ((DOUBLE_EXPONENT_BIAS + 31) << 20);
    01577     Fsr.Data = ConvertToLongwordFromDouble(ROUND_TO_NEAREST,
    01578                                            &DoubleOperand,
    01579                                            &LongwordResult);
    01580
    01581     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    01582         (LongwordResult != 0x80000000)) {
    01583         goto TestFailed;
    01584     }
    01585
    01586     Subtest += 1;
    01587     DoubleOperand.LowPart = 0x0;
    01588     DoubleOperand.HighPart = SIGN | ((DOUBLE_EXPONENT_BIAS + 31) << 20) | 0x1;
    01589     Fsr.Data = ConvertToLongwordFromDouble(ROUND_TO_NEAREST,
    01590                                            &DoubleOperand,
    01591                                            &LongwordResult);
    01592
    01593     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01594         (LongwordResult != INTEGER_NAN)) {
    01595         goto TestFailed;
    01596     }
    01597
    01598     Subtest += 1;
    01599     DoubleOperand.LowPart = 0x0;
    01600     DoubleOperand.HighPart = ((DOUBLE_EXPONENT_BIAS + 32) << 20);
    01601     Fsr.Data = RoundToLongwordFromDouble(ROUND_TO_NEAREST,
    01602                                          &DoubleOperand,
    01603                                          &LongwordResult);
    01604
    01605     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01606         (LongwordResult != INTEGER_NAN)) {
    01607         goto TestFailed;
    01608     }
    01609
    01610     Subtest += 1;
    01611     DoubleOperand.LowPart = 0x0;
    01612     DoubleOperand.HighPart = ((DOUBLE_EXPONENT_BIAS + 31) << 20);
    01613     Fsr.Data = RoundToLongwordFromDouble(ROUND_TO_NEAREST,
    01614                                          &DoubleOperand,
    01615                                          &LongwordResult);
    01616
    01617     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01618         (LongwordResult != INTEGER_NAN)) {
    01619         goto TestFailed;
    01620     }
    01621
    01622     Subtest += 1;
    01623     DoubleOperand.LowPart = 0x0;
    01624     DoubleOperand.HighPart = SIGN | ((DOUBLE_EXPONENT_BIAS + 31) << 20);
    01625     Fsr.Data = RoundToLongwordFromDouble(ROUND_TO_NEAREST,
    01626                                          &DoubleOperand,
    01627                                          &LongwordResult);
    01628
    01629     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    01630         (LongwordResult != 0x80000000)) {
    01631         goto TestFailed;
    01632     }
    01633
    01634     Subtest += 1;
    01635     DoubleOperand.LowPart = 0x0;
    01636     DoubleOperand.HighPart = SIGN | ((DOUBLE_EXPONENT_BIAS + 31) << 20) | 0x1;
    01637     Fsr.Data = RoundToLongwordFromDouble(ROUND_TO_NEAREST,
    01638                                          &DoubleOperand,
    01639                                          &LongwordResult);
    01640
    01641     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01642         (LongwordResult != INTEGER_NAN)) {
    01643         goto TestFailed;
    01644     }
    01645
    01646     Subtest += 1;
    01647     Count = 0;
    01648     DoubleOperand.LowPart = 0x0;
    01649     DoubleOperand.HighPart = SIGN | ((DOUBLE_EXPONENT_BIAS + 31) << 20) | 0x1;
    01650     try {
    01651         Fsr.Data = ConvertToLongwordFromDouble(EV | ROUND_TO_ZERO,
    01652                                                &DoubleOperand,
    01653                                                &LongwordResult);
    01654
    01655     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01656               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01657         Count += 1;
    01658     }
    01659
    01660     if (Count == 0) {
    01661         goto TestFailed;
    01662     }
    01663
    01664     Subtest += 1;
    01665     Count = 0;
    01666     DoubleOperand.LowPart = 0x0;
    01667     DoubleOperand.HighPart = SIGN | ((DOUBLE_EXPONENT_BIAS + 31) << 20) | 0x1;
    01668     try {
    01669         Fsr.Data = TruncateToLongwordFromDouble(EV | ROUND_TO_ZERO,
    01670                                                 &DoubleOperand,
    01671                                                 &LongwordResult);
    01672
    01673     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01674               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01675         Count += 1;
    01676     }
    01677
    01678     if (Count == 0) {
    01679         goto TestFailed;
    01680     }
    01681
    01682     Subtest += 1;
    01683     DoubleOperand.LowPart = 0xfff00000;
    01684     DoubleOperand.HighPart = ((DOUBLE_EXPONENT_BIAS + 30) << 20) | 0xfffff;
    01685     Fsr.Data = ConvertToLongwordFromDouble(ROUND_TO_NEAREST,
    01686                                            &DoubleOperand,
    01687                                            &LongwordResult);
    01688
    01689     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01690         (LongwordResult != INTEGER_NAN)) {
    01691         goto TestFailed;
    01692     }
    01693
    01694     Subtest += 1;
    01695     Count = 0;
    01696     DoubleOperand.LowPart = 0xfff00000;
    01697     DoubleOperand.HighPart = ((DOUBLE_EXPONENT_BIAS + 30) << 20) | 0xfffff;
    01698     try {
    01699         Fsr.Data = ConvertToLongwordFromDouble(EV | ROUND_TO_NEAREST,
    01700                                                &DoubleOperand,
    01701                                                &LongwordResult);
    01702
    01703     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01704               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01705         Count += 1;
    01706     }
    01707
    01708     if (Count == 0) {
    01709         goto TestFailed;
    01710     }
    01711
    01712     Subtest += 1;
    01713     DoubleOperand.LowPart = 0xfff00000;
    01714     DoubleOperand.HighPart = ((DOUBLE_EXPONENT_BIAS + 30) << 20) | 0xfffff;
    01715     Fsr.Data = RoundToLongwordFromDouble(ROUND_TO_NEAREST,
    01716                                          &DoubleOperand,
    01717                                          &LongwordResult);
    01718
    01719     if ((Fsr.Data != (SV | ROUND_TO_NEAREST)) ||
    01720         (LongwordResult != INTEGER_NAN)) {
    01721         goto TestFailed;
    01722     }
    01723
    01724     Subtest += 1;
    01725     Count = 0;
    01726     DoubleOperand.LowPart = 0xfff00000;
    01727     DoubleOperand.HighPart = ((DOUBLE_EXPONENT_BIAS + 30) << 20) | 0xfffff;
    01728     try {
    01729         Fsr.Data = RoundToLongwordFromDouble(EV | ROUND_TO_NEAREST,
    01730                                              &DoubleOperand,
    01731                                              &LongwordResult);
    01732
    01733     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01734               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01735         Count += 1;
    01736     }
    01737
    01738     if (Count == 0) {
    01739         goto TestFailed;
    01740     }
    01741
    01742     //
    01743     // End of test 24.
    01744     //
    01745
    01746     printf("succeeded\n");
    01747     return;
    01748
    01749     //
    01750     // Test 24 failed.
    01751     //
    01752
    01753 TestFailed:
    01754     printf(" subtest %d failed, fsr = %lx, result = %lx\n",
    01755            Subtest,
    01756            Fsr.Data,
    01757            LongwordResult);
    01758
    01759     return;
    01760 }
    01761
    01762 VOID
    01763 Test25 (
    01764     VOID
    01765     )
    01766
    01767 {
    01768
    01769     ULONG Count;
    01770     FLOATING_STATUS Fsr;
    01771     ULARGE_INTEGER DoubleOperand;
    01772     ULARGE_INTEGER DoubleResult;
    01773     ULONG Subtest;
    01774
    01775     //
    01776     // Test 25 - Square root double test.
    01777     //
    01778
    01779     Subtest = 0;
    01780     printf("    Test 25 - square root double ...");
    01781     Subtest += 1;
    01782     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    01783     DoubleOperand.HighPart = DOUBLE_QUIET_NAN;
    01784     Fsr.Data = SquareRootDouble(ROUND_TO_NEAREST,
    01785                                 &DoubleOperand,
    01786                                 &DoubleResult);
    01787
    01788     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    01789         (DoubleResult.LowPart != DOUBLE_NAN_LOW) ||
    01790         (DoubleResult.HighPart != DOUBLE_QUIET_NAN)) {
    01791         goto TestFailed;
    01792     }
    01793
    01794     Subtest += 1;
    01795     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    01796     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    01797     Fsr.Data = SquareRootDouble(ROUND_TO_NEAREST,
    01798                                 &DoubleOperand,
    01799                                 &DoubleResult);
    01800
    01801     if ((Fsr.Data != (SV | XV | ROUND_TO_NEAREST)) ||
    01802         (DoubleResult.LowPart != DOUBLE_NAN_LOW) ||
    01803         (DoubleResult.HighPart != DOUBLE_QUIET_NAN)) {
    01804         goto TestFailed;
    01805     }
    01806
    01807     Subtest += 1;
    01808     Count = 0;
    01809     DoubleOperand.LowPart = DOUBLE_NAN_LOW;
    01810     DoubleOperand.HighPart = DOUBLE_SIGNAL_NAN;
    01811     try {
    01812         Fsr.Data = SquareRootDouble(EV | ROUND_TO_NEAREST,
    01813                                     &DoubleOperand,
    01814                                     &DoubleResult);
    01815
    01816     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01817               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01818         Count += 1;
    01819     }
    01820
    01821     if (Count == 0) {
    01822         goto TestFailed;
    01823     }
    01824
    01825     Subtest += 1;
    01826     DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    01827     DoubleOperand.HighPart = DOUBLE_INFINITY_VALUE_HIGH;
    01828     Fsr.Data = SquareRootDouble(ROUND_TO_NEAREST,
    01829                                 &DoubleOperand,
    01830                                 &DoubleResult);
    01831
    01832     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    01833         (DoubleResult.LowPart != DOUBLE_INFINITY_VALUE_LOW) ||
    01834         (DoubleResult.HighPart != DOUBLE_INFINITY_VALUE_HIGH)) {
    01835         goto TestFailed;
    01836     }
    01837
    01838     Subtest += 1;
    01839     DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    01840     DoubleOperand.HighPart = MINUS_DOUBLE_INFINITY_VALUE;
    01841     Fsr.Data = SquareRootDouble(ROUND_TO_NEAREST,
    01842                                 &DoubleOperand,
    01843                                 &DoubleResult);
    01844
    01845     if ((Fsr.Data != (SV | XV | ROUND_TO_NEAREST)) ||
    01846         (DoubleResult.LowPart != DOUBLE_NAN_LOW) ||
    01847         (DoubleResult.HighPart != DOUBLE_QUIET_NAN)) {
    01848         goto TestFailed;
    01849     }
    01850
    01851 //    Subtest += 1;
    01852 //    Count = 0;
    01853 //    DoubleOperand.LowPart = DOUBLE_INFINITY_VALUE_LOW;
    01854 //    DoubleOperand.HighPart = MINUS_DOUBLE_INFINITY_VALUE;
    01855 //    try {
    01856 //        Fsr.Data = SquareRootDouble(EV | ROUND_TO_NEAREST,
    01857 //                                    &DoubleOperand,
    01858 //                                    &DoubleResult);
    01859 //
    01860 //    } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    01861 //              EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    01862 //        Count += 1;
    01863 //    }
    01864 //
    01865 //    if (Count == 0) {
    01866 //        goto TestFailed;
    01867 //    }
    01868
    01869     Subtest += 1;
    01870     DoubleOperand.LowPart = 0;
    01871     DoubleOperand.HighPart = 0;
    01872     Fsr.Data = SquareRootDouble(ROUND_TO_NEAREST,
    01873                                 &DoubleOperand,
    01874                                 &DoubleResult);
    01875
    01876     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    01877         (DoubleResult.LowPart != 0) ||
    01878         (DoubleResult.HighPart != 0)) {
    01879         goto TestFailed;
    01880     }
    01881
    01882     Subtest += 1;
    01883     DoubleOperand.LowPart = 0;
    01884     DoubleOperand.HighPart = 0 | SIGN;
    01885     Fsr.Data = SquareRootDouble(ROUND_TO_NEAREST,
    01886                                 &DoubleOperand,
    01887                                 &DoubleResult);
    01888
    01889     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    01890         (DoubleResult.LowPart != 0) ||
    01891         (DoubleResult.HighPart != (0 | SIGN))) {
    01892         goto TestFailed;
    01893     }
    01894
    01895 // ****** //
    01896
    01897     Subtest += 1;
    01898     DoubleOperand.LowPart = 0x0;
    01899     DoubleOperand.HighPart = 0x40000;
    01900     Fsr.Data = SquareRootDouble(ROUND_TO_NEAREST,
    01901                                 &DoubleOperand,
    01902                                 &DoubleResult);
    01903
    01904     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    01905         (DoubleResult.LowPart != 0x0) ||
    01906         (DoubleResult.HighPart != 0x80000)) {
    01907         goto TestFailed;
    01908     }
    01909
    01910     Subtest += 1;
    01911     DoubleOperand.LowPart = 0x0;
    01912     DoubleOperand.HighPart = 0x10000;
    01913     Fsr.Data = SquareRootDouble(ROUND_TO_NEAREST,
    01914                                 &DoubleOperand,
    01915                                 &DoubleResult);
    01916
    01917     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    01918         (DoubleResult.LowPart != 0x0) ||
    01919         (DoubleResult.HighPart != 0x40000)) {
    01920         goto TestFailed;
    01921     }
    01922
    01923     Subtest += 1;
    01924     DoubleOperand.LowPart = 0x0;
    01925     DoubleOperand.HighPart = 0x4000;
    01926     Fsr.Data = SquareRootDouble(ROUND_TO_NEAREST,
    01927                                 &DoubleOperand,
    01928                                 &DoubleResult);
    01929
    01930     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    01931         (DoubleResult.LowPart != 0x0) ||
    01932         (DoubleResult.HighPart != 0x20000)) {
    01933         goto TestFailed;
    01934     }
    01935
    01936     Subtest += 1;
    01937     DoubleOperand.LowPart = 0x0;
    01938     DoubleOperand.HighPart = 0x1000;
    01939     Fsr.Data = SquareRootDouble(ROUND_TO_NEAREST,
    01940                                 &DoubleOperand,
    01941                                 &DoubleResult);
    01942
    01943     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    01944         (DoubleResult.LowPart != 0x0) ||
    01945         (DoubleResult.HighPart != 0x10000)) {
    01946         goto TestFailed;
    01947     }
    01948
    01949     Subtest += 1;
    01950     DoubleOperand.LowPart = 0x0;
    01951     DoubleOperand.HighPart = 0x80000;
    01952     Fsr.Data = SquareRootDouble(ROUND_TO_NEAREST,
    01953                                 &DoubleOperand,
    01954                                 &DoubleResult);
    01955
    01956     if ((Fsr.Data != (SU | SI | ROUND_TO_NEAREST)) ||
    01957         (DoubleResult.LowPart != 0x333f9de6) ||
    01958         (DoubleResult.HighPart != 0xb504f)) {
    01959         goto TestFailed;
    01960     }
    01961
    01962 // ****** //
    01963
    01964     //
    01965     // End of test 25.
    01966     //
    01967
    01968     printf("succeeded\n");
    01969     return;
    01970
    01971     //
    01972     // Test 25 failed.
    01973     //
    01974
    01975 TestFailed:
    01976     printf(" subtest %d failed, fsr = %lx, result = %lx, %lx\n",
    01977            Subtest,
    01978            Fsr.Data,
    01979            DoubleResult.LowPart,
    01980            DoubleResult.HighPart);
    01981
    01982     return;
    01983 }
    01984
    01985 VOID
    01986 Test26 (
    01987     VOID
    01988     )
    01989
    01990 {
    01991
    01992     ULONG Count;
    01993     FLOATING_STATUS Fsr;
    01994     ULONG Subtest;
    01995     ULONG SingleResult;
    01996
    01997     //
    01998     // Test 26 - Square root single test.
    01999     //
    02000
    02001     Subtest = 0;
    02002     printf("    Test 26 - square root single ...");
    02003     Subtest += 1;
    02004     Fsr.Data = SquareRootSingle(ROUND_TO_NEAREST,
    02005                                SINGLE_QUIET_NAN,
    02006                                &SingleResult);
    02007
    02008     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    02009         (SingleResult != SINGLE_QUIET_NAN)) {
    02010         goto TestFailed;
    02011     }
    02012
    02013     Subtest += 1;
    02014     Fsr.Data = SquareRootSingle(ROUND_TO_NEAREST,
    02015                                SINGLE_SIGNAL_NAN,
    02016                                &SingleResult);
    02017
    02018     if ((Fsr.Data != (SV | XV | ROUND_TO_NEAREST)) ||
    02019         (SingleResult != SINGLE_QUIET_NAN)) {
    02020         goto TestFailed;
    02021     }
    02022
    02023     Subtest += 1;
    02024     Count = 0;
    02025     try {
    02026         Fsr.Data = SquareRootSingle(EV | ROUND_TO_NEAREST,
    02027                                    SINGLE_SIGNAL_NAN,
    02028                                    &SingleResult);
    02029
    02030     } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    02031               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    02032         Count += 1;
    02033     }
    02034
    02035     if (Count == 0) {
    02036         goto TestFailed;
    02037     }
    02038
    02039     Subtest += 1;
    02040     Fsr.Data = SquareRootSingle(ROUND_TO_NEAREST,
    02041                                 SINGLE_INFINITY_VALUE,
    02042                                 &SingleResult);
    02043
    02044     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    02045         (SingleResult != SINGLE_INFINITY_VALUE)) {
    02046         goto TestFailed;
    02047     }
    02048
    02049     Subtest += 1;
    02050     Fsr.Data = SquareRootSingle(ROUND_TO_NEAREST,
    02051                                 MINUS_SINGLE_INFINITY_VALUE,
    02052                                 &SingleResult);
    02053
    02054     if ((Fsr.Data != (SV | XV | ROUND_TO_NEAREST)) ||
    02055         (SingleResult != SINGLE_QUIET_NAN)) {
    02056         goto TestFailed;
    02057     }
    02058
    02059 //    Subtest += 1;
    02060 //    Count = 0;
    02061 //    try {
    02062 //        Fsr.Data = SquareRootSingle(EV | ROUND_TO_NEAREST,
    02063 //                                   MINUS_SINGLE_INFINITY_VALUE,
    02064 //                                   &SingleResult);
    02065 //
    02066 //    } except ((GetExceptionCode() == STATUS_FLOAT_INVALID_OPERATION) ?
    02067 //              EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
    02068 //        Count += 1;
    02069 //    }
    02070 //
    02071 //    if (Count == 0) {
    02072 //        goto TestFailed;
    02073 //    }
    02074
    02075     Subtest += 1;
    02076     Fsr.Data = SquareRootSingle(ROUND_TO_NEAREST,
    02077                                 0,
    02078                                 &SingleResult);
    02079
    02080     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    02081         (SingleResult != 0)) {
    02082         goto TestFailed;
    02083     }
    02084
    02085     Subtest += 1;
    02086     Fsr.Data = SquareRootSingle(ROUND_TO_NEAREST,
    02087                                 0 | SIGN,
    02088                                 &SingleResult);
    02089
    02090     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    02091         (SingleResult != (0 | SIGN))) {
    02092         goto TestFailed;
    02093     }
    02094
    02095 // ****** //
    02096
    02097     Subtest += 1;
    02098     Fsr.Data = SquareRootSingle(ROUND_TO_NEAREST,
    02099                                 0x200000,
    02100                                 &SingleResult);
    02101
    02102     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    02103         (SingleResult != 0x400000)) {
    02104         goto TestFailed;
    02105     }
    02106
    02107     Subtest += 1;
    02108     Fsr.Data = SquareRootSingle(ROUND_TO_NEAREST,
    02109                                 0x80000,
    02110                                 &SingleResult);
    02111
    02112     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    02113         (SingleResult != 0x200000)) {
    02114         goto TestFailed;
    02115     }
    02116
    02117     Subtest += 1;
    02118     Fsr.Data = SquareRootSingle(ROUND_TO_NEAREST,
    02119                                 0x20000,
    02120                                 &SingleResult);
    02121
    02122     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    02123         (SingleResult != 0x100000)) {
    02124         goto TestFailed;
    02125     }
    02126
    02127     Subtest += 1;
    02128     Fsr.Data = SquareRootSingle(ROUND_TO_NEAREST,
    02129                                 0x8000,
    02130                                 &SingleResult);
    02131
    02132     if ((Fsr.Data != ROUND_TO_NEAREST) ||
    02133         (SingleResult != 0x80000)) {
    02134         goto TestFailed;
    02135     }
    02136
    02137     Subtest += 1;
    02138     Fsr.Data = SquareRootSingle(ROUND_TO_NEAREST,
    02139                                 0x400000,
    02140                                 &SingleResult);
    02141
    02142     if ((Fsr.Data != (SU | SI | ROUND_TO_NEAREST)) ||
    02143         (SingleResult != 0x5a8279)) {
    02144         goto TestFailed;
    02145     }
    02146
    02147 // ****** //
    02148
    02149     //
    02150     // End of test 26.
    02151     //
    02152
    02153     printf("succeeded\n");
    02154     return;
    02155
    02156     //
    02157     // Test 26 failed.
    02158     //
    02159
    02160 TestFailed:
    02161     printf(" subtest %d failed, fsr = %lx, result = %lx\n",
    02162            Subtest,
    02163            Fsr.Data,
    02164            SingleResult);
    02165
    02166     return;
    02167 }