Skip to content
Snippets Groups Projects
Commit 5f00212e authored by 이소현's avatar 이소현
Browse files

lec09

parent d54baf28
No related branches found
No related tags found
No related merge requests found
#include <stdio.h>
#include <math.h>
// #### #### #### #### . #### #### #### #### - 32bit
// Sbit 15bit . 16bit
#define FX_Q_NUM 16
#define FX_2_MINUS_16 1.52587890625e-05F
#define FX_2_PLUS_16 (1<<16)
#define FX_S_15_16 11516 // 1:singed 15 16
#define FX_SYSTEM FX_S_15_16
typedef int fixed32;
fixed32 fromFloat(float fa)
{
return (fixed32) (fa * FX_2_PLUS_16);
}
float toFloat(fixed32 xa)
{
return ((float) (xa)) * FX_2_MINUS_16;
}
fixed32 fxAdd(fixed32 a, fixed32 b)
{
return fromFloat((toFloat(a) + toFloat(b)));
}
fixed32 fxAdd2(fixed32 a, fixed32 b)
{
return a+b;
}
int main()
{
int i=0;
int ia, ib, ic, ic2;
float fa;
fscanf(stdin, "%d %d", &ia, &ib);
for (i=0; i< 64*256*256*256; i+=(256*256))
{
ic = fxAdd(i, i);
ic2 = fxAdd2(i, i);
fprintf(stdout, "%f + %f : %f, %f diff=%d\n", toFloat(i), toFloat(i),toFloat(ic),toFloat(ic2),ic-ic2);
}
fprintf(stdout, "%d + %d : %d\n", ia,ib,ic);
}
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 256271
max locked memory (kbytes, -l) 65536
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 256271
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment