Skip to content

Commit 0b16f2d

Browse files
author
Max Moiseev
committed
[integers] Added truncating initializer from FloatingPoint
1 parent 0eeb827 commit 0b16f2d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/Prototypes/Integers.swift.gyb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ public protocol Integer : ${IntegerBase} {
284284
/// returns `nil` otherwise.
285285
init?<T : FloatingPoint>(exactly source: T)
286286

287+
/// Truncates the `source` to the closest representable value of `Self`.
288+
init<T : FloatingPoint>(_ source: T)
289+
287290
/// Creates an instance of `Self` from the value of any other `Integer`,
288291
/// trapping if value of `source` cannot be represented by `Self`.
289292
init<T : Integer>(_ source: T)
@@ -310,7 +313,6 @@ public protocol Integer : ${IntegerBase} {
310313
/// If `self` is negative, returns the index of the least significant bit of
311314
/// our representation such that all more-significant bits are 1.
312315
/// Has the value -1 if `self` is 0.
313-
/// Has the value equal to `bitWidth - 1` for fixed width integers.
314316
var signBitIndex: Word { get }
315317

316318
% for x in binaryArithmetic['Integer']:
@@ -336,6 +338,10 @@ extension Integer {
336338
fatalError()
337339
}
338340

341+
public init<T : FloatingPoint>(_ source: T) {
342+
fatalError()
343+
}
344+
339345
public var countRepresentedWords: Word {
340346
return (self.bitWidth + ${word_bits} - 1) / ${word_bits}
341347
}

0 commit comments

Comments
 (0)