none
I have a hex number Aabcdeff .I have to binary rotation of 5 .how can we do that in VB.net and also hex can be abcdeff that isnot in multiple of two in that case it should take as 0abcdeff and then convert to b RRS feed

  • Question

  • Question
    You cannot vote on your own post
    0
    I have a hex number Aabcdeff .I have to binary rotation of 5 .how can we do that in VB.net and also hex can be abcdeff  that isnot in multiple of two in that case it should take as 0abcdeff and then convert to binary and do circular rotation .hex representation is in int32 and in some cases is in string, rotation can be
    Friday, November 16, 2018 1:11 AM

All replies

  • I have a hex number Aabcdeff .I have to binary rotation of 5 .how can we do that in VB.net and also hex can be abcdeff  that isnot in multiple of two in that case it should take as 0abcdeff and then convert to binary and do circular rotation 
    • Merged by Stanly Fan Friday, November 16, 2018 1:50 AM the same thread
    Thursday, November 15, 2018 5:18 PM
  • I have a hex number Aabcdeff .I have to binary rotation of 5 .how can we do that in VB.net and also hex can be abcdeff  that isnot in multiple of two in that case it should take as 0abcdeff and then convert to binary and do circular rotation 

    I see nothing in this thread which specifically relates to Windows Forms.
    I would think it would be more on-topic if posted in the Visual Basic forum:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral&filter=alllanguages

    You may need to clarify some of the details:

    When you say "a hex number" just what *exactly* are you describing?

    Is it a string representation of a hex number?

    Is it the hex representation of a numeric variable? If so, what type of
    variable? Int32? Int64? Other?

    When you say "circular rotation" is that a clockwise or counterclockwise 
    rotation?

    - Wayne

    Friday, November 16, 2018 12:43 AM
  • Question
    You cannot vote on your own post
    0
    I have a hex number Aabcdeff .I have to binary rotation of 5 .how can we do that in VB.net and also hex can be abcdeff  that isnot in multiple of two in that case it should take as 0abcdeff and then convert to binary and do circular rotation .hex representation is in int32 and in some cases is in string, rotation can be right or left
    Friday, November 16, 2018 12:57 AM
  • It is intended 32 representation of hex no,and it can be rotated right or left
    Friday, November 16, 2018 1:01 AM
  • Hi

    That is a large Hex number, do you need to work with numbers of such magnitude?

    Here is a LINK that may get you started.


    Regards Les, Livingston, Scotland


    • Edited by leshay Friday, November 16, 2018 1:14 AM
    Friday, November 16, 2018 1:13 AM
  • Yes,that's why I am not understanding how to do circular shift
    Friday, November 16, 2018 2:00 AM
  • It is intended 32 representation of hex no,and it can be rotated right or left

    Well, to get you thinking about various approaches to achieve what you
    want take a look at this example and its output. It is intended as a 
    "visual aid" to bit shifting and bitwise or operations. You will likely
    have to do some adjusting to get where you want to be. It's still not
    entirely clear to me what you want to do or why. It would help if you 
    gave some background info on the application.

    Sub Main()
    
        Dim a As Int32 = &HAABCDEFF
        Dim str As String = Convert.ToString(a, 2)
        str = str.PadLeft(32, "0")
        Console.WriteLine("a  = {0}  &H{1:X}", str, a)
    
        Dim a2 As UInt32 = &HAABCDEFF << 5
        Dim stra2 As String = Convert.ToString(a2, 2)
        stra2 = stra2.PadLeft(32, "0")
        Console.WriteLine("a2 = {0}  &H{1:X}", stra2, a2)
    
        Dim a3 As UInt32 = &HAABCDEFFUI >> 27
        Dim stra3 As String = Convert.ToString(a3, 2)
        stra3 = stra3.PadLeft(32, "0")
        Console.WriteLine("a3 = {0}  &H{1:X}", stra3, a3)
    
        Dim a4 As UInt32 = a2 Or a3
        Dim stra4 As String = Convert.ToString(a4, 2)
        stra4 = stra4.PadLeft(32, "0")
        Console.WriteLine("a4 = {0}  &H{1:X}", stra4, a4)
    
    End Sub

    Output:

    a  = 10101010101111001101111011111111  &HAABCDEFF
    a2 = 01010111100110111101111111100000  &H579BDFE0
    a3 = 00000000000000000000000000010101  &H15
    a4 = 01010111100110111101111111110101  &H579BDFF5

    - Wayne



    • Edited by WayneAKing Friday, November 16, 2018 3:02 AM
    Friday, November 16, 2018 2:34 AM