[FZH] C 语言的疑问

Robin Lee robinlee.sysu at gmail.com
Fri Jun 3 06:41:18 UTC 2011


大致确定,因为如果另定义一个

double d = 3.5;
printf("%#x\n", d);

和先前

printf("%#x\n", f);

的输出相同。

2011/6/3 Caius 'kaio' Chance <kaio at fedoraproject.org>:
> 你確定你輸出的不是內存位置,而是數值?
>
> 2011/6/3 Robin Lee <robinlee.sysu at gmail.com>
>
>> 不确定是否随机数,但每次都不同
>>
>> 2011/6/2 Xu Xin <railwaycat at gmail.com>:
>> > 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 浮点数。
>> >
>> > --
>> > 枕流漱石
>> > _______________________________________________
>> > Chinese mailing list
>> > Chinese at lists.fedoraproject.org
>> > https://admin.fedoraproject.org/mailman/listinfo/chinese
>> >
>> _______________________________________________
>> Chinese mailing list
>> Chinese at lists.fedoraproject.org
>> https://admin.fedoraproject.org/mailman/listinfo/chinese
>>
>
>
>
> --
> Regards ☺ Caius 'kaio' Chance - Fedora Project Contributor http://
> goo.gl/9WWWC
>  <http://goo.gl/9WWWC>IRC: kaio @ freenode | Twitter/Weibo: @K410 | Blog:
> kaio.net
> _______________________________________________
> Chinese mailing list
> Chinese at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/chinese
>


More information about the Chinese mailing list