Skip to content

Commit

Permalink
minor tweaks
Browse files Browse the repository at this point in the history
Slight changes in bounds calculation for upper resistor array initialization. Should be perhaps one value more open.
  • Loading branch information
slugrustle committed Apr 11, 2018
1 parent d7d4550 commit 05ce707
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions high_voltage_divider.html
Original file line number Diff line number Diff line change
Expand Up @@ -690,23 +690,23 @@
// based on minimum upper resistor resistance as well as
// min and max string resistance.
var startRes1 = Math.max(settings.minUpperRes, upperStartRes/11.0);
var startIndex1 = Math.max(0, findNearest(startRes1, resArray)-1);
while (startIndex1 < resArray.length-1 && resArray[startIndex1] < startRes1) {
var startIndex1 = Math.max(0, findNearest(startRes1, resArray)-2);
while (startIndex1 < resArray.length && resArray[startIndex1] < startRes1) {
startIndex1++;
}

var endRes1 = upperEndRes / 2.0;
var endIndex1 = Math.max(1, findNearest(endRes1, resArray)-1);
while (endIndex1 < resArray.length && resArray[endIndex1-1] < endRes1) {
var endIndex1 = Math.max(1, findNearest(endRes1, resArray)-2);
while (endIndex1 < resArray.length && resArray[endIndex1-1] <= endRes1) {
endIndex1++;
}

var jRes1;
for (jRes1 = startIndex1; jRes1 < endIndex1; jRes1++) {
var resVal1 = resArray[jRes1];
var endRes2 = Math.min(10.0 * resVal1, upperEndRes - resVal1);
var endIndex2 = Math.max(1, findNearest(endRes2, resArray)-1);
while (endIndex2 < resArray.length && resArray[endIndex2-1] < endRes2) {
var endIndex2 = Math.max(1, findNearest(endRes2, resArray)-2);
while (endIndex2 < resArray.length && resArray[endIndex2-1] <= endRes2) {
endIndex2++;
}

Expand Down Expand Up @@ -778,7 +778,6 @@
scratchArray = [];
duplicates = [];


// Second stage of pruning. Some values that are very close
// to each other come through; this removes them.
// The cut threshold was determined empirically.
Expand Down

0 comments on commit 05ce707

Please sign in to comment.