round() function doesn't work well - InfoPath Dev
in

InfoPath Dev

round() function doesn't work well

Last post 01-06-2011 11:22 PM by edouard. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 01-06-2011 08:00 AM

    round() function doesn't work well

     I was so confused.

    I'm working on a project creating an InfoPath 2010 form which will submit to an SQL (2008 R2) database. Here's a curious situation. I have two values, I use the round function to restrict the decimal portion to four. Here's the basic calculation: round((@field1 / @field2) * 10000) * 0.0001. The data is valid sometimes.

     I did a test: seting field1 to 1, set field2 to (1,2,3,4,5,6,7,8,9,10,11), the results are (1, 0.5, 0.333300000, 0.25, 0.2, 0.166700000, 0.1429, 0.125, 0.1111, 0.1, 0.090900000), these invalid were when field2 are 3,6,11.

     Anyone have any ideas?

  • 01-06-2011 05:59 PM In reply to

    Re: round() function doesn't work well

    any ideas for this? please help, this is urgent, it drive me crazy.
  • 01-06-2011 08:02 PM In reply to

    Re: round() function doesn't work well

    What's the precision (data type) for the field that is receiving the calculated results?

    Is this all happening within InfoPath, or are you round-tripping the value to SQL and seeing the results change?

    Patrick Halstead
    Project Manager at Qdabra
  • 01-06-2011 11:12 PM In reply to

    Re: round() function doesn't work well

    Try using div 10000 instead of * 0.0001.  That should work better.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-06-2011 11:22 PM In reply to

    Re: round() function doesn't work well

    It works, thank you guys so much.

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.