Bad FP error with MS C++ compiler

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adem24

    Bad FP error with MS C++ compiler

    // MS-Bug # 999,995 (5 left for 1 million bugs :-) :

    const double d = DBL_MIN;

    double v00 = 0.0;
    bool f00 = v00 d;

    double v01 = 0.1;
    bool f01 = v01 d;

    gives wrongly 'false' for f00... :-)

  • Alex Blekhman

    #2
    Re: Bad FP error with MS C++ compiler

    "Adem24" <adem24@adem24. org.invalidwrot e:
    // MS-Bug # 999,995 (5 left for 1 million bugs :-) :
    >
    const double d = DBL_MIN;
    >
    double v00 = 0.0;
    bool f00 = v00 d;
    >
    double v01 = 0.1;
    bool f01 = v01 d;
    >
    gives wrongly 'false' for f00... :-)
    The bug is in your code. DBL_MIN is a minimal positive value.

    Alex


    Comment

    • Adem24

      #3
      Re: Bad FP error with MS C++ compiler

      "Adem24" wrote:
      >
      // MS-Bug # 999,995 (5 left for 1 million bugs :-) :
      >
      const double d = DBL_MIN;
      >
      double v00 = 0.0;
      bool f00 = v00 d;
      >
      double v01 = 0.1;
      bool f01 = v01 d;
      >
      gives wrongly 'false' for f00... :-)
      Further analysis shows that it has nothing todo with the DBL_MIN
      but the value ZERO !
      Ie. the MS compiler treats the value 0 not correctly in FP ops.

      Comment

      • peter koch

        #4
        Re: Bad FP error with MS C++ compiler

        On 20 Jul., 16:10, "Adem24" <ade...@adem24. org.invalidwrot e:
        // MS-Bug  # 999,995 (5 left for 1 million bugs :-) :
        Or Adem24 bug# 3562?
        >
               const double d = DBL_MIN;
        d is bigger than 0: perhaps it would help to read the documentation?
        >
               double v00 = 0.0;
               bool   f00 = v00 d;
        >
               double v01 = 0.1;
               bool   f01 = v01 d;
        >
        gives wrongly 'false' for f00... :-)
        f00 should be true.

        /Peter

        Comment

        • Victor Bazarov

          #5
          Re: Bad FP error with MS C++ compiler

          peter koch wrote:
          On 20 Jul., 16:10, "Adem24" <ade...@adem24. org.invalidwrot e:
          >// MS-Bug # 999,995 (5 left for 1 million bugs :-) :
          Or Adem24 bug# 3562?
          >>
          >const double d = DBL_MIN;
          d is bigger than 0: perhaps it would help to read the documentation?
          >>
          >double v00 = 0.0;
          >bool f00 = v00 d;
          >>
          >double v01 = 0.1;
          >bool f01 = v01 d;
          >>
          >gives wrongly 'false' for f00... :-)
          >
          f00 should be true.
          REALLY? Should it? What's DBL_MIN, by definition? Hint: it's
          defined on the 5.2.4.2.2 of the C standard.

          V
          --
          Please remove capital 'A's when replying by e-mail
          I do not respond to top-posted replies, please don't ask


          Comment

          • Juha Nieminen

            #6
            Re: Bad FP error with MS C++ compiler

            Adem24 wrote:
            "Adem24" wrote:
            >// MS-Bug # 999,995 (5 left for 1 million bugs :-) :
            >>
            > const double d = DBL_MIN;
            >>
            > double v00 = 0.0;
            > bool f00 = v00 d;
            >>
            > double v01 = 0.1;
            > bool f01 = v01 d;
            >>
            >gives wrongly 'false' for f00... :-)
            >
            Further analysis shows that it has nothing todo with the DBL_MIN
            but the value ZERO !
            Ie. the MS compiler treats the value 0 not correctly in FP ops.
            Given that DBL_MIN is a positive value (larger than 0), exactly how is
            this a bug?

            Comment

            • =?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=

              #7
              Re: Bad FP error with MS C++ compiler

              On 2008-07-20 16:10, Adem24 wrote:
              // MS-Bug # 999,995 (5 left for 1 million bugs :-) :
              >
              const double d = DBL_MIN;
              >
              double v00 = 0.0;
              bool f00 = v00 d;
              >
              double v01 = 0.1;
              bool f01 = v01 d;
              >
              gives wrongly 'false' for f00... :-)
              Did you submit this "bug" to the gcc-team also, because I get the same
              effect using gcc as with MSVC.

              --
              Erik Wikström

              Comment

              • Gennaro Prota

                #8
                Re: Bad FP error with MS C++ compiler

                Erik Wikström wrote:
                On 2008-07-20 16:10, Adem24 wrote:
                >// MS-Bug # 999,995 (5 left for 1 million bugs :-) :
                >>
                > const double d = DBL_MIN;
                >>
                > double v00 = 0.0;
                > bool f00 = v00 d;
                >>
                > double v01 = 0.1;
                > bool f01 = v01 d;
                >>
                >gives wrongly 'false' for f00... :-)
                >
                Did you submit this "bug" to the gcc-team also, because I get the same
                effect using gcc as with MSVC.
                :-) Out of curiosity, is there really a bug count for VC++, somewhere?

                --
                Gennaro Prota | <https://sourceforge.net/projects/breeze/>
                Do you need expertise in C++? I'm available.

                Comment

                • Tim Roberts

                  #9
                  Re: Bad FP error with MS C++ compiler

                  "Adem24" <adem24@adem24. org.invalidwrot e:
                  >"Adem24" wrote:
                  >>
                  >// MS-Bug # 999,995 (5 left for 1 million bugs :-) :
                  >>
                  > const double d = DBL_MIN;
                  >>
                  > double v00 = 0.0;
                  > bool f00 = v00 d;
                  >>
                  > double v01 = 0.1;
                  > bool f01 = v01 d;
                  >>
                  >gives wrongly 'false' for f00... :-)
                  >
                  >Further analysis shows that it has nothing todo with the DBL_MIN
                  >but the value ZERO !
                  >Ie. the MS compiler treats the value 0 not correctly in FP ops.
                  I can't tell from this whether you are admitting that you are wrong, or are
                  moving off into other foolishness. "f00" SHOULD be false. Do you now
                  agree with that?
                  --
                  Tim Roberts, timr@probo.com
                  Providenza & Boekelheide, Inc.

                  Comment

                  • Victor Bazarov

                    #10
                    Re: Bad FP error with MS C++ compiler

                    Gennaro Prota wrote:
                    [..]
                    :-) Out of curiosity, is there really a bug count for VC++, somewhere?
                    >
                    There must be. Since you can add to the collection (and check if your
                    addition is in the collection), there must be a way to obtain the size
                    of the collection, right? Now, I am not sure there is a publicly
                    available bug count. See https://connect.microsoft.com/VisualStudio/

                    V
                    --
                    Please remove capital 'A's when replying by e-mail
                    I do not respond to top-posted replies, please don't ask

                    Comment

                    • joseph  cook

                      #11
                      Re: Bad FP error with MS C++ compiler

                      On Jul 20, 10:49 am, "Adem24" <ade...@adem24. org.invalidwrot e:
                      Further analysis shows that  it has nothing todo with the DBL_MIN
                      but the value ZERO !
                      Ie. the MS compiler treats the value 0 not correctly in FP ops.
                      Woah! Slow down. Millions (Billions? Trillions?) of lines of code
                      have been written using Microsoft compilers. Think about the
                      likelyhood that you are the first person to have tried using "0" in a
                      FP operation, and then consider the possibility that the problems lies
                      on your end, not the compilers.

                      --JC

                      Comment

                      • James Kanze

                        #12
                        Re: Bad FP error with MS C++ compiler

                        On Jul 21, 2:51 pm, Victor Bazarov <v.Abaza...@com Acast.netwrote:
                        Gennaro Prota wrote:
                        [..]
                        :-) Out of curiosity, is there really a bug count for VC++, somewhere?
                        There must be. Since you can add to the collection (and check
                        if your addition is in the collection), there must be a way to
                        obtain the size of the collection, right?
                        But what does it mean? Anyone who's worked in support at one
                        time or another knows that 90% of the complaints are user error
                        (like the one that started this thread). The fact that VC++ is
                        the most widely used compiler by beginners probably means that
                        it will get the most "bug reports": for some beginners (often
                        the most stupid), the problem is always the compiler, and not
                        their stupidity.

                        --
                        James Kanze (GABI Software) email:james.kan ze@gmail.com
                        Conseils en informatique orientée objet/
                        Beratung in objektorientier ter Datenverarbeitu ng
                        9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

                        Comment

                        • Victor Bazarov

                          #13
                          Re: Bad FP error with MS C++ compiler

                          James Kanze wrote:
                          On Jul 21, 2:51 pm, Victor Bazarov <v.Abaza...@com Acast.netwrote:
                          >Gennaro Prota wrote:
                          >>[..]
                          >>:-) Out of curiosity, is there really a bug count for VC++, somewhere?
                          >
                          >There must be. Since you can add to the collection (and check
                          >if your addition is in the collection), there must be a way to
                          >obtain the size of the collection, right?
                          >
                          But what does it mean? Anyone who's worked in support at one
                          time or another knows that 90% of the complaints are user error
                          (like the one that started this thread). The fact that VC++ is
                          the most widely used compiler by beginners probably means that
                          it will get the most "bug reports": for some beginners (often
                          the most stupid), the problem is always the compiler, and not
                          their stupidity.
                          Any product, especially as complex as a C++ compiler, contains errors
                          and misbehaviours, most of which are unintentional. *If* the product
                          manufacturer is interested in improving the product or at least their
                          image, they will be collecting the information on what seems to be wrong
                          with their product. Such information is often put in the form of a list
                          (of so called "bugs"). The list is finite, hence has a size. Some
                          manufacturers even make such lists public, many don't. Even if the list
                          is not public, it tends to have a size. That's what it means.

                          The suggestions or complaints are always verified against the product
                          specification, against common sense, product development schedules, etc.
                          If the suggestion is due to user error, it most likely will not be put
                          on the list of suggestions (although if it's an indication of a missing
                          feature or a possible work flow improvement, it might, indirectly). So,
                          the list of bugs most likely does not contain "bug reports" created due
                          to somebody's stupidity.

                          When I say "you can add to the collection" I don't mean "you can send an
                          e-mail about your problem". I mean you can cause the collection to grow
                          if your report is about a real defect in the product or contains a
                          genuine improvement suggestion.

                          V
                          --
                          Please remove capital 'A's when replying by e-mail
                          I do not respond to top-posted replies, please don't ask

                          Comment

                          Working...