Microsoft KB Archive/155622

= FIX: IDE Debugger Truncates Floating Point Numbers =

Article ID: 155622

Article Last Modified on 12/10/2003

-

APPLIES TO

 The Integrated Debugger, when used with:  Microsoft Visual C++ 5.0 Learning Edition

 Microsoft Visual C++ 5.0 Learning Edition

 Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 4.0 Professional Edition</li></ul>

 Microsoft Visual C++ 4.1 Subscription</li></ul>

 Microsoft Visual C++ 4.2 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q155622

<div class="symptoms_section">

SYMPTOMS
If you change the Language Settings under the operating system to a language that uses a comma as the decimal separator, recalculating any floating point numbers in the QuickWatch window in the integrated debugger truncates the floating point number. Thereafter, incorrect results may be generated from program execution. To reproduce the problem, please see the "More Information" section below.

The following language settings may cause this problem. <pre class="fixed_text">  German      Italian    Portuguese    Swedish   Norwegian Indonesian Icelandic  French        Finnish   Dutch Danish     Catalan    Basque

<div class="resolution_section">

RESOLUTION
To work around the problem, use one of the following suggestions:
 * In the QuickWatch window, cast the variable you plan to watch to the proper type. For example, if you plan to watch variable "a" in the following program, because "a" is defined as type double, cast it to a double in the QuickWatch window. That is, type "(double)a" (without the quotation marks) in the QuickWatch window.

-or-
 * In the QuickWatch window, add zero to the variable. For example, in the following program, type "a+0" (without the quotation marks) in the QuickWatch window to watch variable "a".

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ version 5.0.

<div class="moreinformation_section">

MORE INFORMATION
You can use the following steps to reproduce the problem: <ol> Use Control Panel to change language settings to German(Standard), then reboot the system.</li>  Build an application using the source file below: /* Compile options needed: Developer Studio default console application */

#include <stdio.h>

void main {     double a = 1.99; double b;

printf("a = %g\n", a);

b = a; // At this point do QuickWatch and Recalculate for 'a'.

printf("b = %g\n", b); }                   </li> Start debugging and get to the commented line "b = a".</li> Use QuickWatch for "a"; it will show the correct value 1.99.</li> Click Recalculate one or two times more.</li></ol>

Result: The value of "a" is changed to 1.0, and the program's output will be wrong when execution is continued to next line.

Keywords: kbbug kbfix kbide kbprogramming kbvc500fix kbdebug KB155622

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.