July 15, 20169 yr 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 July 15, 20169 yr by jax
July 15, 20169 yr 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.
July 15, 20169 yr 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.
July 15, 20169 yr 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.
July 15, 20169 yr 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.
July 28, 20169 yr 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
July 28, 20169 yr 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