https://bugs.documentfoundation.org/show_bug.cgi?id=162711

            Bug ID: 162711
           Summary: In VBASupport mode, conversion to Integral type must
                    use banker's rounding
           Product: LibreOffice
           Version: unspecified
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: libreoffice-bugs@lists.freedesktop.org
          Reporter: so...@comec92.ru

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

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to