Package erjang

Examples of erjang.EInteger


    return i1.bsl(i2);
  }

  @BIF(type = Type.GUARD, name = "bsr")
  public static EInteger bsr$g(EObject o1, EObject o2) {
    EInteger i1;
    EInteger i2;
    if ((i1 = o1.testInteger()) == null || (i2 = o2.testInteger()) == null)
      return null;
    return i1.bsr(i2);
  }
View Full Code Here


  }
 
  @BIF
  static public EObject posixtime_to_universaltime(EObject a1)
  {
    EInteger num = a1.testInteger();
    if (num == null) throw ERT.badarg(a1);
   
    Calendar out_date = GregorianCalendar.getInstance(UTC_TIME_ZONE);
    out_date.setTimeInMillis(num.longValue() * 1000L);
   
    ETuple3 date2 = new ETuple3();
    date2.set(1, ERT.box(out_date.get(Calendar.YEAR)));
    date2.set(2, ERT.box(out_date.get(Calendar.MONTH)-Calendar.JANUARY+1));
    date2.set(3, ERT.box(out_date.get(Calendar.DAY_OF_MONTH)));
View Full Code Here

          if (!key.equalsExactly( get_key(rec) )) {
            return null;
          }
        }

        EInteger incr;
        ETuple one;
        if ((incr=upd.testInteger()) != null) {
          int idx = keypos1+1;
         
          rec = update(rec, idx, incr);
          if (rec == null) return null;
          map = map.assoc(get_key(rec), rec);
         
          set(map);
          return rec.elm(idx);
         
        } else if ((one=upd.testTuple()) != null) {
         
          if (one.arity() == 2) {
            ESmall eidx = one.elm(1).testSmall();
            incr = one.elm(2).testInteger();
            if (eidx == null || eidx.value > rec.arity() || incr == null) return null;
            int idx = eidx.value;
           
            rec = update(rec, idx, incr);
            if (rec == null) return null;
            map = map.assoc(get_key(rec), rec);
           
            set(map);
            return rec.elm(idx);

          } else if (one.arity() == 4){
           
            ESmall eidx = one.elm(1).testSmall();
            incr = one.elm(2).testInteger();
            EInteger threshold = one.elm(3).testInteger();
            EInteger setvalue = one.elm(4).testInteger();
            if (eidx == null || eidx.value > rec.arity() || incr == null
                || threshold == null || setvalue == null) return null;
            int idx = eidx.value;
           
            rec = update(rec, idx, incr, threshold, setvalue);
            if (rec == null) return null;
            map = map.assoc(get_key(rec), rec);
           
            set(map);
            return rec.elm(idx);

          } else {
            return null;
          }
         
        } else {
          throw new NotImplemented();
        }
       
      }

      private ETuple update(ETuple rec, int idx, EInteger incr) {

        EInteger old = rec.elm(idx).testInteger();
        if (old == null) return null;
        EObject val = old.add(incr);
        rec = ErlBif.setelement(idx, rec, val);

        return rec;
      }
     
      private ETuple update(ETuple rec, int idx, EInteger incr, EInteger threshold, EInteger setvalue) {

        EInteger old = rec.elm(idx).testInteger();
        if (old == null) return null;
        ENumber val = old.add(incr);
       
        if (incr.is_ge(ESmall.ZERO)) {

          if (threshold.is_lt(val)) {
            val = setvalue;
View Full Code Here

  }
 
  @BIF(name="band",type=Type.GUARD)
  static public ENumber band_guard(EObject o1, EObject o2)
  {
    EInteger n1;
    EInteger n2;
    if ((n1=o1.testInteger()) != null) {
      if ((n2=o2.testInteger()) != null) {
        return n1.band(n2);
      }
    }
View Full Code Here

  {
    ESmall sm_s = start.testSmall();
    ESmall sm_e = end.testSmall();
   
    if (sm_s == null || sm_e == null) {
      EInteger i_s;
      EInteger i_e;
      if ((i_s=start.testInteger()) == null
        || (i_e=end.testInteger()) == null) {

        throw ERT.badarg(start, end);
       
View Full Code Here

  {
    if ((end.inc()).is_lt(start))
      throw ERT.badarg(start, end);
   
    ESeq l = ERT.NIL;
    EInteger val = end;
    EInteger first = start;
   
    while (val.is_ge(first)) {
      l = l.cons(val);
      val = val.dec();
    }
View Full Code Here

TOP

Related Classes of erjang.EInteger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.