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/fcnvff.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)  *	Single Floating-point to Double Floating-point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *	Double Floating-point to Single Floating-point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *  External Interfaces:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *	dbl_to_sgl_fcnvff(srcptr,nullptr,dstptr,status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *	sgl_to_dbl_fcnvff(srcptr,nullptr,dstptr,status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *  Internal Interfaces:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *  Theory:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *	<<please update with a overview of the operation of this file>>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * END_DESC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include "float.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include "sgl_float.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include "dbl_float.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include "cnv_float.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *  Single Floating-point to Double Floating-point 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) /*ARGSUSED*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) sgl_to_dbl_fcnvff(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	    sgl_floating_point *srcptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	    unsigned int *nullptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	    dbl_floating_point *dstptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	    unsigned int *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	register unsigned int src, resultp1, resultp2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	register int src_exponent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	src = *srcptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	src_exponent = Sgl_exponent(src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	Dbl_allp1(resultp1) = Sgl_all(src);  /* set sign of result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	/* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  	 * Test for NaN or infinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	if (src_exponent == SGL_INFINITY_EXPONENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		 * determine if NaN or infinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		if (Sgl_iszero_mantissa(src)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 			 * is infinity; want to return double infinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			Dbl_setinfinity_exponentmantissa(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 			Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 			return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 			/* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			 * is NaN; signaling or quiet?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			if (Sgl_isone_signaling(src)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 				/* trap if INVALIDTRAP enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 				if (Is_invalidtrap_enabled())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 					return(INVALIDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 				/* make NaN quiet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 				else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 					Set_invalidflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 					Sgl_set_quiet(src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			/* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			 * NaN is quiet, return as double NaN 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 			Dbl_setinfinity_exponent(resultp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			Sgl_to_dbl_mantissa(src,resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 			Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	/* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  	 * Test for zero or denormalized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	if (src_exponent == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		 * determine if zero or denormalized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		if (Sgl_isnotzero_mantissa(src)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			 * is denormalized; want to normalize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			Sgl_clear_signexponent(src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			Sgl_leftshiftby1(src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			Sgl_normalize(src,src_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			Sgl_to_dbl_exponent(src_exponent,resultp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			Sgl_to_dbl_mantissa(src,resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			Dbl_setzero_exponentmantissa(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	 * No special cases, just complete the conversion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	Sgl_to_dbl_exponent(src_exponent, resultp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	Sgl_to_dbl_mantissa(Sgl_mantissa(src), resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  *  Double Floating-point to Single Floating-point 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /*ARGSUSED*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) dbl_to_sgl_fcnvff(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		    dbl_floating_point *srcptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		    unsigned int *nullptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		    sgl_floating_point *dstptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		    unsigned int *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)         register unsigned int srcp1, srcp2, result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)         register int src_exponent, dest_exponent, dest_mantissa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)         register boolean inexact = FALSE, guardbit = FALSE, stickybit = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	register boolean lsb_odd = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	boolean is_tiny = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	Dbl_copyfromptr(srcptr,srcp1,srcp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)         src_exponent = Dbl_exponent(srcp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	Sgl_all(result) = Dbl_allp1(srcp1);  /* set sign of result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)         /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)          * Test for NaN or infinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)         if (src_exponent == DBL_INFINITY_EXPONENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)                 /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)                  * determine if NaN or infinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)                  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)                 if (Dbl_iszero_mantissa(srcp1,srcp2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)                         /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)                          * is infinity; want to return single infinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)                          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)                         Sgl_setinfinity_exponentmantissa(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)                         *dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)                         return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)                 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)                 /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)                  * is NaN; signaling or quiet?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)                  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)                 if (Dbl_isone_signaling(srcp1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)                         /* trap if INVALIDTRAP enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)                         if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)                         else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 				Set_invalidflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)                         	/* make NaN quiet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)                         	Dbl_set_quiet(srcp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)                 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)                 /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)                  * NaN is quiet, return as single NaN 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)                  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)                 Sgl_setinfinity_exponent(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		Sgl_set_mantissa(result,Dallp1(srcp1)<<3 | Dallp2(srcp2)>>29);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		if (Sgl_iszero_mantissa(result)) Sgl_set_quiet(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)                 *dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)                 return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)         }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)         /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)          * Generate result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)         Dbl_to_sgl_exponent(src_exponent,dest_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	if (dest_exponent > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)         	Dbl_to_sgl_mantissa(srcp1,srcp2,dest_mantissa,inexact,guardbit, 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		stickybit,lsb_odd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		if (Dbl_iszero_exponentmantissa(srcp1,srcp2)){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			Sgl_setzero_exponentmantissa(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 			*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 			return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)                 if (Is_underflowtrap_enabled()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			Dbl_to_sgl_mantissa(srcp1,srcp2,dest_mantissa,inexact,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			guardbit,stickybit,lsb_odd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)                 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			/* compute result, determine inexact info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 			 * and set Underflowflag if appropriate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 			Dbl_to_sgl_denormalized(srcp1,srcp2,dest_exponent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 			dest_mantissa,inexact,guardbit,stickybit,lsb_odd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			is_tiny);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)         /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)          * Now round result if not exact
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)         if (inexact) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)                 switch (Rounding_mode()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)                         case ROUNDPLUS: 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)                                 if (Sgl_iszero_sign(result)) dest_mantissa++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)                                 break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)                         case ROUNDMINUS: 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)                                 if (Sgl_isone_sign(result)) dest_mantissa++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)                                 break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)                         case ROUNDNEAREST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)                                 if (guardbit) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)                                    if (stickybit || lsb_odd) dest_mantissa++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)                                    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)                 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)         }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)         Sgl_set_exponentmantissa(result,dest_mantissa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)         /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)          * check for mantissa overflow after rounding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)         if ((dest_exponent>0 || Is_underflowtrap_enabled()) && 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	    Sgl_isone_hidden(result)) dest_exponent++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)         /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)          * Test for overflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)         if (dest_exponent >= SGL_INFINITY_EXPONENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)                 /* trap if OVERFLOWTRAP enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)                 if (Is_overflowtrap_enabled()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)                         /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)                          * Check for gross overflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)                          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)                         if (dest_exponent >= SGL_INFINITY_EXPONENT+SGL_WRAP) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)                         	return(UNIMPLEMENTEDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)                         
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)                         /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)                          * Adjust bias of result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)                          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 			Sgl_setwrapped_exponent(result,dest_exponent,ovfl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 			*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 			if (inexact) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 			    if (Is_inexacttrap_enabled())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 				return(OVERFLOWEXCEPTION|INEXACTEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 			    else Set_inexactflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)                         return(OVERFLOWEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)                 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)                 Set_overflowflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		inexact = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		/* set result to infinity or largest number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		Sgl_setoverflow(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)         }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)         /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)          * Test for underflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)         else if (dest_exponent <= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)                 /* trap if UNDERFLOWTRAP enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)                 if (Is_underflowtrap_enabled()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)                         /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)                          * Check for gross underflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)                          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)                         if (dest_exponent <= -(SGL_WRAP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)                         	return(UNIMPLEMENTEDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)                         /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)                          * Adjust bias of result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)                          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 			Sgl_setwrapped_exponent(result,dest_exponent,unfl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 			*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 			if (inexact) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 			    if (Is_inexacttrap_enabled())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 				return(UNDERFLOWEXCEPTION|INEXACTEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 			    else Set_inexactflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)                         return(UNDERFLOWEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)                 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)                  /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)                   * result is denormalized or signed zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)                   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)                if (inexact && is_tiny) Set_underflowflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)         }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	else Sgl_set_exponent(result,dest_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)         /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)          * Trap if inexact trap is enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)         if (inexact)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)         	if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)         	else Set_inexactflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)         return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }