Félix Paradis
Félix Paradis

Reputation: 6031

Is NumberInt signed in MongoDB?

The docs have that much to say about NumberInt

By default, the mongo shell treats all numbers as floating-point values. The mongo shell provides the NumberInt() constructor to explicitly specify 32-bit integers.

Which doesn't specify if they are signed or not, ie; if they can handle negative numbers.

I'm about to find out real soon, but for further reference I thought this question might help others find out quicker.

Upvotes: 0

Views: 589

Answers (1)

JohnnyHK
JohnnyHK

Reputation: 311865

Yes, NumberInt supports negative values. In the mongo shell:

> x = NumberInt(-10)
NumberInt(-10)

Upvotes: 1

Related Questions