Bug 151115 - Percentage cell format appends 00 to number content automatically.
Summary: Percentage cell format appends 00 to number content automatically.
Status: RESOLVED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.5.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Gülşah Köse
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-22 07:08 UTC by Gülşah Köse
Modified: 2022-10-10 15:16 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gülşah Köse 2022-09-22 07:08:22 UTC
Description:
-

Steps to Reproduce:
1. Open LibreOffice Calc
2. Set format of the A1 as percentage.
3. Click three times to A1 (to switch edit mode)
4. Type 5
5. Press Enter

Actual Results:
Result is 500%

Expected Results:
It should be 5%


Reproducible: Always


User Profile Reset: No



Additional Info:
-
Comment 1 Mike Kaganski 2022-09-22 08:54:11 UTC
It works *exactly* the same way in MS Excel. This is likely made intentionally to follow Excel behavior.

First, a note. In Calc (and Excel, and other spreadsheet software), a percent format makes the number in the cell mean "part of a whole"; and number 1.0 (one) is considered "a whole", i.e. "100%". Number 0.5 is shown as "50%", and number 0.01 is shown as "1%". This makes normal arithmetic with such cells work as expected: if I need 30% of number 12345, I put 12345 into A1, put 0.3 to B1, and in C1, I use '=A1*B1'. If I format B1 as percent, I get expected display of 30% there.

When I *enter* a number with trailing % sign, Calc divides that number by 100 for me: if I enter 15%, Calc writes number 0.15 into the cell (and may also auto-format the cell to use percentage format, so that that "0.15" is displayed as "15%" to me).

Now how *Excel* behaves with pre-formatted percentage cells:

1. If you do not enter the edit mode (double-click on the cell) prior to typing, it automatically appends the "%" sign to the entered number, so user sees the added percent immediately; the number is processed then with that percent sign, and correctly divided by 100, so a number "5" that you typed will be shown "5%" when you edit, will be converted to 0.05, and stored in the cell (and shown back as "5%").
2. If you enter the edit mode before typing into the cell, it does not add anything to your input, allowing you to enter whatever numbers literally, and thus your "5" will become "5" in the cell value, without any change, and will be shown as "500%" back.

Calc behaves exactly the same way.

Should it be changed?
Comment 2 Roman Kuznetsov 2022-09-25 09:10:11 UTC
What number will be in that cells if I change view from percent to number?

I'm not sure current behaviour should be changed
Comment 3 Eike Rathke 2022-09-25 16:19:05 UTC
Cell values don't change if you change the display format, e.g. display will change from 500% to 5.

This is about *entering* values and the difference whether edit view mode was activated before (no % appended to edit string), or input directly i.e. by just typing digits (% appended if numeric).

I tend to appending a % character also in the already activated edit view because it would be logical as it would be what the user will see after having closed input without being surprised the display is actually what they entered (5 -> 500%), but that then would differ from Excel; hence the illogical behaviour Calc currently has..
Comment 4 Mike Kaganski 2022-09-25 16:53:37 UTC
(In reply to Eike Rathke from comment #3)

IMO, appending the percent also when the edit mode was pre-activated, would also be logical; only when the edit box was empty or had been cleared.

FTR: Google Sheets behave differently in this case: they keep "5", but change cell format from % to generic number.

Possibly that could be a license to be "original" (deviate from Excel), and do append the % in the discussed case?
Comment 5 Eike Rathke 2022-09-29 14:30:29 UTC
Yes, that's what I meant to express, if it didn't come across..
Empty cell -> F2 -> number character typed (digit or minus sign or decimal sperator) -> append % after cursor.
Comment 6 Gülşah Köse 2022-10-10 13:35:25 UTC
Thanks to everyone. Mike is right. For a reason(Still hard to understand for me but that is same for all other apps too.) It is normal to turn 5 to 500%. I'm closing that bug report because i described it wrong. Actual bug is related with online side but instead of edit this report I'll create a new report to be more clear.