Math problem with string result


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46

    Default Math problem with string result

    Hi,
    I got lost in something that should be very simple !
    Through the cmd serin 2 i get a 4 characters (numbers) Str long\4
    example 5894
    Then I display it with the cmd LcdOut str long\4
    Now it comes the problem.
    I should divide /60 the str long\4 (98.2333) and display only 98.
    I can not get neither numbers.

    Thanks for your help
    Lotondo

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    L,

    Did you rebuild your number before doing the division?

    X=5*1000+8*100+9*10+4 ?

    If yes, can you post your code snippet?
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    and why using STR when you can use DEC?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    The code here below is working ok but it shows
    the number not divided. (ex. 5894)
    I tried several ways to divided (ex. /60) this number and
    showing the result (Interger or with decimal) but no success.
    Bye
    Lotondo

    >>>>>>>>>>>

    DEFINE OSC 4

    BAUD VAR BYTE
    LATDEC VAR BYTE[4]

    RX VAR PORTB.1 ' RX fm 232
    BAUD = 188 ' 4800,8,N,1(True,driven)

    PORTB=0

    LCDOut $FE, 1
    LCDOut $FE, $0C

    LOOP:

    SerIn2 RX,BAUD,[wait("$HOLD,"),SKIP 7,STR LATDEC\4]
    Pause 1000

    LCDOut $FE, 1
    LCDOut "RIS: ",STR LATDEC\4
    GoTo LOOP

    End

    >>>>>>>>>>>>>>>>>>>

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Code:
    LATDEC var word
    SerIn2 RX,BAUD,[wait("$HOLD,"),SKIP 7,DEC4 LATDEC]
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Mr_e thanks for yr reply.
    Now, if I set:

    Latfin var byte ------------------> Latfin is Always < 100
    Latfin = (Latdec /60)
    Lcdout Latfin

    Do you think I'll get 98.23 display ?
    How to get only 98 ?

    Thanks

    lotondo

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    you'll never get any float as PBP works with integer.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Thanks,
    I'll try like you said.
    I'll come back to you in case of any other trouble.

    Bye
    Lotondo

Similar Threads

  1. Line Graph, math problem...
    By TerdRatchett in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th May 2009, 04:20
  2. Math help please!!!
    By jbirnsch in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 10th August 2007, 14:45
  3. Visual Basic 6 & Access 2000
    By Demon in forum Off Topic
    Replies: 33
    Last Post: - 7th September 2006, 04:39
  4. PicBasic Pro Math Problem??
    By Glen65 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th March 2006, 04:36
  5. PBP 16-bit ADC result math
    By sonic in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 13th March 2005, 14:21

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts