Math problem on 16F688


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2008
    Posts
    43

    Default Math problem on 16F688

    When I use this statement:
    hserout [dec (12 * 10000),$0D, $0A] the result is 54464.

    Why is the math not working?

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    The math is working great - you overflowed (went beyond 16 bits)

    12*10000 = 120000 = $1D4C0 (hex)
    keeping the lower 16 bits = $D4C0 = 54464

    clear as mud?
    Last edited by paul borgmeier; - 14th June 2008 at 18:46.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    Mar 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default Is there a solution

    Is there anyway to get around this?

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Where are you sending the data? If sending to a PC, send the 12 and send the 10000. Let the program on the PC handle it.

    Or, look at DIV32 in the manual.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    or switch to a 18F, and use LONG variable type
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. 16F688 problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th May 2009, 23:09
  2. Line Graph, math problem...
    By TerdRatchett in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th May 2009, 04:20
  3. PicBasic Pro Math Problem??
    By Glen65 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th March 2006, 04:36
  4. Math problem...with picbasic pro
    By pcaccia in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2005, 19:28
  5. Problem with 16F688 and Hserout
    By DWV in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 19th March 2005, 05:37

Members who have read this thread : 1

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