Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Linux/PA-RISC Project (http://www.parisc-linux.org/)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Floating-point emulation code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  Copyright (C) 2001 Hewlett-Packard (Paul Bame) <bame@debian.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * BEGIN_DESC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *  File:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *	@(#)	pa/spmath/dfadd.c		$Revision: 1.1 $
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *  Purpose:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *	Double_add: add two double precision values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *  External Interfaces:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *	dbl_fadd(leftptr, rightptr, dstptr, status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *  Internal Interfaces:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *  Theory:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *	<<please update with a overview of the operation of this file>>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * END_DESC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include "float.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include "dbl_float.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * Double_add: add two double precision values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) dbl_fadd(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)     dbl_floating_point *leftptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)     dbl_floating_point *rightptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)     dbl_floating_point *dstptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)     unsigned int *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)     register unsigned int signless_upper_left, signless_upper_right, save;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)     register unsigned int leftp1, leftp2, rightp1, rightp2, extent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)     register unsigned int resultp1 = 0, resultp2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)     
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)     register int result_exponent, right_exponent, diff_exponent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)     register int sign_save, jumpsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)     register boolean inexact = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)     register boolean underflowtrap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)         
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)     /* Create local copies of the numbers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)     Dbl_copyfromptr(leftptr,leftp1,leftp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)     Dbl_copyfromptr(rightptr,rightp1,rightp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)     /* A zero "save" helps discover equal operands (for later),  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)      * and is used in swapping operands (if needed).             */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)     Dbl_xortointp1(leftp1,rightp1,/*to*/save);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)     /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)      * check first operand for NaN's or infinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)     if ((result_exponent = Dbl_exponent(leftp1)) == DBL_INFINITY_EXPONENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	if (Dbl_iszero_mantissa(leftp1,leftp2)) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	    if (Dbl_isnotnan(rightp1,rightp2)) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		if (Dbl_isinfinity(rightp1,rightp2) && save!=0) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		    /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		     * invalid since operands are opposite signed infinity's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		    if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)                     Set_invalidflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)                     Dbl_makequietnan(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		    Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		    return(NOEXCEPTION);
^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) 	 	 * return infinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		Dbl_copytoptr(leftp1,leftp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	else 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)             /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)              * is NaN; signaling or quiet?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)              */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)             if (Dbl_isone_signaling(leftp1)) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)                	/* trap if INVALIDTRAP enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)         	/* make NaN quiet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)         	Set_invalidflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)         	Dbl_set_quiet(leftp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)         	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	    /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	     * is second operand a signaling NaN? 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	    else if (Dbl_is_signalingnan(rightp1)) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)         	/* trap if INVALIDTRAP enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)                	if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		/* make NaN quiet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		Set_invalidflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		Dbl_set_quiet(rightp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		Dbl_copytoptr(rightp1,rightp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	    /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  	     * return quiet NaN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  	     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	    Dbl_copytoptr(leftp1,leftp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  	    return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	} /* End left NaN or Infinity processing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)     /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)      * check second operand for NaN's or infinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)     if (Dbl_isinfinity_exponent(rightp1)) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	if (Dbl_iszero_mantissa(rightp1,rightp2)) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	    /* return infinity */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	    Dbl_copytoptr(rightp1,rightp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	    return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)         /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)          * is NaN; signaling or quiet?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)         if (Dbl_isone_signaling(rightp1)) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)             /* trap if INVALIDTRAP enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	    if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	    /* make NaN quiet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	    Set_invalidflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	    Dbl_set_quiet(rightp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	 * return quiet NaN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	Dbl_copytoptr(rightp1,rightp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)     	} /* End right NaN or Infinity processing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)     /* Invariant: Must be dealing with finite numbers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)     /* Compare operands by removing the sign */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)     Dbl_copytoint_exponentmantissap1(leftp1,signless_upper_left);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)     Dbl_copytoint_exponentmantissap1(rightp1,signless_upper_right);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)     /* sign difference selects add or sub operation. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)     if(Dbl_ismagnitudeless(leftp2,rightp2,signless_upper_left,signless_upper_right))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	/* Set the left operand to the larger one by XOR swap *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	 *  First finish the first word using "save"          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	Dbl_xorfromintp1(save,rightp1,/*to*/rightp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	Dbl_xorfromintp1(save,leftp1,/*to*/leftp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)      	Dbl_swap_lower(leftp2,rightp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	result_exponent = Dbl_exponent(leftp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)     /* Invariant:  left is not smaller than right. */ 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)     if((right_exponent = Dbl_exponent(rightp1)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)         {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	/* Denormalized operands.  First look for zeroes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	if(Dbl_iszero_mantissa(rightp1,rightp2)) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	    /* right is zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	    if(Dbl_iszero_exponentmantissa(leftp1,leftp2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		/* Both operands are zeros */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		if(Is_rounding_mode(ROUNDMINUS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		    Dbl_or_signs(leftp1,/*with*/rightp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		    Dbl_and_signs(leftp1,/*with*/rightp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	    else 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		/* Left is not a zero and must be the result.  Trapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		 * underflows are signaled if left is denormalized.  Result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		 * is always exact. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		if( (result_exponent == 0) && Is_underflowtrap_enabled() )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		    /* need to normalize results mantissa */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	    	    sign_save = Dbl_signextendedsign(leftp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		    Dbl_leftshiftby1(leftp1,leftp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		    Dbl_normalize(leftp1,leftp2,result_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		    Dbl_set_sign(leftp1,/*using*/sign_save);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)                     Dbl_setwrapped_exponent(leftp1,result_exponent,unfl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		    Dbl_copytoptr(leftp1,leftp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		    /* inexact = FALSE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		    return(UNDERFLOWEXCEPTION);
^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) 	    Dbl_copytoptr(leftp1,leftp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	    return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	/* Neither are zeroes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	Dbl_clear_sign(rightp1);	/* Exponent is already cleared */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if(result_exponent == 0 )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	    /* Both operands are denormalized.  The result must be exact
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	     * and is simply calculated.  A sum could become normalized and a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	     * difference could cancel to a true zero. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	    if( (/*signed*/int) save < 0 )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		Dbl_subtract(leftp1,leftp2,/*minus*/rightp1,rightp2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		/*into*/resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		if(Dbl_iszero_mantissa(resultp1,resultp2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		    if(Is_rounding_mode(ROUNDMINUS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			Dbl_setone_sign(resultp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		    else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 			{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			Dbl_setzero_sign(resultp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		    Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		    return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	    else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		Dbl_addition(leftp1,leftp2,rightp1,rightp2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		/*into*/resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		if(Dbl_isone_hidden(resultp1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		    Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		    return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	    if(Is_underflowtrap_enabled())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		/* need to normalize result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	    	sign_save = Dbl_signextendedsign(resultp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		Dbl_leftshiftby1(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		Dbl_normalize(resultp1,resultp2,result_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		Dbl_set_sign(resultp1,/*using*/sign_save);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)                 Dbl_setwrapped_exponent(resultp1,result_exponent,unfl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	        Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		/* inexact = FALSE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	        return(UNDERFLOWEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	    Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	    return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	right_exponent = 1;	/* Set exponent to reflect different bias
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 				 * with denomalized numbers. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)     else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	Dbl_clear_signexponent_set_hidden(rightp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)     Dbl_clear_exponent_set_hidden(leftp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)     diff_exponent = result_exponent - right_exponent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)     /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)      * Special case alignment of operands that would force alignment 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)      * beyond the extent of the extension.  A further optimization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)      * could special case this but only reduces the path length for this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)      * infrequent case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)      */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)     if(diff_exponent > DBL_THRESHOLD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	diff_exponent = DBL_THRESHOLD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)     
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)     /* Align right operand by shifting to right */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)     Dbl_right_align(/*operand*/rightp1,rightp2,/*shifted by*/diff_exponent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)     /*and lower to*/extent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)     /* Treat sum and difference of the operands separately. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)     if( (/*signed*/int) save < 0 )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	 * Difference of the two operands.  Their can be no overflow.  A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	 * borrow can occur out of the hidden bit and force a post
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	 * normalization phase.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	Dbl_subtract_withextension(leftp1,leftp2,/*minus*/rightp1,rightp2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	/*with*/extent,/*into*/resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	if(Dbl_iszero_hidden(resultp1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	    /* Handle normalization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	    /* A straight forward algorithm would now shift the result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	     * and extension left until the hidden bit becomes one.  Not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	     * all of the extension bits need participate in the shift.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	     * Only the two most significant bits (round and guard) are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	     * needed.  If only a single shift is needed then the guard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	     * bit becomes a significant low order bit and the extension
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	     * must participate in the rounding.  If more than a single 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	     * shift is needed, then all bits to the right of the guard 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	     * bit are zeros, and the guard bit may or may not be zero. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	    sign_save = Dbl_signextendedsign(resultp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)             Dbl_leftshiftby1_withextent(resultp1,resultp2,extent,resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)             /* Need to check for a zero result.  The sign and exponent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	     * fields have already been zeroed.  The more efficient test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	     * of the full object can be used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)     	    if(Dbl_iszero(resultp1,resultp2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 		/* Must have been "x-x" or "x+(-x)". */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		if(Is_rounding_mode(ROUNDMINUS)) Dbl_setone_sign(resultp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	    result_exponent--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	    /* Look to see if normalization is finished. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	    if(Dbl_isone_hidden(resultp1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		if(result_exponent==0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		    /* Denormalized, exponent should be zero.  Left operand *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		     * was normalized, so extent (guard, round) was zero    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 		    goto underflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 		    /* No further normalization is needed. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		    Dbl_set_sign(resultp1,/*using*/sign_save);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	    	    Ext_leftshiftby1(extent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		    goto round;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	    /* Check for denormalized, exponent should be zero.  Left    *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	     * operand was normalized, so extent (guard, round) was zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	    if(!(underflowtrap = Is_underflowtrap_enabled()) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	       result_exponent==0) goto underflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	    /* Shift extension to complete one bit of normalization and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	     * update exponent. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	    Ext_leftshiftby1(extent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	    /* Discover first one bit to determine shift amount.  Use a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	     * modified binary search.  We have already shifted the result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	     * one position right and still not found a one so the remainder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	     * of the extension must be zero and simplifies rounding. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	    /* Scan bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	    while(Dbl_iszero_hiddenhigh7mantissa(resultp1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		Dbl_leftshiftby8(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		if((result_exponent -= 8) <= 0  && !underflowtrap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		    goto underflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	    /* Now narrow it down to the nibble */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	    if(Dbl_iszero_hiddenhigh3mantissa(resultp1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		/* The lower nibble contains the normalizing one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		Dbl_leftshiftby4(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		if((result_exponent -= 4) <= 0 && !underflowtrap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		    goto underflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	    /* Select case were first bit is set (already normalized)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	     * otherwise select the proper shift. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	    if((jumpsize = Dbl_hiddenhigh3mantissa(resultp1)) > 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 		/* Already normalized */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 		if(result_exponent <= 0) goto underflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		Dbl_set_sign(resultp1,/*using*/sign_save);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		Dbl_set_exponent(resultp1,/*using*/result_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	    Dbl_sethigh4bits(resultp1,/*using*/sign_save);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	    switch(jumpsize) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 		    Dbl_leftshiftby3(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		    result_exponent -= 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		    break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		case 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		    Dbl_leftshiftby2(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		    result_exponent -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		    break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		case 4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		case 5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		case 6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		case 7:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		    Dbl_leftshiftby1(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		    result_exponent -= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 		    break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	    if(result_exponent > 0) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		Dbl_set_exponent(resultp1,/*using*/result_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 		return(NOEXCEPTION); 	/* Sign bit is already set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	    /* Fixup potential underflows */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	  underflow:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	    if(Is_underflowtrap_enabled())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 		Dbl_set_sign(resultp1,sign_save);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)                 Dbl_setwrapped_exponent(resultp1,result_exponent,unfl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		/* inexact = FALSE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		return(UNDERFLOWEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	    /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	     * Since we cannot get an inexact denormalized result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	     * we can now return.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	     */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	    Dbl_fix_overshift(resultp1,resultp2,(1-result_exponent),extent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	    Dbl_clear_signexponent(resultp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	    Dbl_set_sign(resultp1,sign_save);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	    Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	    return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	    } /* end if(hidden...)... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	/* Fall through and round */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	} /* end if(save < 0)... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)     else 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	/* Add magnitudes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	Dbl_addition(leftp1,leftp2,rightp1,rightp2,/*to*/resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	if(Dbl_isone_hiddenoverflow(resultp1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	    /* Prenormalization required. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	    Dbl_rightshiftby1_withextent(resultp2,extent,extent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	    Dbl_arithrightshiftby1(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	    result_exponent++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	    } /* end if hiddenoverflow... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	} /* end else ...add magnitudes... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)     
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)     /* Round the result.  If the extension is all zeros,then the result is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)      * exact.  Otherwise round in the correct direction.  No underflow is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)      * possible. If a postnormalization is necessary, then the mantissa is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)      * all zeros so no shift is needed. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)   round:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)     if(Ext_isnotzero(extent))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	inexact = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	switch(Rounding_mode())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	    case ROUNDNEAREST: /* The default. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	    if(Ext_isone_sign(extent))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 		/* at least 1/2 ulp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 		if(Ext_isnotzero_lower(extent)  ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 		  Dbl_isone_lowmantissap2(resultp2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 		    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 		    /* either exactly half way and odd or more than 1/2ulp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		    Dbl_increment(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	    break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	    case ROUNDPLUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	    if(Dbl_iszero_sign(resultp1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		/* Round up positive results */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 		Dbl_increment(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	    break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	    
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	    case ROUNDMINUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	    if(Dbl_isone_sign(resultp1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 		/* Round down negative results */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 		Dbl_increment(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	    
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	    case ROUNDZERO:;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	    /* truncate is simple */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	    } /* end switch... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	if(Dbl_isone_hiddenoverflow(resultp1)) result_exponent++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)     if(result_exponent == DBL_INFINITY_EXPONENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)         {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)         /* Overflow */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)         if(Is_overflowtrap_enabled())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	    Dbl_setwrapped_exponent(resultp1,result_exponent,ovfl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	    Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	    if (inexact)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		if (Is_inexacttrap_enabled())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 			return(OVERFLOWEXCEPTION | INEXACTEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		else Set_inexactflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	    return(OVERFLOWEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)         else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	    {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	    inexact = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	    Set_overflowflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	    Dbl_setoverflow(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)     else Dbl_set_exponent(resultp1,result_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)     Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)     if(inexact) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	if(Is_inexacttrap_enabled())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	    return(INEXACTEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	else Set_inexactflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)     return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) }