Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

use of float variables and its calculation in PICCLITE compiler

Status
Not open for further replies.

Jyothi@Pic

New Member
Hi,

Below is the code for calculation this code is in PICCLITE compiler
unsigned int AC_MIN=100,adc_value=108,ADC_MIN=62,AC_MAX=240,ADC_MAX=153,ADC_OUT;

ADC_OUT=AC_MIN+((adc_value-ADC_MIN)*((AC_MAX-AC_MIN)/(ADC_MAX-ADC_MIN)));

AS PER MANUAL CALCULATION I HAVE TO GET CC AS OUTPUT IN HEX
AND 204(DECIMAL)

BUT I AM GETTING A8(HEX) 168(DECIMAL)

CAN ANYBODY TELL HOW TO GET THE CORRECT MANUALLY CALCULATED VALUE

and also tell me how variables declared as float works
please for this its urgent

I am new to this

ITS URGENT
 
The manual (calculator) calculation comes out at 170. If you swap your brackets around so the multiply is done before the divide then you will get the correct answer.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top