Functions to work with signed integer variables (OshonSoft Basic).

Status
Not open for further replies.

DogFlu66

Member
These are a group of functions for working with signed integers. If you have a lot of memory it is better to work with long type variables. However, functions are included to work with the other types of variables to use less memory if necessary.
I also leave the result of the simulation of the program.

Code:
'*********************************************
'Functions to work with signed integers.
'By COS, 02/2023, Basic PSI compiler18 v4.37
'*********************************************
Include "_FuncionesEnterosConSigno.bas"
AllDigital
Hseropen 4800  'Initialize serial port
main:
    'Declare variables
    Dim _byte As Byte
    Dim _word As Word
    Dim _long As Long
    Dim _string As String
    'Assigns value to signed variables
    _byte = _sigset("-", 10, _asbyte)
    _word = _sigset("-", 1000, _asword)
    _long = _sigset("-", 100000, _aslong)
    'Send the signed integer variable to the serial port
    Hserout #_byte, " -> ", _sigtostring(_byte, _asbyte), CrLf
    Hserout #_word, " -> ", _sigtostring(_word, _asword), CrLf
    Hserout #_long, " -> ", _sigtostring(_long, _aslong), CrLf
    
    Hserout CrLf  'Next line

    'Division
    Hserout _sigtostring(_word, _asword), " / ", _sigtostring(_byte, _asbyte), " = "
    Hserout _sigtostring(_sigdiv(_word, _asword, _byte, _asbyte), _asword), CrLf
    
    Hserout CrLf  'Next line
    
    'Addition
    Hserout _sigtostring(_byte, _asbyte), " + ", _sigtostring(_word, _asword), " = "
    Hserout _sigtostring(_sigadd(_byte, _asbyte, _word, _asword), _aslong), CrLf

    Hserout CrLf  'Next line
    
    'Subtraction
    Hserout _sigtostring(_long, _aslong), " - ", _sigtostring(_byte, _asbyte), " = "
    Hserout _sigtostring(_sigsub(_long, _aslong, _byte, _asbyte), _aslong), CrLf

    Hserout CrLf  'Next line
    
    'Multiplication
    Hserout _sigtostring(_byte, _asbyte), " * ", _sigtostring(_long, _aslong), " = "
    Hserout _sigtostring(_sigmul(_byte, _asbyte, _long, _aslong), _aslong), CrLf
End

 

Attachments

  • _FuncionesEnterosConSigno.bas
    18.9 KB · Views: 162
You seem fairly knowledgeable about Oshonsoft. Can you tell me does Oshonsoft follow BODMAS.
What will x be in this case?
x=6-3*2

Thanks,

Mike.
 
Complies with standard arithmetic priorities.

Example:
Dim x As Single
Dim y As Single
Dim m As Single
Dim k As Single

x = 6 - 3 * 2
y = 6 - (3 * 2)
m = 6 - 3 * 3
k = 6 - (3 * 3)
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…