我假設你想Xor
布爾值而不是整數本身的二進制表示。所以我的回答是基於這個假設。
如果您對True
使用1,對於False
使用2,那麼我建議您編寫一些轉換函數。
Private Function IntegerToBoolean(number As Integer) As Boolean
Return If(number = 1, True, False)
End Function
Private Function BooleanToInteger(bool As Boolean) As Integer
Return If(bool, 1, 2)
End Function
然後,用這些,它相當瑣碎,書寫你的其他功能:
Private Function IntegerXor(int1 As Integer, int2 As Integer) As Integer
Dim bool1 As Boolean = IntegerToBoolean(int1)
Dim bool2 As Boolean = IntegerToBoolean(int2)
Dim boolResult as Boolean = (bool1 Xor bool2)
Return BooleanToInteger(boolResult)
End Function
等
很明顯,你會做這爲每個號碼在資料表,以及你將爲And
和Or
創建附加功能。
我不明白你的真值表的邏輯。 –
此任務的哪一部分是您遇到的問題?例如,您是否難以生成整數,或執行布爾運算,或者輸出數字或結果表? –
我的表的邏輯是:如果x = 1,則返回true,如果x = 2,則返回false。我不知道如何製作列表並生成表格。布爾操作是xor,xnor而不是。 – Behnood