C99浮点类型中的位数? [英] Number of bits in C99 float types?

查看:93
本文介绍了C99浮点类型中的位数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有机制找到花车中的位数,

加倍,以及长双打?我需要这个与一些

硬件进行通信。


我想我可以尝试从float.h推断出这个,​​但看起来好像

很难。


我不介意一些特定于系统的东西;较旧的gccs在cpu_limits.h和相关文件中有各种各样的定义,但在后来的gcc中我找不到




谢谢 -


Dom

Has anyone got a mechanism for finding the number of bits in floats,
doubles, and long doubles? I need this to communicate with some
hardware.

I guess I could try to deduce this from float.h, but that looks
difficult.

I don''t mind something which is system-specific; the older gccs had
various defines in cpu_limits.h and related files, but I can''t find
anything in later gccs.

Thanks -

Dom

推荐答案

2008年3月17日星期一20:13: 21 +0000,Dom Fulton写道:
On Mon, 17 Mar 2008 20:13:21 +0000, Dom Fulton wrote:

有没有人有机制找到花车中的位数,

加倍,长双打?我需要这个与一些

硬件进行通信。


我想我可以尝试从float.h推断出这个,​​但看起来好像

很难。


我不介意一些特定于系统的东西;较旧的gccs在cpu_limits.h及相关文件中有各种定义,但在后来的gcc中我找不到


Has anyone got a mechanism for finding the number of bits in floats,
doubles, and long doubles? I need this to communicate with some
hardware.

I guess I could try to deduce this from float.h, but that looks
difficult.

I don''t mind something which is system-specific; the older gccs had
various defines in cpu_limits.h and related files, but I can''t find
anything in later gccs.



如果你已经在寻找特定于系统的东西了,为什么你不能只需要把bb的位数作为b $ b代码中的常量?你有什么想要用比特数来b / b

用什么来处理不同的数字?


也就是说,每个对象都包含sizeof(object)* CHAR_BIT位。这些位中的一些
在确定值时可能没有用,这取决于系统和编译器的价值。最有可能的是,在你的系统上,对于浮点类型来说这只会很好。

If you''re already looking for something system-specific, why can''t you
simply put the number of bits as a constant in your code? What do you
want to do with the number of bits, that it''s useful at all to be able to
deal with different numbers?

That said, every object consists of sizeof(object) * CHAR_BIT bits. Some
of those bits may not be useful in determining the value, depending on
the system and compiler. Most likely, on your system, this will work just
fine for floating point types.


我必须支持几个不同的系统 - Windows,SunOS和

各种Linux。我想我可以找出各种平台的答案是什么,并且硬编码,但这给了我一个糟糕的感觉...... b $ b感觉...


sizeof不起作用;由于对齐原因,它被四舍五入。在大多数

系统中,float / double / long double将是32/64/80位,但sizeof

通常为80位浮点数返回96或128。 />

谢谢 -


Dom

I''ve got to support several different systems - Windows, SunOS, and
various Linuxes. I guess I could just find out what the answer is for
the various platforms, and hard-code it in, but that gives me a bad
feeling...

sizeof doesn''t work; it''s rounded up for alignment reasons. On most
systems, float/double/long double will be 32/64/80 bits, but sizeof
generally returns 96 or 128 for 80-bit floats.

Thanks -

Dom


Dom Fulton写道:
Dom Fulton wrote:

我必须支持几种不同的系统 - Windows,SunOS和

各种Linux。我想我可以找出各种平台的答案是什么,并且硬编码,但这给了我一个糟糕的感觉...... b $ b感觉...


sizeof不起作用;由于对齐原因,它被四舍五入。在大多数

系统中,float / double / long double将是32/64/80位,但sizeof

通常为80位浮点数返回96或128。 />

谢谢 -


Dom
I''ve got to support several different systems - Windows, SunOS, and
various Linuxes. I guess I could just find out what the answer is for
the various platforms, and hard-code it in, but that gives me a bad
feeling...

sizeof doesn''t work; it''s rounded up for alignment reasons. On most
systems, float/double/long double will be 32/64/80 bits, but sizeof
generally returns 96 or 128 for 80-bit floats.

Thanks -

Dom



您将在这里找到所需的一切。
http ://docs.sun.com/app/docs/doc/801...uc?l = ru& a = view

处理器很重要,而不是OS /那里你会找到所有的文件

for x86和SPARC。电源PC也是IEEE,没有任何支持

长双。

-

jacob navia

jacob at jacob point remcomp point fr

logiciels / informatique
http://www.cs.virginia.edu/~lcc-win32


这篇关于C99浮点类型中的位数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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