Home | History | Annotate | Line # | Download | only in softfloat
flt_rounds.c revision 1.1
      1  1.1  nat /*	$NetBSD: flt_rounds.c,v 1.1 2025/10/04 21:03:16 nat Exp $	*/
      2  1.1  nat 
      3  1.1  nat /*
      4  1.1  nat  * Written by J.T. Conklin, Apr 11, 1995
      5  1.1  nat  * Public domain.
      6  1.1  nat  */
      7  1.1  nat 
      8  1.1  nat #include <sys/cdefs.h>
      9  1.1  nat #if defined(LIBC_SCCS) && !defined(lint)
     10  1.1  nat __RCSID("$NetBSD: flt_rounds.c,v 1.1 2025/10/04 21:03:16 nat Exp $");
     11  1.1  nat #endif /* LIBC_SCCS and not lint */
     12  1.1  nat 
     13  1.1  nat #include "namespace.h"
     14  1.1  nat #include <machine/float.h>
     15  1.1  nat #include <ieeefp.h>
     16  1.1  nat 
     17  1.1  nat static const int map[] = {
     18  1.1  nat 	1,	/* round to nearest */
     19  1.1  nat 	0,	/* round to zero */
     20  1.1  nat #ifdef __m68k__
     21  1.1  nat 	3,	/* round to positive infinity */
     22  1.1  nat 	2	/* round to negative infinity */
     23  1.1  nat #else
     24  1.1  nat 	2,	/* round to positive infinity */
     25  1.1  nat 	3	/* round to negative infinity */
     26  1.1  nat #endif
     27  1.1  nat };
     28  1.1  nat 
     29  1.1  nat int
     30  1.1  nat __flt_rounds(void)
     31  1.1  nat {
     32  1.1  nat 	return map[fpgetround()];
     33  1.1  nat }
     34