Bug 162711 - In VBASupport mode, conversion to Integral type must use banker's rounding
Summary: In VBASupport mode, conversion to Integral type must use banker's rounding
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-StarBasic
  Show dependency treegraph
 
Reported: 2024-08-30 14:02 UTC by Vladimir Sokolinskiy
Modified: 2024-10-09 03:16 UTC (History)
2 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 Vladimir Sokolinskiy 2024-08-30 14:02:24 UTC
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
Comment 1 Tayi 2024-10-08 17:22:48 UTC Comment hidden (spam)