How do I add a decimal point?


Results 1 to 5 of 5

Threaded View

  1. #4


    Did you find this post helpful? Yes | No

    Default

    You can have a problem with leading zeros in the part after the decimal point, not sure if it effects PBP but it certainly effects picaxe basic.

    Example

    I want to display 102 as decimal with the . between 1 and 0

    1.02

    If you use the method suggested I expect the display will actually show

    1.2 and not 1.02

    It probably works correctly as long there is a number other than 0 present.

    i.e.

    122 would work and display 1.22

    102 would not and would display 1.2 not 1.02.

    Anyone care to comment.

    Here is some picaxe code I use which can probably be adapted for this issue in PBP

    Code:
    VarC = Soc / 100			;Get first part of value (Before decimal point)
    VarA = Soc // 100			;Get second part of value (After decimal point)	
    
    serout Video,BaudT9600,(27,83,0,5,"Soc ",#VarC,".")	;Video Display 
    	
    if VarA < 10 then			;If Leading zero reqd in display due to Value <10 then
    serout Video,BaudT9600,("0",#VarA," % ")	;Video Display
    else
    serout Video,BaudT9600,(#VarA," % ")	;Video Display
    endif
    Last edited by retepsnikrep; - 14th December 2009 at 07:31.

Similar Threads

  1. MAX7219 Helping Hand Please
    By isaac in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 14th February 2014, 15:07
  2. Adding Decimal Point
    By markscotford in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 24th August 2009, 16:12
  3. Decimal point with serout?
    By Kman in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th July 2007, 14:33
  4. hex ascii help please
    By ffr58kk90 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 29th December 2006, 21:09
  5. 16bit variable and degrees conversion
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd May 2005, 17:27

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