[FZH] C 语言的疑问

Xu Xin railwaycat at gmail.com
Thu Jun 2 15:57:51 UTC 2011


2011/6/2 Robin Lee <robinlee.sysu at gmail.com>:
> #include <stdio.h>
>
> int main(int argc, char** argv){
>    float f = 3.5f;
>    printf("%#x\n", f);
>    return 0;
> }
>
>
> 上面的代码在我机器(Linux x86_64)上编译运行,输出的是随机数。怎样解释这个现象?
> 在32位操作系统上,则总是输出0 。这又如何解释?
> _______________________________________________
> Chinese mailing list
> Chinese at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/chinese
>
你确定是随机数?每次输出的结果都不一样么?

你的代码是用 无符号整形 的格式输出了一个 IEEE 浮点数。

-- 
枕流漱石


More information about the Chinese mailing list