Feb 25, 2014 #1 ecaits Member level 4 Joined Jan 16, 2014 Messages 76 Helped 0 Reputation 0 Reaction score 0 Trophy points 6 Activity points 579 Dear All, I cannot perform multiplication and division with integer number in pic 16f877 using hi-tech c compiler. What is reason behind that??? I cannot perform below code. Code: #include<pic.h> #include<htc.h> #include<stdlib.h> #include<math.h> void main() { unsigned int i=12,t=0,k=0,b=0; float j=0; t=i; b=i*0x2; k=i/0x3; j=i; } Last edited by a moderator: Feb 25, 2014
Dear All, I cannot perform multiplication and division with integer number in pic 16f877 using hi-tech c compiler. What is reason behind that??? I cannot perform below code. Code: #include<pic.h> #include<htc.h> #include<stdlib.h> #include<math.h> void main() { unsigned int i=12,t=0,k=0,b=0; float j=0; t=i; b=i*0x2; k=i/0x3; j=i; }
Feb 25, 2014 #2 Raady Here Full Member level 5 Joined Jun 8, 2013 Messages 242 Helped 26 Reputation 52 Reaction score 26 Trophy points 28 Location India Activity points 1,571 for multiplication i/0*3 not i/0x3 - - - Updated - - - you have to write in a language that complier understands ! :wink:
for multiplication i/0*3 not i/0x3 - - - Updated - - - you have to write in a language that complier understands ! :wink:
Feb 25, 2014 #3 ecaits Member level 4 Joined Jan 16, 2014 Messages 76 Helped 0 Reputation 0 Reaction score 0 Trophy points 6 Activity points 579 Raady Here said: for multiplication i/0*3 not i/0x3 - - - Updated - - - you have to write in a language that complier understands ! :wink: Click to expand... If i make same thing which you suggested then also the given code not performing maths operation....
Raady Here said: for multiplication i/0*3 not i/0x3 - - - Updated - - - you have to write in a language that complier understands ! :wink: Click to expand... If i make same thing which you suggested then also the given code not performing maths operation....
Feb 25, 2014 #4 N nick703 Advanced Member level 1 Joined Oct 17, 2011 Messages 422 Helped 21 Reputation 44 Reaction score 22 Trophy points 1,298 Location surat Activity points 3,987 put while(1) loop in your main routine .
Feb 25, 2014 #5 alexan_e Administrator Joined Mar 16, 2008 Messages 11,888 Helped 2,021 Reputation 4,158 Reaction score 2,031 Trophy points 1,393 Location Greece Activity points 64,371 Raady Here said: for multiplication i/0*3 not i/0x3 - - - Updated - - - you have to write in a language that complier understands ! :wink: Click to expand... 0x3 is the hexadecimal form of decimal 3 or binary 0b11 , why do you think that the compiler doesn't understand it? i/0*3 Click to expand... Division by 0 is not a good idea
Raady Here said: for multiplication i/0*3 not i/0x3 - - - Updated - - - you have to write in a language that complier understands ! :wink: Click to expand... 0x3 is the hexadecimal form of decimal 3 or binary 0b11 , why do you think that the compiler doesn't understand it? i/0*3 Click to expand... Division by 0 is not a good idea
Feb 25, 2014 #6 FvM Super Moderator Staff member Joined Jan 22, 2008 Messages 52,484 Helped 14,756 Reputation 29,794 Reaction score 14,121 Trophy points 1,393 Location Bochum, Germany Activity points 298,357 I cannot perform multiplication and division with integer number in pic 16f877 using hi-tech c compiler. Click to expand... You didn't tell a word about the observed problem. I expect this results t=12 b=24 k=4 j=12.000
I cannot perform multiplication and division with integer number in pic 16f877 using hi-tech c compiler. Click to expand... You didn't tell a word about the observed problem. I expect this results t=12 b=24 k=4 j=12.000
Feb 25, 2014 #7 Raady Here Full Member level 5 Joined Jun 8, 2013 Messages 242 Helped 26 Reputation 52 Reaction score 26 Trophy points 28 Location India Activity points 1,571 ecaits said: If i make same thing which you suggested then also the given code not performing maths operation.... Click to expand... what does it show ? error, or show nothing, or showing other than what you are expecting ? - - - Updated - - - alexan_e, You are right , sorry, i over went the concept !
ecaits said: If i make same thing which you suggested then also the given code not performing maths operation.... Click to expand... what does it show ? error, or show nothing, or showing other than what you are expecting ? - - - Updated - - - alexan_e, You are right , sorry, i over went the concept !
Feb 25, 2014 #8 ecaits Member level 4 Joined Jan 16, 2014 Messages 76 Helped 0 Reputation 0 Reaction score 0 Trophy points 6 Activity points 579 Yes sir, you are right, now i m getting same value. But Now, I want to divide j say j/5, then i m not getting expected value???
Yes sir, you are right, now i m getting same value. But Now, I want to divide j say j/5, then i m not getting expected value???
Feb 25, 2014 #9 N nick703 Advanced Member level 1 Joined Oct 17, 2011 Messages 422 Helped 21 Reputation 44 Reaction score 22 Trophy points 1,298 Location surat Activity points 3,987 j is float right and this result is store in which variable u do not described?