Home Forums General Using Ctrlr hex to binary

This topic contains 2 replies, has 2 voices, and was last updated by  hutch 2 months, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #72869

    hutch
    Participant

    Hi

    What would be the best way to convert specific bytes in a data string to binary? For example in a string “F0 05 05 0f 07”, I would like to convert 0f to 00001111 and 07 to 00000111. These individual bits will be used to set specific uiButtons on a panel.

    Thank you !

    #72870
    goodweather
    goodweather
    Participant

    Hi, do you really need the specific binary display with 0 and 1?
    Normally, getting the actual value (in whatever base) would be good enough
    So supposing you can just give that value, it is enough to just use

    tonumber(string.sub(your_data_string, start_pos, start_pos+1),16)
    -- tonumber("0A",16) gives 10
    #72872

    hutch
    Participant

    Many thanks Sir Goodweather. That worked well for my purposes.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Comments are closed.