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

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,513 questions
{count} votes

Accepted answer
  1. Minxin Yu 9,861 Reputation points Microsoft Vendor
    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