You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// let compact = try decode(Compact<UInt64>.self, from: data).value
89
89
```
90
90
91
-
#### Int[128-1024] and UInt[128-1024]
92
-
93
-
`Int[128-1024]` and `UInt[128-1024]` types implemented with `DoubleWidth` Swift type from Apple. It works fine for 128-256 bits but slow for 512-1024 bits.
94
-
95
-
```Swift
96
-
importScaleCodec
97
-
98
-
let data =Data([
99
-
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
100
-
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
101
-
])
102
-
103
-
let encoded =tryencode(UInt128(UInt256(2)^128-1))
104
-
assert(encoded == data))
105
-
106
-
let compact =trydecode(UInt128.self, from: data)
107
-
assert(compact ==UInt128(UInt256(2)^128-1))
108
-
```
109
-
110
91
#### Data fixed encoding
111
92
112
93
`Data` type can be encoded with fixed encoding. In this mode data length will not be stored so length should be provided manually.
0 commit comments