Continue to Site

Welcome to

Welcome to our site! 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.

how to multiply two numbers in c in pic microcontroller?

Not open for further replies.


Full Member level 3
Jul 21, 2009
Reaction score
Trophy points
Activity points
how to multiply in c

I want to multiply 819.2 with 0.0048828125 in pic using C language.
anyone can explain me this and give me C coding.

multiply microcontroller

void mult()
float f;



the answer is 4

multiply two numbers

I hope u had a problem with precision.
u can double or long double for more precise value.

c - multiply two numbers

actually i am taking data from a sensor whose output is 4 volt i.e analog input to pic is 4 volt .now for Vref=5 volt, i have step size of 0.0048828125 so i have multiply the output of controller's builtin A\D to 0.0048828125 to get real value that is 4.
How to do this
A\D binary output is stored in 2 registers as in PIC i.e ADRESl & ADRESH
plz help how to multiply value stored in ADRESL & ADRESH to 0.0048828125

pic c multiply

float ADnumber = (float)((int)(((int)ADRESH << 8 ) | ADRESL)) * 0.0048828125f

I think that would do it. I would check with a normal C compiler first tho. All this does is transform ADRESL & ADRESH into a 16-bit number, change that to a float, and then multiply it with your constant.

multiply number in c

Just because it doesn't have them physically doesn't mean you can't use them virtually. If you are using a C compiler of any variety (MCC18, mikroC, SourceBoost etc) it will use two 8-bit registers for a 16-bit number. That is a really basic concept btw. Trust me, I use only PICs (mainly 18F) and I use 16-bit variables all the time.

multiply in pic

That will do it because there is no need of a 16-bit register in this operation.
He is virtually implementing a 16-bit value using 2 8-bit registers.

Not open for further replies.

Part and Inventory Search

Welcome to