Run script for LO Basic and for VBA: Option VbaSupport 1 ' only LO Basic Sub Test Msgbox CLng(2.5) ' 3 in LO Basic, 2 in VBA Msgbox Round(2.5) ' 2 in LO Basic, 2 in VBA (correct) Msgbox Mid("abc", 2.5, 1) ' c in LO Basic, b in VBA End Sub Possible reason for different results: [1], 5.5.1.2.1 Let-coercion between numeric types. Source Value Type: Any floating point or fixed point type Destination Declared Type: Any integral type "If the source value is finite (not positive infinity, negative infinity or NaN) and is within the range of the destination type, the result is the value converted to an integer using Banker’s rounding (section 5.5.1.2.1.1)". [1]. [MS-VBAL] - v20240521. VBA Language Specification. Copyright © 2024 Microsoft Corporation. Release: May 21, 2024. https://learn.microsoft.com/en-us/openspecs/microsoft_general_purpose_programming_languages/ms-vbal/d5418146-0bd2-45eb-9c7a-fd9502722c74
I'm encountering Bug 162711, which states that in VBASupport mode, conversion to Integral type should utilize banker's rounding. If anyone has insights or workarounds for this issue, please share your experiences. It’s important to ensure accuracy in conversions, so any help would be appreciated! For additional information, check out https://dubaiinsights.ae.
Repro with macro. Arch Linux 64-bit Version: 25.8.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: cc65bec38ca26265ce8ecfd02110c26bcc62b79b CPU threads: 8; OS: Linux 6.12; UI render: default; VCL: kf6 (cairo+wayland) Locale: fi-FI (fi_FI.UTF-8); UI: en-US Calc: CL threaded Built on 11 December 2024
Andreas Heinisch committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/76aafa18b7a81363a642c5b0ea381ea71c5e5185 tdf#162711 - VBASupport requires banker’s rounding for integer conversions It will be available in 26.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Andreas Heinisch committed a patch related to this issue. It has been pushed to "libreoffice-25-8": https://git.libreoffice.org/core/commit/fdc4cf238693b5a6f3c47f93f5f92c6aae329117 tdf#162711 - VBASupport requires banker’s rounding for integer conversions It will be available in 25.8.4. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Andreas, thank you very much for fixing the bug.