09-06-2022 08:36 AM
hello,
i have integer number which is variable 0.869231 and i want to round it nearest number after two decimal points such as 0.869231 should be 0.87 if it is 0.986858 the it should be 0.99.. how can i do it?
thank you
Solved! Go to Solution.
09-06-2022 08:46 AM - edited 09-06-2022 08:46 AM
Hi new,
@newmemeber123 wrote:
i have integer number which is variable 0.869231 and i want to round it nearest number after two decimal points such as 0.869231 should be 0.87 if it is 0.986858 the it should be 0.99.. how can i do it?
So you have float numbers like 0.8692? And you want to round them to 2 significant digits?
Do you want to round them just for display purposes (see item 1) or do you want to use the rounded values later on for other calculations (see item 2)?
09-06-2022 08:48 AM - edited 09-06-2022 08:49 AM
Multiply by 100, round to nearest integer, divide by 100.
09-06-2022 08:50 AM - edited 09-06-2022 08:52 AM
First, you have a floating point number. Integers are whole numbers 0, 1, 2, 3...
Multiply by 100, (or 10^nth where n is the number of places after the decimal point) round then divide by 100 (or 10^nth.)
Edit: I guess I type slow
09-06-2022 11:57 AM - edited 09-06-2022 11:58 AM
Just wanted to add that if you just wanted to compare two numbers (like a test result to a requirement specified to two decimal places), you can do the multiplication,as in the previous posts, for both the result and the requirement, round each to the nearest integer and then do your comparison. This will avoid floating point issues.