Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions src/int.cr
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,7 @@ struct Int8
# Has no effect on 8-bit integers.
#
# ```
# 0x1234_u16.byte_swap # => 0x3412
# 0x5678ABCD_u32.byte_swap # => 0xCDAB7856
# 0x12_i8.byte_swap # => 0x12
# ```
def byte_swap : self
self
Expand Down Expand Up @@ -1012,8 +1011,7 @@ struct Int16
# Has no effect on 8-bit integers.
#
# ```
# 0x1234_u16.byte_swap # => 0x3412
# 0x5678ABCD_u32.byte_swap # => 0xCDAB7856
# 0x1234_i16.byte_swap # => 0x3412
# ```
def byte_swap : self
Intrinsics.bswap16(self).to_i16!
Expand Down Expand Up @@ -1113,8 +1111,7 @@ struct Int32
# Has no effect on 8-bit integers.
#
# ```
# 0x1234_u16.byte_swap # => 0x3412
# 0x5678ABCD_u32.byte_swap # => 0xCDAB7856
# 0x12345678_i32.byte_swap # => 0x78563412
# ```
def byte_swap : self
Intrinsics.bswap32(self).to_i32!
Expand Down Expand Up @@ -1214,8 +1211,8 @@ struct Int64
# Has no effect on 8-bit integers.
#
# ```
# 0x1234_u16.byte_swap # => 0x3412
# 0x5678ABCD_u32.byte_swap # => 0xCDAB7856
# 0x12345678_i64.byte_swap # => 0x7856341200000000
# 0x123456789ABCDEF0_i64.byte_swap # => -0xf21436587a9cbee
# ```
def byte_swap : self
Intrinsics.bswap64(self).to_i64!
Expand Down Expand Up @@ -1317,8 +1314,7 @@ struct Int128
# Has no effect on 8-bit integers.
#
# ```
# 0x1234_u16.byte_swap # => 0x3412
# 0x5678ABCD_u32.byte_swap # => 0xCDAB7856
# 0x123456789_i128.byte_swap # => -0x7698badcff0000000000000000000000
# ```
def byte_swap : self
Intrinsics.bswap128(self).to_i128!
Expand Down Expand Up @@ -1422,8 +1418,7 @@ struct UInt8
# Has no effect on 8-bit integers.
#
# ```
# 0x1234_u16.byte_swap # => 0x3412
# 0x5678ABCD_u32.byte_swap # => 0xCDAB7856
# 0x12_u8.byte_swap # => 0x12
# ```
def byte_swap : self
self
Expand Down Expand Up @@ -1528,7 +1523,6 @@ struct UInt16
#
# ```
# 0x1234_u16.byte_swap # => 0x3412
# 0x5678ABCD_u32.byte_swap # => 0xCDAB7856
# ```
def byte_swap : self
Intrinsics.bswap16(self)
Expand Down Expand Up @@ -1632,8 +1626,7 @@ struct UInt32
# Has no effect on 8-bit integers.
#
# ```
# 0x1234_u16.byte_swap # => 0x3412
# 0x5678ABCD_u32.byte_swap # => 0xCDAB7856
# 0x12345678_u32.byte_swap # => 0x78563412
# ```
def byte_swap : self
Intrinsics.bswap32(self)
Expand Down Expand Up @@ -1737,8 +1730,7 @@ struct UInt64
# Has no effect on 8-bit integers.
#
# ```
# 0x1234_u16.byte_swap # => 0x3412
# 0x5678ABCD_u32.byte_swap # => 0xCDAB7856
# 0x123456789ABCDEF0_u64.byte_swap # => 0xF0DEBC9A78563412
# ```
def byte_swap : self
Intrinsics.bswap64(self)
Expand Down Expand Up @@ -1844,8 +1836,7 @@ struct UInt128
# Has no effect on 8-bit integers.
#
# ```
# 0x1234_u16.byte_swap # => 0x3412
# 0x5678ABCD_u32.byte_swap # => 0xCDAB7856
# 0x123456789ABCDEF013579BDF2468ACE0_u128.byte_swap # => 0xE0AC6824DF9B5713F0DEBC9A78563412
# ```
def byte_swap : self
Intrinsics.bswap128(self)
Expand Down