Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

math calculations

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Unsupported versions
View previous topic :: View next topic  
Author Message
krolikbest

Bascom Member



Joined: 02 Jan 2017
Posts: 71

poland.gif
PostPosted: Wed Oct 17, 2018 3:42 pm    Post subject: math calculations Reply with quote

Hello

I have such equation - C notation
Code:

ud_ratio_first = ((u_first - d_first) * 100) / (u_first + d_first);
 


and would like to write the same in Bascom but somehow I can't. So I've written
Code:

      minus_part = u_first - d_first
      plus_part = u_first + d_first
      minus_part = minus_part * 100
      ud_ratio_first = minus_part / plus_part
 


and I'm wondering it is the only solution or could it be better written (Bascom only, no asm) than I did?

Regards,

Martin

(BASCOM-AVR version : 2.0.8.0 , Latest : 2.0.8.1 )
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Unsupported versions All times are GMT + 1 Hour
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
You cannot attach files in this forum
You cannot download files in this forum