home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / business / cube3d / cube3D.exe / cube3D / src / fixed.h < prev    next >
C/C++ Source or Header  |  2000-12-26  |  1KB  |  41 lines

  1. /*
  2.  * @(#)fixed.h
  3.  *
  4.  * Copyright 1999-2000, Aaron Ardiri (mailto:aaron@ardiri.com)
  5.  * All rights reserved.
  6.  *
  7.  * The  source code  outlines a number of basic Palm Computing Programming
  8.  * principles and you  should be able to take the core structure and write 
  9.  * a large complex program. It is distributed WITHOUT ANY WARRANTY; use it
  10.  * "AS IS" and at your own risk.
  11.  *
  12.  * The code presented is Copyright 1999-2000 by Aaron Ardiri. It should be
  13.  * used for  educational purposes only.  You  shall not modify  the Cube3D 
  14.  * source code in any way and  re-distribute it as your  own,  however you
  15.  * are free to use  the code as  a guide for  developing  programs  on the 
  16.  * Palm Computing Platform.
  17.  */
  18.  
  19. #include "palm.h"
  20.  
  21. #ifndef _FIXED_H
  22. #define _FIXED_H
  23.  
  24. // data types
  25. typedef long fixed; // 32 bit --> 24:8 precision
  26. #define precision 8
  27.  
  28. // fixed mathematical operations
  29. #define Addfx(a,b) (fixed)((fixed)(a) + (fixed)(b))
  30. #define Subfx(a,b) (fixed)((fixed)(a) - (fixed)(b))
  31. #define Mulfx(a,b) (fixed)(((fixed)(a) * (fixed)(b)) >> precision)
  32. #define Divfx(a,b) (fixed)(((fixed)(a) << precision) / (fixed)(b))
  33.  
  34. // fixed mathematical conversions
  35. #define itofx(x) ((fixed)(x) << precision)
  36. #define ftofx(x) ((fixed)(x) * (fixed)(0x01 << precision))
  37. #define fxtoi(x) (((fixed)(x)) >> precision)
  38. #define fxtof(x) (((fixed)(x)) / (float)(0x01 << precision))
  39.  
  40. #endif
  41.