Skip to content

Commit 8e227a7

Browse files
committed
fix #353
1 parent c0838f2 commit 8e227a7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

source/mir/bignum/low_level_view.d

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ struct BigUIntView(W, WordEndian endian = TargetEndian)
11531153
bool opEquals(ulong rhs)
11541154
@safe pure nothrow @nogc const scope
11551155
{
1156-
foreach_reverse(d; lightConst.leastSignificantFirst)
1156+
foreach (d; lightConst.leastSignificantFirst)
11571157
{
11581158
static if (W.sizeof >= ulong.sizeof)
11591159
{
@@ -1171,6 +1171,20 @@ struct BigUIntView(W, WordEndian endian = TargetEndian)
11711171
return rhs == 0;
11721172
}
11731173

1174+
static if (W.sizeof == size_t.sizeof && endian == TargetEndian)
1175+
///
1176+
version(mir_bignum_test)
1177+
@safe pure
1178+
unittest
1179+
{
1180+
auto view2 = BigUIntView!(const(ubyte), WordEndian.big)([1, 0]);
1181+
assert(view2 == 256); // false
1182+
assert(cast(ulong)view2 == 256); // true
1183+
auto view = BigUIntView!(const(ubyte), WordEndian.big)([15, 255, 255]);
1184+
assert(view == 1048575); // false
1185+
assert(cast(ulong)view == 1048575); // true
1186+
}
1187+
11741188
static if (isMutable!W && W.sizeof >= 4)
11751189
/++
11761190
Params:
@@ -1208,7 +1222,6 @@ struct BigUIntView(W, WordEndian endian = TargetEndian)
12081222
return str.length - i;
12091223
}
12101224

1211-
///
12121225
static if (W.sizeof == size_t.sizeof && endian == TargetEndian)
12131226
///
12141227
version(mir_bignum_test)

0 commit comments

Comments
 (0)