Server Data Formatters - Numeric

Intro

Below is a comprehensive list of Numeric data formatters available in Server Connect, accompanied by explanations outlining the purpose and functionality of each.

Numeric Formatters

The Numeric formatters offer a wide range of operations to manipulate and format numeric values according to your needs.:

Floor:

  • Description: Rounds down the given numeric value to the nearest integer.
  • Example: (5.8).floor() returns 5

Ceil:

  • Description: Rounds up the given numeric value to the nearest integer.
  • Example: (5.2).ceil() returns 6

Round:

  • Description: Rounds the given numeric value to the nearest integer.
  • Example: (5.7).round() returns 6

Abs:

  • Description: Returns the absolute value of the given numeric value (removes the sign).
  • Example: (-5.6).abs() returns 5.6

Pow Number:

  • Description: Calculates the power of the given numeric value raised to the specified exponent.
  • Example: (2).pow(3) returns 8

Pad Number:

  • Description: Pads the given numeric value with zeros on the left to match the specified number of digits.
  • Example: (7).padNumber(3) returns '007'

Format Number:

  • Description: Formats the given numeric value with a specified number of decimal places, separator, and thousands delimiter.
  • Example: (12345.6789).formatNumber(2, '.', ',') returns '12,345.68'

Hex:

  • Description: Converts the given hexadecimal value to its decimal representation.
  • Example: ('ff').hex() returns 255

Format Currency:

  • Description: Formats the given numeric value as currency, including a currency unit, decimal separator, and thousands delimiter.
  • Example: (1234.56).currency('$', '.', ',', 2) returns '$1,234.56'

Format Size:

  • Description: Formats the given numeric value as a human-readable file size with optional decimal places.
  • Example: (1024).formatSize(2, true) returns '1.00KiB'
7 Likes