Joined: 08 Sep 2003 Posts: 105 Location: New Castle, DE
Having trouble with Signed and Unsigned INT type conversions
Posted: Tue Oct 28, 2003 2:01 pm
This is what I have that works correct.
Int Nset;
Float Nor_f
Nset = 10;
Nor_f = Nset/.0001174;
Nor_f now = 85178.875
This is all fine and what I expected!
But I need to change Nset to a sign int so that if I decrement Nset I can test for <= zero.
Signed Int Nset;
Float Nor_f
Nset = 10;
Nor_f = Nset/.0001174;
Nor_f now = 5.1265171797906E-32
There must be some thing about type conversions / promotions that I don�t understand.
If I type cast Nset in to a float then it works just fine.
But I though with the constant being a float that the complier would promote Nset to a float automatically?
Signed Int Nset;
Float Nor_f
Nset = 10;
Nor_f = (float)Nset/.0001174;
Nor_f now = 85178.875
Can someone give me insight me on this?
Thank All
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Tue Oct 28, 2003 4:14 pm
The rule with CCS is, if it doesn't work, then type cast it.
(ie., Do whatever you have to do, to make it work).
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum