/************************************************************************ * * * Copyright Digital Equipment Corporation 1998. All rights reserved. * * * * Restricted Rights: Use, duplication, or disclosure by the U.S. * * Government is subject to restrictions as set forth in subparagraph * * (c) (1) (ii) of DFARS 252.227-7013, or in FAR 52.227-19, or in FAR * * 52.227-14 Alt. III, as applicable. * * * * This software is proprietary to and embodies the confidential * * technology of Digital Equipment Corporation. Possession, use, or * * copying of this software and media is authorized only pursuant to a * * valid written license from Digital or an authorized sublicensor. * * * ************************************************************************/ /* chap_3_charconv.c */ /* This program uses the ecvt function to convert a double */ /* value to a string. The program then prints the string. */ #include #include #include #include main() { double val; /* Value to be converted */ int sign, /* Variables for sign */ point; /* and decimal place */ /* Array for the converted string */ static char string[20]; val = -3.1297830e-10; printf("original value: %e\n", val); strcpy(string, ecvt(val, 5, &point, &sign)); printf("converted string: %s\n", string); if (sign) printf("value is negative\n"); else printf("value is positive\n"); printf("decimal point at %d\n", point); }