Skip to content

Commit

Permalink
chore: check lower bound
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Oct 18, 2023
1 parent 820b466 commit 1038e0d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/protons-runtime/src/utils/longbits.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// the largest BigInt we can safely downcast to a Number
const MAX_SAFE_NUMBER_INTEGER = BigInt(Number.MAX_SAFE_INTEGER)
const MIN_SAFE_NUMBER_INTEGER = BigInt(Number.MIN_SAFE_INTEGER)

/**
* Constructs new long bits.
Expand Down Expand Up @@ -117,7 +118,7 @@ export class LongBits {
return zero
}

if (value < MAX_SAFE_NUMBER_INTEGER) {
if (value < MAX_SAFE_NUMBER_INTEGER && value > MIN_SAFE_NUMBER_INTEGER) {
return this.fromNumber(Number(value))
}

Expand Down

0 comments on commit 1038e0d

Please sign in to comment.