Example #1
0
File: add.c Project: Gruelty/urbit
/* functions
*/
  u2_weak                                                         //  transfer
  j2_mbc(Pt1, add)(u2_wire wir_r, 
                   u2_atom a,                                     //  retain
                   u2_atom b)                                     //  retain
  {
    mpz_t a_mp, b_mp;

    u2_mp(a_mp, a);
    u2_mp(b_mp, b);

    mpz_add(a_mp, a_mp, b_mp);
    mpz_clear(b_mp);

    return u2_rl_mp(wir_r, a_mp);
  }
Example #2
0
File: dec.c Project: mnemnion/urbit
  u2_weak                                                         //  transfer
  j2_mbc(Pt1, dec)(u2_wire wir_r, 
                   u2_atom a)                                     //  retain
  {
    if ( _0 == a ) {
      return u2_none;
    } 
    else {
      mpz_t a_mp;

      u2_mp(a_mp, a);
      mpz_sub_ui(a_mp, a_mp, 1);

      return u2_rl_mp(wir_r, a_mp);
    }
  }
Example #3
0
File: mod.c Project: mnemnion/urbit
/* functions
*/
  u2_weak                                                         //  transfer
  j2_mbc(Pt1, mod)(u2_wire wir_r, 
                   u2_atom a,                                     //  retain
                   u2_atom b)                                     //  retain
  {
    if ( _0 == b ) {
      return u2_none;
    } else {
      mpz_t a_mp, b_mp;

      u2_mp(a_mp, a);
      u2_mp(b_mp, b);

      mpz_tdiv_r(a_mp, a_mp, b_mp);
      mpz_clear(b_mp);

      return u2_rl_mp(wir_r, a_mp);
    }
  }
/* u2_ci_mp(): construct atom from GMP.  Caller transfers a_mp.
*/
u2_atom
u2_ci_mp(mpz_t a_mp)
{
  return u2_rl_mp(u2_Wire, a_mp);
}
Example #5
0
File: bail.c Project: MacTop/urbit
/* u2_bn_mp():
**
**   Copy the GMP integer [a] into an atom.
*/
u2_noun
u2_bn_mp(u2_ray wir_r,
         mpz_t  a_mp)
{
  return u2_bl_good(wir_r, u2_rl_mp(wir_r, a_mp));
}