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.
2 of 2 people found this helpful
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.
1 of 1 people found this helpful
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
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).
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.