I've been sent the following C code by a friend:
    
    
    #define IS_BIG_ENDIAN (*(uint16_t *)"\0\xff" < 0x100)
    
    
    Run

I'm wondering how the same would be written in Nim. Note that I know about 
`std/endians`, I'm just curious about the translation of this particular 
snippet. I tried:
    
    
    let isBigEndian = cast[uint16]([0x00'u8, 0xff'u8]) < 0x100
    echo isBigEndian
    
    
    Run

It seems to work correctly, but I'm curious if it's actually correct and if 
there's a better way to write it.

Reply via email to