A huge decimal integer still needs only its final digit for parity. Preserve its exact digits before converting or calculating.
Size does not complicate the mathematics
A decimal integer ending in 9 is odd whether it contains two digits or two hundred. The last-digit proof depends on place value, not on the number’s size. Earlier decimal places contribute multiples of ten, which are even.
The complication usually comes from storing the number in software. If the stored value differs from the typed value, a perfect parity test can still answer the wrong question.
Watch the JavaScript precision boundary
JavaScript’s largest safe integer is 9,007,199,254,740,991, or 2^53 − 1, according to MDN’s MAX_SAFE_INTEGER reference. Above the safe range, Number cannot distinguish every consecutive integer.
For example, converting the decimal string "9007199254740993" to Number produces 9007199254740992. The original integer ends in 3 and is odd; the stored number ends in 2 and is even.
Some larger integers remain exactly representable. The problem is that the representation no longer preserves all neighboring integers, so magnitude alone does not tell you which individual conversions were accurate.
Preserve text until you choose an exact method
If your only task is parity, validate the complete decimal integer string and inspect its last digit. For a format allowing an optional sign and one or more ordinary decimal digits:
function oddDecimalInteger(text) {
if (!/^[+-]?[0-9]+$/.test(text)) {
throw new TypeError('Expected decimal integer digits');
}
return /[13579]$/.test(text);
}
This deliberately rejects commas, decimal points, exponents, and trailing text. Leading zeros do not change the result. The final-digit decision is tiny, but validating a long string still requires examining the input; calling the whole operation constant-time would overstate things.
Use BigInt when you also need arithmetic
Create BigInt directly from the original string:
const n = BigInt('9007199254740993');
const odd = n % 2n !== 0n;
Do not convert through Number first. BigInt(Number(text)) cannot restore digits already lost during the Number conversion. BigInt operands also use BigInt literals such as 2n and 0n.
When values arrive through JSON, an exact decimal string can preserve an integer that a JSON numeric value would lose during parsing. Keep that representation choice consistent through your application.
Use the calculator with the original decimal integer digits, without a decimal point or separators. If you are copying from a spreadsheet or export, verify that the source has not already rounded the value; an exact checker cannot recover missing information.