CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

float32 gives strange results

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dbaltz



Joined: 20 Nov 2009
Posts: 13

View user's profile Send private message

float32 gives strange results
PostPosted: Tue Sep 11, 2012 2:52 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Sep 11, 2012 3:00 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Sep 11, 2012 3:44 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Sep 11, 2012 4:57 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Sep 11, 2012 5:32 pm     Reply with quote

OK, sorry. I somehow skipped over the word MPLAB-X in your first post.
dbaltz



Joined: 20 Nov 2009
Posts: 13

View user's profile Send private message

PostPosted: Wed Sep 12, 2012 10:39 am     Reply with quote

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?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group