Bug 155148 - CDbl is locale dependent but should not be
Summary: CDbl is locale dependent but should not be
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:24.2.0
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-04 14:47 UTC by Regina Henschel
Modified: 2023-07-21 12:06 UTC (History)
3 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 Regina Henschel 2023-05-04 14:47:48 UTC
Execute the following macro (Put the macro in any module in your Standard library, go to a document, press Alt+F11, select the macro and run it.)

sub decimalTest
dim sValue as string
sValue = InputBox("use a decimal point", "CDbl test", "0.5")
dim fValue as double
fValue = CDbl(sValue)
MsgBox("received " & fValue)
end sub

When I enter 0.4 in the input box, I get 4 in the MsgBox.
When I enter 0,4 in the input box, I get 0,4 in the MsgBox.

These are the results when my local setting is "Germany". When I set the local to "English US" I get 0.4 from 0.4 input as expected.

The help states, that CDbl expects a decimal point, but that is not the case for me.
https://help.libreoffice.org/latest/de/text/sbasic/shared/03100400.html?DbPAR=BASIC#bm_id3153750

The problem is likely inherited from OOo. I see the local dependency in AOO too.
Comment 1 himajin100000 2023-05-04 15:55:47 UTC
just a reminder for myself:

https://learn.microsoft.com/en-us/office/vba/language/concepts/getting-started/type-conversion-functions

>You should use the data-type conversion functions instead of Val to provide internationally aware conversions from one data type to another. For example, when you use CCur, different decimal separators, different thousand separators, and various currency options are properly recognized depending on the locale setting of your computer.

https://opengrok.libreoffice.org/xref/core/basic/source/sbx/sbxscan.cxx?r=c76fb95d&fi=ScanNumIntnl#271
Comment 2 Buovjaga 2023-05-12 14:58:13 UTC
I get

Inadmissible value or data type.
Data type mismatch.

Arch Linux 64-bit, X11
Version: 7.6.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: 39b25518ce96a50f54459f681edcb95057507251
CPU threads: 8; OS: Linux 6.3; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 12 May 2023
Comment 3 Andreas Heinisch 2023-07-20 08:11:36 UTC
Repro in:

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: cf5142abbf1ea358e187f1d160c6b339ea11c0b9
CPU threads: 16; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-US
Calc: CL threaded

Same behaviour in M$.
Comment 4 Andreas Heinisch 2023-07-20 08:12:03 UTC
So should we update the help pages for CDbl and CSng accordingly?
Comment 5 Regina Henschel 2023-07-20 13:53:47 UTC
(In reply to Andreas Heinisch from comment #4)
> So should we update the help pages for CDbl and CSng accordingly?

As the local is considered for long time already and considered in MS Office too, I would say yes, update the help pages.
Comment 6 Commit Notification 2023-07-21 12:03:29 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/1c52b29e3858fd600a651635d4d4172a4a5d04d9

tdf#155148 - Reflect the fact that CDbl/Csng is locale dependent