pike.git / lib / modules / Int.pmod

version» Context lines:

pike.git/lib/modules/Int.pmod:29:   //! (@expr{0x7fffffff@}).   //!   //! @note   //! The size of the native integers can be controlled when Pike is   //! compiled with the configure flags @expr{--with-int-int@},   //! @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.   //!   //! @seealso   //! @[swap_long()]   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
pike.git/lib/modules/Int.pmod:98:   class Inf {       protected constant neg = 0;    protected int __hash() { return 17; }    protected int(0..1) _equal(mixed arg) {    if(neg && arg==-Math.inf) return 1;    if(!neg && arg==Math.inf) return 1;    return arg==this;    }    protected int(0..1) _is_type(mixed type) { return (< "int", "object" >)[type]; } -  protected mixed _random() { return this; } +  protected mixed _random(function rnd_string, function rnd) { +  if (neg) return 0; +  return this; +  }    protected mixed _sqrt() { return this; }    // % == nan    // & == nan -  protected mixed `*(mixed ... args) { +  protected mixed `*(mixed arg) {    int n = neg; -  foreach(args, mixed arg) +     if(arg<0) n = !n;    if(n) return ninf;    return inf;    } -  protected mixed ``*(mixed ... args) { return `*(@args); } -  protected mixed `+(mixed ... args) { -  foreach(args, mixed arg) +  protected mixed ``*(mixed arg) { return `*(arg); } +  protected mixed `+(mixed arg) {    if(arg==`-()) error("NaN\n");    return this;    } -  protected mixed ``+(mixed ... args) { return ``+(@args); } -  protected mixed `-(mixed ... args) { -  if(!sizeof(args)) { +  protected mixed ``+(mixed arg) { return ``+(arg); } +  protected mixed `-(void|mixed arg) { +  if(!query_num_arg()) {    if(neg) return inf;    return ninf;    } -  foreach(args, mixed arg) +     if(arg==inf || arg==ninf) error("NaN\n");    return this;    }    protected mixed ``-(mixed arg) {    if(arg==inf || arg==ninf) error("NaN\n");    return this;    }    protected int(0..1) `<(mixed arg) {    if(arg==this) return 0;    return neg;
pike.git/lib/modules/Int.pmod:160:    protected mixed ``>>(mixed arg) {    return 0;    }    protected mixed cast(string to) {    switch(to) {    case "string":    return "inf";    case "float":    return Math.inf;    default: -  error("Can not cast to %O.\n", to); +  return UNDEFINED;    }    }    protected string _sprintf(int t) {    return t=='O' && (neg?"-":"")+"Int.inf";    }   }      class NInf {    inherit Inf;    constant neg = 1;   }      protected Inf ninf = NInf();      //! An object that behaves like positive infinity.   Inf inf = Inf();