shithub: npe

ref: 4fa9b9a395c8ea38e83d84e0d483fe3a329958ea
dir: /libnpe/log2.c/

View raw version
#include <math.h>
#include "_npe.h"

double
log2(double x)
{
	if(x == 0)
		return -hugeD;
	if(x < 0 || isNaN(x))
		return NaN();

	return log(x)*ln2o1;
}

float
log2f(float x)
{
	if(x == 0)
		return -hugeF;

	return log2(x);
}