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.
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
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
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$.
So should we update the help pages for CDbl and CSng accordingly?
(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.
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