Bug 158092 - BASIC, Format: Format (…, "Currency") cuts decimal places
Summary: BASIC, Format: Format (…, "Currency") cuts decimal places
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.6.2.1 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: BASIC-IDE
  Show dependency treegraph
 
Reported: 2023-11-06 16:47 UTC by Robert Großkopf
Modified: 2023-11-10 21:26 UTC (History)
1 user (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 Robert Großkopf 2023-11-06 16:47:13 UTC
Try this procedure with German locale settings:

SUB Formattest
	msgbox Format(123.546, "Currency")
END SUB

Will show 124 € instead of 123,55 €.
Decimal separator and decimal places will be lost.
Value will be rounded without decimal places.

Bug appears in
Version: 7.6.2.1 (X86_64) / LibreOffice Community
Build ID: 56f7684011345957bbf33a7ee678afaf4d2ba333
CPU threads: 6; OS: Linux 5.14; UI render: default; VCL: kf5 (cairo+xcb)
Locale: de-DE (de_DE.UTF-8); UI: de-DE
Calc: threaded

and also in every older version installed here.
Comment 1 Werner Tietz 2023-11-07 15:34:19 UTC
Hello Robert

I wouldn't expect Basic to follow localizations, just use the dot as a decimal separator.

```
SUB Formattest
	msgbox Format(123.546 ,"#,##0.00 €")
END SUB

The output of the msgbox is then localized
Comment 2 Robert Großkopf 2023-11-07 17:41:07 UTC
(In reply to Werner Tietz from comment #1)
> Hello Robert
> 
> I wouldn't expect Basic to follow localizations, just use the dot as a
> decimal separator.
> 
> ```
> SUB Formattest
> 	msgbox Format(123.546 ,"#,##0.00 €")
> END SUB
> 
> The output of the msgbox is then localized

… but Format(123.546, "Currency") would run well in AOO (tested with AOO 4.1.8) and did run in the past with OpenOffice. So I thought it is intended to follow localization. Your code will run well, but doesn't follow the localization. 
Format(123.546, "Currency") will have a look at the localization (€-sign is set right) but will suppress decimal places.
Comment 3 Werner Tietz 2023-11-10 13:02:13 UTC
Hallo Robert

seems locale-related?!

If I switch the UI to **en-US** the Example works as expected:

```
SUB Formattest
	msgbox Format(123.546, "Currency")

'##############
'# 123,55 € 
'############## 
END SUB


```
Version: 7.6.2.1 (AARCH64) / LibreOffice Community
Build ID: 56f7684011345957bbf33a7ee678afaf4d2ba333
CPU threads: 4; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: de-DE (de_DE.UTF-8); UI: en-US
Flatpak
Calc: threaded
```
LO 7.4.7.2 shows the same behaviour

 with UI: en-US  →→ 123,55 €   # ok!
 with UI: de-DE  →→ 123 €      # not ok!