Author Topic: decimal point  (Read 11196 times)

karen

  • Newbie
  • Posts: 18
  • I love YaBB 1G - SP1!
    • View Profile
decimal point
« 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

« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: decimal point
« Reply #1 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.
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

karen

  • Newbie
  • Posts: 18
  • I love YaBB 1G - SP1!
    • View Profile
Re: decimal point
« Reply #2 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
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: decimal point
« Reply #3 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"
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS