Post Reply 
[BUG] Logical AND
01-27-2014, 09:20 AM (This post was last modified: 01-27-2014 09:21 AM by parisse.)
Post: #10
RE: [BUG] Logical AND
a and b returns 0 if a is zero and b otherwise for integers. Returning b is easier than returning 1 because it works for other types (e.g. if b is a variable name or a symbolic expression). For more precision, here is the source code from gen.cc
Code:

  gen operator && (const gen & a,const gen & b){
    if (is_zero(a,context0)){
      if (b.type==_DOUBLE_)
    return 0.0;
      if (b.type==_FLOAT_)
    return giac_float(0);
      return !is_zero(a);
    }
    if (is_zero(b,context0)){
      if (a.type==_DOUBLE_ )
    return 0.0;
      if (a.type==_FLOAT_)
    return giac_float(0);
      return !is_zero(b);
    }
    if (a.type<=_CPLX || a.type==_FLOAT_)
      return b;
    if (b.type<=_CPLX || b.type==_FLOAT_)
      return a;
    if (a.is_symb_of_sommet(at_and)){
      if (b.is_symb_of_sommet(at_and))
    return new_ref_symbolic(symbolic(at_and,gen(mergevecteur(*a._SYMBptr->feuille._VECTptr,*b._SYMBptr->feuille._VECTptr),_SEQ__VECT)));
      vecteur v=*a._SYMBptr->feuille._VECTptr;
      v.push_back(b);
      return new_ref_symbolic(symbolic(at_and,v));
    }
    if (b.is_symb_of_sommet(at_and)){
      vecteur v=*b._SYMBptr->feuille._VECTptr;
      v.push_back(a);
      return new_ref_symbolic(symbolic(at_and,v));
    }
    if ( ((a.type==_IDNT) || (a.type==_SYMB)) || ((a.type==_IDNT) || (a.type==_SYMB)) )
      return symb_and(a,b);
    if ( (a.type==_DOUBLE_) || (b.type==_DOUBLE_) )
      return 1.0;
    if ( (a.type==_FLOAT_) || (b.type==_FLOAT_) )
      return giac_float(1);
    return plus_one;
  }
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
[BUG] Logical AND - Terje Vallestad - 01-26-2014, 04:10 PM
RE: [BUG] Logical AND - Tim Wessman - 01-26-2014, 04:27 PM
RE: [BUG] Logical AND - Terje Vallestad - 01-26-2014, 04:45 PM
RE: [BUG] Logical AND - Tim Wessman - 01-26-2014, 07:49 PM
RE: [BUG] Logical AND - patrice - 01-26-2014, 04:59 PM
RE: [BUG] Logical AND - eried - 01-26-2014, 05:01 PM
RE: [BUG] Logical AND - Tugdual - 01-26-2014, 05:15 PM
RE: [BUG] Logical AND - patrice - 01-26-2014, 05:16 PM
RE: [BUG] Logical AND - Tugdual - 01-26-2014, 06:56 PM
RE: [BUG] Logical AND - parisse - 01-27-2014 09:20 AM
RE: [BUG] Logical AND - Han - 01-28-2014, 12:02 AM
RE: [BUG] Logical AND - Tugdual - 01-27-2014, 06:37 PM
RE: [BUG] Logical AND - patrice - 01-27-2014, 06:42 PM
RE: [BUG] Logical AND - Tugdual - 01-27-2014, 10:53 PM
RE: [BUG] Logical AND - patrice - 01-27-2014, 11:15 PM
RE: [BUG] Logical AND - Terje Vallestad - 01-27-2014, 11:59 PM
RE: [BUG] Logical AND - Joe Horn - 01-28-2014, 06:03 AM
RE: [BUG] Logical AND - parisse - 01-28-2014, 07:32 AM
RE: [BUG] Logical AND - Eddie W. Shore - 01-30-2014, 01:49 PM
RE: [BUG] Logical AND - patrice - 02-01-2014, 07:57 PM
RE: [BUG] Logical AND - Joe Horn - 02-02-2014, 05:07 AM



User(s) browsing this thread: 2 Guest(s)