Brian Dunning's FileMaker Custom Functions

RoundToSigFigs ( number ; sigfigs )

Rounds a number to the specified number of significant figures.

  Average rating: 4.7 (31 votes) Log in to vote

Ryan Brandys   Ryan Brandys
Branmuffin Industries
http://www.branmuffinindustries.com

Share on Facebook Share on Twitter

  Sample input:
1234 ; 1
1234 ; 2
1234 ; 3
0.0009876 ; 1
0.0009876 ; 2
0.0009876 ; 3
  Sample output:
1000
1200
1230
0.001
0.00099
0.000988

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

Rounds a number to the specified number of significant figures. Uses a log base ten to gauge the order of magnitude for "number" and uses that to figure out which decimal place is the rounding point. Then it uses filemaker's built in rounding function to round to that point. For > .5, this function rounds up.

 

Comments

Henry Olders   Henry Olders, Montreal
Dec 1, 2015
because the log function only works with positive numbers, use

Round ( number ; sigfigs - 1 - Floor ( Log ( Abs ( number ) ) ) )
 

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.