Warning[Pe061]: integer operation result is out of range

http://www.amobbs.com/thread-5580618-1-1.html



#define  j 7000
u16 i ;
i=j * 5 ;
IAR下編譯警告:Warning[Pe061]: integer operation result is out of range 
7000*5=35000 < 65535
查到原因:
賦值前,7000×5是作爲有符號整數來計算,溢出了,改爲(u16)7000*(u16)5(強制爲無符號)就是無符號的計算了,一切OK。。。。

    int i,j,k;
    
        for(j=0;j<6;j++)
        {  
            for(i=0;i< (u16)240*(u16)240;i++)
            {  
            }
         }

發佈了7 篇原創文章 · 獲贊 49 · 訪問量 20萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章