01212 {
01213 
01214     ULONG 
Count;
01215     
FLOATING_STATUS Fsr;
01216     ULARGE_INTEGER DoubleOperand;
01217     ULONG LongwordResult;
01218     ULONG Subtest;
01219 
01220     
01221     
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     
01744     
01745 
01746     printf(
"succeeded\n");
01747     
return;
01748 
01749     
01750     
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 }