Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Standard library functions
Forum Updated to NodeBB v4.3 + New Features

Standard library functions

Scheduled Pinned Locked Moved Unsolved C++ Gurus
10 Posts 2 Posters 1.8k 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.
  • Swati777999S Offline
    Swati777999S Offline
    Swati777999
    wrote on last edited by
    #1

    What does the following stand for?

    std::numeric_limits<float>::digits10
    

    “ In order to be irreplaceable, one must always be different” – Coco Chanel

    KroMignonK 1 Reply Last reply
    0
    • Swati777999S Swati777999

      What does the following stand for?

      std::numeric_limits<float>::digits10
      
      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by
      #2

      @Swati777999 Do you have tried to read documentation? => https://en.cppreference.com/w/cpp/types/numeric_limits/digits10

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      Swati777999S 1 Reply Last reply
      3
      • KroMignonK KroMignon

        @Swati777999 Do you have tried to read documentation? => https://en.cppreference.com/w/cpp/types/numeric_limits/digits10

        Swati777999S Offline
        Swati777999S Offline
        Swati777999
        wrote on last edited by
        #3

        @KroMignon
        Yes, it says that number of decimal digits for float value is limited to 6 as per IEEE standard.

        What if I want to write something like this std::numeric_limits<float>::10 --> this gives me error. Is there any otehr alternative for it?

        “ In order to be irreplaceable, one must always be different” – Coco Chanel

        KroMignonK 1 Reply Last reply
        0
        • Swati777999S Swati777999

          @KroMignon
          Yes, it says that number of decimal digits for float value is limited to 6 as per IEEE standard.

          What if I want to write something like this std::numeric_limits<float>::10 --> this gives me error. Is there any otehr alternative for it?

          KroMignonK Offline
          KroMignonK Offline
          KroMignon
          wrote on last edited by
          #4

          @Swati777999 said in Standard library functions:

          What if I want to write something like this std::numeric_limits<float>::10 --> this gives me error. Is there any otehr alternative for it?

          I don't understand what you want to do std::numeric_limits<float>::digits10 is a constant value (is same as FLT_DIG).
          It represent the number of decimal digits that are guaranteed to be preserved in text.

          What should be std::numeric_limits<float>::10?

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          Swati777999S 1 Reply Last reply
          1
          • KroMignonK KroMignon

            @Swati777999 said in Standard library functions:

            What if I want to write something like this std::numeric_limits<float>::10 --> this gives me error. Is there any otehr alternative for it?

            I don't understand what you want to do std::numeric_limits<float>::digits10 is a constant value (is same as FLT_DIG).
            It represent the number of decimal digits that are guaranteed to be preserved in text.

            What should be std::numeric_limits<float>::10?

            Swati777999S Offline
            Swati777999S Offline
            Swati777999
            wrote on last edited by
            #5

            @KroMignon

            in the above case, the number of decimal digits is 6 as per IEEE standard. Suppose I want the decimal digits to be 10 , is there any notation apart from qRound() which achieves it?

            “ In order to be irreplaceable, one must always be different” – Coco Chanel

            KroMignonK 1 Reply Last reply
            0
            • Swati777999S Swati777999

              @KroMignon

              in the above case, the number of decimal digits is 6 as per IEEE standard. Suppose I want the decimal digits to be 10 , is there any notation apart from qRound() which achieves it?

              KroMignonK Offline
              KroMignonK Offline
              KroMignon
              wrote on last edited by
              #6

              @Swati777999 said in Standard library functions:

              Suppose I want the decimal digits to be 10 , is there any notation apart from qRound() which achieves it?

              Again, this is not a parameter, this is a constant: only a 6 digits decimal constant can be stored "loose-less" in in float. 999999 can be store in a float, above this value there will be a little error because of the storing format.

              qRound() will give you the nearest integer value for a float/double value

              It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

              Swati777999S 2 Replies Last reply
              4
              • KroMignonK KroMignon

                @Swati777999 said in Standard library functions:

                Suppose I want the decimal digits to be 10 , is there any notation apart from qRound() which achieves it?

                Again, this is not a parameter, this is a constant: only a 6 digits decimal constant can be stored "loose-less" in in float. 999999 can be store in a float, above this value there will be a little error because of the storing format.

                qRound() will give you the nearest integer value for a float/double value

                Swati777999S Offline
                Swati777999S Offline
                Swati777999
                wrote on last edited by
                #7

                @KroMignon
                Thanks for your explanation.

                “ In order to be irreplaceable, one must always be different” – Coco Chanel

                1 Reply Last reply
                0
                • KroMignonK KroMignon

                  @Swati777999 said in Standard library functions:

                  Suppose I want the decimal digits to be 10 , is there any notation apart from qRound() which achieves it?

                  Again, this is not a parameter, this is a constant: only a 6 digits decimal constant can be stored "loose-less" in in float. 999999 can be store in a float, above this value there will be a little error because of the storing format.

                  qRound() will give you the nearest integer value for a float/double value

                  Swati777999S Offline
                  Swati777999S Offline
                  Swati777999
                  wrote on last edited by
                  #8

                  @KroMignon

                  I just have a point to confirm, any value with digits>6 on the decimal side, will be rounded to 6 decimal digits. Is it correct?

                  “ In order to be irreplaceable, one must always be different” – Coco Chanel

                  KroMignonK 1 Reply Last reply
                  0
                  • Swati777999S Swati777999

                    @KroMignon

                    I just have a point to confirm, any value with digits>6 on the decimal side, will be rounded to 6 decimal digits. Is it correct?

                    KroMignonK Offline
                    KroMignonK Offline
                    KroMignon
                    wrote on last edited by
                    #9

                    @Swati777999 said in Standard library functions:

                    I just have a point to confirm, any value with digits>6 on the decimal side, will be rounded to 6 decimal digits. Is it correct?

                    No this is false. It will be rounded at the nearest integer.

                    It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                    Swati777999S 1 Reply Last reply
                    1
                    • KroMignonK KroMignon

                      @Swati777999 said in Standard library functions:

                      I just have a point to confirm, any value with digits>6 on the decimal side, will be rounded to 6 decimal digits. Is it correct?

                      No this is false. It will be rounded at the nearest integer.

                      Swati777999S Offline
                      Swati777999S Offline
                      Swati777999
                      wrote on last edited by
                      #10

                      @KroMignon
                      Thanks for your clarification.

                      “ In order to be irreplaceable, one must always be different” – Coco Chanel

                      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