# 2019q3: 回顧 Homework [_3_](https://hackmd.io/@sysprog/BJCG-HGdS) / [_4_](https://hackmd.io/@sysprog/Bkb5cDMuH) - [ ] jserv * 檢討事項 : * 補充資訊 : --- ```cpp float_bits float_i2f (int i){ if(i == 0) return 0; int sign = (i >> 31)<<31; int exp = bits_length(i&0x7fffffff) - 1; int frac = bits_mask(exp) & i; return (sign | ((exp + 127) << 23)) | frac; } ``` contributed < `Benny1117Yen` > 上述修改 ```int frac = (bits_mask(exp) & i) << (23 - E)``` 表示還要左移 `23 - E` 來將 `frac` 補到 `23` bits。 不過還可以增加一些條件, [參考](https://github.com/DreamAndDead/CSAPP-3e-Solutions/blob/master/chapter2/code/floats/float-i2f.c)這份,改寫在底下連結 https://hackmd.io/@P86071244/Quiz7#%E6%B8%AC%E9%A9%97-2
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.