Microsoft Knowledge Base Email Alertz

(822024) - With a Microsoft Office InfoPath form template, if you add an expression box that evaluates a mathematical expression that involves decimal numbers, you may receive incorrect results.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 822024 - Last Review: September 22, 2011 - Revision: 5.0

Expression box may return incorrect results for mathematical expressions in InfoPath 2003 or in InfoPath 2007

On This Page

SYMPTOMS

With a Microsoft Office InfoPath form template, if you add an expression box that evaluates a mathematical expression that involves decimal numbers, you may receive incorrect results.

CAUSE

This problem occurs because of a known issue when floating-point numbers are represented in the base-2 (binary) number system. For more information about floating-point errors, click the following article number to view the article in the Microsoft Knowledge Base:
42980  (http://kbalertz.com/Feedback.aspx?kbNumber=42980/ ) (Complete) Tutorial to understand IEEE floating-point errors

RESOLUTION

To resolve this problem, use the round function in the InfoPath form. For example, modify the XPath expression that is mentioned in the "More Information" section as follows:
round((my:field1)+(my:field3)-(my:field2)-(my:field4))=0

MORE INFORMATION

Steps to reproduce the problem

  1. In InfoPath, design a new, blank form.
  2. In the Design Tasks pane, click Layout to open the Layout task pane.
  3. In the Layout task pane, click Table with Title.
  4. In the table, click the text Click to add a title, and then type Accounting Example.
  5. Right-click the text Click to add form content, and then click Split Cells.
  6. In the Split Cells dialog box, set Number of columns to 3, set Number of rows to 3, and then click OK.
  7. Add data to the cells as follows:
    1. Add the following text to the table:
      Collapse this tableExpand this table
      MonthCreditsDebits
      February
      March
    2. In the task pane, click Controls to open the Controls task pane.
    3. Click inside the cell on the second row and the second column, and then click Text Box in the task pane to add a text box.
    4. Right-click the text box, and then click Text Box Properties.
    5. In the Text Box Properties dialog box, set Data type to Decimal (double), set Default value to 1.225, and then click OK.
    6. Repeat steps c through e for the cell in the second row and the third column, but set Default value to 1.225.
    7. Repeat steps c through e for the cell in the third row and the second column, but set Default value to1.333.
    8. Repeat steps c through e for the cell in the third row and the third column, but set Default value to 1.333.
  8. Click outside the table, and then press the ENTER key. Type the following:
    Does account reconcile?
  9. Switch to the Controls task pane, and then click Expression Box.
  10. In the Insert Expression Box dialog box, set XPath to the following, and then click OK:
    (my:field1)+(my:field3)-(my:field2)-(my:field4)=0
Notice that the value of the expression box is set to false after you follow these steps.

APPLIES TO
  • Microsoft Office InfoPath 2007
  • Microsoft Office InfoPath 2003
Keywords: 
kbxml kbbug KB822024
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate