Bug 105107 - Implementation of Round in Basic
Summary: Implementation of Round in Basic
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.2.4.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-04 18:46 UTC by Emersson Augusto Suarez Ortiz
Modified: 2024-01-24 19:44 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 Emersson Augusto Suarez Ortiz 2017-01-04 18:46:28 UTC
Description:
Hi, I noted that Round is not yet implemented in Basic, so, you can rounded a cell in calc, but you can't get the same value from Basic. May be it could be implemented soon in newest versions.

Actual Results:  
You simplement can't use the function 

Expected Results:
Rounded a value to 1, 2, 3 or desired decimal precision.


Reproducible: Always

User Profile Reset: No

Additional Info:


User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0
Comment 1 Buovjaga 2017-01-05 11:14:03 UTC
Sounds sensible -> NEW
Comment 2 Takeshi Abe 2018-12-24 02:38:49 UTC
Round() is available only in the VBA compatibility mode, which you can
enable using "Option Compatible" or "Option VBASupport 1".
Is it better to have it in the normal mode too?
Comment 3 b. 2021-02-04 19:51:59 UTC
In reply to Takeshi Abe from comment #2)
> Is it better to have it in the normal mode too?

yes, of course, not having it is a massive lack in functionality, having to search / investigate first is a massive lack in comfort, 

one can make normal round accessible for macros by 'wrapping it in a procedure call?': 

function round_a (ByVal darg1 as Double, iarg2 as integer)
'bs: 2020-10-27
'make "ROUND" functionality accessible from basic macros, 
'out of duty as limited to 20 decimals, 
oFunctionAccess = createUnoService( "com.sun.star.sheet.FunctionAccess")
round_a = oFunctionAccess.callFunction( "ROUND", array(darg1, iarg2)) 
end function 'round_a

but better would be to have it as a normal basic function, and! one without flaws, afaik nearly all rounding in calc still has errors :-(
Comment 4 Rafael Lima 2024-01-24 19:44:07 UTC
I've tested this today, and as of LO 7.6 the Round function is available without the need for Option Compatible or VBASupport.

The code below runs fine in Basic:

Sub TestRound
    Msgbox Round(1.536, 1)
End Sub

Tested with:

Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: 60(Build:1)
CPU threads: 16; OS: Linux 6.5; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Ubuntu package version: 4:7.6.4-0ubuntu0.23.10.1
Calc: threaded

I'm closing this as WFM. Feel free to reopen if necessary.