for fpu i would do some test for see how is slow fixed point 64 bit
build on unsigned against float IEEE
time and result for doing operations
fixed point using only 32 bit unsigned array [32.64 bit] vs IEEE
double 64 bit
a little slow the fixed point[from 8x to 25x] but one have to get in
count that there are 90_000_000 of operations each operator +-*/
than i don't know if my implementation is ok, could return one error
number, if someone see some wrong number could please say that?
there is someone can propose good set of operation for stress these
float numbers operator?
if see these result i dubit that fpu is essential
base_10=16 precision=2
+Fixed point result=1009.000000 time=8.000000
+IEEE Double result=1008.999997 time=1.000000
-Fixed point result=1000.000000 time=10.000000
-IEEE Double result=1000.000000 time=1.000000
*Fixed point result=8103080.281151 time=18.000000
*IEEE Double result=8103080.323769 time=1.000000
/Fixed point result=1000.000000 time=55.000000
/IEEE Double result=100.000000e1 time=2.000000
#include "myh.h"
#include <time.h>
#define uns unsigned
#define u32 unsigned
#define u64 unsigned __int64
#define i32 int
#define u16 unsigned short
#define u8 unsigned char
#define i8 char
#define i16 short
#define long_long __int64
#define sdC __stdcall
#define ooo cout
#define S sizeof
#define MM Malloc_m
#define FF Free_m
#define F for
#define R return
#define W while
#define G goto
int testVsFloat(void)
{double da, db;
time_t ti, tf;
fnum a, b; /* fixed point float */
u32 i;
set_precision10(16); // for float: 2 unsigned as at right of .
/* + */
ti=time(0);
F(i=0, a=0.0000001, b=1000.0; i<90000000; ++i)
b=b+a;
ooo<<"+Fixed point result="<<b<<" ";
tf=time(0);
P("time=%f\n", difftime(tf, ti));
ti=time(0);
F(i=0, da=0.0000001, db=1000.0; i<90000000; ++i)
db=db+da;
P( "+IEEE Double result=%f ", db);
tf=time(0);
P("time=%f\n", difftime(tf, ti));
/* - */
ti=time(0);
F(i=0; i<90000000; ++i)
b=b-a;
ooo<<"-Fixed point result="<<b<<" ";
tf=time(0);
P("time=%f\n", difftime(tf, ti));
ti=time(0);
F(i=0; i<90000000; ++i)
db=db-da;
P( "-IEEE Double result=%f ", db);
tf=time(0);
P("time=%f\n", difftime(tf, ti));
/* * */
ti=time(0);
F(i=0, a=a+1; i<90000000; ++i)
b=b*a;
ooo<<"*Fixed point result="<<b<<" ";
tf=time(0);
P("time=%f\n", difftime(tf, ti));
ti=time(0);
F(i=0, da=da+1; i<90000000; ++i)
db=db*da;
P( "*IEEE Double result=%f ", db);
tf=time(0);
P("time=%f\n", difftime(tf, ti));
/* / */
ti=time(0);
F(i=0; i<90000000; ++i)
b=b/a;
ooo<<"/Fixed point result="<<b<<" ";
tf=time(0);
P("time=%f\n", difftime(tf, ti));
ti=time(0);
F(i=0; i<90000000; ++i)
db=db/da;
P( "/IEEE Double result=%f ", db);
tf=time(0);
P("time=%f\n", difftime(tf, ti));
}
int main27(int c, char** a)
{testVsFloat();
R 0;
}