To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=107277
                 Issue #|107277
                 Summary|basic: adding currency values overflows when result > 
                        |(2^31)/10000
               Component|framework
                 Version|OOo 3.1
                Platform|All
                     URL|
              OS/Version|Windows XP
                  Status|UNCONFIRMED
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P3
            Subcomponent|scripting
             Assigned to|kr
             Reported by|jsatrus





------- Additional comments from jsat...@openoffice.org Fri Nov 27 19:38:06 
+0000 2009 -------
Try the code below. When you add 2 Currency values and the result is bigger than
(2^31)/10000 the number you get is not expected, is like an overflow.
It does not matter if the numbers you are adding are smaller or bigger than
(2^31)/10000  (like problems because the result needs more than 4 bytes)
(3 different patterns to choose in the code by removing REMs)

I guess this bug should also happen in other OSs

REM  *****  BASIC  *****
REM P0WER(2;31) = 2.147.483.648      (using the "." as thousand separator)
REM POWER(2;31)/10000 = 214.748,3648

Const inc As Currency = 1
Const basenumber As Currency = 214745
Const topnumber As Currency = 214750

REM     Const inc As Currency = 2000
REM     Const basenumber As Currency = 300000
REM     Const topnumber As Currency = 310000

REM     Const inc As Currency = 300000
REM     Const basenumber As Currency = 300000
REM     Const topnumber As Currency = 1000000

Sub Main
        Dim NewTotalPrice As Currency
        Dim OldTotalPrice As Currency
        
        OldTotalPrice = basenumber
        Do      While OldTotalPrice < topnumber
                NewTotalPrice = OldTotalPrice + inc
                MsgBox "Adding " & inc & " to " + OldTotalPrice + " results " & 
NewTotalPrice
                OldTotalPrice = NewTotalPrice
        Loop

End Sub

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@framework.openoffice.org
For additional commands, e-mail: issues-h...@framework.openoffice.org


---------------------------------------------------------------------
To unsubscribe, e-mail: allbugs-unsubscr...@openoffice.org
For additional commands, e-mail: allbugs-h...@openoffice.org

Reply via email to