-
Notifications
You must be signed in to change notification settings - Fork 0
/
Number.h
65 lines (47 loc) · 2.9 KB
/
Number.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//----------------------------------------------------------------------------//
// *** ЦЕЛОЕ ЧИСЛО В РАЗНЫХ СИСТЕМАХ СЧИСЛЕНИЯ *** //
// //
// Файл Number.h //
// //
// Автор ГЛУЩЕНКО Сергей //
// //
// Москва //
//----------------------------------------------------------------------------//
#ifndef NumberH
#define NumberH
#include <string>
#include "Numerical.h"
class TNumber
{
private:
long long int Data; //Само число здесь хранится
int Size; //Разрядность числа
public:
TNumber(void);
virtual ~TNumber(void);
//Инициализирует число нулями и устанавливает 8-разрядную сетку
void Empty(void);
//Возвращает выбранный пользователем битовый массив (часть битов) из числа.
// На вход подаются старший и младший биты. Биты нумеруются справа-налево.
// Например число 123 (десятичное) в двоичной 8-разрядной форме имеет вид 01111011
// 76543210 - номера битов
// GetSomeBits(5,3) вернёт 111 (двоичное), то есть 7 (десятичное)
std::string GetSomeBits(int MaxBit, int MinBit);
//Задать разрядность числа (от 1 до 64 включительно). По умолчанию 8-разрядное
void SetSize(int Value);
//Прочитать разрядность числа
int GetSize(void);
//Задать число в десятичной системе счисления
void SetAsInt(long long int Value);
//Прочитать число в десятичной системе счисления
long long int GetAsInt(void);
//Задать число в двоичной системе счисления
void SetAsBin(std::string Value);
//Прочитать число в двоичной системе счисления
std::string GetAsBin(void);
//Задать число в шестнадцатеричной системе счисления
void SetAsHex(std::string Value);
//Прочитать число в шестнадцатеричной системе счисления
std::string GetAsHex(void);
};
#endif