Announcement

Collapse
No announcement yet.

Miva Merchant Empresa Bugs?

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Re: Rounding bug in 5.06

    Hi Bill,

    On Windows/Empresa 5.06 this seems to be working correctly, yielding 1,1,2 .

    Markus
    Emerald Media, Trade & Technology USA/Germany
    Professional Miva Programming since 1998
    Home of the Emerald Objects Application Server (EOA)
    Multi-dimensional CRM, CMS & E-Commerce

    http://www.emeraldobjects.com
    http://www.sylter-seiten.com

    Comment


      #17
      Re: Rounding bug in 5.06

      The server I am on is not running Windows. I didn't test on Mia, but was told by the person who originally told me of the bug that their Mia 5.03 was reporting it correctly. It was just their 5.06 on the server that was messed up.
      Last edited by wcw; 08-14-07, 01:47 PM.
      Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
      Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
      Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
      Facebook http://www.facebook.com/EmporiumPlus
      Twitter http://twitter.com/emporiumplus

      Comment


        #18
        Re: Rounding bug in 5.06

        This bug is apparently much worse. Expanding the test you get

        0.5 rounds to 0
        1.5 rounds to 2
        2.5 rounds to 2
        3.5 rounds to 4
        4.5 rounds to 4
        5.5 rounds to 6
        6.5 rounds to 6
        7.5 rounds to 8
        8.5 rounds to 8

        Even numbers round down and odd numbers round up. This has nothing to do with banker rounding. Anybody have any thoughts on it?

        Rick - can we get this fixed soon? I realize updating empresa is a major undertaking, but you have to be able to trust a program's math.
        Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
        Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
        Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
        Facebook http://www.facebook.com/EmporiumPlus
        Twitter http://twitter.com/emporiumplus

        Comment


          #19
          Re: MIVA Empresa Bugs?

          Mark, our new VP of Development, will be posting about this shortly.
          Thanks,

          Rick Wilson
          CEO
          Miva, Inc.
          [email protected]
          https://www.miva.com

          Comment


            #20
            Re: Rounding bug in 5.06

            Bill,

            Your test is showing the expected output from the rnd function, i.e. a number ending in .5 rounds towards the even number. Here is a simple C test program:

            #include "stdio.h"

            double d1 = 0.5;
            double d2 = 0.51;
            double d3 = 1.5;

            int main () {
            printf( "%.0f %.0f %.0f\n", d1, d2, d3 );
            }

            It produces the output: "0 1 2"

            What you want to use is either int( number + 0.5 ) or floor( number + 0.5 ) depending on what you want to happen with negative numbers.

            int( -3.2 ) is -3 but floor( -3.2 ) is -4.


            Originally posted by wcw
            This bug is apparently much worse. Expanding the test you get

            0.5 rounds to 0
            1.5 rounds to 2
            2.5 rounds to 2
            3.5 rounds to 4
            4.5 rounds to 4
            5.5 rounds to 6
            6.5 rounds to 6
            7.5 rounds to 8
            8.5 rounds to 8

            Even numbers round down and odd numbers round up. This has nothing to do with banker rounding. Anybody have any thoughts on it?

            Rick - can we get this fixed soon? I realize updating empresa is a major undertaking, but you have to be able to trust a program's math.
            Mark Johnson
            Vice President Development
            Miva Merchant
            [email protected]
            http://www.mivamerchant.com

            Comment


              #21
              Re: Rounding bug in 5.06

              That is not logical. .5 should be expected to round up in every case. Why is Markus finding on Windows Empresa that it works differently, ie .5 rounds up to 1?
              Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
              Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
              Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
              Facebook http://www.facebook.com/EmporiumPlus
              Twitter http://twitter.com/emporiumplus

              Comment


                #22
                Re: Rounding bug in 5.06

                Originally posted by wcw
                That is not logical. .5 should be expected to round up in every case. Why is Markus finding on Windows Empresa that it works differently, ie .5 rounds up to 1?

                I'm sorry that you don't find it logical, but it is the accepted standard for rounding. That is, since 2.5 is exactly half way between 2 and 3, the choice of which way to round is arbitrary. Someone long ago established the "round towards the even number" rule. The accepted standard in computing is the C language printf function which is why I used it in my example. It is also the reason that it is implemented that way in the MivaScript engine.

                I agree with you that if it behaves differently on Windows, that is a problem. I am investigating that now.
                Mark Johnson
                Vice President Development
                Miva Merchant
                [email protected]
                http://www.mivamerchant.com

                Comment


                  #23
                  Re: Rounding bug in 5.06

                  Please keep us posted. If that is the accepted method, I can live with that. Course it should work the same way on Windows (and Mia) the same way.
                  Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
                  Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
                  Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
                  Facebook http://www.facebook.com/EmporiumPlus
                  Twitter http://twitter.com/emporiumplus

                  Comment


                    #24
                    deleted. ..........
                    posted in wrong place
                    Last edited by SpaceMoose; 08-14-07, 05:12 PM.

                    Comment


                      #25
                      Re: Rounding bug in 5.06

                      When they find that there are versions of Empressa that give different
                      results, which version are they going to 'fix'? The useful one?

                      Comment


                        #26
                        Re: MIVA Empresa Bugs?

                        http://en.wikipedia.org/wiki/Roundin...to-even_method I think I learn something from Wiki every day :D

                        PHP does not use the round-to-even method.
                        Code:
                        <?php printf( "%.0f %.0f %.0f\n", 0.5, 0.51, 1.5); //prints: 1 1 2 ?>

                        Comment


                          #27
                          Re: MIVA Empresa Bugs?

                          I have done some research on this issue. Here's what I came up with. The Miva Engine uses the C sprintf function to implement its rnd function and ROUND operator. This is considered a standard way to do rounding. On UNIX systems the sprintf function does the "round to even" method. Unfortuneately on Windows the same function does the "round up" method.

                          So I decided to look around and see how it's done elsewhere. Brandon MUS posted that PHP uses "round up". Perl uses "round to even". Python uses "round to even". Ruby uses "round up".

                          I even looked at Microsoft Excel. It has three functions: ROUND, ROUNDUP and ROUNDDOWN. The last two do exactly what you'd expect, but ROUND behaves identically to ROUNDUP.

                          There is good reason to use the "round to even" method. In calculations on a lot of numbers it avoids the tendency to bias the results in the direction of the rouding. That is going up half the time tends to balance out with the going down half the time.

                          My inclination is to have Miva behave the same on all platforms and use the "round to even" method. I would also be favorable to the Excel idea and add a "round up" and "round down" function.

                          Being new here, we thought we would take an informal poll of the developers. So if you hava an opinion, let us know.
                          Mark Johnson
                          Vice President Development
                          Miva Merchant
                          [email protected]
                          http://www.mivamerchant.com

                          Comment


                            #28
                            Re: MIVA Empresa Bugs?

                            In the past I think there has been an issue with the tax getting rounded inconsistently so that one of the payment modules was messing up on rare occasions. I don't know if it was paylink or which one; maybe someone else knows. But that is a consideration on how to do it. Will it mess up a payment module? Apparently this is bankers rounding and since the major reason for mivascript is a shopping cart that deals with money, the round to even might be the way to go.

                            On the other hand, I vote for the Excel method, ie three different functions, ie rnd(), rndeven(), rndup(). rnd() would stay as it is now, for legacy reasons even though it is not consistant. Those who want to use rndup() function could do it that way. rndeven() would round even on all platforms (windows and unix). The downside is that there is tons of code that are using rnd() and thus inconsistant. So over time, those systems would get changed to the intended rounding system.

                            Thank you very much for getting back to us.
                            Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
                            Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
                            Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
                            Facebook http://www.facebook.com/EmporiumPlus
                            Twitter http://twitter.com/emporiumplus

                            Comment


                              #29
                              Re: MIVA Empresa Bugs?

                              Originally posted by Mark Johnson
                              I even looked at Microsoft Excel. It has three functions: ROUND, ROUNDUP and ROUNDDOWN. The last two do exactly what you'd expect, but ROUND behaves identically to ROUNDUP.

                              There is good reason to use the "round to even" method. In calculations on a lot of numbers it avoids the tendency to bias the results in the direction of the rouding. That is going up half the time tends to balance out with the going down half the time.
                              While that does make things more fair in the long run, it has been a common practice in all fields involving monetary exchanges that you round up - every time. I've seen the "round to even number" before, but that's mostly used in programming areas where you do not necessarily involve money exchanging hands. If you check with your local bank or supermarket or gas station, they always round up to the closest penny. Right or wrong, that's how "everyone in the world" does it in retail and financial businesses.

                              Comment


                                #30
                                Re: MIVA Empresa Bugs?

                                Originally posted by wcw
                                In the past I think there has been an issue with the tax getting rounded inconsistently so that one of the payment modules was messing up on rare occasions.
                                It is still a problem with sales tax and the LinkPoint payment module.

                                Comment

                                Working...
                                X