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

11
LINES

< > BotCompany Repo | #1005824 // sign - return -1, 0 or 1 depending on sign of value (takes double or long, returns int)

JavaX fragment (include)

static int sign(double x) {
  ret x == 0.0 ? 0 : x < 0 ? -1 : 1;
}

static int sign(long x) {
  ret x == 0 ? 0 : x < 0 ? -1 : 1;
}

static int sign(int x) {
  ret x == 0 ? 0 : x < 0 ? -1 : 1;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005824
Snippet name: sign - return -1, 0 or 1 depending on sign of value (takes double or long, returns int)
Eternal ID of this version: #1005824/4
Text MD5: 0a621f80c3d642ad5c4ff570a31b106f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-18 17:08:19
Source code size: 203 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 563 / 603
Version history: 3 change(s)
Referenced in: [show references]