• zygo_histo_morpheus@programming.dev
    link
    fedilink
    arrow-up
    11
    ·
    edit-2
    3 months ago

    Making a u32 pointer from two u16’s isn’t a generic operation because it has to make assumptions about how the pointers work endianess

    Edit: Actually, I’m wrong, didn’t think this through properly. See the replies

        • FizzyOrange@programming.devBanned from community
          link
          fedilink
          arrow-up
          3
          ·
          3 months ago

          Nw. You’re also wrong about endianness. This function would be written exactly the same irrespective of endianness:

          uint32_t u16_high_low_to_u32(uint16_t high, uint16_t low) {
            return (high << 16) | low;
          }
          

          That is endian agnostic.