8 Replies Latest reply on Oct 2, 2016 2:54 PM by J_File

# Setting significant figures for values less than 1

Hi,

I can't seem to find a way to set significant figures (different to decimal places). I have looked in both the inspector and the number functions in the calculations, but nothing seems to jump out at me.

Basically, I want to take be able to say that when a value in a field is less than 1, the result that is returned is to 2 significant figures.

e.g.

0.1234511 = 0.12

0.068331 = 0.068

0.0034551 = 0.0035 (ROUNDED UP)

etc.

Can this be achieved?

James

• ###### 1. Re: Setting significant figures for values less than 1

Round() has a precision parameter. Does that help?

Sent from miPhone

• ###### 2. Re: Setting significant figures for values less than 1

As Beverly says. With Round ( ) you specify the number source and the precision and it will run yup or down as required, thus:

Round ( 0.1234511 ; 2 ) = 0.12

Round ( 0.068331 ; 3 ) = 0.068

Round ( 0.0034551 ; 4 ) = 0.0035

One thing this function won't do, however, is add trailing zeros since they are mathematically meaningless, so if the result is 0.12 and you wanted that to four places it will not give 0.1200.

• ###### 3. Re: Setting significant figures for values less than 1

I am wondering if the OP is looking for a variable field display of significant digits. So if the result is > 0.0999999 (not sure how many decimals this should go to then it would round as 0.xx but as keywords says without the trailing zero,

If the result is >0.00999999 = 0.0xx etc...

There is a custom function at FileMaker Custom Function:RoundToSigFigs ( number ; sigfigs ) that might fit the bill.

2 of 2 people found this helpful
• ###### 4. Re: Setting significant figures for values less than 1

I believe, the OP wants two digits (rounded), starting with the first non-zero digit. Then, 0.0099999 would be an exception

If so, this would be a 'job' for a custom function that checks for the first non-zero digit after the decimal, separates, rounds the following digits - and clues the results together

1 of 1 people found this helpful
• ###### 5. Re: Setting significant figures for values less than 1

Hi,

the link in MaxEh 's post is probably what you want.  Significant digits is not something FM handles natively.  You need a custom function.

• ###### 6. Re: Setting significant figures for values less than 1

That's correct.

As I understand it, the ROUND() function is extremely limited with how many digits it "actually" displays.

For example:

For integer or decimal values for these precision needs, I handle this situation outside of FM.

• ###### 7. Re: Setting significant figures for values less than 1

just in case you don't have FMP Advanced (for custom functions), you can create what I call a "function script".  You would send this script a script parameter (the number to be evaluated); and retrieve the value via Get(ScriptResult).  You would implement the logic of the custom function within the function script (even if it's recursive).

• ###### 8. Re: Setting significant figures for values less than 1

Thanks for all the responses. Max, I think you have hit on what I want.

I do have FM 15 Advanced, so will be able to use the custom functions option which is good news. I suppose I can then use this to run a function based upon the result a calculation gives. Bearing in mind I want to apply this to a calculation result field which could possibly return any number from say 1000 to 0.00001, I would be looking to add some form of logic which would effectively say:

"If the value generated by the calculation is >100, then report to 0 decimal places, if the value generated by the calculation is between 10 and 100, then report too 1 decimal place, if the value generated is between 1 and 10, then report to 2 decimal places, if the value generated by the calculation is <1, then report the value generated to 2 significant figures"

I am probably getting a little ahead of myself, I am only up to page 400 or so on the FM14: The Missing Manual Book, and have not really started building my solution yet, save for playing around with the Dayback Calendar from Seedcase and a bit of a play with layouts.

Once I have finished the book, I also have some 1 to 1 training sessions booked with a FM Training provider here in the UK, so I am sure we can sort this out between us, but thanks for all the help so far.

James