Microsoft KB Archive/37794

= PRB: gcvt Generates Exponential Notation for 0.0x =

Article ID: 37794

Article Last Modified on 12/12/2003

-

APPLIES TO

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

 Microsoft Visual C++ 1.5 Professional Edition

 Microsoft Visual C++ 1.0 Professional Edition

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

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

 Microsoft Visual C++ 5.0 Standard Edition</li></ul>

 Microsoft Visual C++ 6.0 Service Pack 5</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q37794

<div class="notice_section">

<div class="symptoms_section">

SYMPTOMS
The gcvt function returns a value in scientific notation, without regard to the specified precision, when the floating-point value has the form &quot;0.0<x>&quot; and <x> is any sequence of digits.

<div class="cause_section">

CAUSE
This is expected behavior for gcvt.

<div class="resolution_section">

RESOLUTION
If this behavior is not desired, use the fcvt function to convert the floating-point number to a string.

<div class="moreinformation_section">

MORE INFORMATION
The following code demonstrates this behavior:

Sample Code
/* * Compile options needed: None */


 * 1) include <stdio.h>
 * 2) include <stdlib.h>

char buffer[50]; int precision = 20;

void main(void) {  gcvt(-0.1123, precision, buffer);    /* Decimal output */ printf(&quot;buffer ........\&quot;%s\&quot;\n&quot;, buffer);

gcvt(-0.0123, precision, buffer);   /* Scientific notation */ printf(&quot;buffer ........\&quot;%s\&quot;\n&quot;, buffer); }

Keywords: kbcrt kbprb KB37794

-

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

© Microsoft Corporation. All rights reserved.