pike.git / lib / modules / Int.pmod

version» Context lines:

pike.git/lib/modules/Int.pmod:47:    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);   }    - static class Inf { + protected class Inf {    -  static constant neg = 0; -  static int __hash() { return 17; } -  static int(0..1) _equal(mixed arg) { +  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;    } -  static int(0..1) _is_type(mixed type) { return (< "int", "object" >)[type]; } -  static mixed _random() { return this; } -  static mixed _sqrt() { return this; } +  protected int(0..1) _is_type(mixed type) { return (< "int", "object" >)[type]; } +  protected mixed _random() { return this; } +  protected mixed _sqrt() { return this; }    // % == nan    // & == nan -  static mixed `*(mixed ... args) { +  protected mixed `*(mixed ... args) {    int n = neg;    foreach(args, mixed arg)    if(arg<0) n = !n;    if(n) return ninf;    return inf;    } -  static mixed ``*(mixed ... args) { return `*(@args); } -  static mixed `+(mixed ... args) { +  protected mixed ``*(mixed ... args) { return `*(@args); } +  protected mixed `+(mixed ... args) {    foreach(args, mixed arg)    if(arg==`-()) error("NaN\n");    return this;    } -  static mixed ``+(mixed ... args) { return ``+(@args); } -  static mixed `-(mixed ... args) { +  protected mixed ``+(mixed ... args) { return ``+(@args); } +  protected mixed `-(mixed ... args) {    if(!sizeof(args)) {    if(neg) return inf;    return ninf;    }    foreach(args, mixed arg)    if(arg==inf || arg==ninf) error("NaN\n");    return this;    } -  static mixed ``-(mixed arg) { +  protected mixed ``-(mixed arg) {    if(arg==inf || arg==ninf) error("NaN\n");    return this;    } -  static int(0..1) `<(mixed arg) { +  protected int(0..1) `<(mixed arg) {    if(arg==this) return 0;    return neg;    } -  static int(0..1) `>(mixed arg) { +  protected int(0..1) `>(mixed arg) {    if(arg==this) return 0;    return !neg;    } -  static mixed `~() { return `-(); } -  static mixed `<<(mixed arg) { +  protected mixed `~() { return `-(); } +  protected mixed `<<(mixed arg) {    if(arg<0) error("Got negative shift count.\n");    return this;    } -  static mixed ``<<(mixed arg) { +  protected mixed ``<<(mixed arg) {    if(arg<0) return ninf;    return inf;    } -  static mixed `>>(mixed arg) { +  protected mixed `>>(mixed arg) {    if(arg<0) error("Got negative shift count.\n");    return this;    } -  static mixed ``>>(mixed arg) { +  protected mixed ``>>(mixed arg) {    return 0;    } -  static mixed cast(string to) { +  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);    }    } -  static string _sprintf(int t) { +  protected string _sprintf(int t) {    return t=='O' && (neg?"-":"")+"Int.inf";    }   }      class NInf {    inherit Inf;    constant neg = 1;   }    - static Inf ninf = NInf(); + protected Inf ninf = NInf();      //! An infinite number.   Inf inf = Inf();