Obtain Numbers After Decimal Point as Integer

Updated Oct 22, 2023

Reported In

Software

  • LabVIEW

Issue Details

I would like to know if there is a way to obtain only the numbers after the decimal point and have them as an integer, for further processing.

Solution

There is not a function to automatically get those numbers as an integer. However, you can use this picture as a guide for the code to achieve it:



First, use the Format Into String.vi  function to have a set amount of decimal point numbers into a string form. The '.16f' modifier in the format string input gives a 16 digit format to the number. The '#' modifier eliminates the trailing zeros, in case the number does not have enough decimal digits.

After that, the Scan From String.vi eliminates the '0,' expression, leaving just the number to be stored into the number format that the user would like to use, like a double or an integer.

If you have any questions about using these functions, please refer to the related links for detailed information about them.

Once you have done this, you will get the number as seen in the following image:

Additional Information

You need to have into account the limits for each data type, and remember to modify the indicators to be able to show enough digits of precision.