Search code examples
c++integerdecimaldigitsrational-numbers

Transform rational numbers to integers


How can I transform rational numbers like 1.24234 or 45.314 into integers like 124234 or 45314 also getting the number of decimal digits?


Solution

  • Convert to a string

    Find the position of the decimal point.

    Subtract that from the length of the above string, for the number of decimals.

    Then take the point out of the string.