1 /* 2 * ==================================================== 3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 * 5 * Developed at SunPro, a Sun Microsystems, Inc. business. 6 * Permission to use, copy, modify, and distribute this 7 * software is freely granted, provided that this notice 8 * is preserved. 9 * ==================================================== 10 */ 11 12 #include "softmath_private.h" 13 #include <inttypes.h> 14 15 static const float 16 bp[] = {1.0, 1.5,}, 17 dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */ 18 dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */ 19 Zero[] = {0.0, -0.0,}, 20 zero = 0.0, 21 one = 1.0, 22 two = 2.0, 23 two24 = 16777216.0, /* 0x4b800000 */ 24 huge = 1.0e30, 25 tiny = 1.0e-30, 26 /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ 27 L1 = 6.0000002384e-01, /* 0x3f19999a */ 28 L2 = 4.2857143283e-01, /* 0x3edb6db7 */ 29 L3 = 3.3333334327e-01, /* 0x3eaaaaab */ 30 L4 = 2.7272811532e-01, /* 0x3e8ba305 */ 31 L5 = 2.3066075146e-01, /* 0x3e6c3255 */ 32 L6 = 2.0697501302e-01, /* 0x3e53f142 */ 33 P1 = 1.6666667163e-01, /* 0x3e2aaaab */ 34 P2 = -2.7777778450e-03, /* 0xbb360b61 */ 35 P3 = 6.6137559770e-05, /* 0x388ab355 */ 36 P4 = -1.6533901999e-06, /* 0xb5ddea0e */ 37 P5 = 4.1381369442e-08, /* 0x3331bb4c */ 38 lg2 = 6.9314718246e-01, /* 0x3f317218 */ 39 lg2_h = 6.93145752e-01, /* 0x3f317200 */ 40 lg2_l = 1.42860654e-06, /* 0x35bfbe8c */ 41 ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */ 42 cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */ 43 cp_h = 9.6191406250e-01, /* 0x3f764000 =12b cp */ 44 cp_l = -1.1736857402e-04, /* 0xb8f623c6 =tail of cp_h */ 45 ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */ 46 ivln2_h= 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/ 47 ivln2_l= 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/ 48 49 typedef unsigned int u_int32_t; 50 51 typedef union { 52 float value; 53 u_int32_t word; 54 } ieee_float_shape_type; 55 56 #define GET_FLOAT_WORD(i,d) do \ 57 { \ 58 ieee_float_shape_type gf_u; \ 59 gf_u.value = (d); \ 60 (i) = gf_u.word; \ 61 } while(0) 62 63 #define SET_FLOAT_WORD(d,i) do \ 64 { \ 65 ieee_float_shape_type gf_u; \ 66 gf_u.word = (i); \ 67 (d) = gf_u.value; \ 68 } while(0) 69