Loading ...
Sorry, an error occurred while loading the content.

Bug report: ceiling in DOUBLE and REAL

Expand Messages
  • Prager, Daniel (CMIS, Clayton)
    I ve run into problems with ceiling (in both REAL and DOUBLE) with arguments that do not have a fractional part, with the post-condition result_no_smaller
    Message 1 of 11 , May 1, 2000
    • 0 Attachment
      I've run into problems with ceiling (in both REAL and DOUBLE) with
      arguments that do not have a fractional part, with the post-condition
      "result_no_smaller" violated. An example appears below along with
      excerpts from the stack traces. I'm running version -0.77
      of SmallEiffel under Windows NT.

      Notice that the post-conditions on floor and ceiling (shown here for
      DOUBLE) are not symmetric:

      floor: INTEGER is
      -- Greatest integral value no greater than Current.
      [snip]
      ensure
      result_no_greater: Result.to_double <= Current;
      close_enough: Current - Result < one;
      end;

      ceiling: INTEGER is
      -- Smallest integral value no smaller than Current.
      [snip]
      ensure
      result_no_smaller: Current <= Result;
      close_enough: Current - Result < one;
      end;

      BTW: "close-enough" (not the immediate cause of the error) looks to be the
      wrong way round (cut-and-paste strikes again?).


      Cheers

      Daniel


      ----------------------------------------------------------------------------
      ---------
      Example class:
      ----------------------------------------------------------------------------
      ---------
      class BUG

      creation
      make

      feature
      make is
      local
      n: INTEGER
      q: DOUBLE -- or REAL
      do
      q := 5.0
      n := q.floor
      n := q.ceiling -- ensure violation!
      end
      end -- BUG

      ----------------------------------------------------------------------------
      ---------
      Salient part of error message (DOUBLE version):
      ----------------------------------------------------------------------------
      ---------

      ceiling of DOUBLE
      Current = 5.000000
      Result = 5
      d = 5.000000
      line 123 column 37 file c:\elj-win32\SmallEiffel\lib_std\double.e
      ===== Top of run-time stack =====
      *** Error at Run Time *** : Ensure Assertion Violated.
      *** Error at Run Time *** : result_no_smaller

      ----------------------------------------------------------------------------
      ---------
      Salient part of error message (REAL version):
      ----------------------------------------------------------------------------
      ---------
      ceiling of REAL
      Current = 5.000000
      Result = 1371528
      line 103 column 10 file c:\elj-win32\SmallEiffel\lib_std\real.e
      ======================================
      ceiling of DOUBLE
      Current = 5.000000
      Result = 5
      d = 5.000000
      line 123 column 37 file c:\elj-win32\SmallEiffel\lib_std\double.e
      ===== Top of run-time stack =====
      *** Error at Run Time *** : Ensure Assertion Violated.
      *** Error at Run Time *** : result_no_smaller
    • Prager, Daniel (CMIS, Clayton)
      I didn t realise that this bug had reported before; it seems to me that an online register of bugs could be very useful, listing things (in flat DB style) like
      Message 2 of 11 , May 1, 2000
      • 0 Attachment
        I didn't realise that this bug had reported before; it seems to
        me that an online register of bugs could be very useful,
        listing things (in flat DB style) like

        bug / categorization / test / work-around / patch / fixed in version

        Dominique, is there any prospect of you opening up
        your bug database and putting it online?

        Cheers

        Daniel
      • Richie Bielak
        ... What are the chances of having the SmallEiffel project move to SourceForge? We could have CVS with all the code, mailings list and a bug tracking system?
        Message 3 of 11 , May 1, 2000
        • 0 Attachment
          "Prager, Daniel (CMIS, Clayton)" wrote:
          >
          > I didn't realise that this bug had reported before; it seems to
          > me that an online register of bugs could be very useful,
          > listing things (in flat DB style) like
          >
          > bug / categorization / test / work-around / patch / fixed in version
          >
          > Dominique, is there any prospect of you opening up
          > your bug database and putting it online?

          What are the chances of having the SmallEiffel project
          move to SourceForge? We could have CVS with all the code, mailings
          list and a bug tracking system?

          ...richie

          --
          "It is a good day to code" - http://www.netlabs.net/~richieb
        • Dominique Colnet
          ... Actually, I have no bug database. I have just run your program on my Linux and there is no assertion violation. Do you have 2 different C compilers on your
          Message 4 of 11 , May 2, 2000
          • 0 Attachment
            Prager, Daniel (CMIS, Clayton) writes:
            > I didn't realise that this bug had reported before; it seems to
            > me that an online register of bugs could be very useful,
            > listing things (in flat DB style) like
            >
            > bug / categorization / test / work-around / patch / fixed in version
            >
            > Dominique, is there any prospect of you opening up
            > your bug database and putting it online?
            Actually, I have no bug database.
            I have just run your program on my Linux and there is no
            assertion violation.
            Do you have 2 different C compilers on your windows system ?
            Cheers,

            --
            --------------------------------------------------------------
            Dominique COLNET -- UHP (Nancy 1) -- LORIA -- INRIA Lorraine
            http://SmallEiffel.loria.fr -- The GNU Eiffel Compiler
            POST: Loria, B.P. 239,54506 Vandoeuvre les Nancy Cedex, FRANCE
            EMAIL: colnet@... Voice:+33 0383593079 Fax:+33 0383413079
          • Dominique Colnet
            ... I have just looked for SourceForge on the web ... may I ask you on good link to get more information about this ? -- ... Dominique COLNET -- UHP (Nancy 1)
            Message 5 of 11 , May 2, 2000
            • 0 Attachment
              Richie Bielak writes:
              > "Prager, Daniel (CMIS, Clayton)" wrote:
              > >
              > > I didn't realise that this bug had reported before; it seems to
              > > me that an online register of bugs could be very useful,
              > > listing things (in flat DB style) like
              > >
              > > bug / categorization / test / work-around / patch / fixed in version
              > >
              > > Dominique, is there any prospect of you opening up
              > > your bug database and putting it online?
              >
              > What are the chances of having the SmallEiffel project
              > move to SourceForge? We could have CVS with all the code, mailings
              > list and a bug tracking system?
              I have just looked for SourceForge on the web ... may I ask you
              on good link to get more information about this ?

              --
              --------------------------------------------------------------
              Dominique COLNET -- UHP (Nancy 1) -- LORIA -- INRIA Lorraine
              http://SmallEiffel.loria.fr -- The GNU Eiffel Compiler
              POST: Loria, B.P. 239,54506 Vandoeuvre les Nancy Cedex, FRANCE
              EMAIL: colnet@... Voice:+33 0383593079 Fax:+33 0383413079
            • Prager, Daniel (CMIS, Clayton)
              I obtained the original assertion violation using lcc. I just tried MS VC++ 5.0: no problems! So it looks like an lcc problem - any ideas anyone (paging Jacob
              Message 6 of 11 , May 2, 2000
              • 0 Attachment
                I obtained the original assertion violation using lcc.
                I just tried MS VC++ 5.0: no problems!

                So it looks like an lcc problem - any ideas anyone
                (paging Jacob Navia)?

                However, I propose the following revision to the
                post-conditions of ceiling in DOUBLE nonetheless:

                result_no_smaller: Current <= Result.to_double;
                close_enough: Result - Current < one;

                These make it symmetric with floor's pre-conditions,
                should work with lcc (based on the extended test-case below),
                and correct close_enough.

                BTW: Could we please have access to the ANSI C atan2 in DOUBLE too?


                Cheers

                Daniel

                P.S. I think that a decision to make use of SourceForge (or similar
                facilities) would be another excellent step in the evolution of
                SmallEiffel.

                ------------------------------------------------------------------------

                class BUG

                creation
                make

                feature
                make is
                local
                n: INTEGER
                q: DOUBLE -- or REAL
                do
                q := 5.0
                n := q.floor
                -- n := q.ceiling -- ensure violation!
                n := 5

                check q <= n.to_double end -- This is the
                work-around
                check q <= n end -- ensure
                violation as per result_no_smaller
                end
                end -- BUG
              • Dominique Colnet
                ... Jacob and I are working on a similar problem ... I will forward this information to Jacob. Thanks, ... May be this information should be forwarded to Roger
                Message 7 of 11 , May 2, 2000
                • 0 Attachment
                  Prager, Daniel (CMIS, Clayton) writes:
                  > I obtained the original assertion violation using lcc.
                  > I just tried MS VC++ 5.0: no problems!
                  >
                  > So it looks like an lcc problem - any ideas anyone
                  > (paging Jacob Navia)?
                  Jacob and I are working on a similar problem ... I will forward this
                  information to Jacob.
                  Thanks,
                  >
                  > However, I propose the following revision to the
                  > post-conditions of ceiling in DOUBLE nonetheless:
                  >
                  > result_no_smaller: Current <= Result.to_double;
                  > close_enough: Result - Current < one;
                  >
                  > These make it symmetric with floor's pre-conditions,
                  > should work with lcc (based on the extended test-case below),
                  > and correct close_enough.
                  May be this information should be forwarded to Roger Browne & al. to
                  be included in the next ELKS 2000 definition of DOUBLE.
                  >
                  > BTW: Could we please have access to the ANSI C atan2 in DOUBLE too?
                  Yes. This will be part of the next release.
                  >
                  >
                  > Cheers
                  >
                  > Daniel
                  >
                  > P.S. I think that a decision to make use of SourceForge (or similar
                  > facilities) would be another excellent step in the evolution of
                  > SmallEiffel.
                  ie. giving read access on some CVS repository ?
                  Do you also dream to have write access ?

                  Best regards,

                  --
                  --------------------------------------------------------------
                  Dominique COLNET -- UHP (Nancy 1) -- LORIA -- INRIA Lorraine
                  http://SmallEiffel.loria.fr -- The GNU Eiffel Compiler
                  POST: Loria, B.P. 239,54506 Vandoeuvre les Nancy Cedex, FRANCE
                  EMAIL: colnet@... Voice:+33 0383593079 Fax:+33 0383413079
                • Prager, Daniel (CMIS, Clayton)
                  ... This sent me scurrying to check out the ELKS 95 definitions of ceiling and double: ceiling: INTEGER -- Smallest integral value no smaller than current
                  Message 8 of 11 , May 2, 2000
                  • 0 Attachment
                    > Daniel's previous post
                    >> Dominique's reply


                    > However, I propose the following revision to the
                    > post-conditions of ceiling in DOUBLE nonetheless:
                    > [snip]
                    >
                    > result_no_smaller: Current <= Result.to_double;
                    > close_enough: Result - Current < one;
                    >
                    > These make it symmetric with floor's pre-conditions,
                    > should work with lcc

                    >> May be this information should be forwarded to Roger Browne & al. to
                    >> be included in the next ELKS 2000 definition of DOUBLE.

                    This sent me scurrying to check out the ELKS 95 definitions of ceiling
                    and double:

                    ceiling: INTEGER
                    -- Smallest integral value no smaller than current object
                    ensure
                    result_no_smaller: Result >= Current;
                    close_enough: Result - Current < one

                    floor: INTEGER
                    -- Greatest integral value no greater than current object
                    ensure
                    result_no_greater: Result <= Current;
                    close_enough: Current - Result < one

                    These look fine to me as they stand, given proper operation of the
                    balancing rules (which I understand are not going to disappear just
                    yet). So I don't see any issue with the ELKS definition -- hence no
                    need to forward to Roger at this stage.

                    >
                    > BTW: Could we please have access to the ANSI C atan2 in DOUBLE too?
                    >> Yes. This will be part of the next release.

                    Thank-you ;-)

                    Cheers

                    Daniel
                  • Jacob Navia
                    Dear friends: I have found that dammed bug. When comparing a double precision number with an integer, I was emitting the instructions ficompl (address of
                    Message 9 of 11 , May 3, 2000
                    • 0 Attachment
                      Dear friends:
                      I have found that dammed bug. When comparing a double precision number
                      with an integer, I was emitting the instructions

                      ficompl (address of integer)
                      fstsw ax (store status word)
                      sahf (move status word into flags)
                      jae label BUG BUG!!! should be ja and NOT jae!!!
                      ^
                      DAMMED TYPO IN THE COMPILER TABLES!!!!!!!!!!!

                      I apologize for this blunder to all users of lcc-win32. I will setup today
                      a new version of the compiler in

                      http://cs.virginia.edu/~lcc-win32
                      http://ps.qss.cz/lcc

                      Please reload the compiler tomorrow. (I want to add some tests still).


                      Jacob Navia Logiciels/Informatique
                      41 rue Maurice Ravel Tel 01 48.23.51.44
                      93430 Villetaneuse Fax 01 48.23.95.39
                      France
                    • David Broadfoot
                      ... Why does SE change this to the different but equivalent result_no_smaller: Current
                      Message 10 of 11 , May 3, 2000
                      • 0 Attachment
                        > From: Prager, Daniel (CMIS, Clayton)
                        >
                        > This sent me scurrying to check out the ELKS 95 definitions of ceiling
                        > and double:
                        >
                        > ceiling: INTEGER
                        > -- Smallest integral value no smaller than current object
                        > ensure
                        > result_no_smaller: Result >= Current;

                        Why does SE change this to the different but equivalent
                        result_no_smaller: Current <= Result;
                        The ELKS expression following the comment more closely.


                        > close_enough: Result - Current < one

                        ELKS has:
                        close_enough: Current - Result < one;
                        The SE expression is wrong (it will always return true, no matter how large the
                        computed Result is.)


                        > floor: INTEGER
                        > -- Greatest integral value no greater than current object
                        > ensure
                        > result_no_greater: Result <= Current;
                        > close_enough: Current - Result < one

                        ELKS has
                        result_no_greater: Result.to_double <= Current;"
                        Why does SE omit the ".to_double"?

                        In summary, why has SE made all these changes, some arbitrary, some wrong,
                        rather than copy ELKS in its entirety verbatim?

                        Regards,
                        David
                      • Dominique Colnet
                        ... Because those ensure assertions have been written before release -0.79 (ie. before implementation of the balancing rule). This is fixed in the next
                        Message 11 of 11 , May 3, 2000
                        • 0 Attachment
                          David Broadfoot writes:
                          > > From: Prager, Daniel (CMIS, Clayton)
                          > >
                          > > This sent me scurrying to check out the ELKS 95 definitions of ceiling
                          > > and double:
                          > >
                          > > ceiling: INTEGER
                          > > -- Smallest integral value no smaller than current object
                          > > ensure
                          > > result_no_smaller: Result >= Current;
                          >
                          > Why does SE change this to the different but equivalent
                          ... stuff deleted ...
                          > In summary, why has SE made all these changes, some arbitrary, some wrong,
                          > rather than copy ELKS in its entirety verbatim?
                          Because those ensure assertions have been written before
                          release -0.79 (ie. before implementation of the balancing rule).
                          This is fixed in the next release.
                          Thanks,

                          --
                          --------------------------------------------------------------
                          Dominique COLNET -- UHP (Nancy 1) -- LORIA -- INRIA Lorraine
                          http://SmallEiffel.loria.fr -- The GNU Eiffel Compiler
                          POST: Loria, B.P. 239,54506 Vandoeuvre les Nancy Cedex, FRANCE
                          EMAIL: colnet@... Voice:+33 0383593079 Fax:+33 0383413079
                        Your message has been successfully submitted and would be delivered to recipients shortly.