PRB: gcvt() Generates Exponential Notation for 0.0xLast reviewed: July 24, 1997Article ID: Q37794 |
The information in this article applies to:
SYMPTOMSThe gcvt() function returns a value in scientific notation, without regard to the specified precision, when the floating-point value has the form "0.0<x>" and <x> is any sequence of digits.
CAUSEThis is expected behavior for gcvt().
RESOLUTIONIf this behavior is not desired, use the fcvt() function to convert the floating-point number to a string.
MORE INFORMATIONThe following code demonstrates this behavior:
Sample Code
/* * Compile options needed: None */ #include <stdio.h> #include <stdlib.h> char buffer[50]; int precision = 20; void main(void) { gcvt(-0.1123, precision, buffer); /* Decimal output */ printf("buffer ........\"%s\"\n", buffer); gcvt(-0.0123, precision, buffer); /* Scientific notation */ printf("buffer ........\"%s\"\n", buffer); } |
Keywords : CRTIss kbfasttip
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |