Home | History | Annotate | Line # | Download | only in spmath
setovfl.c revision 1.5.70.1
      1 /*	$NetBSD: setovfl.c,v 1.5.70.1 2009/05/13 17:17:48 jym Exp $	*/
      2 
      3 /*	$OpenBSD: setovfl.c,v 1.4 2001/03/29 03:58:19 mickey Exp $	*/
      4 
      5 /*
      6  * Copyright 1996 1995 by Open Software Foundation, Inc.
      7  *              All Rights Reserved
      8  *
      9  * Permission to use, copy, modify, and distribute this software and
     10  * its documentation for any purpose and without fee is hereby granted,
     11  * provided that the above copyright notice appears in all copies and
     12  * that both the copyright notice and this permission notice appear in
     13  * supporting documentation.
     14  *
     15  * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
     16  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     17  * FOR A PARTICULAR PURPOSE.
     18  *
     19  * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
     20  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
     21  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
     22  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
     23  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     24  *
     25  */
     26 /*
     27  * pmk1.1
     28  */
     29 /*
     30  * (c) Copyright 1986 HEWLETT-PACKARD COMPANY
     31  *
     32  * To anyone who acknowledges that this file is provided "AS IS"
     33  * without any express or implied warranty:
     34  *     permission to use, copy, modify, and distribute this file
     35  * for any purpose is hereby granted without fee, provided that
     36  * the above copyright notice and this notice appears in all
     37  * copies, and that the name of Hewlett-Packard Company not be
     38  * used in advertising or publicity pertaining to distribution
     39  * of the software without specific, written prior permission.
     40  * Hewlett-Packard Company makes no representations about the
     41  * suitability of this software for any purpose.
     42  */
     43 
     44 #include <sys/cdefs.h>
     45 __KERNEL_RCSID(0, "$NetBSD: setovfl.c,v 1.5.70.1 2009/05/13 17:17:48 jym Exp $");
     46 
     47 #include "../spmath/float.h"
     48 #include "../spmath/sgl_float.h"
     49 #include "../spmath/dbl_float.h"
     50 
     51 sgl_floating_point
     52 sgl_setoverflow(unsigned int sign)
     53 {
     54 	sgl_floating_point result;
     55 
     56 	/* set result to infinity or largest number */
     57 #if 0
     58 	switch (Rounding_mode()) {
     59 		case ROUNDPLUS:
     60 			if (sign) {
     61 				Sgl_setlargestnegative(result);
     62 			} else {
     63 				Sgl_setinfinitypositive(result);
     64 			}
     65 			break;
     66 		case ROUNDMINUS:
     67 			if (sign==0) {
     68 				Sgl_setlargestpositive(result);
     69 			} else {
     70 				Sgl_setinfinitynegative(result);
     71 			}
     72 			break;
     73 		case ROUNDNEAREST:
     74 			Sgl_setinfinity(result,sign);
     75 			break;
     76 		default:
     77 		case ROUNDZERO:
     78 			Sgl_setlargest(result,sign);
     79 			break;
     80 	}
     81 #endif
     82 	Sgl_setinfinity(result,sign);
     83 	return(result);
     84 }
     85 
     86 dbl_floating_point dbl_setoverflow(sign)
     87 
     88 unsigned int sign;
     89 {
     90 	dbl_floating_point result;
     91 
     92 	/* set result to infinity or largest number */
     93 	/* ignore for now
     94 	switch (Rounding_mode()) {
     95 		case ROUNDPLUS:
     96 			if (sign) {
     97 				Dbl_setlargestnegative(result);
     98 			}
     99 			else {
    100 				Dbl_setinfinitypositive(result);
    101 			}
    102 			break;
    103 		case ROUNDMINUS:
    104 			if (sign==0) {
    105 				Dbl_setlargestpositive(result);
    106 			}
    107 			else {
    108 				Dbl_setinfinitynegative(result);
    109 			}
    110 			break;
    111 		case ROUNDNEAREST:
    112 			Dbl_setinfinity(result,sign);
    113 			break;
    114 		case ROUNDZERO:
    115 			Dbl_setlargest(result,sign);
    116 	}
    117 	*/
    118 	Dbl_setinfinity(result.wd0,result.wd1,sign);
    119 	return(result);
    120 }
    121