source: golgotha/src/i4/math/fixed_test.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 12 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 993 bytes
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#ifdef _MANGLE_INC
10#include "FIXED~HA.HH"
11#else
12#include "fixed_point.hh"
13#endif
14#include <stdio.h>
15
16i4_fixed_point<16> a,b;
17i4_fixed_point<7> c,d,e,f,g,h;
18
19main()
20{
21  a = 1.05;
22  b = 5;
23  i4_fixed_point_convert(c,a+b);
24  d = 4;
25  e = 0.3;
26  f = e+0.6;
27  f -= 0.3;
28  g = d*e/f;
29  printf("%f + %f = %f\n",double(a),double(b),double(c));
30  printf("%f * %f / %f = %f\n",double(d),double(e),double(f),double(g));
31
32  printf("%f / %f = %f\n",double(a), double(b), double(a.divide(b,3)));
33}
Note: See TracBrowser for help on using the repository browser.