2

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.

NewSites
  • 1,402
  • 2
  • 11
  • 26

1 Answers1

1

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

This will apply the Standard-Formatting to the result.

Ike
  • 9,580
  • 4
  • 13
  • 29
  • Thank you. Comparing your answer to Ron's comment, is "@" shorthand for "General"? – NewSites Mar 17 '22 at 13:03
  • Follow-up question: What if I want to preserve that rounding in the stored value, i.e., get rid of the floating point error? I can do `=value(text(C2, "@"))`. Is that the right way, or is there a more direct method? – NewSites Mar 17 '22 at 13:20
  • @ treats the value as Text - I suppose it's the same like "General" - but I couldn't find a documentation. It makes no difference if you add 'Value' to the function – Ike Mar 17 '22 at 14:00
  • I meant if I want to preserve the number correctly rounded in a new cell by itself as a number. – NewSites Mar 17 '22 at 14:27