Home > other >  How to emulate Excel's automatic rounding?
How to emulate Excel's automatic rounding?

Time:03-18

When Excel reports the results of a floating point calculation, it appears to round it to the correct precision based on the significant digits in the input numbers. But if I include the result in a text string, it includes the full precision, including the floating point error:

enter image description here

How can I get the text version to use the same rounding as Excel uses in displaying the number? I suppose I could calculate the maximum number of digits of precision of the input numbers and round() to that precision. Is there an easier/better way?

Using Excel 2019.

CodePudding user response:

You can use: ="The result is " & TEXT(C2,"@")

This will apply the Standard-Formatting to the result.

  • Related