binary numbers

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
cout << "Ivesk sveikojo skaiciaus dali " << endl;
		string sveikojiDalis;
		cin >> sveikojiDalis;
		cout << "Ivesk trupmenine skaiciaus dali " << endl;
		string trupmenineDalis;
		cin >> trupmenineDalis;

		long long sveikas = 0;
		long long trumpas = 0;
		int len = sveikojiDalis.size();
		for (int i = 0; i<len; i++)
		{
			sveikas += (sveikojiDalis[len - i - 1] - 48) * pow(2, i);
			trumpas += (trupmenineDalis[len - i - 1] - 48) * pow(2, i);


		}
		cout << setbase(16);
		cout << sveikas << ",";
		cout << trumpas << ",";

               sveikojiDalis means intpart
              trupmenineDalis means fractionalPart
              sveikas means int
             trumpas means fractional in case this might help


So i have the task to convert from binary to hexademical, decimal and octal. It does convert great to hexademical as stated in this code, by saying great i mean the int part and fractional part seperately. It does convert int parts to decimal and octal correctly aswell but it struggles with fractional part. Do you have any ideas? I hope i said everything correctly
Last edited on
By writing your code full of text in foreign language, you are making others lose pure interest and you will not be getting any help.
Surprisingly, your problem is written in English! I am not sure if it can help, I do not understand any of it actually.
Topic archived. No new replies allowed.