撒拉嘿哟木头 2018-10-29 04:24 采纳率: 100%
浏览 282

C lang 指数长双输出(Mac OS,Xcode)

#include <stdio.h>
#include <float.h>

int main()
{
    float num1 = FLT_MAX;
    double num2 = DBL_MIN;
    long double num3 = LDBL_MAX;
    
    printf("%.2f\n", num1);
    printf("%e\n", num2);
    printf("%Le\n", num3);
    
    return 0;
}

I am working on exponential notation with C and I don't know why the output of long double is not correct (float and double has an output of

340282346638528859811704183484516925440.00

2.225074e-308

but long double has

1.189731e+4932 (in the book it says 1.797693e+308)

Is the output differ from every computer? Then why my mac has the only different value of the long double but not float and double?

</div>

转载于:https://stackoverflow.com/questions/53038728/c-lang-exponential-long-double-output-mac-os-xcode

  • 写回答

2条回答 默认 最新

  • local-host 2018-10-29 04:32
    关注

    As a general statement, the length of each data type is compiler and machine dependent. So the value of float, double and long double are machine and compiler dependent and may be different on different computers

    评论

报告相同问题?

悬赏问题

  • ¥15 计算二重积分∫∫e^(x+y)dxdy,其中0≤x≤1,0≤y≤1,试分别用复合辛普森公式(取n=4)以及高斯求积公式(取n=4)计算积分 给出matlab程序
  • ¥15 opencv 无法读取视频
  • ¥15 用matlab 实现通信仿真
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的