Double (Double-Precision Float)

Last updated: 2026-10-09

Double (Double-Precision Float)

Double is MongoDB's default numeric type: a 64-bit IEEE 754 float, roughly ±1.8×10^308. Bare numbers in mongosh (like 3.14) are Doubles by default. Use it for measurements, percentages, and coordinates; choose Decimal128 for money that must be exact.

CategoryBSON Types
MongoDB Version1.0+
Example Languagemongosh (Shell)

📝 Syntax

{ price: 3.14 }  // bare literal is Double
NumberDouble(3.14)  // explicit
{ price: { $lt: 10.5 } }

Returns:Returns a Double BSON float

▶ Example

Run the commands below in your local mongosh (requires a running mongod):

// Double: comparison and aggregation
use shop
db.products.find({ price: { $gte: 9.99 } })
db.products.aggregate([{ $group: { _id: null, avg: { $avg: '$price' } } }])

Output:

// Products with price >= 9.99, plus the average price

📌 Notes

📚 Related Tutorials

❓ FAQ

QDouble or Decimal128?
ADouble for approximate math (measurements, coordinates); Decimal128 for exact decimal money.
QWhat type is 42 in mongosh?
ADouble. Use Int32(42) or Long(42) when you need an integer.
QHow many significant digits does a Double have?
AAbout 15-17 significant decimal digits; beyond that it rounds in binary.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏