[Libreoffice-bugs] [Bug 142048] New: Long hexadecimal values are wrongly interpreted as Integers when they start with zeroes

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Mon May 3 07:40:44 UTC 2021


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

            Bug ID: 142048
           Summary: Long hexadecimal values are wrongly interpreted as
                    Integers when they start with zeroes
           Product: LibreOffice
           Version: unspecified
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: libreoffice-bugs at lists.freedesktop.org
          Reporter: jean-francois.nifenecker at laposte.net

In Basic, when a numerical value is declared as hexadecimal (ex: MyVar =
&H00008000), the starting zeroes are ignored. Thus the resulting number is
wrongly interpreted (value and type). This also applies to constants declares.

This breaks code. I was mostly programming under v.5.4 without glitches. Since
I upgraded to 7.0.5, the problem has arisen. This problem seems related to bug
#62326 fix (applicable to 6.4).

The code below shows the problem:

Sub TestHex()

        Dim MyInt As Integer
        Dim MyLong As Long
        Dim MyVariant As Variant

        'type 2 = integer ; 3 = long
        'Rule: when the most significant bit is 1, should return a negative
value (see bug #62326).
        'see: https://bugs.documentfoundation.org/show_bug.cgi?id=62326

        'should be: -32768, 2
        MyInt = &H8000
        MsgBox MyInt & Chr(10) & VarType(MyInt)         'OK. returns: -32768, 2

        'should be: 32768, 3
        MyLong = &H00008000
        MsgBox MyLong & Chr(10) & VarType(MyLong)       'NOK. returns: -32768,
3

        'should be: 32768, 3
        MyVariant = &H00008000
        MsgBox MyVariant & Chr(10) & VarType(MyVariant)         'NOK. returns:
-32768, 2

End Sub

I consider this to be a major or critical bug because it actually breaks code.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210503/2f245714/attachment-0001.htm>


More information about the Libreoffice-bugs mailing list