not quite understanding the MATH function


Results 1 to 11 of 11

Threaded View

  1. #7
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    yes, variable>>1 is the same as variable/2. >> is a bnary shift. so if a=8 for example, thats 00001000 in binary. when u shift it all 1 place to the right (>>1), you get 00000100 which is 4 (i.e. you have halved the value).

    I notice you have some (1/2)'s in your modified program, but im afraid that wont work either. PBP will calculate that 1/2 (or 1>>1) as 0. 1 is represented in binary as 00000001 and if you shift that right 1 place you get 00000000.

    Remember that time[lmt] is an allways going to be an integer (whole number). Therefore there is no point in checking if it is equal to 1.5 since it will never be 1.5.
    Last edited by Kamikaze47; - 17th January 2006 at 06:09.

Similar Threads

  1. Resolution integer math assistance?
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th January 2010, 03:01
  2. Line Graph, math problem...
    By TerdRatchett in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th May 2009, 04:20
  3. PBPL Math...new math takes more cycles...Always?
    By skimask in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2008, 10:22
  4. Question for a math guru
    By Christopher4187 in forum General
    Replies: 3
    Last Post: - 22nd November 2006, 09:45
  5. Random function - How to limit it ??
    By martarse in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 30th November 2004, 14:05

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