标签:
// print float bits #include <iostream> using namespace std; int main() { float num = 0.15625; int n = *(int*)(void*)# cout<<(n)<<endl; for(int i = 0; i < 32; ++i) { if(n & (1<<(31-i))) cout<<1; else cout<<0; } cout<<endl; return 0; }
(1.01)2*2(124-127) = 1.25 * 0.125 = 0.15625
对于浮点数一直有些不太明白,看了看博客就小记一下,以供以后查看
标签:
原文地址:http://www.cnblogs.com/yaling/p/5080109.html