File indexing completed on 2024-05-12 17:21:04

0001 /*
0002  * SPDX-FileCopyrightText: 2021-2022 Rohan Asokan <rohan.asokan@students.iiit.ac.in>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 #include <QString>
0007 #include "knumber.h"
0008 
0009 class BinaryNumber {
0010 public:
0011     // construction/destruction
0012     BinaryNumber();
0013     explicit BinaryNumber(const QString &s);
0014     explicit BinaryNumber(const KNumber &num);
0015     BinaryNumber(const BinaryNumber &other);
0016     // ~BinaryNumber();
0017 public:
0018     // assignment
0019     BinaryNumber &operator=(const BinaryNumber &rhs);
0020 public:
0021     // Unary operators
0022     // KNumber &operator~();
0023 public:
0024     // Converters
0025     QString toHex() const;
0026     QString toOct() const;
0027     QString toBin() const;
0028     QString toDec() const;
0029     KNumber toKNum() const;
0030 private:
0031     KNumber m_number;
0032 };
0033 
0034 BinaryNumber operator+(const BinaryNumber &lhs, const BinaryNumber &rhs);
0035 BinaryNumber operator-(const BinaryNumber &lhs, const BinaryNumber &rhs);
0036 BinaryNumber operator*(const BinaryNumber &lhs, const BinaryNumber &rhs);
0037 BinaryNumber operator/(const BinaryNumber &lhs, const BinaryNumber &rhs);
0038 
0039 BinaryNumber operator&(const BinaryNumber &lhs, const BinaryNumber &rhs);
0040 BinaryNumber operator|(const BinaryNumber &lhs, const BinaryNumber &rhs);
0041 BinaryNumber operator^(const BinaryNumber &lhs, const BinaryNumber &rhs);
0042 
0043 BinaryNumber operator<<(const BinaryNumber &lhs, const BinaryNumber &rhs);
0044 BinaryNumber operator>>(const BinaryNumber &lhs, const BinaryNumber &rhs);