DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Looking for _gcvt(double,int,string) (http://www.daniweb.com/forums/thread13451.html)

vegaseat Nov 3rd, 2004 4:12 pm
Looking for _gcvt(double,int,string)
 
I found this neat little GUI calculator program on the net.
It uses a function called _gcvt(double val,int limit,string cBuf), which seems to be used to convert a double val to a string cBuf, with some formatting and limiting.

I replaced it with sprintf(), but the output looks rather crude to the perfectionist.

xfind.exe can find _gcvt in a few header files, but Dev C++ does not respond to it. Does anybody have some past experience with it?

Narue Nov 3rd, 2004 4:34 pm
Re: Looking for _gcvt(double,int,string)
 
_gcvt is a Visual Studio function. sprintf should work fine provided you consider limit as the number of significant precision digits.

>but the output looks rather crude to the perfectionist.
How appropriately vague. Care to be more specific?

vegaseat Nov 3rd, 2004 5:31 pm
Re: Looking for _gcvt(double,int,string)
 
Thanks for the answer!

I will use sprintf(), but need to adjust the precision digits to something sensible.

2.3 + 3.4 = 5.700000000 looks silly!

I had the notion that _gcvt might do this.

Narue Nov 3rd, 2004 6:18 pm
Re: Looking for _gcvt(double,int,string)
 
>2.3 + 3.4 = 5.700000000 looks silly!
You can specify a precision with sprintf:
sprintf ( cBuf, "%.*f", limit, val );

vegaseat Nov 4th, 2004 12:41 pm
Re: Looking for _gcvt(double,int,string)
 
Quote:

Originally Posted by Narue
>2.3 + 3.4 = 5.700000000 looks silly!
You can specify a precision with sprintf:
sprintf ( cBuf, "%.*f", limit, val );

I forgot about that, thanks Narue!


All times are GMT -4. The time now is 12:26 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC