Formats a number with a specified number of decimal places.
tofixed(value, decimalPlaces)
| Parameter | Type | Description |
|---|---|---|
value |
Number | The number to format |
decimalPlaces |
Number | Number of decimal places to display |
String - The number formatted with the specified decimal places.
The tofixed function formats a number to a fixed number of decimal places. This is useful for displaying currency, percentages, and other formatted numeric values.
Result = TOFIXED(3.14159, 2)
// Result: "3.14"
Price = TOFIXED(19.9, 2)
// Result: "19.90"
Result = TOFIXED(2.567, 1)
// Result: "2.6"
// Format a calculated percentage
FormattedPercent = TOFIXED(PERCENT(Completed, Total) * 100, 1)
- Currency display: Format prices and amounts
- Percentage display: Format percentages with precision
- Scientific data: Consistent decimal places
- Reports: Standardized number formatting
- Always returns specified number of decimal places
- Pads with zeros if necessary (19.9 -> "19.90")
- Uses the Math service's
toFixedPrecisemethod - Returns result as string