Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# -> VB: decimal/double instead of int, byte instead of integer #619

Open
jamieS95 opened this issue Aug 25, 2020 · 1 comment
Open

C# -> VB: decimal/double instead of int, byte instead of integer #619

jamieS95 opened this issue Aug 25, 2020 · 1 comment
Labels
C# -> VB Specific to C# -> VB conversion

Comments

@jamieS95
Copy link

jamieS95 commented Aug 25, 2020

Input code

  private static int GetBit(byte[] h, int i)
        {
            return h[i / 8] >> (i % 8) & 1;
        }

Erroneous output

    Private Shared Function GetBit(ByVal h As Byte(), ByVal i As Integer) As Integer
        Return h(i / 8) >> i Mod 8 And 1
    End Function

Expected output

   Private Shared Function GetBit(ByVal h As Byte(), ByVal i As Integer) As Integer
 Return (CInt(h(i \ 8)) >> ((i Mod 8)) And 1)
end function

Details

@jamieS95 jamieS95 added the C# -> VB Specific to C# -> VB conversion label Aug 25, 2020
@jamieS95 jamieS95 changed the title C# -> VB: _Add a short description_ C# -> VB: decimal/double instead of int, byte instead of integer Aug 25, 2020
@GrahamTheCoder
Copy link
Member

I've updated the erroneous output to the output from the latest version (hosted at codeconverter.icsharpcode.net)
I think there are 3 separate fixes needed:

  • Use Integer division where inputs are integers in c#
  • convert left and right of binary expressions to their expected type
  • add parentheses... Basically everywhere

Getting this particular case working should be reasonably straightforward, there are likely lots of related edge cases that are harder.

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# -> VB Specific to C# -> VB conversion
Projects
None yet
Development

No branches or pull requests

2 participants