(max: f64, other_scaling: bool)
| 103 | } |
| 104 | |
| 105 | pub fn max_display(max: f64, other_scaling: bool) -> f64 { |
| 106 | if max == 0. { |
| 107 | return 1.; |
| 108 | } |
| 109 | if max >= 2. { |
| 110 | |
| 111 | /*let tens = count_tens(max) / 10; |
| 112 | if tens == 0 { |
| 113 | return max; |
| 114 | } |
| 115 | if tens == 1 { |
| 116 | return (max / 10.).round() * 10.; |
| 117 | } |
| 118 | |
| 119 | ((max / tens as f64 / 2.).round() * tens as f64) * 2.*/ |
| 120 | |
| 121 | if other_scaling { |
| 122 | let tens = count_tens(max) / 10; |
| 123 | if tens == 0 { |
| 124 | return max; |
| 125 | } |
| 126 | if tens == 1 { |
| 127 | return (max / 10.).round() * 10.; |
| 128 | } |
| 129 | ((max / tens as f64 / 2.).round() * tens as f64) * 2. |
| 130 | } else { |
| 131 | let tens = count_tens(max); |
| 132 | ((max / tens as f64 / 2.).round() * tens as f64) * 2. |
| 133 | } |
| 134 | |
| 135 | |
| 136 | |
| 137 | /* |
| 138 | let new_max = (max / 10f64).round() * 10.; |
| 139 | if new_max == 0. { |
| 140 | return max; |
| 141 | } |
| 142 | new_max |
| 143 | */ |
| 144 | |
| 145 | } else { |
| 146 | let tens = count_inv_tens(max); |
| 147 | ((max * tens as f64 / 2.).round() / tens as f64) * 2. |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | #[test] |
| 152 | fn test_max() { |
no test coverage detected