Brian Dunning's FileMaker Custom Functions

FlexFloor ( number ; precision )

An expanded "Floor" that accepts a precision argument

  Average rating: 4.4 (27 votes) Log in to vote

Kevin Frank   Kevin Frank
Kevin Frank & Associates
http://www.kevinfrank.com

Share on Facebook Share on Twitter

  Sample input:
FlexFloor ( 123.789 ; -3 )
FlexFloor ( 123.789 ; -2 )
FlexFloor ( 123.789 ; -1 )
FlexFloor ( 123.789 ; 0 )
FlexFloor ( 123.789 ; 1 )
FlexFloor ( 123.789 ; 2 )
FlexFloor ( 123.789 ; 3 )
  Sample output:
0
100
120
123
123.7
123.78
123.789

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

While the Floor function by definition returns the greatest integer <= x, I found myself wishing it could accept a precision argument the way Truncate does. The FlexFloor custom function allows this to happen.

At first glance, it appears that FlexFloor's behavior is identical to Truncate's... i.e., they both apparently "always round down", but this is only true for positive numbers. Truncating a *negative* number will make it *larger* (i.e., bring it back toward zero), but FlexFlooring it (or simply Flooring it) will make it *smaller* (i.e., move it farther away from zero).

E.g., Truncate ( -4.7 ; 0 ) = -4 whereas FlexFloor ( -4.7 ; 0 ) = -5

Note: see also the companion custom function, FlexCeiling.

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.