Skip to content

Instantly share code, notes, and snippets.

@jgigault
Created June 18, 2015 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgigault/07d5d0bc37e92f85a396 to your computer and use it in GitHub Desktop.
Save jgigault/07d5d0bc37e92f85a396 to your computer and use it in GitHub Desktop.
#ifndef FIXED_CLASS_HPP
# define FIXED_CLASS_HPP
# include <iostream>
class Fixed
{
public:
Fixed(void);
~Fixed(void);
Fixed(Fixed const & src);
Fixed(int const i);
Fixed(float const i);
Fixed & operator=(Fixed const & rhs);
bool operator>(Fixed const & rhs);
bool operator<(Fixed const & rhs);
bool operator>=(Fixed const & rhs);
bool operator<=(Fixed const & rhs);
bool operator==(Fixed const & rhs);
bool operator!=(Fixed const & rhs);
Fixed operator+(Fixed const & rhs);
Fixed operator-(Fixed const & rhs);
Fixed operator*(Fixed const & rhs);
Fixed operator/(Fixed const & rhs);
Fixed & operator++(void);
Fixed & operator--(void);
Fixed operator++(int n);
Fixed operator--(int n);
int getRawBits(void) const;
void setRawBits(int const raw);
int toInt(void) const;
float toFloat(void) const;
static Fixed & min(Fixed & i, Fixed & j);
static Fixed & max(Fixed & i, Fixed & j);
static Fixed const & min(Fixed const & i, Fixed const & j);
static Fixed const & max(Fixed const & i, Fixed const & j);
static int pow(int const n, int p);
static int rpow(int const n, int p);
static float fpow(float const f, int p);
static float rfpow(float const f, int p);
private:
int _value;
static int const f = 8;
static int const accuracy = 128;
};
std::ostream & operator<<(std::ostream & o, Fixed const & i);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment