Menu

Signed math

Help
2010-03-03
2013-05-30
  • Edward LaBudde

    Edward LaBudde - 2010-03-03

    Hi all just tried out the new release for the signed integer support.  It does not appear to be any different than the 2-11-09 version.  Using dim as integer works the same in both releases.  I tested the signed math with a first order lag and using the PWM to monitor the results, NO GO. It does not produce the correct calculations for signed math.  The serprint 1, command does not work.  It sends out a number of characters equal to the value of the data, 0 = 0 out 1= out, 2=2 out etc.  This was similar to the problem of the old release printing word variables

    Any help?  Thanks Ed.

     
  • Edward LaBudde

    Edward LaBudde - 2010-03-05

    Hi all. Upon further testing I have confirmed that the Integer routines appear to be correctly working.  I tested this with a first order lag which requires negative number processing.  In order to work all variables internal to the calculation must be dim as Integer.  Thanks Hugh!

    Printing out these values still does not work correctly.  If dim as word, the serprint command works fine, not for integer.  Word values opens an address for SERPRINTVAL And uses SERPRINT15 to print to the LCD. 

    Integer opens SysPRINTDATAHandler and uses SERPRINT13 to print values to the LCD display.  This command outputs a series of characters equal to the numeric value of the variable, and does not work correctly.  This is similar to the problem of using serprint on word variables a while back.

    Release 2-11-09 has the Integer routine, but it does not work correctly on the calcualtions.

    Any thoughts?  Best regards, Ed.

     
  • kent_twt4

    kent_twt4 - 2010-03-05

    Hi Ed,

    Good news!! and also a thanks to Hugh, well done.

    Must not have dimensioned all my variables as integers when trying previously, thanks for the tip.  Was able to get the add and subtract working but found similar condition on output.  I was using the alt soft uart routine and a terminal display.  Had to evaluate myvar.15 and if true then print("-") and print (!myvar) (and add one?, I forget), else print(myvar), for proper output.

     
  • Edward LaBudde

    Edward LaBudde - 2010-03-06

    Kent, thanks.
    Since the serprint works for words, I have come up with a work around until Hugh gets time to fix this.  Similar to yours.

    If temp is dim as integer and Display is dim as word, then this will work to display results on serial port:

    if Temp.15 = on then
    Display = 65536 - temp
    else
    Display = temp
    end if

    if Temp.15 = on then
                 serprint 1, "-"  
    serprint 1, Display   
    else
    serprint 1, display
    end if

    Best regards, Ed.

     
  • lsmod

    lsmod - 2012-06-07

    Has anything changed regarding signed integer?

    I would say that i can't use Cowbasic when signed integer and long integer are not supported. :-(
    Also single variables and floating point arithmetic is a must have.

    I am familiarised to use it from Bascom and i use it often!
    This should work in Cowbasic also.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.