Standard library functions
-
wrote on 21 Feb 2022, 07:27 last edited by
What does the following stand for?
std::numeric_limits<float>::digits10
-
What does the following stand for?
std::numeric_limits<float>::digits10
wrote on 21 Feb 2022, 07:30 last edited by@Swati777999 Do you have tried to read documentation? => https://en.cppreference.com/w/cpp/types/numeric_limits/digits10
-
@Swati777999 Do you have tried to read documentation? => https://en.cppreference.com/w/cpp/types/numeric_limits/digits10
wrote on 21 Feb 2022, 08:48 last edited by@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? -
@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?wrote on 21 Feb 2022, 09:03 last edited by@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 asFLT_DIG
).
It represent the number of decimal digits that are guaranteed to be preserved in text.What should be
std::numeric_limits<float>::10
? -
@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 asFLT_DIG
).
It represent the number of decimal digits that are guaranteed to be preserved in text.What should be
std::numeric_limits<float>::10
?wrote on 21 Feb 2022, 09:08 last edited byin 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 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?
wrote on 21 Feb 2022, 09:25 last edited by@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 -
@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 valuewrote on 22 Feb 2022, 02:21 last edited by@KroMignon
Thanks for your explanation. -
@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 valuewrote on 22 Feb 2022, 02:23 last edited byI 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?
-
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?
wrote on 22 Feb 2022, 06:57 last edited by@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.
-
@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.
wrote on 22 Feb 2022, 09:31 last edited by@KroMignon
Thanks for your clarification.
1/10