Index: libucdf/ucdf.c =================================================================== --- libucdf/ucdf.c (revision 36299) +++ libucdf/ucdf.c (revision 36300) @@ -106,9 +106,9 @@ } } - /* "sign extend" */ - if (res >= (1UL << (len*8-1))) - res = -((1UL << (len*8)) - res); + /* sign extend */ + if (((unsigned long)res) >> (len*8-1)) + res |= ((unsigned long)-1) << (len*8-1); return res; }