Hi,
For an integer say 123456, how do i extract the rightmost 3 digits (456) from that integer?
thx
Hi,
For an integer say 123456, how do i extract the rightmost 3 digits (456) from that integer?
thx
you could try a string approach
http://msdn.microsoft.com/library/de...acmausitow.asp
Code:int x = 123456; int y = x % 1000; //Now y is 456
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
Oh modulus the beautiful.... Xsquared beat me to it.
Code:#include <vector> ... ... vector <int> breakdown(int number) { vector<int> buffer; while(true) { if(number / 10 == 0) { buffer.push_back(number); break; } buffer.push_back(number % 10); number /= 10; } return buffer; }
"If you tell the truth, you don't have to remember anything"
-Mark Twain