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.4k 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.
  • S Offline
    S Offline
    Swati777999
    wrote on 21 Feb 2022, 07:27 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

    K 1 Reply Last reply 21 Feb 2022, 07:30
    0
    • S Swati777999
      21 Feb 2022, 07:27

      What does the following stand for?

      std::numeric_limits<float>::digits10
      
      K Offline
      K Offline
      KroMignon
      wrote on 21 Feb 2022, 07:30 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)

      S 1 Reply Last reply 21 Feb 2022, 08:48
      3
      • K KroMignon
        21 Feb 2022, 07:30

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

        S Offline
        S Offline
        Swati777999
        wrote on 21 Feb 2022, 08:48 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

        K 1 Reply Last reply 21 Feb 2022, 09:03
        0
        • S Swati777999
          21 Feb 2022, 08:48

          @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?

          K Offline
          K Offline
          KroMignon
          wrote on 21 Feb 2022, 09:03 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)

          S 1 Reply Last reply 21 Feb 2022, 09:08
          1
          • K KroMignon
            21 Feb 2022, 09:03

            @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?

            S Offline
            S Offline
            Swati777999
            wrote on 21 Feb 2022, 09:08 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

            K 1 Reply Last reply 21 Feb 2022, 09:25
            0
            • S Swati777999
              21 Feb 2022, 09:08

              @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?

              K Offline
              K Offline
              KroMignon
              wrote on 21 Feb 2022, 09:25 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)

              S 2 Replies Last reply 22 Feb 2022, 02:21
              4
              • K KroMignon
                21 Feb 2022, 09:25

                @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

                S Offline
                S Offline
                Swati777999
                wrote on 22 Feb 2022, 02:21 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
                • K KroMignon
                  21 Feb 2022, 09:25

                  @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

                  S Offline
                  S Offline
                  Swati777999
                  wrote on 22 Feb 2022, 02:23 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

                  K 1 Reply Last reply 22 Feb 2022, 06:57
                  0
                  • S Swati777999
                    22 Feb 2022, 02:23

                    @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?

                    K Offline
                    K Offline
                    KroMignon
                    wrote on 22 Feb 2022, 06:57 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)

                    S 1 Reply Last reply 22 Feb 2022, 09:31
                    1
                    • K KroMignon
                      22 Feb 2022, 06:57

                      @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.

                      S Offline
                      S Offline
                      Swati777999
                      wrote on 22 Feb 2022, 09:31 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

                      1/10

                      21 Feb 2022, 07:27

                      • Login

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