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 }