Internet PLC Forum

General => Technical support => Topic started by: danier on April 10, 2011, 08:47:54 PM

Title: divide decimals
Post by: danier 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))

Title: Re:divide decimals
Post by: garysdickinson 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]