Skip to content

Commit a97d92d

Browse files
committed
Float80 performance
1 parent c3ae04c commit a97d92d

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

stdlib/public/core/FloatingPointToString.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ fileprivate func _backend_256bit(
12811281
let powerOfTenExponent = intervalContainingPowerOf10_Binary128(p: -base10Exponent,
12821282
lower: &powerOfTenRoundedDown,
12831283
upper: &powerOfTenRoundedUp)
1284-
let extraBits = binaryExponent + powerOfTenExponent
1284+
let extraBits = binaryExponent &+ powerOfTenExponent
12851285

12861286
// Step 5: Scale the interval (with rounding)
12871287
let integerBits = 14
@@ -1292,30 +1292,30 @@ fileprivate func _backend_256bit(
12921292
// Narrow the interval (odd significand)
12931293
u = powerOfTenRoundedDown
12941294
u.multiplyRoundingDown(by: upperMidpointExact)
1295-
u.shiftRightRoundingDown(by: integerBits - extraBits)
1295+
u.shiftRightRoundingDown(by: integerBits &- extraBits)
12961296

12971297
l = powerOfTenRoundedUp
12981298
l.multiplyRoundingUp(by: lowerMidpointExact)
1299-
l.shiftRightRoundingUp(by: integerBits - extraBits)
1299+
l.shiftRightRoundingUp(by: integerBits &- extraBits)
13001300
} else {
13011301
// Widen the interval (even significand)
13021302
u = powerOfTenRoundedUp
13031303
u.multiplyRoundingUp(by: upperMidpointExact)
1304-
u.shiftRightRoundingUp(by: integerBits - extraBits)
1304+
u.shiftRightRoundingUp(by: integerBits &- extraBits)
13051305

13061306
l = powerOfTenRoundedDown
13071307
l.multiplyRoundingDown(by: lowerMidpointExact)
1308-
l.shiftRightRoundingDown(by: integerBits - extraBits)
1308+
l.shiftRightRoundingDown(by: integerBits &- extraBits)
13091309
}
13101310

13111311
// Step 6: Align first digit, adjust exponent
13121312
while u.high._high < (UInt64(1) << high64FractionBits) {
1313-
base10Exponent -= 1
1313+
base10Exponent &-= 1
13141314
l.multiply(by: UInt32(10))
13151315
u.multiply(by: UInt32(10))
13161316
}
13171317
var t = u
1318-
var delta = u - l
1318+
var delta = u &- l
13191319

13201320
// Step 7: Generate digits
13211321

@@ -1355,7 +1355,7 @@ fileprivate func _backend_256bit(
13551355
toUncheckedByteOffset: nextDigit,
13561356
as: UInt16.self)
13571357
unsafe buffer.storeBytes(of: asciiDigitTable[Int(bitPattern:d34)],
1358-
toUncheckedByteOffset: nextDigit + 2,
1358+
toUncheckedByteOffset: nextDigit &+ 2,
13591359
as: UInt16.self)
13601360
nextDigit &+= 4
13611361
t = t0
@@ -1370,8 +1370,8 @@ fileprivate func _backend_256bit(
13701370
delta.multiply(by: UInt32(10))
13711371
t.multiply(by: UInt32(10))
13721372
let digit = UInt8(truncatingIfNeeded: t.extractIntegerPart(integerBits))
1373-
buffer.storeBytes(of: 0x30 + digit,
1374-
toByteOffset: nextDigit,
1373+
buffer.storeBytes(of: 0x30 &+ digit,
1374+
toUncheckedByteOffset: nextDigit,
13751375
as: UInt8.self)
13761376
nextDigit &+= 1
13771377
}
@@ -1383,17 +1383,17 @@ fileprivate func _backend_256bit(
13831383
// 64 bits here.
13841384
let deltaHigh64 = delta.high._high
13851385
let tHigh64 = t.high._high
1386-
if deltaHigh64 >= tHigh64 + (UInt64(1) << high64FractionBits) {
1386+
if deltaHigh64 >= tHigh64 &+ (UInt64(1) << high64FractionBits) {
13871387
let skew: UInt64
13881388
if isBoundary {
1389-
skew = deltaHigh64 - deltaHigh64 / 3 - tHigh64
1389+
skew = deltaHigh64 &- deltaHigh64 / 3 &- tHigh64
13901390
} else {
1391-
skew = deltaHigh64 / 2 - tHigh64
1391+
skew = deltaHigh64 / 2 &- tHigh64
13921392
}
13931393
let one = UInt64(1) << high64FractionBits
13941394
let fractionMask = one - 1
13951395
let oneHalf = one >> 1
1396-
var lastDigit = unsafe buffer.unsafeLoad(fromUncheckedByteOffset: nextDigit - 1,
1396+
var lastDigit = unsafe buffer.unsafeLoad(fromUncheckedByteOffset: nextDigit &- 1,
13971397
as: UInt8.self)
13981398
if (skew & fractionMask) == oneHalf {
13991399
let adjust = skew >> high64FractionBits
@@ -1404,7 +1404,7 @@ fileprivate func _backend_256bit(
14041404
lastDigit &-= UInt8(truncatingIfNeeded: adjust)
14051405
}
14061406
buffer.storeBytes(of: lastDigit,
1407-
toByteOffset: nextDigit - 1,
1407+
toByteOffset: nextDigit &- 1,
14081408
as: UInt8.self)
14091409
}
14101410

@@ -1897,7 +1897,7 @@ fileprivate struct UInt256 {
18971897
return UInt(truncatingIfNeeded: integral)
18981898
}
18991899

1900-
static func - (lhs: UInt256, rhs: UInt256) -> UInt256 {
1900+
static func &- (lhs: UInt256, rhs: UInt256) -> UInt256 {
19011901
var t = UInt128(lhs.low._low) &+ UInt128(~rhs.low._low) &+ 1
19021902
let newlowlow = t._low
19031903
t = UInt128(t._high) &+ UInt128(lhs.low._high) &+ UInt128(~rhs.low._high)

0 commit comments

Comments
 (0)