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

13
LINES

< > BotCompany Repo | #1013672 // roundDownTo - unintuitive argument order

JavaX fragment (include)

// TODO: optimize to x-(x%n) in case that's the same thing
// (or x-mod(x,n)?)
static int roundDownTo(int n, int x) {
  return x/n*n;
}

static long roundDownTo(long n, long x) {
  return x/n*n;
}

static double roundDownTo(double n, double x) {
  return floor(x/n)*n;
}

Author comment

Began life as a copy of #1001008

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1013672
Snippet name: roundDownTo - unintuitive argument order
Eternal ID of this version: #1013672/5
Text MD5: 221efe77d9e0ce004b716c8436901579
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-12-07 21:46:34
Source code size: 282 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 489 / 1304
Version history: 4 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1031831 - roundDownTo_rev - more unintuitive argument order
#1036229 - roundTo - unintuitive argument order