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

Help me why function not return exactly value

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



Joined: 09 Oct 2006
Posts: 12
Location: hoangsam

View user's profile Send private message AIM Address Yahoo Messenger ICQ Number

Help me why function not return exactly value
PostPosted: Tue Apr 16, 2024 10:45 am     Reply with quote

Help me why function not return exactly value

Last edited by thanhhavdt on Mon May 06, 2024 9:32 am; edited 1 time in total
gaugeguy



Joined: 05 Apr 2011
Posts: 290

View user's profile Send private message

PostPosted: Tue Apr 16, 2024 12:14 pm     Reply with quote

Your comment and function do not match.

Quote:
Data_DKX = (((400*a)+(40*(b+45))+(4*c)+d)); //Data_DKX = ((10000*a)+(1000*(b+45))+(100*c)+d)/25;


If the part in the commented section is correct, then it appears you divided each constant by 25 except for the constant of 1 for d.
thanhhavdt



Joined: 09 Oct 2006
Posts: 12
Location: hoangsam

View user's profile Send private message AIM Address Yahoo Messenger ICQ Number

PostPosted: Wed Apr 17, 2024 7:18 am     Reply with quote

gaugeguy wrote:
Your comment and function do not match.

Quote:
Data_DKX = (((400*a)+(40*(b+45))+(4*c)+d)); //Data_DKX = ((10000*a)+(1000*(b+45))+(100*c)+d)/25;


If the part in the commented section is correct, then it appears you divided each constant by 25 except for the constant of 1 for d.

Sorry, comment is:
Data_DKX = (((400*a)+(40*(b+45))+(4*c)+d)); //Data_DKX = (((10000*a)+(1000*(b+45))+(100*c))/25)+d;
and Data_DKX = ((((400*a)+(40*(b))+(4*c)+d))-1800); //Data_DKX = (((10000*a)+(1000*(b-45))+(100*c))/25)+d;
temtronic



Joined: 01 Jul 2010
Posts: 9133
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Apr 17, 2024 9:09 am     Reply with quote

It'd be easier to see your error if you break down the equation !
ie
answer=first math term 'a'
answer =answer + 2nd math term 'b'
answer =answer + 3rd math term 'c'
answer=answer + 4th math term 'd'

Having it in one long line of code can be very confusing and hard to read.
Now once you have the correct code, you could reduce to one line.

Also put comments at the end of lines of code. Old habit from assembler days but it really,really helps and cost you nothing. Handy for when you ask 'is this right ?' or 3 days later when you ask yourself WHY did I code this mess ??
thanhhavdt



Joined: 09 Oct 2006
Posts: 12
Location: hoangsam

View user's profile Send private message AIM Address Yahoo Messenger ICQ Number

PostPosted: Wed Apr 17, 2024 6:12 pm     Reply with quote

In read_Data_DKX_song_met(), Data_DKX= 10000; 10002; ....13400
but in read_Data_DKX_song_deximet(), Data_DKX= 10001; 10002; ....13999
function read_Data_DKX_song_deximet() return exactly value with even number (Data_DKX= 10000; 10002; ....) but not with odd number (Data_DKX= 10001; 10003; ....). Please heplme
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