Last active
September 18, 2018 06:57
-
-
Save blubberdiblub/80a9a819432cd4f5698de7c62ccbc36a to your computer and use it in GitHub Desktop.
linear sweep variant #1
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
private static void sweepLinear(double min, double max, int num_intervals) { | |
double step = (max - min) / num_intervals; | |
double value = min; | |
while (value <= max) { | |
doSomethingWithValue(value); | |
value += step; | |
} | |
} | |
/* Output: | |
1.5 | |
2.0 | |
2.5 | |
1.5 | |
1.6 | |
1.7000000000000002 | |
1.8000000000000003 | |
1.9000000000000004 | |
2.0000000000000004 | |
2.1000000000000005 | |
2.2000000000000006 | |
2.3000000000000007 | |
2.400000000000001 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment