https://bugs.documentfoundation.org/show_bug.cgi?id=152739
Bug ID: 152739 Summary: Round ROUND_HALF_UP is OK in Python, but NO in Basic when call the same Python def. Product: LibreOffice Version: 7.1.8.1 release Hardware: All OS: Windows (All) Status: UNCONFIRMED Severity: normal Priority: medium Component: BASIC Assignee: libreoffice-bugs@lists.freedesktop.org Reporter: e...@helpidea.net Description: I have a Python function for round up numbers, that works fine: ' # RoundUP.py file in Script ' from decimal import Decimal, getcontext, ROUND_HALF_UP # # Round UP ' round_context = getcontext() ' round_context.rounding = ROUND_HALF_UP ' # ------------------------------------- ' def roundUp(x, digits, precision=5): ' tmp = round(Decimal(x), precision) ' fRet = float(tmp.__round__(digits)) ' return fRet ' # --------------------------------------------------------------- ' if __name__ == '__main__': ' fRU = roundUp(2.125, 2) # -> 2.13 ' fRU = roundUp(3.125, 2) # -> 3.13 ' fRU = roundUp(-2.125, 2) # -> -2.13 ' fRU = roundUp(4.125, 2) # -> 4.13 ' fRU = roundUp(2.225, 2) # -> 2.23 ' pass I call that function from Basic, and the result change: fRU = RoundUp(2.125, 2) ' 2.12 Now i have 2.12, not 2.13. Why ??? '---BASIC------------------------ Function RoundUp(num, dec) ' Number to Double Up Dim vRoundUp sFunctionPy = "vnd.sun.star.script:RoundUP.py$roundUp"& _ "?language=Python&location=user" oMSPF = createUnoService( _ "com.sun.star.script.provider.MasterScriptProviderFactory") gScriptProvider = oMSPF.createScriptProvider("") oScript = gScriptProvider.getScript(sFunctionPy) vRoundUp = oScript.invoke(Array(num, dec), Array(), Array()) RoundUp = vRoundUp End Function Steps to Reproduce: 1.Copy a RoundUP.py file in Script (the code is in Description above) 2.Run Main in Calc RounUP.ods 3.Examine the different results Actual Results: 2.12 Expected Results: 2.13 Reproducible: Always User Profile Reset: No Additional Info: Version: 7.1.8.1 (x64) / LibreOffice Community Build ID: e1f30c802c3269a1d052614453f260e49458c82c CPU threads: 16; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win Locale: it-IT (it_IT); UI: it-IT Calc: CL -- You are receiving this mail because: You are the assignee for the bug.