J
j_depp_99
My program reads in hex values from a file and then performs
arithmetic operations on them. All works well except when I use large
hex values and my answers are incorrect. For example 10000000000000-1
should give
FFFFFFFFFFFFF but it does not. I considered converting to decimal to
solve my problem but I'm not sue how to convert my string variable
into a decimal value.
Here's a snippet of my code:
I first convert my two strings into hex, then perform the subtraction,
but when I check the value of num7, it does not display
10000000000000. The other operations also involve large hexadecimal
values. Is there perhaps a limit on the length C++, can handle?
<code\>
istringstream(op5) >> std::hex >> num7;
istringstream(op6) >> std::hex >> num8;
cout << op5 << "-" << op6 << "=";
num9= num7-num8;
cout.flags(ios::hex);
cout << uppercase << hex << num9 << endl;
</code>
Thanks
arithmetic operations on them. All works well except when I use large
hex values and my answers are incorrect. For example 10000000000000-1
should give
FFFFFFFFFFFFF but it does not. I considered converting to decimal to
solve my problem but I'm not sue how to convert my string variable
into a decimal value.
Here's a snippet of my code:
I first convert my two strings into hex, then perform the subtraction,
but when I check the value of num7, it does not display
10000000000000. The other operations also involve large hexadecimal
values. Is there perhaps a limit on the length C++, can handle?
<code\>
istringstream(op5) >> std::hex >> num7;
istringstream(op6) >> std::hex >> num8;
cout << op5 << "-" << op6 << "=";
num9= num7-num8;
cout.flags(ios::hex);
cout << uppercase << hex << num9 << endl;
</code>
Thanks