Convert double to integer without function

Oct 29, 2019 at 4:06am
Hello,
Can I convert double to integer without function? e,g. 0.75 to 75 or 12.9064 to 129064

I think we have to multiply the number by 10, but what is final condition for the end of loop?
Oct 29, 2019 at 4:29am
Oct 29, 2019 at 9:00am
Shervan360 wrote:
Can I convert double to integer without function


Not reliably. The fact that there is typically 6 digits precision doesn't mean your double is precisely 12.9064 ... it will be stored to the nearest binary representation of floating-point numbers. So, how many digits it is depends on what precision you are measuring to.

You could, of course, just input it as a string and then simply erase the decimal point!
Topic archived. No new replies allowed.