Java doc.replaceItemValue(fldname, Floatvalue) precision problems

I’m having precision problems. I have a WebQueryOpen agent that sets various fields on my form. Some of the values are Floats. When I use doc.replaceItemValue() to set the field, the value that gets displayed isn’t quite the same number.

For example, if the Float variable ‘f’ has a value of 15.95, when I set the field with doc.replaceItemValue(), the value on the form is 15.94999999.

I’ve tried also using a Double. Same results.

One ‘workaround’ I’ve found is to do a .toString() on the Float (e.g. “doc.replaceItemValue(fldname, f.toString()”). While this works - I get 15.95 in the field - the field is then a text field, not a number field.

Any ideas?

Subject: Java doc.replaceItemValue(fldname, Floatvalue) precision problems

Use BigDecimal class of java.math you will get all sorts of api to round the new value up to 15.95