Skip to content

Commit 292b2d1

Browse files
committed
Only populate digits from float when the value is > 1
This prevents us producing incorrect Nat objects with leading zeroes, something we currently don't allow in the representation (we store zero implicitly as an empty array) Fixes #90
1 parent 9a3cd79 commit 292b2d1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arby/include/arby/Nat.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ namespace com::saxbophone::arby {
198198
throw std::domain_error("Nat cannot be Infinite or NaN");
199199
}
200200
Nat output;
201-
while (value > 0) {
201+
while (value > 1) { // value < 1 is zero which we store implicitly as empty array
202202
StorageType digit = (StorageType)std::fmod(value, Nat::BASE);
203203
output._digits.push_front(digit);
204204
value /= Nat::BASE;

0 commit comments

Comments
 (0)