can't print correctly a long double in C -
I'm trying a simple long double print, but it does not work
I Which tried:
long double LD = 5.32; Printf ("Take with LD =% \ n", LD); Printf ("LF with LD =% LF \ n", LD); Printf ("ld with lg =% lg \ n", ld); Output:
with LD = -3.209071e-105 ld LF = -0.000000 LD with LG = -3.20907e-105 with a new value:
ld = 6.72; Output:
LD with LDP = -1972024235903379200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000 LD with LD = 111 LD with L = Lk972024e = -lk97202e + 111 < / Code>
There is a similar problem with minidized under Windows if this is not what you use If so, this answer probably does not apply.
The problem is that the compiler (GCC) and runtime library (Microsoft) is implemented by different groups that are different, considering how the type represents a long double . (GCC uses <128> 128 bit for long dual code; Microsoft uses 64 bits, as is the same representation as double ). Any representation of representation As is perfectly legitimate, but they are incompatible with each other or if there is a bug in the GCC or Microsoft's library, but the way Minjeed has integrated them.
Your choice is to use an implementation except minijwe, which works for writing or copying code that is long double correctly, or any library function To avoid calling, take the arguments or return results of long double ( long double computing should not be long because they do not have any library functions it is said). For example, you can convert to double and print with % g , with some range and accuracy. To compile with another (probably better) workaround, -D__USE_MINGW_ANSI_STDIO , which means that instead of relying on Microsoft implementation, printf and The causes of friends use their own implementation.
Comments
Post a Comment