I have two unsigned long long int variables that i want to compare (such as >=, == etc) and occasionally want to apply arithmatic to (simple - operations mainly).
For example if i have two unsigned long long int variables:
a = 3316757944182080000
b = 1284800371338750000
and i want to subtract b from a (such as: c = a -b) i end up getting rubbish data in c:
that is c prints as (1.64148E+19) where c should actually equal (2.03196E+18).
D:\prog\cc\foo> copy con a.cpp
#include <iostream>
using namespace std;
int main()
{
typedef unsigned long long int huge;
huge a = 3316757944182080000ULL;
huge b = 1284800371338750000ULL;
huge c = a - b;
cout << c << endl;
return 0;
}
^Z
1 file(s) copied.
D:\prog\cc\foo> g++ a.cpp
D:\prog\cc\foo> a
2031957572843330000
D:\prog\cc\foo> _
Turn on all your compiler warnings and tell us what you get (and what compiler you are using).