00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "epsilon.h"
00024
00025 using namespace lux;
00026
00027 float MachineEpsilon::minEpsilon = DEFAULT_EPSILON_MIN;
00028 float MachineEpsilon::maxEpsilon = DEFAULT_EPSILON_MAX;
00029
00030 void MachineEpsilon::SetMin(const float min) {
00031 minEpsilon = min;
00032 }
00033
00034 void MachineEpsilon::SetMax(const float max) {
00035 maxEpsilon = max;
00036 }
00037
00038 void MachineEpsilon::Test() {
00039 char buf[256];
00040 MachineFloat mf;
00041 mf.f = DEFAULT_EPSILON_STATIC;
00042 sprintf(buf,"Epsilon.DefaultEpsilonStatic: %x", mf.i & 0x7fffff);
00043 luxError(LUX_NOERROR, LUX_DEBUG, buf);
00044
00045 sprintf(buf,"Epsilon.DefaultEpsilonStaticBitAdvance(0.f): %e", MachineEpsilon::E(0.f));
00046 luxError(LUX_NOERROR, LUX_DEBUG, buf);
00047 sprintf(buf,"Epsilon.DefaultEpsilonStaticBitAdvance(1.f): %e", MachineEpsilon::E(1.f));
00048 luxError(LUX_NOERROR, LUX_DEBUG, buf);
00049
00050 for (float v = 1e-5f; v < 1e5f; v *= 2.0f) {
00051 sprintf(buf,"Epsilon.Test: %f => %e", v, E(v));
00052 luxError(LUX_NOERROR, LUX_DEBUG, buf);
00053 sprintf(buf,"Epsilon.Test: %f => %e", -v, E(-v));
00054 luxError(LUX_NOERROR, LUX_DEBUG, buf);
00055 }
00056 }