pike.git / lib / modules / Int.pmod

version» Context lines:

pike.git/lib/modules/Int.pmod:34:   //! @expr{--with-long-int@}, and @expr{--with-long-long-int@}. The   //! default is to use the longest available integer type that fits   //! inside a pointer, which typically means that it's 64 bit on "true"   //! 64 bit architectures.   //!   //! @note   //! If Pike is compiled with the configure flag   //! @expr{--without-bignum@} (which is discouraged), then all   //! arithmetic operations will instead silently wrap around at these   //! limits. +  + //! Swaps the upper and lower byte in a word. + int(0..65535) swap_word(int(0..65535) i) { +  return ((i&255)<<8) | ((i&(255<<8))>>8); + } +  + //! Swaps the upper and lower word in a longword, and the upper and + //! lower bytes in the words. Simply put, the bytes are reversed. + int(0..4294967295) swap_long(int(0..4294967295) i) { +  return ((i&255)<<24) | ((i&(255<<8))<<8) | +  ((i&(255<<16))>>8) | ((i&(255<<24))>>24); + }