Nabend,
ich habe ein Problem mit dem Umwandeln von Dezimal-Zahlen ins Dualsystem. Wenn ich Zahlen bis 255 eingebe und umwandeln lasse, tritt kein Problem auf. Wenn ich aber eine größere Zahl eingebe, fängt das Programm wieder von 0 an zu zählen.
|
C/C++ Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include <iostream>
#include <bitset>
#include <string>
#include <typeinfo>
using namespace std;
int main ()
{
unsigned long long int number = NULL;
cin >> number;
bitset<8> binary (number);
cout << "Zahl: " << binary.to_ulong() << "(" << number << ")" << endl;
cout << "Binaer: " << binary << endl;
//Überprüfung was für Variablentyp vorliegt
cout << "Var-Typ: " << typeid(binary.to_ulong()).name();
return 0;
}
|
Als Fehlersuchhilfe hab ich mir mal den Variabln-Typen ausgeben lassen, der jedoch "m" ist. Ich hab noch nie von so einem Variablen-Typ gehört
Hab momentan keine Ansätze, wie man das Problem lösen könnte. 255 ist ja die max Anzahl des Var-Typs char. Mehr ist mir noch nicht eingefallen.
Wäre dankbar für Problemlösungen oder Lösungsansätze