MCPcopy Create free account
hub / github.com/elftausend/graplot / max_display

Function max_display

src/eval.rs:105–149  ·  view source on GitHub ↗
(max: f64, other_scaling: bool)

Source from the content-addressed store, hash-verified

103}
104
105pub 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]
152fn test_max() {

Callers 3

runFunction · 0.85
runFunction · 0.85
showMethod · 0.85

Calls 2

count_tensFunction · 0.85
count_inv_tensFunction · 0.85

Tested by

no test coverage detected