Microsoft KB Archive/119504

= PRB: Result Differs Between 16-bit and 32-bit _gcvt =

Article ID: 119504

Article Last Modified on 12/1/2003

-

APPLIES TO

 The C Run-Time (CRT), when used with:  Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Professional Edition

 Microsoft Visual C++ 5.0 Learning Edition 

-

<div class="notice_section">

This article was previously published under Q119504

<div class="symptoms_section">

SYMPTOMS
Using the following test case, 32-bit _gcvt returns a different value than 16-bit _gcvt: double r1 = 1.797693134862315E+308; char buf[40];

_gcvt(r1, 15, buf); The 16-bit _gcvt rounds the value to 1.79769313486232E+308, but the 32-bit _gcvt truncates the value to 1.79769313486231E+308.

<div class="cause_section">

CAUSE
The low-level floating-point-to-string conversion routines were completely rewritten for Win32. The 32-bit output routines use an internal 12-byte floating-point format for the intermediate values and a new conversion algorithm. The specific value used in the test case mentioned in the "SYMPTOMS" section is at the limit of type "double," and the new conversion routine exhibits this problem when converting the value to a 12-byte value. The conversion routine yields a mantissa string of 79769313486231490 instead of 797693134862315, which causes the rounding problems in this particular case.

Keywords: kbcrt kbprb KB119504

-

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

© Microsoft Corporation. All rights reserved.