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?

Recommended Answers

All 4 Replies

_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?

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.

>2.3 + 3.4 = 5.700000000 looks silly!
You can specify a precision with sprintf:

sprintf ( cBuf, "%.*f", limit, val );

>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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.