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!

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

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:

In cygwin:

1 answer

  • answered 2021-04-08 15:43 FabQrz

    Download separated "MinGW-W64 Online Installer" (the mingw included in the codeblocks is 32bits because this is printed 12bit)

    and

    Install the version 7.3.0. (the version 8.1.0 is bugged because this is printed 0.000000 or -0.000000).