File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -1248,7 +1248,7 @@ struct Bit : FixedWidthInteger, UnsignedInteger {
1248
1248
}
1249
1249
1250
1250
var trailingZeroBitCount : Int {
1251
- return value. trailingZeroBitCount
1251
+ return Int ( ~ value & 1 )
1252
1252
}
1253
1253
1254
1254
static var max : Bit {
@@ -1268,7 +1268,7 @@ struct Bit : FixedWidthInteger, UnsignedInteger {
1268
1268
}
1269
1269
1270
1270
var leadingZeroBitCount : Int {
1271
- return value. nonzeroBitCount - 7
1271
+ return Int ( ~ value & 1 )
1272
1272
}
1273
1273
1274
1274
var bigEndian : Bit {
@@ -1489,6 +1489,15 @@ BitTests.test("Basics") {
1489
1489
1490
1490
expectEqual ( x, x + y)
1491
1491
expectGT ( x, x &+ x)
1492
+
1493
+ expectEqual ( 1 , x. nonzeroBitCount)
1494
+ expectEqual ( 0 , y. nonzeroBitCount)
1495
+
1496
+ expectEqual ( 0 , x. leadingZeroBitCount)
1497
+ expectEqual ( 1 , y. leadingZeroBitCount)
1498
+
1499
+ expectEqual ( 0 , x. trailingZeroBitCount)
1500
+ expectEqual ( 1 , y. trailingZeroBitCount)
1492
1501
}
1493
1502
1494
1503
var BigIntTests = TestSuite ( " BigInt " )
You can’t perform that action at this time.
0 commit comments