Skip to content

Commit

Permalink
Implement the initializers of 'FixedWidthInteger' for 'Int8'
Browse files Browse the repository at this point in the history
  • Loading branch information
kyouko-taiga committed Oct 4, 2023
1 parent 1d3d9f2 commit 8f42857
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Library/Hylo/Core/Numbers/Integers/Int8.hylo
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ public type Int8 {

memberwise init

/// Creates an instance with value `0`.
public init() {
&self.value = Builtin.zeroinitializer_i8()
}

/// Creates an instance with the same memory representation as `other`.
public init(bit_pattern other: UInt8) {
&self.value = other.value
Expand Down Expand Up @@ -121,3 +116,16 @@ public conformance Int8: SignedNumeric {
}

}

public extension Int8 {

public init() {
&self.value = Builtin.zeroinitializer_i8()
}

public init<T: BinaryInteger>(truncating_or_extending source: T) {
let w = source.words()
&self.value = Builtin.trunc_word_i8(w[w.start_index()].value)
}

}

0 comments on commit 8f42857

Please sign in to comment.