@@ -4,7 +4,7 @@ using namespace qlibs;
44
55fp16Raw_t fp16::Min = -2147483647 ; // skipcq: CXX-W2009
66fp16Raw_t fp16::Max = 2147483647 ; // skipcq: CXX-W2009
7- bool fp16::rounding = true ; // skipcq: CXX-W2009
7+ bool fp16::flag_rounding = true ; // skipcq: CXX-W2009
88bool fp16::saturation = false ; // skipcq: CXX-W2009
99const fp16Raw_t fp16::exp_max = 681391 ;
1010const fp16Raw_t fp16::f2 = 131072 ;
@@ -22,7 +22,7 @@ int fp16::toInt( const fp16 &x ) noexcept
2222{
2323 int retValue;
2424
25- if ( rounding ) {
25+ if ( flag_rounding ) {
2626 if ( x.value >= 0 ) {
2727 retValue = ( x.value + ( one >> 1 ) ) / one;
2828 }
@@ -61,7 +61,7 @@ fp16Raw_t fp16::fromFloat( const float x ) noexcept
6161 float f_value;
6262 /* cstat -CERT-FLP36-C -CERT-FLP34-C*/
6363 f_value = x * static_cast <float >( one );
64- if ( rounding ) {
64+ if ( flag_rounding ) {
6565 f_value += ( f_value >= 0 .0F ) ? 0 .5F : -0 .5F ;
6666 }
6767 return static_cast <fp16Raw_t>( f_value );
@@ -73,7 +73,7 @@ fp16Raw_t fp16::fromDouble( const double x ) noexcept
7373 double d_value;
7474 /* cstat -CERT-FLP36-C -CERT-FLP34-C*/
7575 d_value = x * static_cast <double >( one );
76- if ( rounding ) {
76+ if ( flag_rounding ) {
7777 d_value += ( d_value >= 0.0 ) ? 0.5 : -0.5 ;
7878 }
7979 return static_cast <fp16Raw_t>( d_value );
@@ -149,7 +149,7 @@ fp16Raw_t fp16::mul( const fp16Raw_t x,
149149 a = ( mulH < 0 ) ? -1 : 0 ;
150150 /* cstat +MISRAC++2008-5-0-3*/
151151 if ( a == ( mulH >> 15 ) ) {
152- if ( rounding ) {
152+ if ( flag_rounding ) {
153153 uint32_t tmp2;
154154
155155 tmp2 = mulL;
@@ -207,7 +207,7 @@ fp16Raw_t fp16::div( const fp16Raw_t x,
207207 xRem <<= 1 ;
208208 bit >>= 1 ;
209209 }
210- if ( rounding ) {
210+ if ( flag_rounding ) {
211211 if ( xRem >= xDiv ) {
212212 ++quotient;
213213 }
@@ -228,7 +228,7 @@ fp16Raw_t fp16::div( const fp16Raw_t x,
228228 return saturate ( retValue, x, y );
229229}
230230/* ============================================================================*/
231- fp16Raw_t fp16::abs ( fp16Raw_t x ) noexcept
231+ fp16Raw_t fp16::absolute ( fp16Raw_t x ) noexcept
232232{
233233 fp16Raw_t retValue;
234234
@@ -260,7 +260,7 @@ fp16Raw_t fp16::sqrt( fp16Raw_t x ) noexcept
260260
261261 retValue = 0 ;
262262 /* cstat -MISRAC++2008-5-0-3*/
263- bit = ( 0 != ( x & static_cast <fp16Raw_t>( 4293918720 ) ) ) ? ( 1U << 30U ) : ( 1U << 18U ) ;
263+ bit = ( 0 != ( x & static_cast <fp16Raw_t>( 4293918720 ) ) ) ? 1073741824U : 262144U ;
264264 /* cstat +MISRAC++2008-5-0-3*/
265265 while ( bit > static_cast <uint32_t >( x ) ) {
266266 bit >>= 2U ;
@@ -292,7 +292,7 @@ fp16Raw_t fp16::sqrt( fp16Raw_t x ) noexcept
292292 }
293293 }
294294 }
295- if ( ( rounding ) && ( x > retValue ) ) {
295+ if ( ( flag_rounding ) && ( x > retValue ) ) {
296296 ++retValue;
297297 }
298298
@@ -386,7 +386,7 @@ fp16Raw_t fp16::rs( fp16Raw_t x ) noexcept
386386{
387387 fp16Raw_t retValue;
388388
389- if ( rounding ) {
389+ if ( flag_rounding ) {
390390 retValue = ( x >> 1U ) + ( x & 1 );
391391 }
392392 else {
@@ -418,7 +418,7 @@ fp16Raw_t fp16::log2i( fp16Raw_t x ) noexcept
418418 x = rs ( x );
419419 }
420420 }
421- if ( rounding ) {
421+ if ( flag_rounding ) {
422422 x = mul ( x, x );
423423 if ( x >= f2 ) {
424424 ++retValue;
@@ -657,7 +657,7 @@ fp16Raw_t fp16::tanh( fp16Raw_t x ) noexcept
657657 retValue = -one;
658658 }
659659 else {
660- retValue = abs ( x );
660+ retValue = absolute ( x );
661661 epx = exp ( retValue );
662662 enx = exp ( -retValue );
663663 retValue = div ( epx - enx, epx + enx );
@@ -704,7 +704,7 @@ fp16Raw_t fp16::pow( fp16Raw_t x,
704704 }
705705 else {
706706 fp16Raw_t tmp;
707- tmp = mul ( y, log ( abs ( x ) ) );
707+ tmp = mul ( y, log ( absolute ( x ) ) );
708708 if ( overflow != tmp ) {
709709 retValue = exp ( tmp );
710710 if ( x < 0 ) {
0 commit comments