division problem 500000 / 133


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: division problem 500000 / 133

    Here is a snipit form a program I use and it works great:
    '************************************************* *******************
    CALCF_C: 'CALCULATE DEG.F and DEG.C for LM 95231 TEMPERATURE SENSOR READING
    '************************************************* *******************
    CALCF:
    SCRATCH = TEMPREAD * 1000
    TEMPF = DIV32 17777
    TEMPF = TEMPF * 10
    TEMPF = TEMPF + OFFSET
    CALCC:
    SCRATCH = TEMPREAD * 10
    TEMPC = DIV32 32
    RETURN

    Just make sure you don't have any interrupts going on when using DIV32.
    I also think your problem may be that you are using a variable after the DIV32 keyword. Try entering the constant value and see if that doesn't work.
    Last edited by Dave; - 24th May 2013 at 13:01.
    Dave Purola,
    N8NTA
    EN82fn

  2. #2
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: division problem 500000 / 133

    Dummy = 500*1000 ' Produce intermediate result of 500000
    Result = DIV32 133

    lcdout $FE,2, "Duty:", dec Result

    ... still getting 65535 as output

    Thats all I have in the program, no interrupt nothing else !

    then I initialized my parameters this way:
    a var word
    b var word
    a= 500
    b = 1000
    Dummy VAR word
    Result VAR WORD
    Divider con 145

    Dummy = a * b ' Produce intermediate result of 500000
    Result = DIV32 133

    and its now working.. Dummy doesnt like numbers
    Last edited by lerameur; - 25th May 2013 at 16:36.

Similar Threads

  1. // Division Operator
    By Dick Ivers in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th September 2011, 15:27
  2. What is wrong with this division?
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 5th March 2010, 18:34
  3. Division by 0
    By sirvo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 4th August 2007, 02:11
  4. Division with some decimal
    By Darklakebridge7 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 10th May 2007, 07:41
  5. division
    By eoasap in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th March 2006, 17:26

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