long double is printed incorrectly in CodeBlocks using MinGW/long double

The problem:

My code work's fine using Cygwin (long double is printed like having 16 bytes of memory, and the min and max values are ok), but using MinGW the CodeBlocks say long double have 12 bytes of memory (if I modify the code to show the size in int instead long double, in long double is -2,000000), and the min and max values it's printed like -0,000000 both.

Codeblocks version: 20.03.
MinGW-W64 project (version 8.1.0, 32/64 bit, SEH).

I tried with the prompt but, is the same thing! The problem is directly with the CodeBlocks, and Windows; I can have something but not all.

I saw in a post that this problem is generated by windows, but if it works with Cygwin, then there is a solution that maybe someone somewhere knows... I don't know if have one archive that can be replaced from Cygwin to MinGW maybe?

Observation:

I can use Cygwin, but Portuguese has so many accented words, and I use them to name my directories, so when I use Cygwin the things are complicated, and I don't know how can I include some libs like conio.h correctly, and the MinGW has included libs like conio.h so I prefer to learn how to resolve this problem.

#include <stdio.h>
#include <math.h>

int main()
{
// Declaration of variables
long double min, max, size;

// Size
size = sizeof(long double);

// Min and Max
min = pow(2, (sizeof(long double)*8))*(-1);
max = pow(2, (sizeof(long double)*8));

// Print of results
printf("Size of long double: %Lf\n", size);
printf("Min of long double: %Lf\n", min);
printf("Max of long double: %Lf\n", max);

// end of main
return(0);
}

In mingw: [1]: https://i.stack.imgur.com/DiN5p.png

In cygwin: [2]: https://i.stack.imgur.com/lHW32.png

Sorry about my English... I tried XD!



Read more here: https://stackoverflow.com/questions/66996900/long-double-is-printed-incorrectly-in-codeblocks-using-mingw-long-double

Content Attribution

This content was originally published by FabQrz at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: