b1b87c8521
- custom load capped at cargo capacity (error when exceeded); full load shows the cargo capacity; zero cargo pins load to empty and disables the toggle - per-input red border + tooltip for every invalid value (blocks, techs, load, MAT, modernization target); no value may be negative; locking a speed is disabled when drive is zero - display every computed number (results + goal-seek back-solved input) rounded up to 3 decimals via a shared pkg/calc Ceil3 bridged to wasm; engine keeps its own round-to-nearest util.Fixed* - modernization total upgrade cost spans two columns (single line) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
20 lines
843 B
Go
20 lines
843 B
Go
package calc
|
|
|
|
import "math"
|
|
|
|
// Ceil3 rounds num UP to three decimal places. The ship-class
|
|
// calculator displays every computed value (and every goal-seek
|
|
// back-solved input) through this so a result is never shown lower than
|
|
// it really is — e.g. a speed of 5.0003 reads as 5.001, not 5.000, which
|
|
// matters when a fraction of a light-year decides whether a ship clears
|
|
// the gap to a planet. It is display-only and lives here (rather than in
|
|
// the engine's round-to-nearest util.Fixed*) so the UI bridge can reach
|
|
// the one implementation through WASM.
|
|
//
|
|
// num is pre-rounded to nine decimals before the ceil so float64
|
|
// representation noise does not push an exact value up a step (e.g. a
|
|
// computed 5.0 stored as 5.0000000002 stays 5.0).
|
|
func Ceil3(num float64) float64 {
|
|
return math.Ceil(math.Round(num*1e9)/1e6) / 1000
|
|
}
|