Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Util/Math functions Demo
Function:
Required plugins for this example: MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/Math functions Demo
This example is the version from Sun, 17th Mar 2012.
Project "Math functions Demo.rbp"
FileTypes
Filetype text
End FileTypes
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() TestIntOps() MsgBox "The bitwise integer functions seem to be working fine." quit End EventHandler
End Class
Module TestModule
Sub TestIntOps() // This routine tests the Integer methods Dim i, j, k as Integer i = BitValMBS(5) // = 32 assert(i = 32, "BitVal") i = BitInclMBS(6, 0) assert(i = 7, "BitIncl #1") i = BitInclMBS(i, 2) assert(i = 7, "BitIncl #2") i = BitExclMBS(6, 0) assert(i = 6, "BitExcl #1") i = BitExclMBS(6, 1) assert(i = 4, "BitExcl #2") assert(BitIsSetMBS(1, 0), "BitIsSet #1") assert(not BitIsSetMBS(1, 1), "BitIsSet #2") i = ArithmeticShiftMBS(2, 1) assert(i = 4, "ArithmeticShift #1") i = ArithmeticShiftMBS(1, 31) assert(i = BitValMBS(31), "ArithmeticShift #2") i = ArithmeticShiftMBS(4, -1) assert(i = 2, "ArithmeticShift #3") i = ArithmeticShiftMBS(4, -3) assert(i = 0, "ArithmeticShift #4") i = ArithmeticShiftMBS(-4, -1) assert(i = -2, "ArithmeticShift #5") i = LogicalShiftMBS(2, 1) assert(i = 4, "LogicalShift #1") i = LogicalShiftMBS(1, 31) assert(i = BitValMBS(31), "LogicalShift #2") i = LogicalShiftMBS(4, -1) assert(i = 2, "LogicalShift #3") i = LogicalShiftMBS(4, -3) assert(i = 0, "LogicalShift #4") i = LogicalShiftMBS(BitValMBS(31), -1) assert(i = BitValMBS(30), "LogicalShift #5") i = BitwiseNotMBS(-2) assert(i = 1, "BitwiseNot") i = BitwiseRotateMBS(&H0110, 1, 0, 16) assert(i = &H0220, "BitwiseRotate #1") i = BitwiseRotateMBS(&H0220, -1, 0, 32) assert(i = &H0110, "BitwiseRotate #2") i = BitwiseRotateMBS(&HF0100, -1, 0, 32) assert(i = &H78080, "BitwiseRotate #3") i = BitwiseRotateMBS(&HF0100, -1, 0, 16) assert(i = &HF0080, "BitwiseRotate #4") i = BitwiseRotateMBS(&HF0100, 1, 0, 17) assert(i = &HE0201, "BitwiseRotate #5") i = BitwiseRotateMBS(&HE0201, -1, 1, 16) assert(i = &HE0101, "BitwiseRotate #6") i = BitwiseRotateMBS(&HE0103, 1, 1, 16) assert(i = &HE0205, "BitwiseRotate #7") End Sub
Sub assert(assertion as Boolean, msg as String) if not assertion then MsgBox "The following function does not work as expected:" + chr(13) + msg quit end End Sub
End Module
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Util Plugin.




Links
MBS FileMaker blog