• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Oct 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. union {
2.         double number;
3.         long long inumber;
4.         char bytes[sizeof(double)];
5.     };
6.     number = 0;
7.     char sign3 = 1;
8.     int dotPos2 = -1;
9.     string doubleEnter = "";
10.     system("cls");
11.     cout << "DOUBLE " << numberSystem << " system\n";
12.     printAlphabet(numberSystem);
13.     cout << "Enter number: ";
14.     fractionalNumberEnter(doubleEnter, numberSystem, sign3, dotPos2);
15.     if (dotPos2 != -1) {
16.         for (int i = 0; i < dotPos2; i++) {
17.             if (doubleEnter[i] - '0' < 10)
18.                 number += (doubleEnter[i] - '0') * degree(dotPos2 - i - 1, numberSystem);
19.             else {
20.                 if (doubleEnter[i] <= 'Z') {
21.                     number += (doubleEnter[i] - '0' - 7 /*number that deletes the difference between the character A and number 10*/) * degree(dotPos2 - i - 1, numberSystem);
22.                 }
23.                 else {
24.                     number += (doubleEnter[i] - '0' - 7 - 6 /*number that deletes the difference between the character a and 10*/) * degree(dotPos2 - i - 1, numberSystem);
25.                 }
26.             }
27.         }
28.         for (int i = dotPos2 + 1; i < doubleEnter.length(); i++) {
29.             if (doubleEnter[i] - '0' < 10)
30.                 number += (doubleEnter[i] - '0') * degree(dotPos2 - i, numberSystem);
31.             else {
32.                 if (doubleEnter[i] <= 'Z') {
33.                     number += (doubleEnter[i] - '0' - 7 /*number that deletes the difference between the character A and number 10*/) * degree(dotPos2 - i, numberSystem);
34.                 }
35.                 else {
36.                     number += (doubleEnter[i] - '0' - 7 - 6 /*number that deletes the difference between the character a and number 10*/) * degree(dotPos2 - i, numberSystem);
37.                 }
38.             }
39.         }
40.     }
41.     else {
42.         for (int i = 0; i < doubleEnter.length(); i++) {
43.             if (doubleEnter[i] - '0' < 10) {
44.                 number += (doubleEnter[i] - '0') * degree(doubleEnter.length() - i - 1, numberSystem);
45.             }
46.             else {
47.                 if (doubleEnter[i] <= 'Z') {
48.                     number += (doubleEnter[i] - '0' - 7 /*number that deletes the difference between the character A and number 10*/) * degree(doubleEnter.length() - i - 1, numberSystem);
49.                 }
50.                 else {
51.                     number += (doubleEnter[i] - '0' - 7 - 6 /*number that deletes the difference between the character A and number 10*/) * degree(doubleEnter.length() - i - 1, numberSystem);
52.                 }
53.             }
54.         }
55.     }
56.     number *= sign3;
57.     cout << "\ndecimal notation: " << fixed << number << endl;
58.     long long temperal;
59.     temperal = inumber;
60.     cout << "binary notation: ";
61.     bit_print(bytes, sizeof(double), hConsole);
62.     cout << endl;
63.     cout << "Dou you want to change some bits?\n[y] - yes\n[n] - no";
64.     char c;
65.     c = 0;
66.     do {
67.         c = _getch();
68.     } while (c != 'y' && c != 'n');
69.     cout << endl;
70.     if (c == 'y') {
71.         bitChange(temperal, hConsole);
72.         inumber = temperal;
73.         cout << "changed demical notation: " << number << endl;
74.         cout << "changed binary notation: ";
75.         bit_print(bytes, sizeof(double), hConsole);
76.         cout << endl;
77.     }
78.     cout << "Press ESC to exit...";
79.     char exitcode;
80.     do {
81.         exitcode = _getch();
82.     } while (exitcode != 27);
83.     system("cls");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top