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

Raady Here

Full Member level 5
Joined
Jun 8, 2013
Messages
244
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:
 

ecaits

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

nick703

Advanced Member level 1
Joined
Oct 17, 2011
Messages
414
Helped
21
Reputation
44
Reaction score
22
Trophy points
1,298
Location
surat
Activity points
3,872
put while(1) loop in your main routine .
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,021
Reputation
4,158
Reaction score
2,032
Trophy points
1,393
Location
Greece
Activity points
64,375
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
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,956
Helped
14,344
Reputation
28,952
Reaction score
13,086
Trophy points
1,393
Location
Bochum, Germany
Activity points
282,435
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
 

Raady Here

Full Member level 5
Joined
Jun 8, 2013
Messages
244
Helped
26
Reputation
52
Reaction score
26
Trophy points
28
Location
India
Activity points
1,571
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 !
 

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

nick703

Advanced Member level 1
Joined
Oct 17, 2011
Messages
414
Helped
21
Reputation
44
Reaction score
22
Trophy points
1,298
Location
surat
Activity points
3,872
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

Top