Pattern( not working consistently


in formulafill, arraybuild, etc. statements, the pattern( function isn’t working.

md is a float field; mdtex is a text field.
     field mdtxt     formulafiill pattern(md, ‘#.##’)
results in values like this:

oddly, message pattern(9.289999999999999, ‘#.##’) gives me what i expect: 9.29.
but mdtxt = pattern(9.289999999999999, ‘#.##’) results in 9.289999999999999.


I can’t duplicate this. In a new database, the A field is a text field. The B field is float. Entering 9.29, 85.49, and 71.99 into the B field cause them to be displayed as I entered them in a text editor object, but as 9.289999999999999, 85.48999999999999, and 71.98999999999999 in a text display object.

Field A
FormulaFill B

puts the long numbers in the A field.

Field A
FormulaFill pattern(B,'#.##')

puts 9.29, 85.49, and 71.99 in the A field

If the number is already text, the pattern( function just passes the text along as it found it, so

Field A
FormulaFill pattern(str(B),'#.##')

puts 9.289999999999999, 85.48999999999999, and 71.98999999999999 into the A field.


You described the reason: Your field mdtxt is a text field. I think you will get the same result if you use

message pattern(mdtxt,'#.##')

If you want to do calculations with the contents of your text field, you have to use the val( function to convert the text into a value. (Or easier: you set the field a floating number field with a #.## output pattern.)


to kjm,
i’m not trying to do any calculations in a text field.
i’m trying to populate a text field with text that looks like numbers rounded to 2 decimal places, but i’m not getting that. i’m getting the long floating point number.
pattern( isn’t doing its job.

to dave,
apparently you aren’t having the issue. pattern( is behaving as expected for you.
but it isn’t for me.
i’d be happy to send you my file.


I sent you a personal message with my email address.


Both the md, and the mdtxt fields were text fields, not float. When its first parameter is already text, the pattern( function simply passes that value on unchanged.