Created
September 15, 2019 04:46
-
-
Save altimmons/7532823bb3cf7f95a63d145f6017063e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double x1 = 1.0, x2 = 10.0; //or float x1 = 1.0f, x2 =2.0f | |
double f = Math.random()/Math.nextDown(1.0); | |
double x = x1*(1.0 - f) + x2*f; | |
//test code | |
int c = 0; | |
while(c< 20) { | |
float x1 = 1.0f, x2 = 10.0f; | |
double f = Math.random() / Math.nextDown( 1.0 ); | |
double x = x1 * ( 1.0 - f ) + x2 * f; | |
System.out.printf( "%d) %f\n" , (c + 1), x ); | |
c++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment