Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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 (correct) and 1 (incorrect)
expected:   2.3 and 1.0

How can I work around this? I'm running FM Pro 12 Advanced.

Edited by jax

13 minutes ago, jax said:

That's a bug as far as I can see.

No, it's not a bug at all. The result of the Round() function is a number. A number does not have trailing (or leading) zeros. If you want to format the number to always display one decimal digit, you can use:
 

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

which calculates a text result.

  • Author

Thanks comment. Works like a charm.

I interpreted this differently since in my work as a scientist 1.0 means you are sure about the decimal. 1 means you have no idea whether it's 1.0 or 1.4. This is why I expected Round (number;1) to also return a zero.

Hey comment, just wanted to say, that function using SerialIncrement is awesome.

I had never seen that function before (introduced in FileMaker 7), but now plan to find a way to use it very soon. Great technique.

5 hours ago, jax said:

in my work as a scientist 1.0 means you are sure about the decimal.

I understand that but I don't think it's feasible, in a general computing language, to keep track of every number's value and precision. You would also have to modify the arithmetic rules applied to these numbers.

  • 2 weeks later...

Admittedly I'm a noob wading around in the deep end of the pool, but can't you use the data tab on the Inspector to set the number of decimal places to 1?  The underlying data in the Table doesn't change from what was entered so the accuracy isn't altered, but the display is now in the format I think you are looking for (You entered 1.0 and it will display as 1.0).

hth

Yes Guy, the data formatting options in the Inspector are often all that's needed. The exceptions are things like merging a decimal number into a block of text for an email or whatever, which sounds like what the goal is here.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.