Skip to content

Commit 524ed5e

Browse files
committed
extend fixed API
1 parent 69e7b6b commit 524ed5e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

source/mir/bignum/fixed.d

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Params:
1515
size = size in bits
1616
+/
1717
struct UInt(size_t size)
18-
if (size % (size_t.sizeof * 8) == 0 && size >= (size_t.sizeof * 8))
18+
if (size % (size_t.sizeof * 8) == 0 && size >= size_t.sizeof * 8)
1919
{
2020
import mir.bignum.fixed: UInt;
2121
/++
@@ -25,7 +25,7 @@ struct UInt(size_t size)
2525

2626
///
2727
this(size_t N)(auto ref const size_t[N] data)
28-
if (N <= this.data.length)
28+
if (N && N <= this.data.length)
2929
{
3030
version(LittleEndian)
3131
this.data[0 .. N] = data;
@@ -306,6 +306,15 @@ struct UInt(size_t size)
306306
return this;
307307
}
308308

309+
/++
310+
+/
311+
ref UInt!size opAssign(uint rhsSize)(UInt!rhsSize rhs) scope return
312+
@safe pure nothrow @nogc
313+
{
314+
this.data = UInt!size(rhs).data;
315+
return this;
316+
}
317+
309318
/++
310319
`bool overflow = a += b ` and `bool overflow = a -= b` operations.
311320
+/

0 commit comments

Comments
 (0)