diff options
author | John Hauser <jhauser@eecs.berkeley.edu> | 2017-02-10 12:38:35 -0800 |
---|---|---|
committer | John Hauser <jhauser@eecs.berkeley.edu> | 2017-02-10 12:38:35 -0800 |
commit | f755993d040a8ea9c1acf758efce76da60870627 (patch) | |
tree | dbc9bd5562476b06769ac1a1fe429ac1dde56b84 /source/subj-C/subjfloat.c | |
parent | ddfb9e70c434ae238635784ce66cb7ed93d0a2e7 (diff) | |
download | berkeley-testfloat-3-f755993d040a8ea9c1acf758efce76da60870627.zip berkeley-testfloat-3-f755993d040a8ea9c1acf758efce76da60870627.tar.gz berkeley-testfloat-3-f755993d040a8ea9c1acf758efce76da60870627.tar.bz2 |
Release 3c. See "doc/TestFloat-history.html".
Diffstat (limited to 'source/subj-C/subjfloat.c')
-rw-r--r-- | source/subj-C/subjfloat.c | 132 |
1 files changed, 81 insertions, 51 deletions
diff --git a/source/subj-C/subjfloat.c b/source/subj-C/subjfloat.c index b42075e..f5381a4 100644 --- a/source/subj-C/subjfloat.c +++ b/source/subj-C/subjfloat.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 The Regents of the University of California. -All rights reserved. +Copyright 2011, 2012, 2013, 2014, 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: @@ -95,7 +95,6 @@ uint_fast8_t subjfloat_clearExceptionFlags( void ) } union f32_f { float32_t f32; float f; }; -union f64_d { float64_t f64; double d; }; float32_t subj_ui32_to_f32( uint32_t a ) { @@ -106,15 +105,6 @@ float32_t subj_ui32_to_f32( uint32_t a ) } -float64_t subj_ui32_to_f64( uint32_t a ) -{ - union f64_d uZ; - - uZ.d = a; - return uZ.f64; - -} - float32_t subj_ui64_to_f32( uint64_t a ) { union f32_f uZ; @@ -124,15 +114,6 @@ float32_t subj_ui64_to_f32( uint64_t a ) } -float64_t subj_ui64_to_f64( uint64_t a ) -{ - union f64_d uZ; - - uZ.d = a; - return uZ.f64; - -} - float32_t subj_i32_to_f32( int32_t a ) { union f32_f uZ; @@ -142,15 +123,6 @@ float32_t subj_i32_to_f32( int32_t a ) } -float64_t subj_i32_to_f64( int32_t a ) -{ - union f64_d uZ; - - uZ.d = a; - return uZ.f64; - -} - float32_t subj_i64_to_f32( int64_t a ) { union f32_f uZ; @@ -160,15 +132,6 @@ float32_t subj_i64_to_f32( int64_t a ) } -float64_t subj_i64_to_f64( int64_t a ) -{ - union f64_d uZ; - - uZ.d = a; - return uZ.f64; - -} - uint_fast32_t subj_f32_to_ui32_rx_minMag( float32_t a ) { union f32_f uA; @@ -205,17 +168,6 @@ int_fast64_t subj_f32_to_i64_rx_minMag( float32_t a ) } -float64_t subj_f32_to_f64( float32_t a ) -{ - union f32_f uA; - union f64_d uZ; - - uA.f32 = a; - uZ.d = uA.f; - return uZ.f64; - -} - float32_t subj_f32_add( float32_t a, float32_t b ) { union f32_f uA, uB, uZ; @@ -290,6 +242,60 @@ bool subj_f32_lt( float32_t a, float32_t b ) } +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + +#ifdef FLOAT64 + +union f64_d { float64_t f64; double d; }; + +float64_t subj_ui32_to_f64( uint32_t a ) +{ + union f64_d uZ; + + uZ.d = a; + return uZ.f64; + +} + +float64_t subj_ui64_to_f64( uint64_t a ) +{ + union f64_d uZ; + + uZ.d = a; + return uZ.f64; + +} + +float64_t subj_i32_to_f64( int32_t a ) +{ + union f64_d uZ; + + uZ.d = a; + return uZ.f64; + +} + +float64_t subj_i64_to_f64( int64_t a ) +{ + union f64_d uZ; + + uZ.d = a; + return uZ.f64; + +} + +float64_t subj_f32_to_f64( float32_t a ) +{ + union f32_f uA; + union f64_d uZ; + + uA.f32 = a; + uZ.d = uA.f; + return uZ.f64; + +} + uint_fast32_t subj_f64_to_ui32_rx_minMag( float64_t a ) { union f64_d uA; @@ -421,6 +427,11 @@ bool subj_f64_lt( float64_t a, float64_t b ) } +#endif + +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + #if defined EXTFLOAT80 && defined LONG_DOUBLE_IS_EXTFLOAT80 void subj_ui32_to_extF80M( uint32_t a, extFloat80_t *zPtr ) @@ -460,6 +471,8 @@ void subj_f32_to_extF80M( float32_t a, extFloat80_t *zPtr ) } +#ifdef FLOAT64 + void subj_f64_to_extF80M( float64_t a, extFloat80_t *zPtr ) { union f64_d uA; @@ -469,6 +482,8 @@ void subj_f64_to_extF80M( float64_t a, extFloat80_t *zPtr ) } +#endif + uint_fast32_t subj_extF80M_to_ui32_rx_minMag( const extFloat80_t *aPtr ) { @@ -506,6 +521,8 @@ float32_t subj_extF80M_to_f32( const extFloat80_t *aPtr ) } +#ifdef FLOAT64 + float64_t subj_extF80M_to_f64( const extFloat80_t *aPtr ) { union f64_d uZ; @@ -515,6 +532,8 @@ float64_t subj_extF80M_to_f64( const extFloat80_t *aPtr ) } +#endif + void subj_extF80M_add( const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr ) @@ -578,6 +597,9 @@ bool subj_extF80M_lt( const extFloat80_t *aPtr, const extFloat80_t *bPtr ) #endif +/*---------------------------------------------------------------------------- +*----------------------------------------------------------------------------*/ + #if defined FLOAT128 && defined LONG_DOUBLE_IS_FLOAT128 void subj_ui32_to_f128M( uint32_t a, float128_t *zPtr ) @@ -617,6 +639,8 @@ void subj_f32_to_f128M( float32_t a, float128_t *zPtr ) } +#ifdef FLOAT64 + void subj_f64_to_f128M( float64_t a, float128_t *zPtr ) { union f64_d uA; @@ -626,6 +650,8 @@ void subj_f64_to_f128M( float64_t a, float128_t *zPtr ) } +#endif + uint_fast32_t subj_f128M_to_ui32_rx_minMag( const float128_t *aPtr ) { @@ -663,6 +689,8 @@ float32_t subj_f128M_to_f32( const float128_t *aPtr ) } +#ifdef FLOAT64 + float64_t subj_f128M_to_f64( const float128_t *aPtr ) { union f64_d uZ; @@ -672,6 +700,8 @@ float64_t subj_f128M_to_f64( const float128_t *aPtr ) } +#endif + void subj_f128M_add( const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr ) |