some help with math


Closed Thread
Results 1 to 40 of 65

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: some help with math

    if Event1_OT_Hour >23 then Event1_OT_Hour = 23
    if Event1_OT_Hour <1 then Event1_OT_Hour = 0
    can be replaced by if Event1_OT_Hour is a byte

    Event1_OT_Hour=Event1_OT_Hour min 23
    saves heaps of typing if nothing else

  2. #2
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: some help with math

    has anyone a way to use 2 word value varables to accumulate an math value with out using longs or floating point

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,621


    Did you find this post helpful? Yes | No

    Default Re: some help with math

    Hi,
    Depends on your particular needs, here's one way to be used when the value to be added fits within a WORD:
    Code:
    HW VAR WORD
    LW VAR WORD
    Temp VAR WORD
    AddValue VAR WORD
    
    Temp = LW    ' Copy low word
    
    LW = LW + AddValue
    
    IF LW < Temp THEN   ' Low word wrapped around
      HW = HW + 1
    ENDIF
    If the value to be added is always one then:
    Code:
    HW VAR WORD
    LW VAR WORD
    
    LW = LW + 1
    IF LW = 0 THEN    'Low word wrapped around.
       HW = HW + 1
    ENDIF
    /Henrik.

  4. #4
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: some help with math

    Why you don't try N-Bit_MATH?
    http://www.picbasic.co.uk/forum/show...2694#post82694
    I use this code to store result as string in array
    Code:
    'Convert 64Bit to string
        @  MOVE?CP  10, _Tmp64bit   ; copy a CONSTANT to a Pvar
        FOR i=19 TO 0 STEP -1
            @  MATH_DIV  _Int64Bit, _Tmp64bit, _Res64bit    ; Res = A / B;  Remainder in REG_Z
            ValueStr[i]=REG_Z+48
            @  MOVE?PP  _Res64bit, _Int64Bit                ; copy a Pvar to a Pvar
        NEXT i

Similar Threads

  1. Help with A/D math!
    By dbodenheimer in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 19th March 2011, 00:51
  2. Math help please...
    By Ioannis in forum General
    Replies: 2
    Last Post: - 20th June 2008, 10:18
  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. Math help please!!!
    By jbirnsch in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 10th August 2007, 14:45
  5. math help
    By houa in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th January 2006, 16:58

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