Problem with a division of a value bigger than 127

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem with a division of a value bigger than 127

1,499 次查看
dvw
Contributor I
This is my problem:
 
static int a;
a=127/2;
ok, a=63
 
static int a;
static int b;
a=127;
b=a/2;
ok, a=63
 
static int a;
a=128/2;
ok, a=64
 
static int a;
static int b;
a=128;
b=a/2;
Problem: a=193
 
I've tryied different types like floats, signed and unsigned int, but nothing worked...
Could someone help me to find the problem?
 
Thanks!
 
 
 
 
 
标签 (1)
标记 (1)
0 项奖励
回复
1 回复

672 次查看
CrasyCat
Specialist III
Hello
 
- Which CPU are you targeting (HC08, HC12, Coldfire, ..)
- Which version of CodeWarrior are you using?
To retrieve that info:
- Start CodeWarrior
- Select Help -> About Freescale CodeWarrior
- Click on "Install Products"
- CodeWarrior version used is displayed on top in the Installed Products dialog.
 
CrasyCat
0 项奖励
回复