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

44
LINES

< > BotCompany Repo | #1001796 // min function

JavaX fragment (include)

1  
static int min(int a, int b) {
2  
  ret Math.min(a, b);
3  
}
4  
5  
static long min(long a, long b) {
6  
  ret Math.min(a, b);
7  
}
8  
9  
static float min(float a, float b) { ret Math.min(a, b); }
10  
static float min(float a, float b, float c) { ret min(min(a, b), c); }
11  
12  
static double min(double a, double b) {
13  
  ret Math.min(a, b);
14  
}
15  
16  
static double min(double[] c) {
17  
  double x = Double.MAX_VALUE;
18  
  for (double d : c) x = Math.min(x, d);
19  
  ret x;
20  
}
21  
22  
static float min(float[] c) {
23  
  float x = Float.MAX_VALUE;
24  
  for (float d : c) x = Math.min(x, d);
25  
  ret x;
26  
}
27  
28  
static byte min(byte[] c) {
29  
  byte x = 127;
30  
  for (byte d : c) if (d < x) x = d;
31  
  ret x;
32  
}
33  
34  
static short min(short[] c) {
35  
  short x = 0x7FFF;
36  
  for (short d : c) if (d < x) x = d;
37  
  ret x;
38  
}
39  
40  
static int min(int[] c) {
41  
  int x = Int.MAX_VALUE;
42  
  for (int d : c) if (d < x) x = d;
43  
  ret x;
44  
}

Author comment

Began life as a copy of #1001664

download  show line numbers  debug dex  old transpilations   

Travelled to 20 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, uelavcdoioby, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1001796
Snippet name: min function
Eternal ID of this version: #1001796/3
Text MD5: b3e9a9e68362cd1207d46e1e600ebde3
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-01-11 13:43:15
Source code size: 871 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 711 / 5004
Version history: 2 change(s)
Referenced in: [show references]