www.delorie.com/archives/browse.cgi | search |
Sender: | hecht AT DH_NRZ24 DOT dillinger DOT de |
Message-ID: | <3588A620.1CFB@dillinger.de> |
Date: | Thu, 18 Jun 1998 08:31:12 +0300 |
From: | Michael Hecht <michael DOT hecht AT dillinger DOT de> |
MIME-Version: | 1.0 |
To: | jonathan DOT villani AT videotron DOT ca |
CC: | djgpp AT delorie DOT com |
Subject: | Re: float convertion |
Try this one: #include <stdio.h> int main() { float f = 3.14159; /* i'm not sure about the right value */ double d = 3.1415926543; /* i'm not sure about the right value */ char sf[256]; /* this should be enough */ char sd[256]; /* this should be enough */ sprintf(sf,"%.6f",f); sprintf(sd,"%.8lf",d); printf("\nresult is: %.6f = '%s' , %.8lf = '%s'\n",f,sf,d,sd); return 0; } result is: 3.141590 = '3.141590' , 3.14159265 = '3.14159265'
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |