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

4
LINES

< > BotCompany Repo | #1032491 // quantizeToNLevelsBetweenZeroAndOne_stretch - returns first level as 0 and last level as 1

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (100L/1K).

static double quantizeToNLevelsBetweenZeroAndOne_stretch(int n, double x) {
  x = clampZeroToOne(x);
  ret doubleRatio(min(n-1, floor(x*n)), n-1);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032491
Snippet name: quantizeToNLevelsBetweenZeroAndOne_stretch - returns first level as 0 and last level as 1
Eternal ID of this version: #1032491/1
Text MD5: aee8cbd9ae554ecb2477ceae784478ed
Transpilation MD5: 436045f45573991972cd0440f20b9a9c
Author: stefan
Category: javax / maths
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-10 17:31:48
Source code size: 151 bytes / 4 lines
Pitched / IR pitched: No / No
Views / Downloads: 177 / 243
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1032492 - quantizeToNLevelsBetweenZeroAndOne_midPoint - returns mid point of interval (e.g. .25 or .75)
#1033572 - quantize0To255 [posterize]