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

Mathematical library bug?

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



Joined: 01 Oct 2008
Posts: 2

View user's profile Send private message

Mathematical library bug?
PostPosted: Fri Nov 20, 2009 7:21 am     Reply with quote

I noticed the following strange problem:

Z=Y+X;

X is always nonnegative.

Y is usually 0.0

If presentation of Y is "0x00000000" everything is OK, but if presentation is "0x80000000" something very strange happens.

Z=Y+X = -X ??????

For example:

-0.0 + 88.36 = -88.36

I use PCD compiler Version 4.093 with dsPIC33FG128MC804.

My application used a big data stream from PC and it is very uncomfortable to check every time if value is equal to "0x80000000" and change the presentation to "0x00000000".
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Nov 20, 2009 9:03 am     Reply with quote

Yes, still present with PCD V4.100.
Quote:
float x,y,z
x=-0.0;
y=1.0;
z=x+y;

z gives -1.0
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 20, 2009 1:29 pm     Reply with quote

It does work OK in the PCM and PCH compilers with vs. 4.100.
Results are:
Quote:
1.00

Test program:
Code:

#include <18F452.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//======================================
int8  main ()
{
float x,y,z;

x=-0.0;
y=1.0;

z=x+y;

printf("%3.2f \n\r", z);

while(1);
}
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