How do I remove trailing zeroes?

What function can I use to remove excessive trailing zeroes after the decimal point?
I have values like 123.00000 123.40000 123.45000 123.45600 123.45670 123.45678
I do not want any unnecessary trailing zeroes; just one if it is x.0

Posted on Jul 29, 2018 2:49 AM

Reply
11 replies

Jul 30, 2018 2:23 AM in response to Apophis

Those "ridiculous little errors" are artifacts of the translation of base 10 (decimal) numbers that include a fractional part being translated to floating point base 2 (binary) numbers of fixed precision for calculation by the computer, then being translated back to base 10 for display.


The problem is a simple one: there are decimal fractions that can be represented exactly in base 10 that simply cannot be represented exactly in fixed precision floating point binary numbers.


Binary floating point calculations follow The IEEE Standard for Floating-Point Arithmetic (IEEE 754), originally written in 1985, the current version (according to the Wikipedia article on the topic) is the 2008 revision.


For the precision expected in 'ordinary' arithmetic, rounding your final result to a set number of places after the decimal will usually suffice. A general rule of thumb is to round final results to a precision no greater than the lowest precision of any input value obtained by measuring.


For either of the 'ridiculous small error' examples supplied above, rounding to any where from 4 to 'one fewer than displayed in the example' places after the decimal should produce the precise result you expect. Rounding to four places will produce that result with no trailing zeros.


ROUND(formula,4)


Regards,

Barry

Jul 30, 2018 2:23 AM in response to Barry

Thanks. My point in describing this problem as "ridiculous little errors" is whilst that there may well be a technical detailed explanation of why it happens, the average user should not have to read up on IEEE 754 to understand out such technical problems. They should be dealt with automatically by the software.
I have ended up appending another column for the calculated value (including the numerous decimal places), with the original column now showing the "ROUND" value.

Jul 30, 2018 10:33 PM in response to Apophis

"Deal(ing) with them automatically" requires knowing the purpose of individual uses of the calculations displaying FP Binary errors. Some spreadsheet developers have chosen to guess that, and have included automatic 'corrections' to fit that guess. Others have chosen to implement IEEE 754 in a manner that permits the individual user to apply no corrections or to choose corrections that fit what they are actually doing, rather than rely on a developer correctly guessing.


If you think Apple has made the wrong choice, and would like to see that corrected, then you should be taking to Apple. Here, your audience is users of the software, not the development team.


Numbers menu,

Provide Numbers Feedback.

Make your request for a feature enhancement to fit your needs.


Regards,

Barry

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do I remove trailing zeroes?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.