Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

invalid operands to binary >>

Status
Not open for further replies.

vinay shabad

Junior Member level 3
Joined
Dec 13, 2010
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,769
can someone help me i am getting the following error


humidum &= ~(0x0003);
return ((21965 * humidumm) >> 13) - 46850;
do i need to add any special headers for using this
 

alexxx

Advanced Member level 4
Joined
Apr 17, 2011
Messages
1,013
Helped
273
Reputation
552
Reaction score
270
Trophy points
1,383
Location
Greece
Activity points
7,938
vinay shabad said:
do i need to add any special headers for using this
No special header is needed for this. My compiler compiles it without errors. Can you post the function involved and the function call?
 

vinay shabad

Junior Member level 3
Joined
Dec 13, 2010
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,769
int humidum;

humidum &= ~(0x0003);

fsxhumi= ((21965) * humidumm) >> 13 - 46850;

if (fsxhumi < 0)
{

fsxhumi = -fsxhumi;
DisplaySign = 1;
}
else DisplaySign = 0;

if (fsxhumi < 100)
{
DigitPointSegEnable = 1;
fsxhumi = fsxhumi*100;
}
else
{
DigitPointSegEnable = 0;
}


tt = (int) fsxhumi;
DigitA = (unsigned char) ((int) (tt / 100)); //(extrait la partie des dizaines)
tt = tt % 100;
DigitB = (unsigned char) ((int) (tt / 10));
tt = tt % 10;
DigitC = (unsigned char) tt;

}
 

alexxx

Advanced Member level 4
Joined
Apr 17, 2011
Messages
1,013
Helped
273
Reputation
552
Reaction score
270
Trophy points
1,383
Location
Greece
Activity points
7,938
Again my compiler gives me no errors. What is the problem you are facing, can you please describe?
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,020
Reputation
4,156
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
If for some reason your compiler doesn't accept the shifting (which seems strange) you can divide by 2^13 (0h80000) instead

fsxhumi= ((21965 * humidumm) /0h80000) - 46850;

Another note, in your code you have
fsxhumi= ((21965) * humidumm) >> 13 - 46850;

have you tried with fsxhumi= ((21965 * humidumm) >> 13) - 46850;

Alex
 

vinay shabad

Junior Member level 3
Joined
Dec 13, 2010
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,769
i tried to use your code with

fsxhumi= ((21965 * humidumm) /0h80000) - 46850;
but it is showing

error: invalid suffix "h80000" on integer constant

---------- Post added at 13:41 ---------- Previous post was at 13:39 ----------

yes i tried with the second one

fsxhumi= ((21965 * humidumm) >> 13) - 46850;
its showing following error



error: invalid operands to binary >>
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,020
Reputation
4,156
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
sorry, that was my mistake, I meant a hex format 0x80000

Also it might be better ti use some typecasting too
fsxhumi= ((long int)(21965 * humidumm) /0h80000) - 46850;

what type is fsxhumi, can it hold the result?
And how many bits are your integers?

Alex
 

vinay shabad

Junior Member level 3
Joined
Dec 13, 2010
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,769
float fsxhumi,i gussed it hex nd tried with it
i am notgetting error but it is not showing output
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,455
Helped
14,040
Reputation
28,333
Reaction score
12,691
Trophy points
1,393
Location
Bochum, Germany
Activity points
275,990
humidumm isn't a defined variable in your code. Either it's a trivial typo or you missed to post the complete code.
Please clarify.

P.S.: >> 13 can be replaced by /0x2000, I think. No idea, where the /0x80000 comes from?
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,020
Reputation
4,156
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
I did the stupid mistake actually, I have used the calculator in hex mode and I did 2^13 but 13 in hex mode equals 19 decimal so the result I got was for 2^19 :oops:

Alex
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top