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.

Problem of variable format reading in MPLAB

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
Hello Sirs,

I am working on PIC16F877 using hi-tech c compiler.

if i declare one integer variable say i = 200. then when i observe it in watch window of mplab then it shows equivalent hex value i.e. C8.

If I want to do division operation with i, say a = i/6.82; then it always take hex value in i but i want to do division operation with decimal only.

How i can solve this problem???
 

0xC8 is the equivalent hex of 200(decimal). your ans will be in hex convert it into decimal in order to get the result you expect
 

But when i convert the hex to decimal and take that decimal value in variable then that variable also shows the hex value, not decimal value.... that is the problem...
 

In watch window u can choose to see HEX or Decimal or BINARY or all.
That should solve the problem.
 

u should take typecast and u will get only decimal value


exp .......a=(int)(i/6.82)
 

Code:
exp .......a=(int)(i/6.82)
The result type depends on the data type of a, not a type cast. Automatic type conversion according to C standard takes place. (You probably should read a C text book to deserve your name :) )

Either a is an integer type, then the result will be displayed as such and you can read it in the watch window in the decimal display, if you enabled the decimal column or chose decimal as the default format. Or it's float type, then you need to select the proper float format used by your compiler.
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top