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

floating point problems with pic24F

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



Joined: 03 Jul 2009
Posts: 8

View user's profile Send private message

floating point problems with pic24F
PostPosted: Sat Aug 29, 2009 4:49 pm     Reply with quote

Hi,
I need to write a simple code with some float variable on a PIC24F but just with a simple assignment in mplab sim appears some strange values.
For example this code ....
Code:

#include <24FJ16GA002.h>
#use delay(clock=8000000)

void main()

   float a;
   a=-1;
   a=1;
   a=0;
}

... produces these results (value column, on watch window in mplab sim):
a=-1 ==> 4.61853961e-041
a=1 ==> 4.60060299e-041
I've tried to declare float32 instead of float, but with the same strange results.


With a PIC18F everything works fine, then...where is the problem?
My compiler version is 4.072

Thanks!!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Aug 29, 2009 5:07 pm     Reply with quote

It's a MPLAB watch window issue only, see http://www.ccsinfo.com/forum/viewtopic.php?t=39486
hexfet13



Joined: 03 Jul 2009
Posts: 8

View user's profile Send private message

PostPosted: Sun Aug 30, 2009 6:07 am     Reply with quote

Thanks for your reply but there's a chance to set the appropriate floating point format in the "value" column in watch window? (sprintf works fine but is uncomfortable to use it)
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Aug 30, 2009 7:02 am     Reply with quote

As I reported in the linked thread, I was able to set the correct format in MPLAB V8.20. It either doesn't work in some MPLAB versions, or the original poster didn't manage to find the setting. As I have no problems with displaying float watches, I didn't try to clarify the issue. If there's an MPLAB problem, you should contact Microchip.
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