<!-- llms-explorer concept facts · https://llms-explorer.com/tree/numeric-base-conversion-in-aggregation-expressions/ · pack 2026-10-29 · ~1352 tokens -->

# Numeric-base conversion in aggregation expressions

> Source-anchored research for Numeric-base conversion in aggregation expressions. Run status: COMPLETED.

Parent: [MongoDB Aggregation Pipeline](https://llms-explorer.com/tree/mongodb-aggregation-pipeline/) · 4 facets · 16 facts · page: https://llms-explorer.com/tree/numeric-base-conversion-in-aggregation-expressions/

## How it works

- Other conversion paths validate base but otherwise ignore it; supplying an unsupported radix does not become harmless merely because that conversion does not use base. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert.md)
- Conversion failures return onError when supplied; otherwise they abort the operation. Null or missing input uses onNull, defaulting to null. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert.md)
- The r8.3.0 implementation formats double and decimal inputs with explicit base through signed long long; integral values outside that range cause ConversionFailure. Hexadecimal output uses uppercase letters without a prefix. (low confidence) — [source](https://raw.githubusercontent.com/mongodb/mongo/r8.3.0/src/mongo/db/exec/expression/evaluate_math.cpp)

## Measurements and reference values

- For string-to-int, long, double, or decimal conversion with an explicit base, use valid digits without prefixes such as 0x. For example, "1010" at base 2 becomes 10; "A" at base 16 becomes 10. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert.md)
- String inputs must use valid digits and fit the target numeric range; a hexadecimal 0x prefix is rejected even with base 16. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert.md)

## Problems, failure modes and limitations

- For numeric-to-string conversion, base selects the output representation: 10 becomes "1010" at base 2 and "A" at base 16. Fractional numeric inputs cause conversion failure when base is specified, including base 10. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert.md)
- In MongoDB 8.3.0, any explicit base, including 10, parses strings through signed long long before casting to the target. Fractional strings and values beyond signed 64-bit range therefore fail even for double or decimal targets. (low confidence) — [source](https://raw.githubusercontent.com/mongodb/mongo/r8.3.0/src/mongo/db/exec/expression/evaluate_math.cpp)
- A Stack Overflow question reports that $toInt on the hexadecimal string "0x0" returns an illegal-hexadecimal-input error. This statement records the question author's reported behavior, not a test of a current server release. (low confidence) — [source](https://api.stackexchange.com/2.3/questions/67426169?site=stackoverflow&filter=withbody)

## Facts and statements

- MongoDB 8.3 adds an optional $convert base expression for string/numeric conversion. Supported radices are 2, 8, 10, and 16; null behaves like omission. (high confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert.md)
- In MongoDB 8.3.0, parseBase raises 3501300 for a non-integral argument and 3501301 for an unsupported radix. Validation occurs before the ConversionFailure handler, so onError does not catch these errors. Null input returns before parseBase. (low confidence) — [source](https://raw.githubusercontent.com/mongodb/mongo/r8.3.0/src/mongo/db/exec/expression/evaluate_math.cpp)
- NoSQLBooster 11.1 announces aggregation-helper support for MongoDB 8.3 and documents the new $convert base parameter and its four radices. This is first-party evidence of client-tool support, not independent server implementation verification. (low confidence) (verified as of 2026-09-30) — [source](https://www.nosqlbooster.com/blog/announcing-nosqlbooster-11-1/)
- base applies between strings and int, long, double, or decimal. Null or omitted base preserves default behavior; other conversions validate base but ignore it. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert.md)
- For example, input "1010", to "int", base 2 produces 10; input 10, to "string", base 16 produces "A". (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert.md)
- With explicit base, numeric-to-string conversion requires an integer value; 10.5 with base 2 fails or returns onError. MongoDB 8.3.0 also requires double and decimal values to fit signed long long. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert.md)
- NoSQLBooster’s September 30, 2026 release announcement describes 11.1 aggregation helper support for MongoDB 8.3 and explicitly lists the new $convert base parameter. (low confidence) — [source](https://www.nosqlbooster.com/blog/announcing-nosqlbooster-11-1/)
- An answer to the hexadecimal-conversion question defines a custom baseToDecimal expression that maps hexadecimal digits to positions in 0123456789ABCDEF, multiplies them by powers of the radix, and sums the terms. Its example converts "A3F" using base 16. (low confidence) — [source](https://api.stackexchange.com/2.3/questions/67426169/answers?site=stackoverflow&filter=withbody)
