You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.0 KiB
53 lines
2.0 KiB
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* Fixed.hpp :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/06/20 10:06:37 by narnaud #+# #+# */
|
|
/* Updated: 2022/06/23 10:33:51 by narnaud ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#pragma once
|
|
|
|
#include <iostream>
|
|
#include <cmath>
|
|
|
|
class Fixed {
|
|
|
|
public:
|
|
Fixed (void);
|
|
Fixed (const int init_int);
|
|
Fixed (const float init_float);
|
|
Fixed (Fixed const & src);
|
|
~Fixed (void);
|
|
Fixed & operator= (Fixed const & src);
|
|
Fixed operator+ (Fixed const & src);
|
|
Fixed operator- (Fixed const & src);
|
|
Fixed operator* (Fixed const & src);
|
|
Fixed operator/ (Fixed const & src);
|
|
Fixed & operator++ ();
|
|
Fixed & operator-- ();
|
|
Fixed operator++ (int);
|
|
Fixed operator-- (int);
|
|
bool operator< (Fixed const & src);
|
|
bool operator> (Fixed const & src);
|
|
bool operator<= (Fixed const & src);
|
|
bool operator>= (Fixed const & src);
|
|
bool operator== (Fixed const & src);
|
|
bool operator!= (Fixed const & src);
|
|
int getRawBits(void) const;
|
|
void setRawBits(int const raw);
|
|
float toFloat(void) const;
|
|
int toInt(void) const;
|
|
static Fixed & min(Fixed & a, Fixed & b);
|
|
static Fixed & max(Fixed & a, Fixed & b);
|
|
static const Fixed & min(Fixed const & a, Fixed const & b);
|
|
static const Fixed & max(Fixed const & a, Fixed const & b);
|
|
private:
|
|
int _raw_bits;
|
|
static const int _fract_bits;
|
|
};
|
|
std::ostream & operator << (std::ostream &out, const Fixed &f);
|
|
|