nice
This commit is contained in:
parent
c4e0902193
commit
be0015e889
1 changed files with 5 additions and 9 deletions
|
|
@ -674,15 +674,11 @@ write_matrix_to_values_and_value_strings :: proc(values: []f32, value_strings: [
|
||||||
}
|
}
|
||||||
|
|
||||||
write_float_to_buffer :: proc(buffer: []byte, value: f32) {
|
write_float_to_buffer :: proc(buffer: []byte, value: f32) {
|
||||||
fraction := fract(value)
|
switch {
|
||||||
if fraction == 0.0 {
|
case fract(value) == 0.0: fmt.bprintf(buffer, "%.0f", value)
|
||||||
fmt.bprintf(buffer, "%.0f", value)
|
case fract(value * 10.0) == 0.0: fmt.bprintf(buffer, "%.1f", value)
|
||||||
} else if fract(fraction * 10.0) == 0.0 {
|
case fract(value * 100.0) == 0.0: fmt.bprintf(buffer, "%.2f", value)
|
||||||
fmt.bprintf(buffer, "%.1f", value)
|
case: fmt.bprintf(buffer, "%.3f", value)
|
||||||
} else if fract(fraction * 100.0) == 0.0 {
|
|
||||||
fmt.bprintf(buffer, "%.2f", value)
|
|
||||||
} else {
|
|
||||||
fmt.bprintf(buffer, "%.3f", value)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue