aboutsummaryrefslogtreecommitdiff
path: root/source/testfloat.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/testfloat.c')
-rw-r--r--source/testfloat.c83
1 files changed, 74 insertions, 9 deletions
diff --git a/source/testfloat.c b/source/testfloat.c
index f58cf53..f72e726 100644
--- a/source/testfloat.c
+++ b/source/testfloat.c
@@ -1,12 +1,12 @@
/*============================================================================
-This C source file is part of TestFloat, Release 3b, a package of programs for
+This C source file is part of TestFloat, Release 3c, a package of programs for
testing the correctness of floating-point arithmetic complying with the IEEE
Standard for Floating-Point, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
-California. All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -65,7 +65,9 @@ static void (*subjFunctionPtr)();
typedef float16_t funcType_a_ui32_z_f16( uint32_t );
#endif
typedef float32_t funcType_a_ui32_z_f32( uint32_t );
+#ifdef FLOAT64
typedef float64_t funcType_a_ui32_z_f64( uint32_t );
+#endif
#ifdef EXTFLOAT80
typedef void funcType_a_ui32_z_extF80( uint32_t, extFloat80_t * );
#endif
@@ -76,7 +78,9 @@ typedef void funcType_a_ui32_z_f128( uint32_t, float128_t * );
typedef float16_t funcType_a_ui64_z_f16( uint64_t );
#endif
typedef float32_t funcType_a_ui64_z_f32( uint64_t );
+#ifdef FLOAT64
typedef float64_t funcType_a_ui64_z_f64( uint64_t );
+#endif
#ifdef EXTFLOAT80
typedef void funcType_a_ui64_z_extF80( uint64_t, extFloat80_t * );
#endif
@@ -87,7 +91,9 @@ typedef void funcType_a_ui64_z_f128( uint64_t, float128_t * );
typedef float16_t funcType_a_i32_z_f16( int32_t );
#endif
typedef float32_t funcType_a_i32_z_f32( int32_t );
+#ifdef FLOAT64
typedef float64_t funcType_a_i32_z_f64( int32_t );
+#endif
#ifdef EXTFLOAT80
typedef void funcType_a_i32_z_extF80( int32_t, extFloat80_t * );
#endif
@@ -98,7 +104,9 @@ typedef void funcType_a_i32_z_f128( int32_t, float128_t * );
typedef float16_t funcType_a_i64_z_f16( int64_t );
#endif
typedef float32_t funcType_a_i64_z_f32( int64_t );
+#ifdef FLOAT64
typedef float64_t funcType_a_i64_z_f64( int64_t );
+#endif
#ifdef EXTFLOAT80
typedef void funcType_a_i64_z_extF80( int64_t, extFloat80_t * );
#endif
@@ -112,7 +120,9 @@ typedef uint_fast64_t funcType_a_f16_z_ui64( float16_t );
typedef int_fast32_t funcType_a_f16_z_i32( float16_t );
typedef int_fast64_t funcType_a_f16_z_i64( float16_t );
typedef float32_t funcType_a_f16_z_f32( float16_t );
+#ifdef FLOAT64
typedef float64_t funcType_a_f16_z_f64( float16_t );
+#endif
#ifdef EXTFLOAT80
typedef void funcType_a_f16_z_extF80( float16_t, extFloat80_t * );
#endif
@@ -132,7 +142,9 @@ typedef int_fast64_t funcType_a_f32_z_i64( float32_t );
#ifdef FLOAT16
typedef float16_t funcType_a_f32_z_f16( float32_t );
#endif
+#ifdef FLOAT64
typedef float64_t funcType_a_f32_z_f64( float32_t );
+#endif
#ifdef EXTFLOAT80
typedef void funcType_a_f32_z_extF80( float32_t, extFloat80_t * );
#endif
@@ -144,6 +156,7 @@ typedef float32_t funcType_abz_f32( float32_t, float32_t );
typedef float32_t funcType_abcz_f32( float32_t, float32_t, float32_t );
typedef bool funcType_ab_f32_z_bool( float32_t, float32_t );
+#ifdef FLOAT64
typedef uint_fast32_t funcType_a_f64_z_ui32( float64_t );
typedef uint_fast64_t funcType_a_f64_z_ui64( float64_t );
typedef int_fast32_t funcType_a_f64_z_i32( float64_t );
@@ -162,6 +175,7 @@ typedef float64_t funcType_az_f64( float64_t );
typedef float64_t funcType_abz_f64( float64_t, float64_t );
typedef float64_t funcType_abcz_f64( float64_t, float64_t, float64_t );
typedef bool funcType_ab_f64_z_bool( float64_t, float64_t );
+#endif
#ifdef EXTFLOAT80
typedef uint_fast32_t funcType_a_extF80_z_ui32( const extFloat80_t * );
@@ -172,7 +186,9 @@ typedef int_fast64_t funcType_a_extF80_z_i64( const extFloat80_t * );
typedef float16_t funcType_a_extF80_z_f16( const extFloat80_t * );
#endif
typedef float32_t funcType_a_extF80_z_f32( const extFloat80_t * );
+#ifdef FLOAT64
typedef float64_t funcType_a_extF80_z_f64( const extFloat80_t * );
+#endif
#ifdef FLOAT128
typedef void funcType_a_extF80_z_f128( const extFloat80_t *, float128_t * );
#endif
@@ -194,7 +210,9 @@ typedef int_fast64_t funcType_a_f128_z_i64( const float128_t * );
typedef float16_t funcType_a_f128_z_f16( const float128_t * );
#endif
typedef float32_t funcType_a_f128_z_f32( const float128_t * );
+#ifdef FLOAT64
typedef float64_t funcType_a_f128_z_f64( const float128_t * );
+#endif
#ifdef EXTFLOAT80
typedef void funcType_a_f128_z_extF80( const float128_t *, extFloat80_t * );
#endif
@@ -312,6 +330,8 @@ float32_t
}
+#ifdef FLOAT64
+
static
uint_fast32_t
subjFunction_a_f64_z_ui32_rx(
@@ -361,6 +381,8 @@ float64_t
}
+#endif
+
#ifdef EXTFLOAT80
static
@@ -488,8 +510,10 @@ void
#endif
funcType_abz_f32 *trueFunction_abz_f32;
funcType_ab_f32_z_bool *trueFunction_ab_f32_z_bool;
+#ifdef FLOAT64
funcType_abz_f64 *trueFunction_abz_f64;
funcType_ab_f64_z_bool *trueFunction_ab_f64_z_bool;
+#endif
#ifdef EXTFLOAT80
funcType_abz_extF80 *trueFunction_abz_extF80;
funcType_ab_extF80_z_bool *trueFunction_ab_extF80_z_bool;
@@ -519,12 +543,14 @@ void
ui32_to_f32, (funcType_a_ui32_z_f32 *) subjFunctionPtr );
break;
#endif
+#ifdef FLOAT64
#ifdef SUBJ_UI32_TO_F64
case UI32_TO_F64:
test_a_ui32_z_f64(
ui32_to_f64, (funcType_a_ui32_z_f64 *) subjFunctionPtr );
break;
#endif
+#endif
#ifdef EXTFLOAT80
#ifdef SUBJ_UI32_TO_EXTF80
case UI32_TO_EXTF80:
@@ -555,12 +581,14 @@ void
ui64_to_f32, (funcType_a_ui64_z_f32 *) subjFunctionPtr );
break;
#endif
+#ifdef FLOAT64
#ifdef SUBJ_UI64_TO_F64
case UI64_TO_F64:
test_a_ui64_z_f64(
ui64_to_f64, (funcType_a_ui64_z_f64 *) subjFunctionPtr );
break;
#endif
+#endif
#ifdef EXTFLOAT80
#ifdef SUBJ_UI64_TO_EXTF80
case UI64_TO_EXTF80:
@@ -591,12 +619,14 @@ void
i32_to_f32, (funcType_a_i32_z_f32 *) subjFunctionPtr );
break;
#endif
+#ifdef FLOAT64
#ifdef SUBJ_I32_TO_F64
case I32_TO_F64:
test_a_i32_z_f64(
i32_to_f64, (funcType_a_i32_z_f64 *) subjFunctionPtr );
break;
#endif
+#endif
#ifdef EXTFLOAT80
#ifdef SUBJ_I32_TO_EXTF80
case I32_TO_EXTF80:
@@ -627,12 +657,14 @@ void
i64_to_f32, (funcType_a_i64_z_f32 *) subjFunctionPtr );
break;
#endif
+#ifdef FLOAT64
#ifdef SUBJ_I64_TO_F64
case I64_TO_F64:
test_a_i64_z_f64(
i64_to_f64, (funcType_a_i64_z_f64 *) subjFunctionPtr );
break;
#endif
+#endif
#ifdef EXTFLOAT80
#ifdef SUBJ_I64_TO_EXTF80
case I64_TO_EXTF80:
@@ -674,12 +706,14 @@ void
f16_to_f32, (funcType_a_f16_z_f32 *) subjFunctionPtr );
break;
#endif
+#ifdef FLOAT64
#ifdef SUBJ_F16_TO_F64
case F16_TO_F64:
test_a_f16_z_f64(
f16_to_f64, (funcType_a_f16_z_f64 *) subjFunctionPtr );
break;
#endif
+#endif
#ifdef EXTFLOAT80
#ifdef SUBJ_F16_TO_EXTF80
case F16_TO_EXTF80:
@@ -802,12 +836,14 @@ void
break;
#endif
#endif
+#ifdef FLOAT64
#ifdef SUBJ_F32_TO_F64
case F32_TO_F64:
test_a_f32_z_f64(
f32_to_f64, (funcType_a_f32_z_f64 *) subjFunctionPtr );
break;
#endif
+#endif
#ifdef EXTFLOAT80
#ifdef SUBJ_F32_TO_EXTF80
case F32_TO_EXTF80:
@@ -905,6 +941,7 @@ void
break;
/*--------------------------------------------------------------------
*--------------------------------------------------------------------*/
+#ifdef FLOAT64
case F64_TO_UI32:
test_a_f64_z_ui32_rx(
f64_to_ui32, subjFunction_a_f64_z_ui32_rx, roundingMode, exact );
@@ -1030,6 +1067,7 @@ void
(funcType_ab_f64_z_bool *) subjFunctionPtr
);
break;
+#endif
/*--------------------------------------------------------------------
*--------------------------------------------------------------------*/
#ifdef EXTFLOAT80
@@ -1073,12 +1111,14 @@ void
extF80M_to_f32, (funcType_a_extF80_z_f32 *) subjFunctionPtr );
break;
#endif
+#ifdef FLOAT64
#ifdef SUBJ_EXTF80_TO_F64
case EXTF80_TO_F64:
test_a_extF80_z_f64(
extF80M_to_f64, (funcType_a_extF80_z_f64 *) subjFunctionPtr );
break;
#endif
+#endif
#ifdef FLOAT128
#ifdef SUBJ_EXTF80_TO_F128
case EXTF80_TO_F128:
@@ -1198,12 +1238,14 @@ void
f128M_to_f32, (funcType_a_f128_z_f32 *) subjFunctionPtr );
break;
#endif
+#ifdef FLOAT64
#ifdef SUBJ_F128_TO_F64
case F128_TO_F64:
test_a_f128_z_f64(
f128M_to_f64, (funcType_a_f128_z_f64 *) subjFunctionPtr );
break;
#endif
+#endif
#ifdef EXTFLOAT80
#ifdef SUBJ_F128_TO_EXTF80
case F128_TO_EXTF80:
@@ -1345,6 +1387,9 @@ void
#ifndef SUBJFLOAT_ROUND_NEAR_MAXMAG
if ( roundingCode != ROUND_NEAR_MAXMAG ) {
#endif
+#if defined FLOAT_ROUND_ODD && ! defined SUBJFLOAT_ROUND_NEAR_MAXMAG
+ if ( roundingCode != ROUND_ODD ) {
+#endif
if (
functionAttribs
& (FUNC_ARG_ROUNDINGMODE | FUNC_EFF_ROUNDINGMODE)
@@ -1364,6 +1409,9 @@ void
}
testFunctionInstance( functionCode, roundingMode, exact );
if ( roundingCodeIn || ! roundingCode ) break;
+#if defined FLOAT_ROUND_ODD && ! defined SUBJFLOAT_ROUND_NEAR_MAXMAG
+ }
+#endif
#ifndef SUBJFLOAT_ROUND_NEAR_MAXMAG
}
#endif
@@ -1429,7 +1477,7 @@ int main( int argc, char *argv[] )
" -errors <num> --Stop each function test after <num> errors.\n"
" * -errors 20\n"
" -errorstop --Exit after first function with any error.\n"
-" -forever --Test one function repeatedly (implies `-level 2').\n"
+" -forever --Test one function repeatedly (implies '-level 2').\n"
" -checkNaNs --Check for bitwise correctness of NaN results.\n"
#ifdef EXTFLOAT80
" -precision32 --For extF80, test only 32-bit rounding precision.\n"
@@ -1460,7 +1508,9 @@ int main( int argc, char *argv[] )
" f16 --Binary 16-bit floating-point (half-precision).\n"
#endif
" f32 --Binary 32-bit floating-point (single-precision).\n"
+#ifdef FLOAT64
" f64 --Binary 64-bit floating-point (double-precision).\n"
+#endif
#ifdef EXTFLOAT80
" extF80 --Binary 80-bit extended floating-point.\n"
#endif
@@ -1472,7 +1522,14 @@ int main( int argc, char *argv[] )
" minMag --Round to minimum magnitude (toward zero).\n"
" min --Round to minimum (down).\n"
" max --Round to maximum (up).\n"
+#ifdef SUBJFLOAT_ROUND_NEAR_MAXMAG
" near_maxMag --Round to nearest/maximum magnitude (nearest/away).\n"
+#endif
+#if defined FLOAT_ROUND_ODD && defined SUBJFLOAT_ROUND_ODD
+" odd --Round to odd (jamming). (Not allowed as an inherent\n"
+" rounding mode. For 'roundToInt_x', rounds to minimum\n"
+" magnitude instead.)\n"
+#endif
,
stdout
);
@@ -1555,9 +1612,17 @@ int main( int argc, char *argv[] )
roundingCode = ROUND_NEAR_MAXMAG;
#else
fail(
- "Rounding mode near_maxMag is not supported or cannot be tested"
+ "Rounding mode 'near_maxMag' is not supported or cannot be tested"
);
#endif
+#ifdef FLOAT_ROUND_ODD
+ } else if ( ! strcmp( argPtr, "rodd" ) ) {
+#ifdef SUBJFLOAT_ROUND_ODD
+ roundingCode = ROUND_ODD;
+#else
+ fail( "Rounding mode 'odd' is not supported or cannot be tested" );
+#endif
+#endif
} else if ( ! strcmp( argPtr, "tininessbefore" ) ) {
softfloat_detectTininess = softfloat_tininess_beforeRounding;
} else if ( ! strcmp( argPtr, "tininessafter" ) ) {
@@ -1575,7 +1640,7 @@ int main( int argc, char *argv[] )
for (;;) {
functionNamePtr = standardFunctionInfoPtr->namePtr;
if ( ! functionNamePtr ) {
- fail( "Invalid argument `%s'", *argv );
+ fail( "Invalid argument '%s'", *argv );
}
if ( ! strcmp( argPtr, functionNamePtr ) ) break;
++standardFunctionInfoPtr;
@@ -1585,7 +1650,7 @@ int main( int argc, char *argv[] )
[standardFunctionInfoPtr - standardFunctionInfos];
if ( ! subjFunctionPtr ) {
fail(
- "Function `%s' is not supported or cannot be tested",
+ "Function '%s' is not supported or cannot be tested",
argPtr
);
}
@@ -1606,7 +1671,7 @@ int main( int argc, char *argv[] )
standardFunctionInfoPtr, roundingPrecision, roundingCode );
} else {
if ( testLoops_forever ) {
- fail( "Can test only one function with `-forever' option" );
+ fail( "Can test only one function with '-forever' option" );
}
if ( numOperands == 1 ) {
standardFunctionInfoPtr = standardFunctionInfos;
@@ -1656,7 +1721,7 @@ int main( int argc, char *argv[] )
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
optionError:
- fail( "`%s' option requires numeric argument", *argv );
+ fail( "'%s' option requires numeric argument", *argv );
}