I came across a weird behaviour when saving a double value on mongodb with mongoose v5.11.15
I have to double values: this amount: 0.6 item amount: 0.3
the sum shoud be 0.9
however on the Database the value is saved as 0.89999999999
This is my code:
try {
console.log('this amount: ', this.amount)
console.log('item amount: ', item.amount)
this.amount = this.amount + item.amount
await this.save()
} catch (e) {
console.log(e)
}
Has anyone come across this behaviour? is there a way to store the exact value?