^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ===============================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) This C header file is part of the SoftFloat IEC/IEEE Floating-point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) Arithmetic Package, Release 2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) Written by John R. Hauser. This work was made possible in part by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) International Computer Science Institute, located at Suite 600, 1947 Center
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) Street, Berkeley, California 94704. Funding was partially provided by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) National Science Foundation under grant MIP-9311980. The original version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) of this code was written as part of a project to build a fixed-point vector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) processor in collaboration with the University of California at Berkeley,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) overseen by Profs. Nelson Morgan and John Wawrzynek. More information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) is available through the Web page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) http://www.jhauser.us/arithmetic/SoftFloat-2b/SoftFloat-source.txt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) Derivative works are acceptable, even for commercial purposes, so long as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) (1) they include prominent notice that the work is derivative, and (2) they
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) include prominent notice akin to these three paragraphs for those parts of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) this code that are retained.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ===============================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #ifndef __SOFTFLOAT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define __SOFTFLOAT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) The macro `FLOATX80' must be defined to enable the extended double-precision
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) floating-point format `floatx80'. If this macro is not defined, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) `floatx80' type will not be defined, and none of the functions that either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) input or output the `floatx80' type will be defined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #ifdef CONFIG_FPE_NWFPE_XP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define FLOATX80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) Software IEC/IEEE floating-point types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) typedef u32 float32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) typedef u64 float64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #ifdef __ARMEB__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) u16 __padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u16 high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) u16 high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) u16 __padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) u64 low;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) } __attribute__ ((packed,aligned(4))) floatx80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) Software IEC/IEEE floating-point underflow tininess-detection mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) extern signed char float_detect_tininess;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) float_tininess_after_rounding = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) float_tininess_before_rounding = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) Software IEC/IEEE floating-point rounding mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) //extern int8 float_rounding_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) float_round_nearest_even = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) float_round_to_zero = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) float_round_down = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) float_round_up = 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) Software IEC/IEEE floating-point exception flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) float_flag_inexact = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) float_flag_underflow = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) float_flag_overflow = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) float_flag_divbyzero = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) float_flag_invalid = 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) ScottB: November 4, 1998
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) Changed the enumeration to match the bit order in the FPA11.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) float_flag_invalid = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) float_flag_divbyzero = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) float_flag_overflow = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) float_flag_underflow = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) float_flag_inexact = 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) Routine to raise any or all of the software IEC/IEEE floating-point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) exception flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) void float_raise( signed char );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) Software IEC/IEEE integer-to-floating-point conversion routines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) float32 int32_to_float32( struct roundingData *, signed int );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) float64 int32_to_float64( signed int );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #ifdef FLOATX80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) floatx80 int32_to_floatx80( signed int );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) Software IEC/IEEE single-precision conversion routines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) signed int float32_to_int32( struct roundingData *, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) signed int float32_to_int32_round_to_zero( float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) float64 float32_to_float64( float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #ifdef FLOATX80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) floatx80 float32_to_floatx80( float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) Software IEC/IEEE single-precision operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) float32 float32_round_to_int( struct roundingData*, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) float32 float32_add( struct roundingData *, float32, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) float32 float32_sub( struct roundingData *, float32, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) float32 float32_mul( struct roundingData *, float32, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) float32 float32_div( struct roundingData *, float32, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) float32 float32_rem( struct roundingData *, float32, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) float32 float32_sqrt( struct roundingData*, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) char float32_eq( float32, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) char float32_le( float32, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) char float32_lt( float32, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) char float32_eq_signaling( float32, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) char float32_le_quiet( float32, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) char float32_lt_quiet( float32, float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) char float32_is_signaling_nan( float32 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) Software IEC/IEEE double-precision conversion routines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) signed int float64_to_int32( struct roundingData *, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) signed int float64_to_int32_round_to_zero( float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) float32 float64_to_float32( struct roundingData *, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) #ifdef FLOATX80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) floatx80 float64_to_floatx80( float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) Software IEC/IEEE double-precision operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) float64 float64_round_to_int( struct roundingData *, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) float64 float64_add( struct roundingData *, float64, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) float64 float64_sub( struct roundingData *, float64, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) float64 float64_mul( struct roundingData *, float64, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) float64 float64_div( struct roundingData *, float64, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) float64 float64_rem( struct roundingData *, float64, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) float64 float64_sqrt( struct roundingData *, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) char float64_eq( float64, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) char float64_le( float64, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) char float64_lt( float64, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) char float64_eq_signaling( float64, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) char float64_le_quiet( float64, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) char float64_lt_quiet( float64, float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) char float64_is_signaling_nan( float64 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #ifdef FLOATX80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) Software IEC/IEEE extended double-precision conversion routines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) signed int floatx80_to_int32( struct roundingData *, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) signed int floatx80_to_int32_round_to_zero( floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) float32 floatx80_to_float32( struct roundingData *, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) float64 floatx80_to_float64( struct roundingData *, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) Software IEC/IEEE extended double-precision operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) floatx80 floatx80_round_to_int( struct roundingData *, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) floatx80 floatx80_add( struct roundingData *, floatx80, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) floatx80 floatx80_sub( struct roundingData *, floatx80, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) floatx80 floatx80_mul( struct roundingData *, floatx80, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) floatx80 floatx80_div( struct roundingData *, floatx80, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) floatx80 floatx80_rem( struct roundingData *, floatx80, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) floatx80 floatx80_sqrt( struct roundingData *, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) char floatx80_eq( floatx80, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) char floatx80_le( floatx80, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) char floatx80_lt( floatx80, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) char floatx80_eq_signaling( floatx80, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) char floatx80_le_quiet( floatx80, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) char floatx80_lt_quiet( floatx80, floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) char floatx80_is_signaling_nan( floatx80 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) extern flag floatx80_is_nan(floatx80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static inline flag extractFloat32Sign(float32 a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return a >> 31;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) static inline flag float32_eq_nocheck(float32 a, float32 b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return (a == b) || ((bits32) ((a | b) << 1) == 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) static inline flag float32_lt_nocheck(float32 a, float32 b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) flag aSign, bSign;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) aSign = extractFloat32Sign(a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) bSign = extractFloat32Sign(b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if (aSign != bSign)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) return aSign && ((bits32) ((a | b) << 1) != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) return (a != b) && (aSign ^ (a < b));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) static inline flag extractFloat64Sign(float64 a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) return a >> 63;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static inline flag float64_eq_nocheck(float64 a, float64 b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) return (a == b) || ((bits64) ((a | b) << 1) == 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) static inline flag float64_lt_nocheck(float64 a, float64 b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) flag aSign, bSign;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) aSign = extractFloat64Sign(a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) bSign = extractFloat64Sign(b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (aSign != bSign)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) return aSign && ((bits64) ((a | b) << 1) != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) return (a != b) && (aSign ^ (a < b));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) extern flag float32_is_nan( float32 a );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) extern flag float64_is_nan( float64 a );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) extern int32 float64_to_uint32( struct roundingData *roundData, float64 a );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) extern int32 float64_to_uint32_round_to_zero( float64 a );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) #endif