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

simple float and int arithmetic...

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







simple float and int arithmetic...
PostPosted: Thu Mar 25, 2004 11:45 am     Reply with quote

suppose i have:

Code:
int delta_y;
float slope;

...
delta_y = 0x4D; /* this is decimal 77 */
slope = (float) delta_y / 50.0;


Using MPLAB's IDE for debugging, I find that my slope ends up equaling:
-3.773486e-005 ????

I expect it to look more like 77/50 = 1.54

Can someone shed some light how to get my desired 1.54 answer? Perhaps i'm not even expressing it the correct way and that's why i'm getting an error.

-Mike
valemike
Guest







Found the Problem
PostPosted: Thu Mar 25, 2004 12:36 pm     Reply with quote

Looks like Microchip's MPLAB doesn't interpret correctly the way that CCS stores floats. I did a printf() instead and all is fine.
dilandau



Joined: 25 Aug 2010
Posts: 11

View user's profile Send private message

PostPosted: Thu Mar 31, 2011 11:30 am     Reply with quote

Dont know if this is a very old topic but here you have the solution from CCS

http://www.ccsinfo.com/faq.php?page=mplab_float
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