View previous topic :: View next topic |
Author |
Message |
hexfet13
Joined: 03 Jul 2009 Posts: 8
|
floating point problems with pic24F |
Posted: Sat Aug 29, 2009 4:49 pm |
|
|
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
|
|
|
hexfet13
Joined: 03 Jul 2009 Posts: 8
|
|
Posted: Sun Aug 30, 2009 6:07 am |
|
|
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
|
|
Posted: Sun Aug 30, 2009 7:02 am |
|
|
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. |
|
|
|