Using data type other than int as index value in C++ for loop

c, c++, loops, type-conversion

Solution

You can use an `unsigned long long` which is 264 or roughly 1019

This assumes that your compiler supports 64-bit integers.

Problem

I am accepting an input from user as a float value. This value can go up to "10 raised to power 18". The next step involves finding all the divisors of this number. for which i am doing the following: ``` for(i=2; i<=n/2 ; i++) { if(n%i==0) v.push_back(i); } ``` Here, n is the number entered by the user. Problem is that n is float and using it in if loop index causes it's value to be limited to '10 raised to the power 9' Hence, is there any way to use data type other than int for using values of range '10 raised to power 18'?

Original source