Another math problem for PBP


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Just SCALE everything up so there are NO decimals to get in the way.... for a start, why are you dividing by 1000? Lose it and save some bytes...

    Your example...

    Addrsm = 40832
    Chipselect is = 2

    memperc=Addrsm/128 (answer will be 319 - memperc is a WORD of course)
    If Chipselect=2 then memperc=memperc+500

    You don't need to deal with calculating all of 100% of memory, just calculate the lower 50% block or the upper 50% block, and in the case of the upper block just add 50% to get the final answer. Then to display...

    LCDOut "Memory="
    If memperc>999 then LCDOut #memperc DIG 3
    If memperc>99 then LCDOut #memperc DIG 2
    LCDOut #memperc DIG 1,".",#memperc DIG 0,"%"

    Your display should show "Memory=81.9%" with leading zeros surpressed.

  2. #2
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125


    Did you find this post helpful? Yes | No

    Thumbs up

    THANK YOU!!! I was too close to the flame to see the answer... Excellent! The only tweak I had was adding a "#" in front of the display digits...

    Tom

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 problem with string result
    By Lotondo in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 15th November 2006, 10:06
  3. PicBasic Pro Math Problem??
    By Glen65 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th March 2006, 04:36
  4. Math Formula / Variable Problem! Help!
    By bwarp in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th February 2006, 07:59
  5. Math problem...with picbasic pro
    By pcaccia in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2005, 19:28

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