Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

bigfix.h

Go to the documentation of this file.
00001 // bigfix.h
00002 //
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // 128-bit fixed point (64.64) numbers for high-precision celestial
00006 // coordinates.  When you need millimeter accurate navigation across a scale
00007 // of thousands of light years, doubles just don't do it.
00008 //
00009 // This program is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 
00014 
00015 #ifndef _BIGFIX_H_
00016 #define _BIGFIX_H_
00017 
00018 #define N_WORDS 8
00019 #include <string>
00020 
00021 class BigFix
00022 {
00023 public:
00024         BigFix();
00025         BigFix(int);
00026         BigFix(double);
00027         BigFix(const std::string&);
00028 
00029         operator double() const;
00030         operator float() const;
00031 
00032         BigFix operator-() const;
00033 
00034         friend BigFix operator+(BigFix, BigFix);
00035         friend BigFix operator-(BigFix, BigFix);
00036         friend BigFix operator*(BigFix, BigFix);
00037         friend bool operator==(BigFix, BigFix);
00038         friend bool operator!=(BigFix, BigFix);
00039 
00040         int sign();
00041 
00042         // for debugging
00043         void dump();
00044         std::string toString();
00045 
00046 private:
00047         unsigned short n[N_WORDS];  // high 16-bits is n[N_WORDS - 1]
00048 };
00049 
00050 #endif // _BIGFIX_H_

Generated on Sat Jan 14 22:30:32 2006 for Celestia by  doxygen 1.4.1