Changeset 14159
- Timestamp:
- 07/21/16 16:42:29 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ChartUtil.cs
r14156 r14159 37 37 38 38 // if one of the interval ends is a multiple of 5 or 10, change the other interval end to be a multiple as well 39 if (decimalRank > 0) { 40 if (((aMin % 5).IsAlmost(0) || (aMin % 10).IsAlmost(0)) && !((aMax % 5).IsAlmost(0) || (aMax % 10).IsAlmost(0))) { 41 aMax = Math.Min(aMax + 5 - aMax % 5, aMax + 10 - aMax % 10); 42 } else if (((aMax % 5).IsAlmost(0) || (aMax % 10).IsAlmost(0)) && !((aMin % 5).IsAlmost(0) || (aMin % 10).IsAlmost(0))) { 43 aMin = Math.Max(aMin - aMin % 5, aMin - aMin % 10); 44 } 39 if ((aMin.Mod(5).IsAlmost(0) || aMin.Mod(10).IsAlmost(0)) && Math.Abs(aMax) >= 5 && !(aMax.Mod(5).IsAlmost(0) || aMax.Mod(10).IsAlmost(0))) { 40 aMax = Math.Min(aMax + 5 - aMax % 5, aMax + 10 - aMax % 10); 41 } else if ((aMax.Mod(5).IsAlmost(0) || aMax.Mod(10).IsAlmost(0)) && Math.Abs(aMin) >= 5 && !(aMin.Mod(5).IsAlmost(0) || aMin.Mod(10).IsAlmost(0))) { 42 aMin = Math.Max(aMin - aMin.Mod(5), aMin - aMin.Mod(10)); 45 43 } 46 44 … … 92 90 var floor = (int)Math.Floor(value); 93 91 var pow = (int)Math.Pow(10, decimalRank); 94 var mod = floor % pow; 95 if (mod < 0) mod += pow; 92 var mod = Mod(floor, pow); 96 93 return floor - mod; 97 94 } … … 103 100 var ceil = (int)Math.Ceiling(value); 104 101 var pow = (int)Math.Pow(10, decimalRank); 105 var mod = ceil % pow; 106 if (mod < 0) mod += pow; 102 var mod = Mod(ceil, pow); 107 103 return ceil - mod + pow; 108 104 } … … 135 131 return Math.Abs(value - other) < eps; 136 132 } 133 134 private static double Mod(this double a, double b) { 135 return a - b * Math.Floor(a / b); 136 } 137 137 } 138 138 }
Note: See TracChangeset
for help on using the changeset viewer.