Deleted Added
full compact
b_log.c (138924) b_log.c (150318)
1/*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 21 unchanged lines hidden (view full) ---

30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35static char sccsid[] = "@(#)log.c 8.2 (Berkeley) 11/30/93";
36#endif /* not lint */
37#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 21 unchanged lines hidden (view full) ---

30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35static char sccsid[] = "@(#)log.c 8.2 (Berkeley) 11/30/93";
36#endif /* not lint */
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/lib/msun/bsdsrc/b_log.c 138924 2004-12-16 20:40:37Z das $");
38__FBSDID("$FreeBSD: head/lib/msun/bsdsrc/b_log.c 150318 2005-09-19 11:28:19Z bde $");
39
40#include <math.h>
41#include <errno.h>
42
43#include "mathimpl.h"
44
45/* Table-driven natural logarithm.
46 *

--- 25 unchanged lines hidden (view full) ---

72 * (This is done differently in the original paper)
73 *
74 * Special cases:
75 * 0 return signalling -Inf
76 * neg return signalling NaN
77 * +Inf return +Inf
78*/
79
39
40#include <math.h>
41#include <errno.h>
42
43#include "mathimpl.h"
44
45/* Table-driven natural logarithm.
46 *

--- 25 unchanged lines hidden (view full) ---

72 * (This is done differently in the original paper)
73 *
74 * Special cases:
75 * 0 return signalling -Inf
76 * neg return signalling NaN
77 * +Inf return +Inf
78*/
79
80#define endian (((*(int *) &one)) ? 1 : 0)
81#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000
82
83#define N 128
84
85/* Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128.
86 * Used for generation of extend precision logarithms.
87 * The constant 35184372088832 is 2^45, so the divide is exact.
88 * It ensures correct reading of logF_head, even for inaccurate
89 * decimal-to-binary conversion routines. (Everybody gets the
90 * right answer for integers less than 2^53.)

--- 342 unchanged lines hidden (view full) ---

433struct Double
434#ifdef _ANSI_SOURCE
435__log__D(double x)
436#else
437__log__D(x) double x;
438#endif
439{
440 int m, j;
80#define N 128
81
82/* Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128.
83 * Used for generation of extend precision logarithms.
84 * The constant 35184372088832 is 2^45, so the divide is exact.
85 * It ensures correct reading of logF_head, even for inaccurate
86 * decimal-to-binary conversion routines. (Everybody gets the
87 * right answer for integers less than 2^53.)

--- 342 unchanged lines hidden (view full) ---

430struct Double
431#ifdef _ANSI_SOURCE
432__log__D(double x)
433#else
434__log__D(x) double x;
435#endif
436{
437 int m, j;
441 double F, f, g, q, u, v, u2, one = 1.0;
438 double F, f, g, q, u, v, u2;
442 volatile double u1;
443 struct Double r;
444
445 /* Argument reduction: 1 <= g < 2; x/2^m = g; */
446 /* y = F*(1 + f/F) for |f| <= 2^-8 */
447
448 m = logb(x);
449 g = ldexp(x, -m);

--- 27 unchanged lines hidden ---
439 volatile double u1;
440 struct Double r;
441
442 /* Argument reduction: 1 <= g < 2; x/2^m = g; */
443 /* y = F*(1 + f/F) for |f| <= 2^-8 */
444
445 m = logb(x);
446 g = ldexp(x, -m);

--- 27 unchanged lines hidden ---