Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why do floating-point variables in MPLAB IDE have the wrong value?

0
Posted

Why do floating-point variables in MPLAB IDE have the wrong value?

0

MPLAB IDE’s Watch window interprets all floating-point variables (whether defined as ‘float’ or ‘double’) as 32-bit values unless you manually change the properties for each one. Since the HI-TECH C compilers for PIC10/12/16 and for PIC18 allocate 24 bits for ‘float’ and ‘double’ types, unless you explicitly specify otherwise, this means all floating-point values displayed in the Watch view will be incorrect. This does not affect the operation of code, merely what values are displayed when debugging. To correct the display, right-click on the variable name in the Watch window and select Properties. Change the Size field to 24 bits. Also ensure that the Format field is set to IEEE Float (as opposed to MCHP Float) — this is the only format used in HI-TECH C. You will need to do this for each floating-point variable added to the Watch view. Incidentally, if you meant to use 32-bit floating point types in your project, adjust the Size of Double and/or the Size of Float fields in the Globa

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123