How to make Visual Studio UI show the precise underlying float point numbers?

John 76 Reputation points
2022-05-16T20:06:05.873+00:00

Hi all,

int main() {  
    float a = 123.45;  
    return 0;  
}  

By default, the UI value will show an approximated number.

What's the option to show the precise underlying number (123.4499969482421875 rather than 123.44997)?

202368-image.png

Developer technologies | C++
{count} votes

Accepted answer
  1. Minxin Yu 13,506 Reputation points Microsoft External Staff
    2022-05-17T01:58:36.537+00:00

    Hi, @John

    You need to use double a = 123.45f; instead of float.
    13 decimal places for double are reliable.
    the difference:
    123. 44999694824219 //13 . 14 is not unreliable
    123. 4499969482421875
    202545-image.png
    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.