Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

Not performing multiplication and division operation with decimal number in PIC

Status
Not open for further replies.

ecaits

Member level 4
Member level 4
Joined
Jan 16, 2014
Messages
76
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
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:

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:



If i make same thing which you suggested then also the given code not performing maths operation....
 

for multiplication i/0*3 not i/0x3

- - - Updated - - -

you have to write in a language that complier understands ! :wink:

0x3 is the hexadecimal form of decimal 3 or binary 0b11 , why do you think that the compiler doesn't understand it?

Division by 0 is not a good idea
 

I cannot perform multiplication and division with integer number in pic 16f877 using hi-tech c compiler.
You didn't tell a word about the observed problem.

I expect this results t=12 b=24 k=4 j=12.000
 

If i make same thing which you suggested then also the given code not performing maths operation....

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 !
 

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???
 

j is float right and this result is store in which variable u do not described?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top