8 Replies Latest reply on Jul 17, 2016 6:24 AM by greatgrey

# suspected bug Round function - numbers ending in zero not rounded

I use a formula to round a number to 1 decimal point and put brackets around it before plugging it into a text document. This works fine for most numbers but it fails for numbers ending in zero. They are instead returned by the function without any decimal, 1 nothing instead of 1.0. That's a bug as far as I can see. If I specify 1 decimal point and get none from the function, I consider the code broken.

input:      numbers with variable decimal points, e.g. 2.345 and 1.0

formula:    "(" & Round ( final grade ; 1 ) & ")"

output:     2.3   and  1

expected:   2.3   and  1.0

How can I work around this?

• ###### 1. Re: suspected bug Round function - numbers ending in zero not rounded

There might be a neater way, but this works (where NumberOriginal is your 'final grade').

"("

&

Div ( NumberOriginal ; 1 )

&

Case (

Mod (  Round ( NumberOriginal ; 1 ); 1 ) = 0 ; ".0" ;

Mod (  Round ( NumberOriginal ; 1 ); 1 )

)

& ")"

1 of 1 people found this helpful
• ###### 2. Re: suspected bug Round function - numbers ending in zero not rounded

As it turns out the FileMaker Round function works differently from what I expected. It does not return trailing zeros.

Comment supplied the following solution to this problem :

Let (
r = Round ( final grade ; 1 )
;
Int ( r ) & SerialIncrement ( ".0" ; 10 * Mod ( r ; 1 ) )
)

• ###### 3. Re: suspected bug Round function - numbers ending in zero not rounded

Thanks Alan. Both answers are very similar.

• ###### 4. Re: suspected bug Round function - numbers ending in zero not rounded

If you are just displaying the field. open the inspector data tab and go to the bottom and tell it to display it as a decimal with 1 place. Otherwise the above is needed.

• ###### 5. Re: suspected bug Round function - numbers ending in zero not rounded

But the brackets wouldn't be available then, I don't think.

• ###### 6. Re: suspected bug Round function - numbers ending in zero not rounded

True you would have to Make the (    )   part of your layout.

put in text box

(<<field name>>)

then click out of it then select the text box and format it as 1 digit decimal.  See attached file

1 of 1 people found this helpful
• ###### 7. Re: suspected bug Round function - numbers ending in zero not rounded

greatgrey wrote:

If you are just displaying the field. open the inspector data tab and go to the bottom and tell it to display it as a decimal with 1 place. Otherwise the above is needed.

That was my first attempt but since the field content comes from the Round function you cannot make any changes once it's been converted. And as Alan pointed out, I wouldn't be able to add the brackets which are required by the report style. If you add them as elements separate from the number, as I attempted, you get oversized spaces between brackets and the number -  (    1.0    ).

What I didn't know yet is your neat trick to add a variable content directly to text. I used a separate field for the number and then 2 text elements with a bracket each and spacing is horrible there even with automatic left shift set in the object options. Your: average (<<fieldname>>) is a great solution (see below). Thanks.

• ###### 8. Re: suspected bug Round function - numbers ending in zero not rounded

It's just the standard labels and Merge fields