/* *Checkfordenormalizedorzeroaddoperand.
*/ if (add_exponent == 0) { /* check for zero */ if (Dbl_iszero_mantissa(opnd3p1,opnd3p2)) { /* right is zero */ /* Left can't be zero and must be result. * *Thefinalresultisnowintmpresandmpy_exponent, *andneedstoberoundedandsqueezedbackinto *doubleprecisionformatfromdoubleextended.
*/
result_exponent = mpy_exponent;
Dblext_copy(tmpresp1,tmpresp2,tmpresp3,tmpresp4,
resultp1,resultp2,resultp3,resultp4);
sign_save = Dbl_signextendedsign(resultp1);/*save sign*/ goto round;
}
/* Align right operand by shifting it to the right */
Dblext_clear_sign(rightp1);
Dblext_right_align(rightp1,rightp2,rightp3,rightp4, /*shifted by*/diff_exponent);
/* Treat sum and difference of the operands separately. */ if ((int)save < 0) { /* *Differenceofthetwooperands.Overflowcanoccurifthe *multiplyoverflowed.Aborrowcanoccuroutofthehidden *bitandforceapostnormalizationphase.
*/
Dblext_subtract(tmpresp1,tmpresp2,tmpresp3,tmpresp4,
rightp1,rightp2,rightp3,rightp4,
resultp1,resultp2,resultp3,resultp4);
sign_save = Dbl_signextendedsign(resultp1); if (Dbl_iszero_hidden(resultp1)) { /* Handle normalization */ /* A straightforward algorithm would now shift the *resultandextensionleftuntilthehiddenbit *becomesone.Notalloftheextensionbitsneed *participateintheshift.Onlythetwomost *significantbits(roundandguard)areneeded. *Ifonlyasingleshiftisneededthentheguard *bitbecomesasignificantloworderbitandthe *extensionmustparticipateintherounding. *Ifmorethanasingleshiftisneeded,thenall *bitstotherightoftheguardbitarezeros,
* and the guard bit may or may not be zero. */
Dblext_leftshiftby1(resultp1,resultp2,resultp3,
resultp4);
/* Need to check for a zero result. The sign and *exponentfieldshavealreadybeenzeroed.Themore *efficienttestofthefullobjectcanbeused.
*/ if(Dblext_iszero(resultp1,resultp2,resultp3,resultp4)){ /* Must have been "x-x" or "x+(-x)". */ if (Is_rounding_mode(ROUNDMINUS))
Dbl_setone_sign(resultp1);
Dbl_copytoptr(resultp1,resultp2,dstptr); return(NOEXCEPTION);
}
result_exponent--;
/* Look to see if normalization is finished. */ if (Dbl_isone_hidden(resultp1)) { /* No further normalization is needed */ goto round;
}
/* Discover first one bit to determine shift amount. *Useamodifiedbinarysearch.Wehavealready *shiftedtheresultonepositionrightandstill *notfoundaonesotheremainderoftheextension
* must be zero and simplifies rounding. */ /* Scan bytes */ while (Dbl_iszero_hiddenhigh7mantissa(resultp1)) {
Dblext_leftshiftby8(resultp1,resultp2,resultp3,resultp4);
result_exponent -= 8;
} /* Now narrow it down to the nibble */ if (Dbl_iszero_hiddenhigh3mantissa(resultp1)) { /* The lower nibble contains the
* normalizing one */
Dblext_leftshiftby4(resultp1,resultp2,resultp3,resultp4);
result_exponent -= 4;
} /* Select case where first bit is set (already
* normalized) otherwise select the proper shift. */
jumpsize = Dbl_hiddenhigh3mantissa(resultp1); if (jumpsize <= 7) switch(jumpsize) { case1:
Dblext_leftshiftby3(resultp1,resultp2,resultp3,
resultp4);
result_exponent -= 3; break; case2: case3:
Dblext_leftshiftby2(resultp1,resultp2,resultp3,
resultp4);
result_exponent -= 2; break; case4: case5: case6: case7:
Dblext_leftshiftby1(resultp1,resultp2,resultp3,
resultp4);
result_exponent -= 1; break;
}
} /* end if (hidden...)... */ /* Fall through and round */
} /* end if (save < 0)... */ else { /* Add magnitudes */
Dblext_addition(tmpresp1,tmpresp2,tmpresp3,tmpresp4,
rightp1,rightp2,rightp3,rightp4, /*to*/resultp1,resultp2,resultp3,resultp4);
sign_save = Dbl_signextendedsign(resultp1); if (Dbl_isone_hiddenoverflow(resultp1)) { /* Prenormalization required. */
Dblext_arithrightshiftby1(resultp1,resultp2,resultp3,
resultp4);
result_exponent++;
} /* end if hiddenoverflow... */
} /* end else ...add magnitudes... */
/* Round the result. If the extension and lower two words are *allzeros,thentheresultisexact.Otherwiseroundinthe *correctdirection.Underflowispossible.Ifapostnormalization *isnecessary,thenthemantissaisallzerossonoshiftisneeded.
*/
round: if (result_exponent <= 0 && !Is_underflowtrap_enabled()) {
Dblext_denormalize(resultp1,resultp2,resultp3,resultp4,
result_exponent,is_tiny);
}
Dbl_set_sign(resultp1,/*using*/sign_save); if (Dblext_isnotzero_mantissap3(resultp3) ||
Dblext_isnotzero_mantissap4(resultp4)) {
inexact = TRUE; switch(Rounding_mode()) { case ROUNDNEAREST: /* The default. */ if (Dblext_isone_highp3(resultp3)) { /* at least 1/2 ulp */ if (Dblext_isnotzero_low31p3(resultp3) ||
Dblext_isnotzero_mantissap4(resultp4) ||
Dblext_isone_lowp2(resultp2)) { /* either exactly half way and odd or
* more than 1/2ulp */
Dbl_increment(resultp1,resultp2);
}
} break;
case ROUNDPLUS: if (Dbl_iszero_sign(resultp1)) { /* Round up positive results */
Dbl_increment(resultp1,resultp2);
} break;
case ROUNDMINUS: if (Dbl_isone_sign(resultp1)) { /* Round down negative results */
Dbl_increment(resultp1,resultp2);
}
case ROUNDZERO:; /* truncate is simple */
} /* end switch... */ if (Dbl_isone_hiddenoverflow(resultp1)) result_exponent++;
} if (result_exponent >= DBL_INFINITY_EXPONENT) { /* trap if OVERFLOWTRAP enabled */ if (Is_overflowtrap_enabled()) { /* *Adjustbiasofresult
*/
Dbl_setwrapped_exponent(resultp1,result_exponent,ovfl);
Dbl_copytoptr(resultp1,resultp2,dstptr); if (inexact) if (Is_inexacttrap_enabled()) return (OPC_2E_OVERFLOWEXCEPTION |
OPC_2E_INEXACTEXCEPTION); else Set_inexactflag(); return (OPC_2E_OVERFLOWEXCEPTION);
}
inexact = TRUE;
Set_overflowflag(); /* set result to infinity or largest number */
Dbl_setoverflow(resultp1,resultp2);
} elseif (result_exponent <= 0) { /* underflow case */ if (Is_underflowtrap_enabled()) { /* *Adjustbiasofresult
*/
Dbl_setwrapped_exponent(resultp1,result_exponent,unfl);
Dbl_copytoptr(resultp1,resultp2,dstptr); if (inexact) if (Is_inexacttrap_enabled()) return (OPC_2E_UNDERFLOWEXCEPTION |
OPC_2E_INEXACTEXCEPTION); else Set_inexactflag(); return(OPC_2E_UNDERFLOWEXCEPTION);
} elseif (inexact && is_tiny) Set_underflowflag();
} else Dbl_set_exponent(resultp1,result_exponent);
Dbl_copytoptr(resultp1,resultp2,dstptr); if (inexact) if (Is_inexacttrap_enabled()) return(OPC_2E_INEXACTEXCEPTION); else Set_inexactflag(); return(NOEXCEPTION);
}
/* *Checkfordenormalizedorzeroaddoperand.
*/ if (add_exponent == 0) { /* check for zero */ if (Dbl_iszero_mantissa(opnd3p1,opnd3p2)) { /* right is zero */ /* Left can't be zero and must be result. * *Thefinalresultisnowintmpresandmpy_exponent, *andneedstoberoundedandsqueezedbackinto *doubleprecisionformatfromdoubleextended.
*/
result_exponent = mpy_exponent;
Dblext_copy(tmpresp1,tmpresp2,tmpresp3,tmpresp4,
resultp1,resultp2,resultp3,resultp4);
sign_save = Dbl_signextendedsign(resultp1);/*save sign*/ goto round;
}
/* Align right operand by shifting it to the right */
Dblext_clear_sign(rightp1);
Dblext_right_align(rightp1,rightp2,rightp3,rightp4, /*shifted by*/diff_exponent);
/* Treat sum and difference of the operands separately. */ if ((int)save < 0) { /* *Differenceofthetwooperands.Overflowcanoccurifthe *multiplyoverflowed.Aborrowcanoccuroutofthehidden *bitandforceapostnormalizationphase.
*/
Dblext_subtract(tmpresp1,tmpresp2,tmpresp3,tmpresp4,
rightp1,rightp2,rightp3,rightp4,
resultp1,resultp2,resultp3,resultp4);
sign_save = Dbl_signextendedsign(resultp1); if (Dbl_iszero_hidden(resultp1)) { /* Handle normalization */ /* A straightforward algorithm would now shift the *resultandextensionleftuntilthehiddenbit *becomesone.Notalloftheextensionbitsneed *participateintheshift.Onlythetwomost *significantbits(roundandguard)areneeded. *Ifonlyasingleshiftisneededthentheguard *bitbecomesasignificantloworderbitandthe *extensionmustparticipateintherounding. *Ifmorethanasingleshiftisneeded,thenall *bitstotherightoftheguardbitarezeros,
* and the guard bit may or may not be zero. */
Dblext_leftshiftby1(resultp1,resultp2,resultp3,
resultp4);
/* Need to check for a zero result. The sign and *exponentfieldshavealreadybeenzeroed.Themore *efficienttestofthefullobjectcanbeused.
*/ if (Dblext_iszero(resultp1,resultp2,resultp3,resultp4)) { /* Must have been "x-x" or "x+(-x)". */ if (Is_rounding_mode(ROUNDMINUS))
Dbl_setone_sign(resultp1);
Dbl_copytoptr(resultp1,resultp2,dstptr); return(NOEXCEPTION);
}
result_exponent--;
/* Look to see if normalization is finished. */ if (Dbl_isone_hidden(resultp1)) { /* No further normalization is needed */ goto round;
}
/* Discover first one bit to determine shift amount. *Useamodifiedbinarysearch.Wehavealready *shiftedtheresultonepositionrightandstill *notfoundaonesotheremainderoftheextension
* must be zero and simplifies rounding. */ /* Scan bytes */ while (Dbl_iszero_hiddenhigh7mantissa(resultp1)) {
Dblext_leftshiftby8(resultp1,resultp2,resultp3,resultp4);
result_exponent -= 8;
} /* Now narrow it down to the nibble */ if (Dbl_iszero_hiddenhigh3mantissa(resultp1)) { /* The lower nibble contains the
* normalizing one */
Dblext_leftshiftby4(resultp1,resultp2,resultp3,resultp4);
result_exponent -= 4;
} /* Select case where first bit is set (already
* normalized) otherwise select the proper shift. */
jumpsize = Dbl_hiddenhigh3mantissa(resultp1); if (jumpsize <= 7) switch(jumpsize) { case1:
Dblext_leftshiftby3(resultp1,resultp2,resultp3,
resultp4);
result_exponent -= 3; break; case2: case3:
Dblext_leftshiftby2(resultp1,resultp2,resultp3,
resultp4);
result_exponent -= 2; break; case4: case5: case6: case7:
Dblext_leftshiftby1(resultp1,resultp2,resultp3,
resultp4);
result_exponent -= 1; break;
}
} /* end if (hidden...)... */ /* Fall through and round */
} /* end if (save < 0)... */ else { /* Add magnitudes */
Dblext_addition(tmpresp1,tmpresp2,tmpresp3,tmpresp4,
rightp1,rightp2,rightp3,rightp4, /*to*/resultp1,resultp2,resultp3,resultp4);
sign_save = Dbl_signextendedsign(resultp1); if (Dbl_isone_hiddenoverflow(resultp1)) { /* Prenormalization required. */
Dblext_arithrightshiftby1(resultp1,resultp2,resultp3,
resultp4);
result_exponent++;
} /* end if hiddenoverflow... */
} /* end else ...add magnitudes... */
/* Round the result. If the extension and lower two words are *allzeros,thentheresultisexact.Otherwiseroundinthe *correctdirection.Underflowispossible.Ifapostnormalization *isnecessary,thenthemantissaisallzerossonoshiftisneeded.
*/
round: if (result_exponent <= 0 && !Is_underflowtrap_enabled()) {
Dblext_denormalize(resultp1,resultp2,resultp3,resultp4,
result_exponent,is_tiny);
}
Dbl_set_sign(resultp1,/*using*/sign_save); if (Dblext_isnotzero_mantissap3(resultp3) ||
Dblext_isnotzero_mantissap4(resultp4)) {
inexact = TRUE; switch(Rounding_mode()) { case ROUNDNEAREST: /* The default. */ if (Dblext_isone_highp3(resultp3)) { /* at least 1/2 ulp */ if (Dblext_isnotzero_low31p3(resultp3) ||
Dblext_isnotzero_mantissap4(resultp4) ||
Dblext_isone_lowp2(resultp2)) { /* either exactly half way and odd or
* more than 1/2ulp */
Dbl_increment(resultp1,resultp2);
}
} break;
case ROUNDPLUS: if (Dbl_iszero_sign(resultp1)) { /* Round up positive results */
Dbl_increment(resultp1,resultp2);
} break;
case ROUNDMINUS: if (Dbl_isone_sign(resultp1)) { /* Round down negative results */
Dbl_increment(resultp1,resultp2);
}
case ROUNDZERO:; /* truncate is simple */
} /* end switch... */ if (Dbl_isone_hiddenoverflow(resultp1)) result_exponent++;
} if (result_exponent >= DBL_INFINITY_EXPONENT) { /* Overflow */ if (Is_overflowtrap_enabled()) { /* *Adjustbiasofresult
*/
Dbl_setwrapped_exponent(resultp1,result_exponent,ovfl);
Dbl_copytoptr(resultp1,resultp2,dstptr); if (inexact) if (Is_inexacttrap_enabled()) return (OPC_2E_OVERFLOWEXCEPTION |
OPC_2E_INEXACTEXCEPTION); else Set_inexactflag(); return (OPC_2E_OVERFLOWEXCEPTION);
}
inexact = TRUE;
Set_overflowflag();
Dbl_setoverflow(resultp1,resultp2);
} elseif (result_exponent <= 0) { /* underflow case */ if (Is_underflowtrap_enabled()) { /* *Adjustbiasofresult
*/
Dbl_setwrapped_exponent(resultp1,result_exponent,unfl);
Dbl_copytoptr(resultp1,resultp2,dstptr); if (inexact) if (Is_inexacttrap_enabled()) return (OPC_2E_UNDERFLOWEXCEPTION |
OPC_2E_INEXACTEXCEPTION); else Set_inexactflag(); return(OPC_2E_UNDERFLOWEXCEPTION);
} elseif (inexact && is_tiny) Set_underflowflag();
} else Dbl_set_exponent(resultp1,result_exponent);
Dbl_copytoptr(resultp1,resultp2,dstptr); if (inexact) if (Is_inexacttrap_enabled()) return(OPC_2E_INEXACTEXCEPTION); else Set_inexactflag(); return(NOEXCEPTION);
}
/* *Checkfordenormalizedorzeroaddoperand.
*/ if (add_exponent == 0) { /* check for zero */ if (Sgl_iszero_mantissa(opnd3)) { /* right is zero */ /* Left can't be zero and must be result. * *Thefinalresultisnowintmpresandmpy_exponent, *andneedstoberoundedandsqueezedbackinto *doubleprecisionformatfromdoubleextended.
*/
result_exponent = mpy_exponent;
Sglext_copy(tmpresp1,tmpresp2,resultp1,resultp2);
sign_save = Sgl_signextendedsign(resultp1);/*save sign*/ goto round;
}
/* Align right operand by shifting it to the right */
Sglext_clear_sign(rightp1);
Sglext_right_align(rightp1,rightp2,/*shifted by*/diff_exponent);
/* Treat sum and difference of the operands separately. */ if ((int)save < 0) { /* *Differenceofthetwooperands.Overflowcanoccurifthe *multiplyoverflowed.Aborrowcanoccuroutofthehidden *bitandforceapostnormalizationphase.
*/
Sglext_subtract(tmpresp1,tmpresp2, rightp1,rightp2,
resultp1,resultp2);
sign_save = Sgl_signextendedsign(resultp1); if (Sgl_iszero_hidden(resultp1)) { /* Handle normalization */ /* A straightforward algorithm would now shift the *resultandextensionleftuntilthehiddenbit *becomesone.Notalloftheextensionbitsneed *participateintheshift.Onlythetwomost *significantbits(roundandguard)areneeded. *Ifonlyasingleshiftisneededthentheguard *bitbecomesasignificantloworderbitandthe *extensionmustparticipateintherounding. *Ifmorethanasingleshiftisneeded,thenall *bitstotherightoftheguardbitarezeros,
* and the guard bit may or may not be zero. */
Sglext_leftshiftby1(resultp1,resultp2);
/* Need to check for a zero result. The sign and *exponentfieldshavealreadybeenzeroed.Themore *efficienttestofthefullobjectcanbeused.
*/ if (Sglext_iszero(resultp1,resultp2)) { /* Must have been "x-x" or "x+(-x)". */ if (Is_rounding_mode(ROUNDMINUS))
Sgl_setone_sign(resultp1);
Sgl_copytoptr(resultp1,dstptr); return(NOEXCEPTION);
}
result_exponent--;
/* Look to see if normalization is finished. */ if (Sgl_isone_hidden(resultp1)) { /* No further normalization is needed */ goto round;
}
/* Discover first one bit to determine shift amount. *Useamodifiedbinarysearch.Wehavealready *shiftedtheresultonepositionrightandstill *notfoundaonesotheremainderoftheextension
* must be zero and simplifies rounding. */ /* Scan bytes */ while (Sgl_iszero_hiddenhigh7mantissa(resultp1)) {
Sglext_leftshiftby8(resultp1,resultp2);
result_exponent -= 8;
} /* Now narrow it down to the nibble */ if (Sgl_iszero_hiddenhigh3mantissa(resultp1)) { /* The lower nibble contains the
* normalizing one */
Sglext_leftshiftby4(resultp1,resultp2);
result_exponent -= 4;
} /* Select case where first bit is set (already
* normalized) otherwise select the proper shift. */
jumpsize = Sgl_hiddenhigh3mantissa(resultp1); if (jumpsize <= 7) switch(jumpsize) { case1:
Sglext_leftshiftby3(resultp1,resultp2);
result_exponent -= 3; break; case2: case3:
Sglext_leftshiftby2(resultp1,resultp2);
result_exponent -= 2; break; case4: case5: case6: case7:
Sglext_leftshiftby1(resultp1,resultp2);
result_exponent -= 1; break;
}
} /* end if (hidden...)... */ /* Fall through and round */
} /* end if (save < 0)... */ else { /* Add magnitudes */
Sglext_addition(tmpresp1,tmpresp2,
rightp1,rightp2, /*to*/resultp1,resultp2);
sign_save = Sgl_signextendedsign(resultp1); if (Sgl_isone_hiddenoverflow(resultp1)) { /* Prenormalization required. */
Sglext_arithrightshiftby1(resultp1,resultp2);
result_exponent++;
} /* end if hiddenoverflow... */
} /* end else ...add magnitudes... */
/* Round the result. If the extension and lower two words are *allzeros,thentheresultisexact.Otherwiseroundinthe *correctdirection.Underflowispossible.Ifapostnormalization *isnecessary,thenthemantissaisallzerossonoshiftisneeded.
*/
round: if (result_exponent <= 0 && !Is_underflowtrap_enabled()) {
Sglext_denormalize(resultp1,resultp2,result_exponent,is_tiny);
}
Sgl_set_sign(resultp1,/*using*/sign_save); if (Sglext_isnotzero_mantissap2(resultp2)) {
inexact = TRUE; switch(Rounding_mode()) { case ROUNDNEAREST: /* The default. */ if (Sglext_isone_highp2(resultp2)) { /* at least 1/2 ulp */ if (Sglext_isnotzero_low31p2(resultp2) ||
Sglext_isone_lowp1(resultp1)) { /* either exactly half way and odd or
* more than 1/2ulp */
Sgl_increment(resultp1);
}
} break;
case ROUNDPLUS: if (Sgl_iszero_sign(resultp1)) { /* Round up positive results */
Sgl_increment(resultp1);
} break;
case ROUNDMINUS: if (Sgl_isone_sign(resultp1)) { /* Round down negative results */
Sgl_increment(resultp1);
}
case ROUNDZERO:; /* truncate is simple */
} /* end switch... */ if (Sgl_isone_hiddenoverflow(resultp1)) result_exponent++;
} if (result_exponent >= SGL_INFINITY_EXPONENT) { /* Overflow */ if (Is_overflowtrap_enabled()) { /* *Adjustbiasofresult
*/
Sgl_setwrapped_exponent(resultp1,result_exponent,ovfl);
Sgl_copytoptr(resultp1,dstptr); if (inexact) if (Is_inexacttrap_enabled()) return (OPC_2E_OVERFLOWEXCEPTION |
OPC_2E_INEXACTEXCEPTION); else Set_inexactflag(); return (OPC_2E_OVERFLOWEXCEPTION);
}
inexact = TRUE;
Set_overflowflag();
Sgl_setoverflow(resultp1);
} elseif (result_exponent <= 0) { /* underflow case */ if (Is_underflowtrap_enabled()) { /* *Adjustbiasofresult
*/
Sgl_setwrapped_exponent(resultp1,result_exponent,unfl);
Sgl_copytoptr(resultp1,dstptr); if (inexact) if (Is_inexacttrap_enabled()) return (OPC_2E_UNDERFLOWEXCEPTION |
OPC_2E_INEXACTEXCEPTION); else Set_inexactflag(); return(OPC_2E_UNDERFLOWEXCEPTION);
} elseif (inexact && is_tiny) Set_underflowflag();
} else Sgl_set_exponent(resultp1,result_exponent);
Sgl_copytoptr(resultp1,dstptr); if (inexact) if (Is_inexacttrap_enabled()) return(OPC_2E_INEXACTEXCEPTION); else Set_inexactflag(); return(NOEXCEPTION);
}
/* *Checkfordenormalizedorzeroaddoperand.
*/ if (add_exponent == 0) { /* check for zero */ if (Sgl_iszero_mantissa(opnd3)) { /* right is zero */ /* Left can't be zero and must be result. * *Thefinalresultisnowintmpresandmpy_exponent, *andneedstoberoundedandsqueezedbackinto *doubleprecisionformatfromdoubleextended.
*/
result_exponent = mpy_exponent;
Sglext_copy(tmpresp1,tmpresp2,resultp1,resultp2);
sign_save = Sgl_signextendedsign(resultp1);/*save sign*/ goto round;
}
/* Align right operand by shifting it to the right */
Sglext_clear_sign(rightp1);
Sglext_right_align(rightp1,rightp2,/*shifted by*/diff_exponent);
/* Treat sum and difference of the operands separately. */ if ((int)save < 0) { /* *Differenceofthetwooperands.Overflowcanoccurifthe *multiplyoverflowed.Aborrowcanoccuroutofthehidden *bitandforceapostnormalizationphase.
*/
Sglext_subtract(tmpresp1,tmpresp2, rightp1,rightp2,
resultp1,resultp2);
sign_save = Sgl_signextendedsign(resultp1); if (Sgl_iszero_hidden(resultp1)) { /* Handle normalization */ /* A straightforward algorithm would now shift the *resultandextensionleftuntilthehiddenbit *becomesone.Notalloftheextensionbitsneed *participateintheshift.Onlythetwomost *significantbits(roundandguard)areneeded. *Ifonlyasingleshiftisneededthentheguard *bitbecomesasignificantloworderbitandthe *extensionmustparticipateintherounding. *Ifmorethanasingleshiftisneeded,thenall *bitstotherightoftheguardbitarezeros,
* and the guard bit may or may not be zero. */
Sglext_leftshiftby1(resultp1,resultp2);
/* Need to check for a zero result. The sign and *exponentfieldshavealreadybeenzeroed.Themore *efficienttestofthefullobjectcanbeused.
*/ if (Sglext_iszero(resultp1,resultp2)) { /* Must have been "x-x" or "x+(-x)". */ if (Is_rounding_mode(ROUNDMINUS))
Sgl_setone_sign(resultp1);
Sgl_copytoptr(resultp1,dstptr); return(NOEXCEPTION);
}
result_exponent--;
/* Look to see if normalization is finished. */ if (Sgl_isone_hidden(resultp1)) { /* No further normalization is needed */ goto round;
}
/* Discover first one bit to determine shift amount. *Useamodifiedbinarysearch.Wehavealready *shiftedtheresultonepositionrightandstill *notfoundaonesotheremainderoftheextension
* must be zero and simplifies rounding. */ /* Scan bytes */ while (Sgl_iszero_hiddenhigh7mantissa(resultp1)) {
Sglext_leftshiftby8(resultp1,resultp2);
result_exponent -= 8;
} /* Now narrow it down to the nibble */ if (Sgl_iszero_hiddenhigh3mantissa(resultp1)) { /* The lower nibble contains the
* normalizing one */
Sglext_leftshiftby4(resultp1,resultp2);
result_exponent -= 4;
} /* Select case where first bit is set (already
* normalized) otherwise select the proper shift. */
jumpsize = Sgl_hiddenhigh3mantissa(resultp1); if (jumpsize <= 7) switch(jumpsize) { case1:
Sglext_leftshiftby3(resultp1,resultp2);
result_exponent -= 3; break; case2: case3:
Sglext_leftshiftby2(resultp1,resultp2);
result_exponent -= 2; break; case4: case5: case6: case7:
Sglext_leftshiftby1(resultp1,resultp2);
result_exponent -= 1; break;
}
} /* end if (hidden...)... */ /* Fall through and round */
} /* end if (save < 0)... */ else { /* Add magnitudes */
Sglext_addition(tmpresp1,tmpresp2,
rightp1,rightp2, /*to*/resultp1,resultp2);
sign_save = Sgl_signextendedsign(resultp1); if (Sgl_isone_hiddenoverflow(resultp1)) { /* Prenormalization required. */
Sglext_arithrightshiftby1(resultp1,resultp2);
result_exponent++;
} /* end if hiddenoverflow... */
} /* end else ...add magnitudes... */
/* Round the result. If the extension and lower two words are *allzeros,thentheresultisexact.Otherwiseroundinthe *correctdirection.Underflowispossible.Ifapostnormalization *isnecessary,thenthemantissaisallzerossonoshiftisneeded.
*/
round: if (result_exponent <= 0 && !Is_underflowtrap_enabled()) {
Sglext_denormalize(resultp1,resultp2,result_exponent,is_tiny);
}
Sgl_set_sign(resultp1,/*using*/sign_save); if (Sglext_isnotzero_mantissap2(resultp2)) {
inexact = TRUE; switch(Rounding_mode()) { case ROUNDNEAREST: /* The default. */ if (Sglext_isone_highp2(resultp2)) { /* at least 1/2 ulp */ if (Sglext_isnotzero_low31p2(resultp2) ||
Sglext_isone_lowp1(resultp1)) { /* either exactly half way and odd or
* more than 1/2ulp */
Sgl_increment(resultp1);
}
} break;
case ROUNDPLUS: if (Sgl_iszero_sign(resultp1)) { /* Round up positive results */
Sgl_increment(resultp1);
} break;
case ROUNDMINUS: if (Sgl_isone_sign(resultp1)) { /* Round down negative results */
Sgl_increment(resultp1);
}
case ROUNDZERO:; /* truncate is simple */
} /* end switch... */ if (Sgl_isone_hiddenoverflow(resultp1)) result_exponent++;
} if (result_exponent >= SGL_INFINITY_EXPONENT) { /* Overflow */ if (Is_overflowtrap_enabled()) { /* *Adjustbiasofresult
*/
Sgl_setwrapped_exponent(resultp1,result_exponent,ovfl);
Sgl_copytoptr(resultp1,dstptr); if (inexact) if (Is_inexacttrap_enabled()) return (OPC_2E_OVERFLOWEXCEPTION |
OPC_2E_INEXACTEXCEPTION); else Set_inexactflag(); return (OPC_2E_OVERFLOWEXCEPTION);
}
inexact = TRUE;
Set_overflowflag();
Sgl_setoverflow(resultp1);
} elseif (result_exponent <= 0) { /* underflow case */ if (Is_underflowtrap_enabled()) { /* *Adjustbiasofresult
*/
Sgl_setwrapped_exponent(resultp1,result_exponent,unfl);
Sgl_copytoptr(resultp1,dstptr); if (inexact) if (Is_inexacttrap_enabled()) return (OPC_2E_UNDERFLOWEXCEPTION |
OPC_2E_INEXACTEXCEPTION); else Set_inexactflag(); return(OPC_2E_UNDERFLOWEXCEPTION);
} elseif (inexact && is_tiny) Set_underflowflag();
} else Sgl_set_exponent(resultp1,result_exponent);
Sgl_copytoptr(resultp1,dstptr); if (inexact) if (Is_inexacttrap_enabled()) return(OPC_2E_INEXACTEXCEPTION); else Set_inexactflag(); return(NOEXCEPTION);
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.76Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-09-30)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.