Wraps a float for print so it comes out with a chosen width, number of decimals or notation.
formatFloat :: (
value: Any,
width := -1,
trailing_width := -1,
mode := FormatFloat.Mode.DECIMAL,
zero_removal := FormatFloat.Zero_Removal.YES
) -> FormatFloat
Parameters
- value: Any
- width := -1
- the least number of characters; shorter text is padded with spaces on the left. -1 for no padding.
- trailing_width := -1
- digits after the decimal point; 6 when negative.
- mode := FormatFloat.Mode.DECIMAL
.DECIMAL,.SCIENTIFICor.SHORTEST.- zero_removal := FormatFloat.Zero_Removal.YES
- whether zeros at the end of the fraction are dropped:
.YESdrops them all,.ONE_ZERO_AFTER_DECIMALkeeps one,.NOkeeps them. Withtrailing_widthset, dropped zeros leave spaces so columns still line up.
Returns
assert(tprint("%", formatFloat(3.14159, trailing_width = 2)) == "3.14");