View previous topic :: View next topic |
Author |
Message |
dbaltz
Joined: 20 Nov 2009 Posts: 13
|
float32 gives strange results |
Posted: Tue Sep 11, 2012 2:52 pm |
|
|
I have a PCH application for a PIC18F46K22 that uses the float32 type. It was working with a previous compiler version (PCM) but now the floating point calculations are not working. MPLAB-X shows the value in the Watch window with a Type of "float_mbe" which I can't find documented anywhere.
Code: |
float32 Reading = 0;
Reading = 3.0f;
|
Shows the following in the Watch window:
Code: |
Name Type Address Value
Reading float_mbe 0x96 2.3138E-41
|
If I look at Reading in the ToolTip window (when hovering over the variable) it shows the hex value as: 0x00004080.
Is there a mixup here between the IEEE FP format and the Microchip float32 format?
My compiler version is PCH v4.135. |
|
|
dbaltz
Joined: 20 Nov 2009 Posts: 13
|
|
Posted: Tue Sep 11, 2012 3:00 pm |
|
|
On further examination, this appears to be a display issue with MPLAB. The values are being calculated correctly, but displayed in the IDE incorrectly. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 11, 2012 3:44 pm |
|
|
It works for me with MPLAB vs. 8.86. Just set it for MCHP Float format.
Do this by right-clicking on the Watch Window and selecting the Properties menu.
Then do a mouse-over of the "Reading = 3.0f;" line in the source window
and you will see "Reading = 3.00000000". |
|
|
dbaltz
Joined: 20 Nov 2009 Posts: 13
|
|
Posted: Tue Sep 11, 2012 4:57 pm |
|
|
I don't get anything by right-clicking in the Variable window of MPLAB-X. I can right-click the value and get IEEE FP choices but don't see an MCHP choice. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 11, 2012 5:32 pm |
|
|
OK, sorry. I somehow skipped over the word MPLAB-X in your first post. |
|
|
dbaltz
Joined: 20 Nov 2009 Posts: 13
|
|
Posted: Wed Sep 12, 2012 10:39 am |
|
|
PCM programmer wrote: | OK, sorry. I somehow skipped over the word MPLAB-X in your first post. |
It looks like MPLAB-X doesn't support the PCH float format anymore. Is there an option in PCH to use IEEE 4-byte floats? |
|
|
|