backup - no unique long long function

This commit is contained in:
dwarning 2007-12-27 22:02:06 +00:00
parent 1e3367b0d3
commit 6464cf535d
3 changed files with 7 additions and 6 deletions

View File

@ -8,7 +8,7 @@ Copyright 1999 Emmanuel Rouat
#ifndef MISSING_MATH_H_INCLUDED #ifndef MISSING_MATH_H_INCLUDED
#define MISSING_MATH_H_INCLUDED #define MISSING_MATH_H_INCLUDED
bool AlmostEqualUlps(double, double, long int); bool AlmostEqualUlps(float, float, int);
#ifndef HAVE_ERFC #ifndef HAVE_ERFC
extern double erfc(double); extern double erfc(double);

View File

@ -11,17 +11,18 @@ $Id$
#include "ngspice.h" #include "ngspice.h"
#include "missing_math.h" #include "missing_math.h"
/* Initial AlmostEqualULPs version - fast and simple, but */ /* Initial AlmostEqualULPs version - fast and simple, but */
/* some limitations. */ /* some limitations. */
bool AlmostEqualUlps(double A, double B, long int maxUlps) bool AlmostEqualUlps(float A, float B, int maxUlps)
{ {
long int intDiff; int intDiff;
assert(sizeof(double) == sizeof(long int)); assert(sizeof(float) == sizeof(int));
if (A == B) if (A == B)
return TRUE; return TRUE;
intDiff = abs(*(long int*)&A - *(long int*)&B); intDiff = abs(*(int*)&A - *(int*)&B);
if (intDiff <= maxUlps) if (intDiff <= maxUlps)
return TRUE; return TRUE;

View File

@ -6,7 +6,7 @@
#ifndef MISSING_MATH_H_INCLUDED #ifndef MISSING_MATH_H_INCLUDED
#define MISSING_MATH_H_INCLUDED #define MISSING_MATH_H_INCLUDED
bool AlmostEqualUlps(double, double, long int); bool AlmostEqualUlps(float, float, int);
#ifndef HAVE_ERFC #ifndef HAVE_ERFC
double erfc(double); double erfc(double);