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 - Show more from this author
Kevin Frank & Associates
https://filemakerhacks.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.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: