Home  |  About  | Last |  Submit  |  Contact

 Tweet

 Question 2's complement in VB ( Physics Help and Math Help - Physics Forums Programming )Updated: 2008-03-15 20:26:43 (3)
 2's complement in VB is there a function available that will perform 2's complement on a byte? or a way to convert a byte or char to binary so I can do the operation myself? thanks, ioll
 Answers: 2's complement in VB ( Physics Help and Math Help - Physics Forums Programming )
 2's complement in VB thank you very much again! ionlylooklazy
 2's complement in VB It should be pretty simple. All you need to do is perform a bitwise NOT and then add a 1. You would convert your byte or char to an Int, perform the bitwise Not, and then add a 1. In C# the ~ is the bitwise NOT, so you would do: Code: int b = 230; int bAfter2sC = ~b + 1 In VB.Net try: Code: Dim b As Integer Dim bAfter2sC As Integer bAfter2sC = Not(b) + 1 -Job-
 2's complement in VB It should be pretty simple. All you need to do is perform a bitwise NOT and then add a 1. You would convert your byte or char to an Int, perform the bitwise Not, and then add a 1. In C# the ~ is the bitwise NOT, so you would do: Code: int b = 230; int bAfter2sC = ~b + 1 In VB.Net try: Code: Dim b As Integer Dim bAfter2sC As Integer bAfter2sC = Not(b) + 1 -Job-
 - Source: 2's complement in VB Physics Help and Math Help - Physics Forums Programming- Previous Question: serial communication in VB Physics Help and Math Help - Physics Forums Programming- Next Question: Latex: odd pages = figures, even pages = text? Physics Help and Math Help - Physics Forums Programming