1
0
This repository has been archived on 2025-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
CPP_Module_02/ex02/Fixed.hpp

61 lines
2.1 KiB
C++
Raw Normal View History

2024-11-20 12:47:39 +01:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Fixed.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/09 19:23:08 by adjoly #+# #+# */
/* Updated: 2024/11/20 12:40:10 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <iostream>
class Fixed {
private:
int _number;
static const int _fractBit = 8;
public:
Fixed(void);
Fixed(const int nbr);
Fixed(const float nbr);
Fixed(const Fixed& cpy);
Fixed& operator=(const Fixed&);
float operator+(const Fixed&);
float operator-(const Fixed&);
float operator*(const Fixed&);
float operator/(const Fixed&);
bool operator<(const Fixed&) const;
bool operator>(const Fixed&) const;
bool operator<=(const Fixed&) const;
bool operator>=(const Fixed&) const;
bool operator==(const Fixed&) const;
bool operator!=(const Fixed&) const;
Fixed& operator--(void);
Fixed operator--(int);
Fixed& operator++(void);
Fixed operator++(int);
static Fixed& min(Fixed& fst, Fixed& scnd);
static Fixed& max(Fixed& fst, Fixed& scnd);
static const Fixed& min(const Fixed& fst, const Fixed& scnd);
static const Fixed& max(const Fixed& fst, const Fixed& scnd);
~Fixed(void);
int toInt(void) const;
float toFloat(void) const;
int getRawBits( void ) const;
void setRawBits( int const raw );
};
std::ostream &operator<<(std::ostream &file, Fixed const &fixed);