mikroc 8.0 float array problems

Status
Not open for further replies.

zia

Full Member level 5
Joined
Sep 24, 2010
Messages
284
Helped
27
Reputation
54
Reaction score
26
Trophy points
1,318
Location
Islamabad Pakistan
Activity points
2,746
hi friends
i have faced a strange problem in mikroc compiler.
const float a[]={1.2,2.8,5.1};
char i=1;
then a should equals to 1.2 but not
if replace float with int i-e const int a[]={1,7,9};
then a gives value 7.
but in the case of float why not getting exact value.
may you explain?
 

index 0 is the first position, index 1 is the second position.

Try

const float a[]={1.2,2.8,5.1};
unsigned int i=1;

then a now should be 2.8, because i=1 not 0
 

sorry writing mistake in post ,yes you are right but i am getting zero. but if declares float by int , it works fine.
 

Sorry, how do you check de value?
If you are using a printf, make sure you are formatting "%f".
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…