display numbers on lcd

Discussion in 'Embedded Systems and Microcontrollers' started by h.d, Mar 1, 2008.

  1. h.d

    Thread Starter Active Member

    Oct 22, 2007
    150
    0
    hi for all
    am work in PIC and want to display numbers on LCD
    the numbers have fraction(3.1)like that
    how can i display it un lcd (how to write the program)
    i try it as float then cinvert to string the result is like (3.099999)
    i need (3.1)
    am programming by mBASIC.
    thanks
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Coming up with 3.099999 instead of 3.1 is due to a rounding error. You may need to write some extra code to evaluate math results and round the decimal results up befor converting to ASCII.
     
  3. h.d

    Thread Starter Active Member

    Oct 22, 2007
    150
    0
    no am write like that
    a=3.1
    floattostr(a,a1)
    lcd_out(1,1,a1)

    so no need for rounding
    and the problem that i need to display only one digit after comma not 5 digits.
     
  4. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Truncate the variable before displaying it. Might be easiest to evaluate the string to delete all trailing 0's.
     
  5. h.d

    Thread Starter Active Member

    Oct 22, 2007
    150
    0
    how??can you give an example....plz
     
Loading...