Simple subtraction


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Simple subtraction

    Ok thanks -- I'll look at it closer -- at least I know it should work with a minus 1.

    I use Micro code studio by the way. Is there another IDE that is straightforward like it is but has a few more features? For example, you can't even comment out a block of code, just individual lines.

    Also, I have never really had any experience with simulators. My Picbasic interest sort of peaked 20 years ago (although I still think it's fantastic) and back then simulation was a bad word.

    Be nice if they came up with something that could scroll through your code and detect operational errors. ?

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Simple subtraction

    Here comes a dumb question --

    var1 = word
    var2 = byte

    var1 = 2
    var2 = 3

    Can't you compare a word to a byte?

    If var1 <= var2 then
    do this

    It's in my head that a word is a number with the capability of larger numbers but also higher resolution for smaller numbers?
    (More decimal places?) So a 2 as a word variable is the same as a byte.

    Wrong? Do I need to use var.highbyte instead ? (hobbyist -- so I forget this stuff).

  3. #3
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Simple subtraction

    You can use a word somewhat like a float, but essentially, I believe you can compare those two types.
    Even if they didn’t directly compare, you could compare the byte to the lower word byte, and if the upper word byte is zero,
    the first compare with he lower byte is valid. otherwise if the upper word byte is not zero, the word is higher.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Simple subtraction

    In PBP all variable types stores integer values only so only the size of the number they can hold changes. The resolution is always the same.
    I see no, and don't know of any, issues with comparing a BYTE to WORD or the other way around but again remember that BYTES and WORDS are always unsigned integers so a variable containing 253 will be smaller than a BYTE (or WORD) variable containin the result of 100-101.

    /Henrik.

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: Simple subtraction

    Quote Originally Posted by Michael View Post
    Ok thanks -- I'll look at it closer -- at least I know it should work with a minus 1.

    I use Micro code studio by the way. Is there another IDE that is straightforward like it is but has a few more features? For example, you can't even comment out a block of code, just individual lines.
    Hightlite the block of code, then click comment - all lines will then be commented out - same in reverse to uncomment

Similar Threads

  1. Replies: 4
    Last Post: - 2nd November 2012, 09:47
  2. This should be simple?
    By jderson in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th September 2008, 21:20
  3. Addition and subtraction
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 25th January 2008, 14:24
  4. This is probably quite simple
    By Russ Kincaid in forum mel PIC BASIC
    Replies: 11
    Last Post: - 9th August 2006, 14:30
  5. Simple If.. Then help:
    By Tear in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th June 2005, 20: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