Numerical question


Closed Thread
Results 1 to 3 of 3
  1. #1

    Default Numerical question

    Hello to all,
    What is the best numerical format to use while sending serial data? I am asking because I was using binary, but after reading and rereading some of my program it came to me that my program would not divide binary, assuming this of'course, even my calculator won't do it. I thought about using Hex but if I am using a variable that is a byte, 8 bits right?, and I have three variables total, and I want the first to equal the sum of the second and third then I want to divide by two. Using hex or decimal will it really come out the same?

    Ex:
    mouse VAR BYTE
    cat VAR BYTE
    dog VAR BYTE

    mouse =%00000001
    cat = %00000001
    dog =%00000000

    dog = (cat + mouse)
    IF cat = (dog / 2) then
    HIGH 1
    Else
    LOW 1
    ENDIF
    Last edited by tazntex; - 29th July 2008 at 21:08. Reason: typing error

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    Code:
    mouse =%00000001
    cat = %00000001
    dog =%00000000
    
    dog = (cat + mouse)
    IF cat = (dog / 2) then
    HIGH 1
    Else
    LOW 1
    ENDIF
    is equal to

    Code:
    mouse = 1
    cat = 1
    dog = 0
    
    dog = ( cat + mouse )
    if cat = (dog / 2) then
    HIGH 1
    ELSE
    LOW 1
    ENDIF
    is equal to

    Code:
    mouse = $1
    cat = $1
    dog = $0
    
    dog = ( cat + mouse )
    if cat = (dog / $2) then
    HIGH 1
    ELSE
    LOW 1
    ENDIF

  3. #3

    Default

    Thanks for the info, just wanted to make sure.

Similar Threads

  1. Crystals & Caps - Super noob question??
    By kevj in forum General
    Replies: 4
    Last Post: - 24th September 2007, 17:11
  2. Remote PIC input question
    By Adrian in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st September 2007, 15:44
  3. PIC16F684 Program question
    By Nicholas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2006, 14:30
  4. Question for a math guru
    By Christopher4187 in forum General
    Replies: 3
    Last Post: - 22nd November 2006, 09:45
  5. Please answer my first question
    By John_001 in forum Off Topic
    Replies: 1
    Last Post: - 15th September 2006, 06:49

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