Author Topic: divide decimals  (Read 10834 times)

danier

  • Newbie
  • *
  • Posts: 14
  • I'm a llama!
    • View Profile
divide decimals
« on: April 10, 2011, 08:47:54 PM »
traduccti?n espanis to ingl?s

Regards
 I have the following questions with the following function
 1.se can divide decimals, annex the following function
 when I run it shows me the error missing)
 is that you can not or I'm doing wrong

v= ((ADC(3)/15,5))


garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:divide decimals
« Reply #1 on: April 10, 2011, 11:12:52 PM »
Danier,

TBASIC only supports integer math.

I believe that 15,5 is a number between 15 and 16.  In the
US we would write this number as 15.5

TBASIC will go nuts with the "," and spit out all sorts of error
messages.  This crazy behavior is the best that it can do.

I think that this will give you the results that you desire:


v = (ADC(3) * 10 ) / 155

Another way of thinking about this is

    ADC(3)      ADC(3) * 10       ADC(3) * 10
   --------   =  -------------  = -------------
    15.5         15.5 * 10             155




Gary D.
[/font]
« Last Edit: April 10, 2011, 11:44:23 PM by garysdickinson »