Swaps

Issue #1012 new
Former user created an issue

Would it be possible to implement byte wise swaps to switch between little endian and big endian? And then bit wise to reverse order of each bit, the most significant bit becoming the least significant bit (on a scale of 8, 16, 32, 64 bit numbers)?

Comments (1)

  1. Tey'

    Even though your feature request is for the bitfield component, note that you can create you own user functions to do bytes swapping:

    swap32(v) = ((v & 0xFF) << 24) | ((v & 0xFF00) << 8) | ((v & 0xFF0000) >> 8) | ((v & 0xFF000000) >> 24)
    
    hex(swap32(0x12345678))
    = 0x78563412
    

    The swap function for each bits is more cumbersome to write but you'll only have to do that once.

  2. Log in to comment