-3
我試圖將一些銀行代碼爲JavaScript,但遇到顛簸,因爲我不知道是什麼一些斯威夫特這些運營商的做,所以到這是類似於JavaScript表單我無法將它轉換。下面是代碼:斯威夫特運營商解釋
private var portMasks = [UInt8](count: 3, repeatedValue: 0)
var newMask = UInt8(newState.rawValue * Int(powf(2, Float(pinIndex))))
portMasks[Int(port)] &= ~(1 << pinIndex) //prep the saved mask by zeroing this pin's corresponding bit
newMask |= portMasks[Int(port)] //merge with saved port state
portMasks[Int(port)] = newMask
data1 = newMask<<1; data1 >>= 1 //remove MSB
data2 = newMask >> 7 //use data1's MSB as data2's LSB
凡pinIndex
,port
已經被定義,都UInt8
。
我不是在尋找的實際轉換 - 我可以做我自己。只需從數學/程序化的角度尋找這些行中每一行的解釋即可。
所有Swift運算符都詳細記載在參考中:https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AdvancedOperators.html#//apple_ref/doc/uid/TP40014097-CH27 -ID28。 –
感謝您的鏈接!它有一些操作符,但缺少'>> ='和'| =' –
在至少瀏覽文檔之前,您沒有發佈有關Swift的問題,是嗎? :) –