/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3d, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 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:
uint_fast64_t sigZ;
int_fast16_t expDiff;
struct uint128 sig128C;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union ui64_f64 uZ;
/*------------------------------------------------------------------------
sig128Z.v64 = sig128Z.v64 - sigC;
if ( ! (sig128Z.v64 | sig128Z.v0) ) goto completeCancellation;
if ( sig128Z.v64 & UINT64_C( 0x8000000000000000 ) ) {
- signZ ^= 1;
+ signZ = ! signZ;
sig128Z = softfloat_sub128( 0, 0, sig128Z.v64, sig128Z.v0 );
}
} else {
sig128Z.v64 = sig128Z.v0;
sig128Z.v0 = 0;
}
- shiftCount = softfloat_countLeadingZeros64( sig128Z.v64 ) - 1;
- expZ -= shiftCount;
- if ( shiftCount < 0 ) {
- sigZ = softfloat_shortShiftRightJam64( sig128Z.v64, -shiftCount );
+ shiftDist = softfloat_countLeadingZeros64( sig128Z.v64 ) - 1;
+ expZ -= shiftDist;
+ if ( shiftDist < 0 ) {
+ sigZ = softfloat_shortShiftRightJam64( sig128Z.v64, -shiftDist );
} else {
sig128Z =
softfloat_shortShiftLeft128(
- sig128Z.v64, sig128Z.v0, shiftCount );
+ sig128Z.v64, sig128Z.v0, shiftDist );
sigZ = sig128Z.v64;
}
sigZ |= (sig128Z.v0 != 0);
if ( sigC ) goto propagateNaN_ZC;
if ( signZ == signC ) goto uiZ;
}
- invalid:
softfloat_raiseFlags( softfloat_flag_invalid );
uiZ = defaultNaNF64UI;
propagateNaN_ZC:
if ( ! (expC | sigC) && (signZ != signC) ) {
completeCancellation:
uiZ =
- packToF64UI( softfloat_roundingMode == softfloat_round_min, 0, 0 );
+ packToF64UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
}
uiZ:
uZ.ui = uiZ;
int_fast16_t expZ;
uint32_t sig128Z[4];
uint64_t sigZ;
- int_fast16_t shiftCount, expDiff;
+ int_fast16_t shiftDist, expDiff;
uint32_t sig128C[4];
union ui64_f64 uZ;
softfloat_mul64To128M( sigA, sigB, sig128Z );
sigZ =
(uint64_t) sig128Z[indexWord( 4, 3 )]<<32 | sig128Z[indexWord( 4, 2 )];
- shiftCount = 0;
+ shiftDist = 0;
if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
--expZ;
- shiftCount = -1;
+ shiftDist = -1;
}
if ( ! expC ) {
if ( ! sigC ) {
- if ( shiftCount ) sigZ <<= 1;
+ if ( shiftDist ) sigZ <<= 1;
goto sigZ;
}
normExpSig = softfloat_normSubnormalF64Sig( sigC );
if ( expDiff < 0 ) {
expZ = expC;
if ( (signZ == signC) || (expDiff < -1) ) {
- shiftCount -= expDiff;
- if ( shiftCount) {
- sigZ = softfloat_shiftRightJam64( sigZ, shiftCount );
+ shiftDist -= expDiff;
+ if ( shiftDist) {
+ sigZ = softfloat_shiftRightJam64( sigZ, shiftDist );
}
} else {
- if ( ! shiftCount ) {
+ if ( ! shiftDist ) {
softfloat_shortShiftRight128M( sig128Z, 1, sig128Z );
}
}
} else {
- if ( shiftCount ) softfloat_add128M( sig128Z, sig128Z, sig128Z );
+ if ( shiftDist ) softfloat_add128M( sig128Z, sig128Z, sig128Z );
if ( ! expDiff ) {
sigZ =
(uint64_t) sig128Z[indexWord( 4, 3 )]<<32
sig128Z[indexWord( 4, 3 )] = sigZ>>32;
sig128Z[indexWord( 4, 2 )] = sigZ;
if ( sigZ & UINT64_C( 0x8000000000000000 ) ) {
- signZ ^= 1;
+ signZ = ! signZ;
softfloat_negX128M( sig128Z );
}
} else {
}
/*--------------------------------------------------------------------
*--------------------------------------------------------------------*/
- shiftCount = 0;
+ shiftDist = 0;
sigZ =
(uint64_t) sig128Z[indexWord( 4, 3 )]<<32
| sig128Z[indexWord( 4, 2 )];
if ( ! sigZ ) {
- shiftCount = 64;
+ shiftDist = 64;
sigZ =
(uint64_t) sig128Z[indexWord( 4, 1 )]<<32
| sig128Z[indexWord( 4, 0 )];
}
- shiftCount += softfloat_countLeadingZeros64( sigZ ) - 1;
- if ( shiftCount ) {
- expZ -= shiftCount;
- softfloat_shiftLeft128M( sig128Z, shiftCount, sig128Z );
+ shiftDist += softfloat_countLeadingZeros64( sigZ ) - 1;
+ if ( shiftDist ) {
+ expZ -= shiftDist;
+ softfloat_shiftLeft128M( sig128Z, shiftDist, sig128Z );
sigZ =
(uint64_t) sig128Z[indexWord( 4, 3 )]<<32
| sig128Z[indexWord( 4, 2 )];
if ( sigC ) goto propagateNaN_ZC;
if ( signZ == signC ) goto uiZ;
}
- invalid:
softfloat_raiseFlags( softfloat_flag_invalid );
uiZ = defaultNaNF64UI;
propagateNaN_ZC:
if ( ! (expC | sigC) && (signZ != signC) ) {
completeCancellation:
uiZ =
- packToF64UI( softfloat_roundingMode == softfloat_round_min, 0, 0 );
+ packToF64UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
}
uiZ:
uZ.ui = uiZ;