Reputation: 69
Without using any STL library function, can anyone kindly explain to me how to take a big int, lets say 288895 into something like 2888 and 95? I have trouble thinking of a proper solution.
For Example 288895 could be used to store both the employee number and the score employee got as his rating. I want it to be split into 2888 for student number and 95 for the exam.
Edit* I have thought of separating this into a string, using
substr(1,4)
in order to recreate a new string for the first part and using substr() again to recreate the string for the second part. Then I would return the function using these strings, I wonder if that was a viable option to apart from using the % operator like the comments suggested...
Thank You.
Upvotes: 0
Views: 70
Reputation: 106
I would look at using the mod (%
) operator. 288895 % 100
gives 95
, and you can integer divide by 100
so 288895 / 100
gives you the 2888
.
Upvotes: 2