gmpy2 qdiv() returns mpq where mpz would be possible










0















I wonder if I don't get something here... Why does qdiv(8,2) return an mpq instead of an mpz?



See here:



Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gmpy2 import qdiv
>>> help(qdiv)
Help on built-in function qdiv in module gmpy2:

qdiv(...)
qdiv(x[, y=1]) -> number

Return x/y as 'mpz' if possible, or as 'mpq' if x is not exactly
divisible by y.
>>> qdiv(8,2)
mpq(4,1)
>>> qdiv(4,1)
mpz(4)


I thought the whole idea was to return an mpz if possible?










share|improve this question


























    0















    I wonder if I don't get something here... Why does qdiv(8,2) return an mpq instead of an mpz?



    See here:



    Python 3.5.2 (default, Nov 23 2017, 16:37:01)
    [GCC 5.4.0 20160609] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from gmpy2 import qdiv
    >>> help(qdiv)
    Help on built-in function qdiv in module gmpy2:

    qdiv(...)
    qdiv(x[, y=1]) -> number

    Return x/y as 'mpz' if possible, or as 'mpq' if x is not exactly
    divisible by y.
    >>> qdiv(8,2)
    mpq(4,1)
    >>> qdiv(4,1)
    mpz(4)


    I thought the whole idea was to return an mpz if possible?










    share|improve this question
























      0












      0








      0








      I wonder if I don't get something here... Why does qdiv(8,2) return an mpq instead of an mpz?



      See here:



      Python 3.5.2 (default, Nov 23 2017, 16:37:01)
      [GCC 5.4.0 20160609] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      >>> from gmpy2 import qdiv
      >>> help(qdiv)
      Help on built-in function qdiv in module gmpy2:

      qdiv(...)
      qdiv(x[, y=1]) -> number

      Return x/y as 'mpz' if possible, or as 'mpq' if x is not exactly
      divisible by y.
      >>> qdiv(8,2)
      mpq(4,1)
      >>> qdiv(4,1)
      mpz(4)


      I thought the whole idea was to return an mpz if possible?










      share|improve this question














      I wonder if I don't get something here... Why does qdiv(8,2) return an mpq instead of an mpz?



      See here:



      Python 3.5.2 (default, Nov 23 2017, 16:37:01)
      [GCC 5.4.0 20160609] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      >>> from gmpy2 import qdiv
      >>> help(qdiv)
      Help on built-in function qdiv in module gmpy2:

      qdiv(...)
      qdiv(x[, y=1]) -> number

      Return x/y as 'mpz' if possible, or as 'mpq' if x is not exactly
      divisible by y.
      >>> qdiv(8,2)
      mpq(4,1)
      >>> qdiv(4,1)
      mpz(4)


      I thought the whole idea was to return an mpz if possible?







      python gmpy






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 17:01









      cxxlcxxl

      2,70621945




      2,70621945






















          1 Answer
          1






          active

          oldest

          votes


















          1














          I believe that is a bug that was fixed in version 2.0.5. Your example works with 2.0.8. What version of gmpy2 are you using?



          Python 3.6.6 (default, Sep 12 2018, 18:26:19) 
          [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
          Type "help", "copyright", "credits" or "license" for more information.
          >>> import gmpy2
          >>> gmpy2.qdiv(8,2)
          mpz(4)
          >>> gmpy2.qdiv(4,1)
          mpz(4)
          >>> gmpy2.version()
          '2.0.8'
          >>>


          Edit



          This is a bug in gmpy2 2.1.0 alpha release. A fix has been committed to the master trunk at the main repository - gmpy2. It will be included in version 2.1.0a5.






          share|improve this answer

























          • I use version 2.1.0a1.

            – cxxl
            Nov 16 '18 at 9:34






          • 1





            Oops, I didn't get it fixed in the 2.1 series. I will try to get a fix in this weekend.

            – casevh
            Nov 16 '18 at 14:13










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305313%2fgmpy2-qdiv-returns-mpq-where-mpz-would-be-possible%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I believe that is a bug that was fixed in version 2.0.5. Your example works with 2.0.8. What version of gmpy2 are you using?



          Python 3.6.6 (default, Sep 12 2018, 18:26:19) 
          [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
          Type "help", "copyright", "credits" or "license" for more information.
          >>> import gmpy2
          >>> gmpy2.qdiv(8,2)
          mpz(4)
          >>> gmpy2.qdiv(4,1)
          mpz(4)
          >>> gmpy2.version()
          '2.0.8'
          >>>


          Edit



          This is a bug in gmpy2 2.1.0 alpha release. A fix has been committed to the master trunk at the main repository - gmpy2. It will be included in version 2.1.0a5.






          share|improve this answer

























          • I use version 2.1.0a1.

            – cxxl
            Nov 16 '18 at 9:34






          • 1





            Oops, I didn't get it fixed in the 2.1 series. I will try to get a fix in this weekend.

            – casevh
            Nov 16 '18 at 14:13















          1














          I believe that is a bug that was fixed in version 2.0.5. Your example works with 2.0.8. What version of gmpy2 are you using?



          Python 3.6.6 (default, Sep 12 2018, 18:26:19) 
          [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
          Type "help", "copyright", "credits" or "license" for more information.
          >>> import gmpy2
          >>> gmpy2.qdiv(8,2)
          mpz(4)
          >>> gmpy2.qdiv(4,1)
          mpz(4)
          >>> gmpy2.version()
          '2.0.8'
          >>>


          Edit



          This is a bug in gmpy2 2.1.0 alpha release. A fix has been committed to the master trunk at the main repository - gmpy2. It will be included in version 2.1.0a5.






          share|improve this answer

























          • I use version 2.1.0a1.

            – cxxl
            Nov 16 '18 at 9:34






          • 1





            Oops, I didn't get it fixed in the 2.1 series. I will try to get a fix in this weekend.

            – casevh
            Nov 16 '18 at 14:13













          1












          1








          1







          I believe that is a bug that was fixed in version 2.0.5. Your example works with 2.0.8. What version of gmpy2 are you using?



          Python 3.6.6 (default, Sep 12 2018, 18:26:19) 
          [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
          Type "help", "copyright", "credits" or "license" for more information.
          >>> import gmpy2
          >>> gmpy2.qdiv(8,2)
          mpz(4)
          >>> gmpy2.qdiv(4,1)
          mpz(4)
          >>> gmpy2.version()
          '2.0.8'
          >>>


          Edit



          This is a bug in gmpy2 2.1.0 alpha release. A fix has been committed to the master trunk at the main repository - gmpy2. It will be included in version 2.1.0a5.






          share|improve this answer















          I believe that is a bug that was fixed in version 2.0.5. Your example works with 2.0.8. What version of gmpy2 are you using?



          Python 3.6.6 (default, Sep 12 2018, 18:26:19) 
          [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
          Type "help", "copyright", "credits" or "license" for more information.
          >>> import gmpy2
          >>> gmpy2.qdiv(8,2)
          mpz(4)
          >>> gmpy2.qdiv(4,1)
          mpz(4)
          >>> gmpy2.version()
          '2.0.8'
          >>>


          Edit



          This is a bug in gmpy2 2.1.0 alpha release. A fix has been committed to the master trunk at the main repository - gmpy2. It will be included in version 2.1.0a5.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 18 '18 at 21:38

























          answered Nov 14 '18 at 20:37









          casevhcasevh

          8,94211522




          8,94211522












          • I use version 2.1.0a1.

            – cxxl
            Nov 16 '18 at 9:34






          • 1





            Oops, I didn't get it fixed in the 2.1 series. I will try to get a fix in this weekend.

            – casevh
            Nov 16 '18 at 14:13

















          • I use version 2.1.0a1.

            – cxxl
            Nov 16 '18 at 9:34






          • 1





            Oops, I didn't get it fixed in the 2.1 series. I will try to get a fix in this weekend.

            – casevh
            Nov 16 '18 at 14:13
















          I use version 2.1.0a1.

          – cxxl
          Nov 16 '18 at 9:34





          I use version 2.1.0a1.

          – cxxl
          Nov 16 '18 at 9:34




          1




          1





          Oops, I didn't get it fixed in the 2.1 series. I will try to get a fix in this weekend.

          – casevh
          Nov 16 '18 at 14:13





          Oops, I didn't get it fixed in the 2.1 series. I will try to get a fix in this weekend.

          – casevh
          Nov 16 '18 at 14:13



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305313%2fgmpy2-qdiv-returns-mpq-where-mpz-would-be-possible%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

          Museum of Modern and Contemporary Art of Trento and Rovereto