MySQL Forums
Forum List  »  Connector/Node.js

Unexpected rounding value for updating Decimal field
Posted by: Kevin Lau
Date: March 22, 2021 01:36PM

create table (
`Total_Profit` DECIMAL(16,2) NULL);

Expected behavior
Mysql statement
update table set Total_Profit = '-56565656.56' where ID = '1';
Result will become -56565656.56 on the table.

Unexpected behavior in Nodejs connector

.set(Total_Profit, -56565656.56)

The result will become -56565700.00 on the Mysql database

Try updating smaller negative values -56556.56, resulting in -56556.60
Try updating smaller positive values 56556.56, resulting in 56556.60

Why the unexpected number rounding? Thanks.

Options: ReplyQuote

Written By
Unexpected rounding value for updating Decimal field
March 22, 2021 01:36PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.