1125 - } val *=p; p = 0; if(val >= 10.00){...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> #include<cmath> using namespace std; enum { SIZ = 20, }; char dat[SIZ]; void fun(){ printf(" 0.000000e+000\n"); return; } bool neg = dat[0]=='1'; double val, p, iter; int i; p = 0; for(i=1; i<8; i++){ p *= 2; if(dat[i]=='1'){ p += 1; } } p -= 63; p = pow(2.0, p); val = iter = 1.0; for(i=8; i<16; i++){ iter /= 2; if(dat[i]=='1'){ val += iter; }
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } val *=p; p = 0; if(val &gt;= 10.00){ while(val &gt;= 10.00){ val /= 10; p++; } } else if(val &lt; 1.00){ while(val &lt; 1.00){ val *= 10; p--; } } i = (int)p; printf(&quot;%s&quot;, neg?&quot;-&quot;:&quot; &quot;); printf(&quot;%.6lfe%+04d\n&quot;, val, i); } int main(){ printf(&quot;Program 6 by team X\n&quot;); while(scanf(&quot;%s&quot;, dat) &gt; 0){ fun(); } printf(&quot;End of program 6 by team X\n&quot;); return 0; }...
View Full Document

Ask a homework question - tutors are online