Internet PLC Forum

General => Technical support => Topic started by: karen on November 18, 2002, 09:25:07 AM

Title: decimal point
Post by: karen on November 18, 2002, 09:25:07 AM
x = x + 8 ' Progressive increment(??) after every call  
IF x > 3800 THEN  
    j = 0
    x = 0    
ELSE  
    j = 240 - X*240/3800  
ENDIF
  


SETLCD 0,1,CHR$(1)  ' clear screen
SETLCD 1,1,"-------INPUT---------"
SETLCD 2,1,"      Current"
SETLCD 3,1,"        "+str$(j)+" ma"        
SETLCD 4,1,"_____Press Enter____ "

how do i show a the number with a decimal point the variable is j  ;D

thanks

Title: Re: decimal point
Post by: support on November 18, 2002, 09:45:34 AM
To display a number X with say 1 decimal place (i.e. 1234 is to be displayed as 123.4), do the following:


 SETLCD "X="+ STR$(X/10)+"."+STR$(X MOD 10)

You can display two decimal points by using 100 as the divisor.
Title: Re: decimal point
Post by: karen on November 18, 2002, 10:14:04 AM
tried that but it just gives me a 0. my number as you can tell from the equation at the top every time i press the button the value of j does not increase until two pushes  3800/240=15.333 so i want to show the . number sorry my description is so bad

ta

karen
Title: Re: decimal point
Post by: support on November 18, 2002, 10:32:11 AM
So you should compute the whole expression that is boosted by 10 or hundred time first.

E.g.  J = 24000 - X*24000/3800

The result is that J is 100 time bigger than the actual number. Now you have a number that you can display as "15.33"