On 10/13/2017 09:24 AM, Alex Bennée wrote: > +int float16_eq(float16 a, float16 b, float_status *status) > +{ > + uint32_t av, bv; > + a = float16_squash_input_denormal(a, status); > + b = float16_squash_input_denormal(b, status); > + > + if ( ( ( extractFloat16Exp( a ) == 0x1F ) && extractFloat16Frac( a ) ) > + || ( ( extractFloat16Exp( b ) == 0x1F ) && extractFloat16Frac( b ) )
float16_is_any_nan > + ) { > + float_raise(float_flag_invalid, status); > + return 0; > + } > + av = float16_val(a); > + bv = float16_val(b); > + return ( av == bv ) || ( (uint32_t) ( ( av | bv )<<1 ) == 0 ); For this trick to work you have to truncate to uint16_t not uint32_t. It might be easier to read as a == b || float16_is_zero(a | b) That said, I wonder if it wouldn't be better to implement all of these in terms of float16_compare, rather than duplicating all of this code. r~