Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

14
LINES

< > BotCompany Repo | #1001946 // mathOp - perform math operation

JavaX fragment (include)

static BigInteger mathOp(S op, BigInteger a, BigInteger b) {
  if (eq(op, "+"))
    ret a.add(b);
  else if (eq(op, "-"))
    ret a.subtract(b);
  else if (eq(op, "*"))
    ret a.multiply(b);
  else if (eq(op, "/"))
    ret a.divide(b);
  else if (eq(op, "^"))
    ret a.pow(b.intValue()); // weird that it takes an int
  else
    throw fail("Unknown math op: " + op);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001946
Snippet name: mathOp - perform math operation
Eternal ID of this version: #1001946/1
Text MD5: 527961ffb3ec713909f1fe7f48a3e4b3
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-10 00:27:21
Source code size: 383 bytes / 14 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 671 / 863
Referenced in: [show references]