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)

1  
static BigInteger mathOp(S op, BigInteger a, BigInteger b) {
2  
  if (eq(op, "+"))
3  
    ret a.add(b);
4  
  else if (eq(op, "-"))
5  
    ret a.subtract(b);
6  
  else if (eq(op, "*"))
7  
    ret a.multiply(b);
8  
  else if (eq(op, "/"))
9  
    ret a.divide(b);
10  
  else if (eq(op, "^"))
11  
    ret a.pow(b.intValue()); // weird that it takes an int
12  
  else
13  
    throw fail("Unknown math op: " + op);
14  
}

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: 673 / 866
Referenced in: [show references]