Number Fields

Number Fields

Number

Number fields are used for values that are added, counted, or measured. Values can include (or not include) decimal places and formatting of your choosing.

Number field settings

Number field settings

Settings:

  • Decimal places: A number of decimal places to include when displaying the number
  • Thousands: You can choose none, comma, period, or space to separate thousands
  • Format: Whether to format your number with currency letters or your own custom before and after the text
  • Default Value: This value will be used by default if no value is entered

Number Field Rounding Options

Overview

Knack provides three rounding options for Number fields to control how decimal values are displayed when the stored precision exceeds the field's decimal place setting. All numeric fields in Knack are stored with up to 10 decimal places in the database, but you can configure how those values appear in your application.

Understanding Rounding Options

When Rounding Applies

Rounding only occurs when:

  • A field stores more decimal places than the field type is configured to display
  • For example, a value of 3.14159 stored in a field set to display 2 decimal places

All three rounding methods handle this scenario differently.

The Three Rounding Methods

Round Default (Standard Rounding)

How it works: Rounds to the nearest value. When exactly halfway between two values (e.g., .5), rounds away from zero.

Examples:

  • 1.5 with 0 decimals → 2
  • -1.5 with 0 decimals → -2
  • 1.25 with 1 decimal → 1.3
  • -1.25 with 1 decimal → -1.3

When to use: This is the standard rounding method taught in school and used in most spreadsheet applications. Use this for general-purpose rounding in most scenarios.

Best for:

  • Financial calculations
  • General mathematical operations
  • When consistency with Excel/Google Sheets is important
  • When working with negative numbers and you need symmetrical rounding behavior

Round Up (Ceiling)

How it works: Always rounds toward positive infinity, regardless of whether the number is positive or negative.

Examples with positive numbers:

  • 1.3 with 0 decimals → 2
  • 1.21 with 1 decimal → 1.3

Examples with negative numbers:

  • -1.3 with 0 decimals → -1 (rounds toward positive infinity)
  • -1.21 with 1 decimal → -1.2

When to use: When you need values to consistently round in the positive direction across all numbers.

Best for:

  • Inventory calculations where you need to ensure sufficient quantity
  • Scenarios where underestimating would cause problems

Technical note: This implements the mathematical "ceiling" or "ceil" function

Round Down (Floor)

How it works: Always rounds toward negative infinity, regardless of whether the number is positive or negative.

Examples with positive numbers:

  • 1.7 with 0 decimals → 1
  • 1.29 with 1 decimal → 1.2

Examples with negative numbers:

  • -1.7 with 0 decimals → -2 (rounds toward negative infinity)
  • -1.29 with 1 decimal → -1.3

When to use: When you need values to consistently round in the negative direction across all numbers.

Best for:

  • Discount calculations
  • Scenarios where overestimating would cause problems

Technical note: This implements the mathematical "floor" function.

✏️

This is how Round Up and Round down work for **negative **numbers

MethodExampleKnack Result
Round Up-1.3 with 0 decimals-1 (toward positive ∞)
Round Down-1.7 with 0 decimals-2 (toward negative ∞)



Currency

Currency fields are like Number fields, but with a currency symbol and formats for decimals and commas automatically included.

Currency field settings

Currency field settings

Settings:

  • Format: The type of currency used to format each number
  • Default Value: This value will be used by default if no value is entered

Auto Increment

Auto increment fields are used to give each record a unique ID by starting at one (1) and adding one for each new record.

Auto Increment field settings

Auto Increment field settings


📘

Auto Increment fields are unique, ascending, and immutable. The number may not be sequential.


Related Links