使用MinGW/long double在CodeBlocks中错误地打印了long double [英] Long double is printed incorrectly in CodeBlocks using MinGW/long double

查看:95
本文介绍了使用MinGW/long double在CodeBlocks中错误地打印了long double的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

我的代码工作使用Cygwin很好(打印长双精度有16个字节的内存,最小和最大值是可以的),但是使用MinGW的CodeBlocks表示长双精度有12字节的内存(如果我修改了代码以int代替long double来显示大小,在long double中显示为-2,000000),并且将最小值和最大值打印为-0,000000.

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.

代码块版本:20.03.
MinGW-W64项目(版本8.1.0,32/64位,SEH).

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!

我在帖子中看到此问题是Windows产生的,但是如果它与Cygwin一起使用,那么有解决方案,也许某个地方的人知道...

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

观察:

我可以使用Cygwin,但是葡萄牙语有很多带重音的单词,并且我用它们来命名目录,所以当我使用Cygwin时,事情很复杂,而且我不知道如何包含诸如conio之类的库.h正确,并且MinGW包含了conio.h之类的库,因此我更喜欢学习如何解决此问题.

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);
}

在mingw中:

在Cygwin中:

推荐答案

下载单独的"MinGW-W64在线安装程序"(代码块中包含的mingw是32位,因为它是12位打印的)

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

安装版本7.3.0.(版本8.1.0出现错误,因为它打印的是0.000000或-0.000000).

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

这篇关于使用MinGW/long double在CodeBlocks中错误地打印了long double的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆