[Calc] number format: show two digit only if any decimal is present

Hi folks,
I’d like to format my cells in order to show two digits with any decimal part,
but only if number have decimal!

e.g.:

123,4567 → 123,46
123,45 ----> 123,45
123,4 ------> 123,40
123 --------> 123

Any hints?

Thanks

EDIT: add integer example

Meant “Number is not integer.”?

Let it be.
I cannot imagine a good reason to do so.
= =
If there can actually be one, you need to understand that Calc has no special type Integer. All numeric cell values are internally represented in the same way. To test numbers for being integer can use the Boolean expression INT(mynumber)=mynumber but has to accept that a rounding to about 16 significant digits is applied.
If this is accepted, a condotional format can be applied. (Use a monotype font then.)

See
disask_134439_funnyformat.ods (7.5 KB)

2 Likes

select the cells in question and apply a cell-style with numberformat-code: 0,00

1 Like

No, because when I have an integer number, that format style will show “,00”
e.g.:
150 → 150,00
While I want integer numbers, that’s without a decimal part,
to be displayed without the ugly ‘,00’ part

What you want is probably only possible with conditional formatting with two conditions.

In the first condition, you check for numbers with a non-zero remainder and assign a corresponding cell style (0.00). In the second condition, you check for a remainder of zero and create a corresponding cell style (0).

zero or not zero 1.ods (11,6 KB)

3 Likes

Numbers are not made to be pretty, but to present unmistakeable information.
Lupp personally finds columns of decimal numbers which aren’t aligned according to the positional values very ugly.
It took me some willpower to make the CF example for you.

format 0,##

2026-04-28 13 55 56

You won’t achieve that with your suggestions

There are more things in heaven and earth, Horatio, / Than are dreamt of in your philosophy.

@Lupp and @PKG , we’re in the world of approximate calculations. We can check whether a (double) number is an integer like this:

=ABS(A1 - ROUND(A1, 0)) < 0.0000000001

Set the number format code as 0,## (if your decimal separator is a comma). The # symbol means “does not display extra zeros”. This is explained in the Help content (“Number Format Codes”).