Loading

CEILING and FLOOR Salesforce Formula Functions Return Unexpected Results for Negative Numbers

Publiceringsdatum: May 21, 2026
Beskrivning
When using the CEILING() and FLOOR() formula functions, numbers are rounded up (to the nearest integer) and down (to the nearest integer) respectively.  However, when the number is negative, the behavior is reversed.  

For example, the results of a positive and negative number:

CEILING (2.5) = 3.0
FLOOR (2.5) = 2.0

CEILING (-2.5) = -3.0
FLOOR(-2.5) = -2.0
Lösning

How CEILING() and FLOOR() Work with Negative Numbers

When a negative number is used in a CEILING() function, the application uses the FLOOR() function instead.  And when the FLOOR() function is used for a negative number, the CEILING() function will be used.  

In other words the function applies on the number as an absolute value. Example for Ceiling of -2.5, the system applies the Ceiling to 2.5 and hence the result is 3. Then the negative is added.

This behavior is by design. Both CEILING() and FLOOR() apply their logic to the absolute value of a negative number, then reapply the negative sign. For example: CEILING(-2.5) — the system applies CEILING to 2.5 to get 3, then applies the negative to get -3.

Knowledge-artikelnummer

000386432

 
Laddar
Salesforce Help | Article