AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

1994.09.16 04:17 "TIFF Bit Ordering Versus Fill Order", by John M Davison
1994.09.19 23:31 "Re: TIFF Bit Ordering Versus Fill Order", by Jim Arnold
1994.09.20 12:29 "MSB vs. LSB. (Was: TIFF Bit Ordering Versus Fill Order)", by Thomas Kinsman
[...]

1994.09.20 12:29 "MSB vs. LSB. (Was: TIFF Bit Ordering Versus Fill Order)", by Thomas Kinsman

#include <stdio.h>

union
{
        long    field1;
        char    field2[4];
}  var;

main()
{
    var.field2[0] = 0;
    var.field2[1] = 1;
    var.field2[2] = 2;
    var.field2[3] = 3;
    
    if (var.field1 == (1 << 16) + (2<<8) + 3)
            puts("Big-endian");
    else if (var.field1 == (3 << 24) + (2<<16) + (1 << 8))
            puts("Little-endian");
    else
            puts("unknown-endian");
}