To download NI software, including the products shown below, visit ni.com/downloads.
This example demonstrates how to round a number after the decimal point to a specific number of places.
Description
This example code allows the user to round numbers after the decimal place by treating these numbers as integers. For example, assume the user starts with the number 54.345 and wanted to round this number two places after the decimal point. This example would multiply the number by 10^2 to move the decimal two places to the right. The "Round to Nearest" function is then used to round 5434.5 to the nearest integer resulting in 5435. The code will then divide 5435 by 10^2 to move the decimal back to the left by two places. This results in the number 54.35.
Requirements
Software
Hardware
Steps to Implement or Execute Code
Additional Information or References
**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Thanks for posting. Could you please rename your attachment to include the LabVIEW version?