On Tue, Feb 22, 2011 at 3:54 AM, Kai Tietz <ktiet...@googlemail.com> wrote:
> 2011/2/22 Jim Michaels <jmich...@yahoo.com>:
>> #include <tr1/stdint.h>
>> #include <stdio.h>
>> int main(void) {
>>     int64_t n1=1300000000000LL;
>>     int64_t n2=1999888999256LL;
>>     double
>>         dnum=n1,
>>         dden=n2,
>>         dpercent=n1;
>>     long double
>>         ldnum=n1,
>>         ldden=n2,
>>         ldpercent=n1;
>>
>>     dpercent/=dden;
>>     dpercent*=100;
>>
>>     ldpercent/=ldden;
>>     ldpercent*=100;
>>
>>
>>     printf("n1=%I64d, n2=%I64d\n", n1, n2);
>>     printf("dnum=%g, dden=%g, dpercent=%4.2f", dnum, dden, dpercent);
>>     //printf("ldnum=%Lg, ldden=%Lg, ldpercent=%4.2Lf\n", ldnum, ldden,
>> ldpercent);//this gives error on the L
>>     printf("ldnum=%lg, ldden=%lg, ldpercent=%4.2lf\n", ldnum, ldden,
>> ldpercent);
>>     //%Lf is a microsoft format and is preferred over %lf for stability.
>>     //should display percentages with 3 places to left, and 2 places to
>> right of decimal point.
>>     return 0;
>> }
>>
>> /*
>> mingw-test-printf-lf.cpp: In function 'int main()':
>> mingw-test-printf-lf.cpp:25:79: warning: format '%lg' expects type 'double',
>> but argument 2 has type 'long double'
>> mingw-test-printf-lf.cpp:25:79: warning: format '%lg' expects type 'double',
>> but argument 3 has type 'long double'
>> mingw-test-printf-lf.cpp:25:79: warning: format '%4.2lf' expects type
>> 'double', but argument 4 has type 'long double'
>>
>> so... how to you display a long double in printf????
>>
>> */
>
> Hello,
>
> msvcrt's printf/scanf routines don't support 80-bit 'long double'
> printing. We introduced for this ISO-C POSIX compatible printf/scanf
> routines - wide-character ISO -C printf and ISO-C ascii+wide-character
> scanf rountines are just available on mingw-w64's trunk runtime.
> You have here two different ways to solve this. You can call directly
> the ISO-C printf routines by prefixing the printf/scanf routine by
> __mingw_<fct>.
> Other way here is to define before including "stdio.h/wchar.h" headers
> the macro __USE_MINGW_ANSI_STDIO with value one. If you are using C++
> (this is caused by libstdc++ header, which are undefining
> macro-replacement of those functions) you need to include here at the
> end of include block the mingw-w64 specific header _mingw_print_pop.h
> header. This should work too.
>
> I hope it helps,
> Kai

When you get Kai's suggestion to work, would you mind adding this as a
FAQ in the wiki?

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to