Bug 90826 - number format with text gives sign at wrong position
Summary: number format with text gives sign at wrong position
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.5.0 release
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Number-Format
  Show dependency treegraph
 
Reported: 2015-04-24 08:57 UTC by Robert Pollak
Modified: 2020-06-20 13:07 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
screenshot of the bug (43.38 KB, image/png)
2015-05-15 09:10 UTC, Robert Pollak
Details
test file (8.73 KB, application/x-vnd.oasis.opendocument.spreadsheet)
2015-05-17 19:24 UTC, raal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Pollak 2015-04-24 08:57:46 UTC
When using the format code <"d =" 0.00> on a cell containing -1.23, the cell wrongly displays "-d = 1.23" instead of "d = -1.23".

(Seen with LO 4.3.6.2)
Comment 1 Joel Madero 2015-04-25 03:41:21 UTC
This is not a bug - just the incorrect number format.

Set to "d="#.## without the <> and you'll get the right answer
Comment 2 Robert Pollak 2015-05-07 10:12:32 UTC
Sorry, I have been unclear. I was using the angle brackets to quote the format code - I did not use them *in* the code.

I did not know that the # sign can be used instead of 0. However, using "d="#.## still gives me the wrong -d=1.23 . Can't anyone reproduce this?

Maybe it's dependent on the localization settings. I am using German LibreOffice on German Windows 7, with the standard document language set to English (USA) to get a period as decimal separator (bug 46448).
Comment 3 Joel Madero 2015-05-07 14:46:40 UTC
REOPENED is incorrect status - moving to UNCONFIRMED.
Comment 4 Buovjaga 2015-05-15 07:34:51 UTC
Could not reproduce.

Please test with 4.4.3.
For completeness: what operating system are you using?

Set to NEEDINFO.
Change back to UNCONFIRMED, if the problem persists. Change to RESOLVED WORKSFORME, if the problem went away.

Win 7 Pro 64-bit, Version: 4.4.3.2
Build ID: 88805f81e9fe61362df02b9941de8e38a9b5fd16
Locale: fi_FI
Comment 5 Robert Pollak 2015-05-15 09:07:53 UTC
Ok, I am now on 4.4:

Version: 4.4.3.2
Build-ID: 88805f81e9fe61362df02b9941de8e38a9b5fd16
Gebietsschema: de_AT

The language settings are now all set to default:
Benutzeroberfläche (User Interface): Standard - Deutsch (Deutschland)
Gebietsschema (Localization Scheme): Deutsch (Österreich)
Standardsprachen der Dokumente - Westlich (Standard language): Deutsch (Österreich).

The bug remains: Using "d="#,## gives me -d=1,23 .
(I am always testing in new documents.)

Switching localization scheme and standard language to English (USA) does not help. I will attach a screenshot.

I assume the user interface language depends on the Windows language? Btw., I'm seeing this on two different machines, with Windows 7 Pro 64-bit.
Comment 6 Robert Pollak 2015-05-15 09:10:19 UTC
Created attachment 115617 [details]
screenshot of the bug
Comment 7 raal 2015-05-17 19:24:04 UTC
Created attachment 115684 [details]
test file

I can confirm with LO Version: 4.4.4.0.0+
Build ID: 1a2a094795e10f514eb421e68bbd705ea5251b76
TinderBox: Linux-rpm_deb-x86_64@46-TDF, Branch:libreoffice-4-4, Time: 2015-05-14_09:47:46
anf LO 3.5
Comment 8 QA Administrators 2016-09-20 09:41:52 UTC Comment hidden (obsolete)
Comment 9 Robert Pollak 2016-09-21 07:24:07 UTC
I still see the but (e.g. with raal's attached test file) in:
Version: 5.2.1.2
Build-ID: 31dd62db80d4e60af04904455ec9c9219178d620
CPU-Threads: 8; BS-Version: Windows 6.1; UI-Render: Standard; 
Gebietsschema: en-US (de_AT); Calc: group
Comment 10 Xisco Faulí 2017-09-29 08:52:18 UTC Comment hidden (obsolete)
Comment 11 Xavier Van Wijmeersch 2017-09-30 08:00:44 UTC
The problem is still there, there is a in between solution, not a nice one

"d= "-#.## 

So entering 1.23 will give you "d= -1.23"

tested with

Version: 6.0.0.0.alpha0+
Build ID: 19910c461230f70bb9e98ad44db3525f0d755724
CPU threads: 8; OS: Linux 4.9; UI render: default; VCL: kde4; 
Locale: nl-BE (en_US.UTF-8); Calc: group;

and 5.4.3
Comment 12 QA Administrators 2018-10-01 02:53:58 UTC Comment hidden (obsolete)
Comment 13 Robert Pollak 2018-10-02 21:22:21 UTC
I still see the bug in 6.0.6.2 on Linux Mint 19.
Comment 14 QA Administrators 2019-10-03 02:59:30 UTC Comment hidden (obsolete)
Comment 15 Robert Pollak 2019-10-04 09:29:06 UTC
I still see the bug (with raals test file) on

Version: 6.3.1.2
Build ID: 1:6.3.1~rc2-0ubuntu0.18.04.1~lo1
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: en-US (en_DK.utf8); UI-Language: en-US
Calc: threaded

Note that Xavier's comment 11 is not a workaround, since it includes manually replacing negative values by positive ones. This does not work for computed values with arbitrary sign.
Comment 16 Roman Kuznetsov 2020-06-07 16:18:29 UTC
repro in

Version: 7.1.0.0.alpha0+
Build ID: 2047a5978ac8188e61da9cd3b2f40d86df5570bb
CPU threads: 4; OS: Mac OS X 10.15.5; UI render: default; VCL: osx
Locale: ru-RU (ru_RU.UTF-8); UI: en-US
Calc: threaded
Comment 17 Laurent Balland 2020-06-07 18:37:10 UTC
You must defined your positive and negative format:
"d = "0.00;"d = "-0.00
or
"d = "0.00;"d = minus"0.00

Calc cannot guess where you want your negative sign. For instance, you may want it on left side of the cell:
+* 0.00;-* 0.00

If you do not define a format for negative values, then Calc use as default:
-format for positive value

Check help about Number format codes:
https://help.libreoffice.org/6.4/en-US/text/shared/01/05020301.html?DbPAR=SHARED#bm_id3153514
Comment 18 Buovjaga 2020-06-07 18:39:34 UTC
Thanks, Laurent. Looks like this was never a bug, so tweaking status.
Comment 19 Robert Pollak 2020-06-08 11:12:59 UTC
For me and four other commenters here this violates the principle of least surprise.

What about the definition:
If you do not define a format for negative values, then Calc uses the format for positive value as default, with "-" inserted in front (or wherever the locale demands) of the _actual_number_.

Why should the sign be anywhere else in this case?
Comment 20 Laurent Balland 2020-06-18 19:34:12 UTC
(In reply to Robert Pollak from comment #19)
> For me and four other commenters here this violates the principle of least
> surprise.
> 
> What about the definition:
> If you do not define a format for negative values, then Calc uses the format
> for positive value as default, with "-" inserted in front (or wherever the
> locale demands) of the _actual_number_.
> 
> Why should the sign be anywhere else in this case?

I just described how spreadsheets work from decades.
There exists many conventions to represent negative number (colored in red, between brackets). The default one was defined as "add a minus sign on the most left position". If you prefer a different one, you can define it through format codes given above. Changing default behavior is quite risky.
Comment 21 Robert Pollak 2020-06-20 13:07:39 UTC
> Changing default behavior is quite risky.

You are right. So I suggest adding the minus (-) sign as a new placeholder in number format codes, telling where the minus of negative numbers should be displayed.
This would yield the simple format code "d =" -0.00 for my case.