5 Replies Latest reply on Jun 29, 2015 9:54 AM by philmodjunk

    Rounding Bug?

    firebase

      Title

      Rounding Bug?

      Post

      This actually should round to 13 right?

      Round ( 12,9948000000000002 ; 2 )

      But the result is 12,99.

        • 1. Re: Rounding Bug?
          SteveMartino

          If you want to only see whole numbers i would think to try Round(field;0), or do you need to see the number to 2 places?

          • 2. Re: Rounding Bug?
            firebase

            I need 2 digits after the , like 12,34

            My problem is that another app was calculating 13 out of this and Fm is calculating 12,99 out of this.

            To my point of view 12,99 is wrong.

            • 3. Re: Rounding Bug?
              philmodjunk

              There is no bug.

              Round ( 12,9948000000000002 ; 2 )

              will round the value to 2 places after the decimal. That will be 12,99, not 13.

              To get no places after the decimal, use 0 for the second parameter:

              Round ( 12,9948000000000002 ; 0 )

              That will return a value of 13

              • 4. Re: Rounding Bug?
                firebase

                I allways thought that all known numbers would be considered to be round up from the last digit and not only tha last digit before the cut.

                So that would make 13 instead of 12,99.

                But I went trough wikipedia and I am still now clear what is right???

                • 5. Re: Rounding Bug?
                  philmodjunk

                  This is a basic math question. If you compare the typical rounding taught in a grade school math text book to how the Round function works, they are completely consistent.

                  Rounding 12,9948 to two decimals means that you examine the 3rd digit after the decimal. That value is 4. Values of 4 or smaller are simply discarded. Values of 5 or larger result in adding 1 to the digit to the immediate left. The value of the 4th digit, 8 in this case has no effect on how the number is rounded.

                  Thus, the correct value returned is 12,99---exactly the value returned by this FileMaker function when you specify a parameter of 2 for 2 decimal places.