Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Wiki Discussion
  4. [SOLVED] You are not allowed to edit this page.

[SOLVED] You are not allowed to edit this page.

Scheduled Pinned Locked Moved Wiki Discussion
8 Posts 4 Posters 5.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leon.anavi
    wrote on last edited by
    #1

    Hi,

    Why I am not able to edit "this page":http://developer.qt.nokia.com/wiki/Integer_Division_gives_0 ?

    I would like to replace the C style cast:

    @double c = (double) a / b;@

    with static_cast due to its advantages:

    @double c = static_cast<double>(a/b);@

    Using C style cast in C++ source code is a bad practice and should not exist in this code snippet!

    Thanks,
    Leon

    http://anavi.org/

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      I don't know why the page is locked (someone else is trying to edit?)

      But your correction is wrong!

      You calculate the division using integers and cast that result to a double, which leads to the undesired reusult of 0. If you really want to use a c++ cast, then it must be

      @
      double c = static_cast<double>(a)/b;
      @

      Using C-style casts for number conversions is acceptable, IMHO. So if you really want to add static cast, add it as an alternative.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • L Offline
        L Offline
        leon.anavi
        wrote on last edited by
        #3

        [quote author="Volker" date="1304548096"]
        But your correction is wrong!

        You calculate the division using integers and cast that result to a double, which leads to the undesired reusult of 0. If you really want to use a c++ cast, then it must be

        @
        double c = static_cast<double>(a)/b;
        @
        [/quote]

        Hi Volker,

        Yes, of course! Thanks for pointing it out - it was a silly typing mistake I did not want to change the algorithm just the C style cast :)

        I insist on adding an example with static_cast, but I still cannot edit the page. I will try again tomorrow. Btw do you get the same message if you try to edit it?

        Thanks,
        Leon

        http://anavi.org/

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          Hi Leon,
          yes, I get the same message, I cannot edit it either. If it's still locked tomorrow, I'll point some of the DevNet devs to it.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • H Offline
            H Offline
            HuXiKa
            wrote on last edited by
            #5

            If you want to add a few examples, you should include "this":http://stackoverflow.com/questions/332030/when-should-static-cast-dynamic-cast-and-reinterpret-cast-be-used too. It's a must read for everyone.

            If you can find faults of spelling in the text above, you can keep them.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              leon.anavi
              wrote on last edited by
              #6

              [quote author="Volker" date="1304549611"]Hi Leon,
              yes, I get the same message, I cannot edit it either. If it's still locked tomorrow, I'll point some of the DevNet devs to it.[/quote]

              Hi Volker,

              I still get the same message. Can you please notify DevNet devs about this issue?

              [quote author="HuXiKa" date="1304549724"]If you want to add a few examples, you should include "this":http://stackoverflow.com/questions/332030/when-should-static-cast-dynamic-cast-and-reinterpret-cast-be-used too. It's a must read for everyone.[/quote]

              Thanks for the link. You can add such kind of information to Qt DevNet wiki yourself too. Just find and appropriate article or create a new one. Do not hesitate and help us extend the wiki :)

              10x,
              Leon

              http://anavi.org/

              1 Reply Last reply
              0
              • T Offline
                T Offline
                troubalex
                wrote on last edited by
                #7

                It was locked. No idea why. Now it's unlocked and you can edit it. :)

                THE CAKE IS A LIE
                Web Community Manager - Qt Development Frameworks

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  leon.anavi
                  wrote on last edited by
                  #8

                  [quote author="Alexandra" date="1304610030"]It was locked. No idea why. Now it's unlocked and you can edit it. :)[/quote]

                  Alexandra, Volker, thanks! :) I have successfully add an example with static_cast.

                  Thanks,
                  Leon

                  http://anavi.org/

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved