Skip to content

Commit 6d896c0

Browse files
Distance now behaves as expected
1 parent 2abd185 commit 6d896c0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

js_src/chord.js

+6
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@ m.max_outgoing = mesh.max_outgoing;
3333
m.distance = function distance(a, b, limit) {
3434
let raw = BigInt(a).minus(b);
3535
if (limit !== undefined) {
36+
if (raw.lesser(0)) {
37+
return raw.mod(limit).plus(limit).mod(limit);
38+
}
3639
return raw.mod(limit);
3740
}
3841
else {
42+
if (raw.lesser(0)) {
43+
return raw.mod(m.limit).plus(m.limit).mod(m.limit);
44+
}
3945
return raw.mod(m.limit);
4046
}
4147
};

0 commit comments

Comments
 (0)