在C上定义LDBL_MAX / MIN [英] Define LDBL_MAX/MIN on C

查看:782
本文介绍了在C上定义LDBL_MAX / MIN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在和C一起工作,我必须做一个练习,我必须打印 long double min long double的值最大



我使用 float.h 作为标题,但是这两个宏 LDBL_MIN / MAX )给我相同的价值,就像它只是一个双重的。



我正在使用Visual Studio 2015,如果我将鼠标悬停在 LDBL MIN 上,则说 #define LDBL_MIN DBL_MIN 。是为什么打印 dbl_min 而不是 ldbl_min



如何解决这个问题?

  printf(Type :长双值:%lf最小值:%e最大值:%e内存:%lu\\\

val10,LDBL_MIN,LDBL_MAX,longd_size);

这是一个问题,因为我的作业需要两个不同的值用于 LDBL DBL

解决方案

C不指定 long double 必须比 double 更高的精度/范围。



所以即使实现将它们视为不同的类型,它们可能具有相同的实现,范围,精度,最小值,最大值等。



关于Visual Studio, MS Long Double 有助于。



要解决问题,请使用另一个支持 long double 的编译器,其精度/范围比<$ c更大$ C>双。也许 GCC


I'm working with C, I have to do an exercise in which I have to print the value of long double min and long double max.

I used float.h as header, but these two macros (LDBL_MIN/MAX) give me the same value as if it was just a double.

I'm using Visual Studio 2015 and if I hover the mouse on LDBL MIN it says #define LDBL_MIN DBL_MIN. Is that why it prints dbl_min instead of ldbl_min?

How can I fix this problem?

printf("Type: Long Double Value: %lf Min: %e Max: %e Memory:%lu\n", 
    val10, LDBL_MIN, LDBL_MAX, longd_size);

It is a problem because my assignment requires two different values for LDBL and DBL.

解决方案

C does not specify that long double must have a greater precision/range than double.

So even if the implementation treats them as different types, they may have the same implementation, range, precision, min value, max value, etc.

Concerning Visual Studio, MS Long Double helps.

To fix the problem, use another compiler that supports long double with a greater precision/range than double. Perhaps GCC?

这篇关于在C上定义LDBL_MAX / MIN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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