We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ea548ef commit dc6b920Copy full SHA for dc6b920
bson-kotlinx/src/main/kotlin/org/bson/codecs/kotlinx/BsonEncoder.kt
@@ -218,9 +218,12 @@ internal class DefaultBsonEncoder(
218
else -> {
219
val decimal = BigDecimal(content)
220
when {
221
- decimal.stripTrailingZeros().scale() > 0 &&
222
- DOUBLE_MIN_VALUE <= decimal && decimal <= DOUBLE_MAX_VALUE ->
223
- encodeDouble(element.double)
+ decimal.stripTrailingZeros().scale() > 0 ->
+ if (DOUBLE_MIN_VALUE <= decimal && decimal <= DOUBLE_MAX_VALUE) {
+ encodeDouble(element.double)
224
+ } else {
225
+ writer.writeDecimal128(Decimal128(decimal))
226
+ }
227
INT_MIN_VALUE <= decimal && decimal <= INT_MAX_VALUE ->
228
encodeInt(element.int)
229
LONG_MIN_VALUE <= decimal && decimal <= LONG_MAX_VALUE ->
0 commit comments