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.

multiply decimal numbers in PIC

Status
Not open for further replies.

anurag2700

Newbie level 6
Joined
Jun 18, 2009
Messages
13
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,364
how do u multiply decimals

please help me in multiply or dividing two decimal numbers in PIC.
EXAMPLE--43.2 x 23.6
 

operations on decimal numbers pic

You have to declare variable like a float instead int or char.
Regards
 

pic multiply

i have to use this in PIC16f877A and in assembly language.
 

how do u divide decimals

I have somewhere multiply two 8-bit integers. Do u want it?

Code:
Mul
	clrf       resL            ; clear resL
	clrf       resH            ; clear resH
	movlw      8               ; set number ..
	movwf      cnt_art	      ; .. of bits in intB
	movfw      intA	         ; intA > W
	bcf        STATUS, C	    ; clear carry

Rotation
	rrf        intB, f	       ; intB >> 1
	btfsc      STATUS, C        ; if last bit in intB was 1
	addwf      resH, f	       ;   do this
	rrf        resH, f	       ; resH >> 1
	rrf        resL, f	       ; resL >> 1
	decfsz     cnt_art,F	     ; decrement counter
	goto       Rotation	      ; if this isn't go back to Rotation	
	movfw      resL	          ; resL -> PORTB
	movwf      output	        ; W -> PORTB
	entr                        ; macro entr
	movfw      resH	          ; resH -> PORTB
	movwf      output	        ; W -> PORTB
	entr                        ; macro entr
	return                      ; return
 

13/24 decimal

yeah......plzz send na...
do you know how to do in decimal like 43.2 x 35.7
 

pic multiply by 100

There is problem with impementation of float. U must crat varibale which contain mantisa and exponent and it isn't easy.
 

multiply decimals in assembly language

anurag2700 said:
please help me in multiply or dividing two decimal numbers in PIC.
EXAMPLE--43.2 x 23.6
Since you provided very little information about your real application, I'll solve your example by simply representing the numbers with fixed (as opposed to floating) decimal point and further operate on them using integer multiplication/division.

Say that representing all your numbers with 2 decimals is enough precision. You then store them as multiplied by 100 so they appear integer and you can use integer operations on them.
If you multiply two of them, for example, you’ll get an integer part (that you can extract by dividing the result by 10000) and 4 “decimals” (that you can extract by doing a modulo 10000), all this encoded on a [long] integer.

I hope this method suits you, because I have a feeling that you’re not going to get an implementation of the IEEE754 in assembly on this forum (look it further here https://en.wikipedia.org/wiki/IEEE754).

Arthur
 

model decimal multiplication pic

If you know how to implement division in asm, you can try : 432 x 236 / 100. And take care to keep the multiplicands on 16bits. You will loose some precision but you can avoid floating point in this way.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top