# Logarithmic Tables

**URL:** https://boards.straightdope.com/t/logarithmic-tables/793079
**Category:** Factual Questions
**Created:** [August 8, 2017, 10:44am UTC](https://boards.straightdope.com/t/logarithmic-tables/793079 "2017-08-08T10:44:31Z")
**Posts on this page:** 1
**Showing post:** 11

<div class="post-metadata">

### Author: ![septimus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/septimus/32/410_2.png) [@septimus](https://boards.straightdope.com/u/septimus)
#### Post date: [August 8, 2017, 4:00pm UTC](https://boards.straightdope.com/t/logarithmic-tables/793079/11 "2017-08-08T16:00:26Z")

</div>

Here is some real C code to compute (_but with no error-checking_) logarithm base _e_.

```auto

/*
 * This code is loosely based on Freeware;
 * x_log() is similar to log() but does no error-checking.
 * x_frexp() accomplishes the built-in function frexp()
 * but is much slower. It is included to make this
 * wholly self-contained.
 * No copyright is claimed by Septimus G. Stevens VII.
 * Use of this code for satiric purposes is encouraged.
 */
 
double x_frexp(double x, int *xpon)
{
	int	xp = 0;
	while (x >= 1)
		x /= 2, xp++;
	while (x < 0.5)
		x *= 2, xp--;
	*xpon = xp;
	return x;
}

double x_log(double x)
{
        double z, w;
        int xpon;

        x = 1.4142135623730950488 * x_frexp(x, &xpon);
	z = 2 * (x-1) / (x+1);
	w = z * z;
	x = z;
	z *= - w * 64.124943423745581147
		+ w*w * 16.383943563021534222
		- w*w*w * 0.78956112887491257267;
	z /= -769.49932108494879777
		+ w * 312.03222091924532844
		- w*w * 35.667977739034646171
		+ w*w*w;
        return x + z + xpon * .69314718055994530941
		- .3465735902799726547;
}

```

---

_[View the full topic](https://boards.straightdope.com/t/logarithmic-tables/793079)._
