Skip to content

Latest commit

 

History

History
75 lines (51 loc) · 1.54 KB

File metadata and controls

75 lines (51 loc) · 1.54 KB

tofixed

Formats a number with a specified number of decimal places.

Syntax

tofixed(value, decimalPlaces)

Parameters

Parameter Type Description
value Number The number to format
decimalPlaces Number Number of decimal places to display

Returns

String - The number formatted with the specified decimal places.

Description

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.

Examples

Basic Usage

Result = TOFIXED(3.14159, 2)
// Result: "3.14"

Currency Formatting

Price = TOFIXED(19.9, 2)
// Result: "19.90"

Rounding

Result = TOFIXED(2.567, 1)
// Result: "2.6"

With Calculations

// Format a calculated percentage
FormattedPercent = TOFIXED(PERCENT(Completed, Total) * 100, 1)

Use Cases

  • Currency display: Format prices and amounts
  • Percentage display: Format percentages with precision
  • Scientific data: Consistent decimal places
  • Reports: Standardized number formatting

Related Functions

Notes

  • Always returns specified number of decimal places
  • Pads with zeros if necessary (19.9 -> "19.90")
  • Uses the Math service's toFixedPrecise method
  • Returns result as string