FileMaker Number Functions And Negative Values

From Dwayne Wright PMP, PMI-ACP, CSM
Certified FileMaker Developer

WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright
YOUTUBE: FileMakerThoughts

Working with number functions are pretty straight forward until you start working with negative values. Using the negative number of - 189.12548, the following functions (ABS, Round, Truncate, Floor, Ceiling and Integer) return what value and why? What if we use a negative value in the second parameter (where available) to determine the direction from the decimal point?

------------
Abs ( - 189.12548 ) returns 189.12548
The Abs is short for absolute and always returns a positive number. Commonly used to know the difference between two values without knowing which is greater.

This is pretty simple to figure out.

------------
Round ( - 189.12548; 2 ) returns -189.13
Round ( - 189.12548; -2 ) returns -200

A function commonly used to round a number to a specified number of decimal places in the second part of the functions parameter. The specified rounding space takes numbers below 5 and rounds them downward. Numbers equal to or above 5 are rounded upward.

Again, this one is pretty straight forward. Round ( numberToEvaluate; 2 ) returns -189.13 because we are going two deep to the right of the decimal point and rounding the 5 digit upward. Round ( numberToEvaluate; -2 ) returns -200 because we are going two places to the left of the decimal point and rounding the 8 upward.

------------
Truncate ( - 189.12548; 2 ) returns -189.12
Truncate ( - 189.12548; -2 ) returns -100

Truncate gives you a number that is cut off to a number of decimal places that you specify. This doesn't do any rounding but simply a cutoff point. Truncating with a negative precision will take you to the right of the decimal point.

Again, this one is pretty straight forward. Truncate ( numberToEvaluate; 2 ) returns -189.12 because we are going two deep to the right of the decimal point and stopping. Truncate ( numberToEvaluate; -2 ) returns -100 because we are going two places to the left of the decimal point and stopping.

------------
Floor ( - 189.12548 ) returns -190

The floor function returns a number rounded down to it's next closest integer value.

Now this one could possibly throw you because you may automatically think -189 is the answer. This is because mentally we don’t work with negative numbers that much and we think 189 is lower than 190. However, in a negative number situation, -190 is less than -189. Some others get confused because they think floor means zero and it does not.

------------
Ceiling ( -189.12548 ) returns -189

Ceiling will return a number rounded up to the next integer value.

Learning how Floor reacted to a negative value prepares you for how Ceiling will handle it.

------------
Int ( -189.12548 ) returns -189

This function is used to return a whole number for a given number or field, however it does not perform this by rounding. For instance, the integer value for the number 5.3 would return as 5 and the integer value for the number 5.7 would return as 5.

=
More info about the author and FileMaker in general, contact me at info@dwaynewright.com.

© 2009 - Dwayne Wright - dwaynewright.com

The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.