TutorialRounding numbers in Gravity Forms

Do you want more options to round numbers in Gravity Forms Number Fields and calculations? And decide in which direction to round the number, like rounding up (ceil), rounding down (floor) or automatically (round up or down dependend on the value you want to round)? With the GravityWP – Advanced Number Field that’s as easy as it gets.

Rounding up to 5 decimal places

With Advanced Number Field enabled, you can easily select a checkbox in your Field Settings of the Gravity Forms Number Field you want to round. Two extra options appear:

  • Rounding to decimal places: you can select up to 5 decimal places to round.
  • Rounding method: Round (up or down depending on the value), Ceil (rounding up), Floor (rounding down)
Screenshot Rounding options and settings Advanced Number Field for Gravity Forms Number Fields.
Screenshot Rounding options and settings Advanced Number Field for Gravity Forms Number Fields.

Using rounding on calculations

You can also activate rounding on calculations. Make a calculations like you are used to, using Merge Tags with number values and select ‘Round the Value’ to automatically round the outcome of the calculation.

Sceenshot of activating rounding on a Gravity Forms number field calculation.
Sceenshot of activating rounding on a Gravity Forms number field calculation.

Use in combination with custom units

You can use the rounding option in combination with custom units like square or cubic meters (m2, m3), the percentage sign (%), degrees Celcius or Fahrenheid (°C, °F), Irradiance (W/m2) or another custom unit.

Check out the Tutorial about Custom Units for Gravity Forms Number Fields.

Screenshot of adding custom unit square meter (m2) to the Gravity Forms Number Field.
Screenshot of adding custom unit square meter (m2) to the Gravity Forms Number Field.

Rounding without add-on

You can read on the Gravity Forms community forum more about rounding without an add-on. This is no standard functionality in Gravity Forms for rounding, but with custom JavaScript/jQuery you can program your own solution if you want the rounding to happen in real time.

If real-time rounding is not necessary, you can also use the gform_field_validation filter to check the entered value or the gform_pre_submission filter to change the value after submission. Read more on the Gravity Forms forum.

Rounding by Increments GravityWiz

Gravity Perks has a snippet available to round numbers by increment using specific CSS classes. You can add the snippet to your functions.php file or download it as a plugin from their website. This can be also very handy if you want rounding on bigger numbers, like rounding to 100 if something is above 50.

FAQ about rounding numbers in Gravity Forms

Can you round numbers in Gravity Forms without a plugin?

There are no default options in Gravity Forms to round numbers. As explained on the Gravity Forms community forum, you’ll need some custom JavaScript/jQuery or if real-time rounding is not necessary, use Gravity Forms filters.

Can I use rounding for calculations with Advanced Number Field?

Yes, you can also apply rounding on calculations in Gravity Forms Number Fields. The rounding will take place on the final calculated value.

Up to how many decimal places can I round with Advanced Number Field?

You can round up Gravity Forms Number Fields up to 5 decimal places.

Can I force rounding to an integer with Advanced Number Field?

Yes, you can set the number of decimal places to 0 and the Gravity Forms Number Field will only accept whole numbers.

Read more tutorials about GravityWP BV

GravityWP develops add-ons to collect and manage your data better.
All tutorials GravityWP BV