最近在學習游戲引擎開發,看到game engine development 上講解的用類型雙關來轉換大小端的方式:
union intWithFloat{
int32_t m_i32;
float m_f32;}
float swapFloat32(float value){
intWithFloat i;
i.m_i32 = value;
i.m_f32 = swapInt32(i.m_i32)
return i.m_f32;} 樓主小白,不太理解這裏爲什麼要這麼複雜,直接構造一個轉換函數來轉換float32爲什麼不行,這裏使用類型雙關又有什麼意義==?
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/49049.html
標籤:其它游戲引擎
上一篇:新手求助
