How can I suppress the decimal point and trailling zeros in decimal places?

I’m trying to format a number so that:

  • If it’s an integer, only the integer is displayed
  • If there are decimal places, a maximum of two are displayed
  • Any trailing zeros in decimal places are not displayed
  • The decimal point is only shown when it is required
  • Negatives and numbers higher than 10 are not relevant

This image shows what I’ve tried and I go into a bit more detail below that. Please note that the ‘Ideal Solution’ column has been graphically edited from the output shown in the ‘Number’ column.
LibreOffice Calc Numeric Formatting

I looked in the Help and found the section on number formats (file:///usr/share/libreoffice/help/en-GB/text/shared/01/05020301.html).

I applied the format 0.?? as the documentation states:

The ? works as the # but adds a space character to keep decimal alignment if there is a hidden non-significant zero.

As you can see from the image, the decimal alignment only works if you’re using a monospace font. This may be a bug, but I don’t know the software well enough to decide. I tried to fix this by using the underscore character to specify space width, but found that it was for inserting an actual space rather than specifying the width of all spaces in the format.

At this point, I’m assuming that what I want to achieve is not possible, and I’m using the monospace font approach.

So two questions:

  • Am I right, and I can’t get the format I’m after?
  • Is the decimal alignment using a proportional font a bug I should report?

You must do calculation with these numbers?


EDIT:
imagen

2 Likes

No calculation is required. This is purely to display numbers entered directly into the cells.

Unless you are saying that I need to do some kind of calculation to get the output I want?

Note tdf#158890. The width of ? should correspond to figure space U+2007 since 24.8.

I was asking for that, while thinking in a solution with numbers as text. But this is not needed.
Just select the Standard number format (as @karolus stated), and change the Alignment and Indent as shown in my first comment.
imagen

1 Like

I didn’t see the image the first time I saw your reply, but the image solved it for me. Many thanks.

Could you tell me how to align the number 12 reasonably?
I can’t believe that somebody is satisfied with
grafik

@Lupp definitely, if one takes the explicit:

Oh dear!
I didn’t read that to the end. Sorry!
(But I still can’t think of a use-case.)

your asking exactly for Standard-Number-format!

1 Like

I’m not clear on what ‘standard’ means. The only thing I can see that sounds similar is ‘General’.

Can you provide a format string so I can understand what the format is?

I don’t see a problem.
Number format: # ##0,??

Снимок экрана 2025-06-24 160429

As @SlowLearner1 explained, and shown in the comparison screenshot, the picture that you show differs from the ideal case, when there is no decimals. The ideal solution will not include decimal separator.

However, the “adjust to decimal separator” seems to imply the decimal separator :slight_smile:

:slight_smile:
It’s possible that the author of the topic has a version of LO earlier than 24.8.
Thanks to the developers for fixing the bug tdf#158890.

That’s exactly the case. I’m running version 24.2. I’ve verified that the bug fix tdf#158890 would have been a solution, by trying out 25.2.4 on another machine, but I don’t want to update my existing version as I only use it rarely.

1 Like

(post deleted by author)

without words
000_LO-CALC_stupid number formatting_104827.ods (17.6 KB)