Home > Back-end >  How to solve the problem of accurate amount
How to solve the problem of accurate amount

Time:09-29

As title, bosses share experience, how to use int and string respectively receive amount is also no loss of accuracy,

CodePudding user response:

Financial related digital operation must use BigDecimal class

CodePudding user response:

reference 1st floor sotondolphin response:
financial related digital operation must use BigDecimal class

Some people say that can receive int with online, but the unit for the points

CodePudding user response:

reference missing through the snow on the second floor response:
Quote: refer to 1st floor sotondolphin response:

Financial related digital operations must use BigDecimal class

Someone said that the online can use int receiving, but the unit is


Well, this is a textbook example of practical application won't do that

CodePudding user response:

reference sotondolphin reply: 3/f
Quote: refer to the second floor through the snow missing reply:

Quote: refer to 1st floor sotondolphin response:

Financial related digital operations must use BigDecimal class

Someone said that the online can use int receiving, but the unit is


Well, this is a textbook example of practical application won't do that


Thank you, can I trouble you to knock a piece of code, I want to see the process

CodePudding user response:

These are the two problems, one is the interface definition, one is the internal operation

Interface, the string is the most common, by using the interface between interconnected, one does not use the amount of less than, (the most simple, look at the exchange rate), after don't want to change the interface, use the
string value
Internal calculation, must use BigDecimal, single precision floating point number can only guarantee the accuracy of 6-7, the level of about 10 w, will appear between 0.01 can't continuous said,

BigDecimal using can look at:
https://juejin.im/post/5d81e96b51882507ba2269d8


CodePudding user response:

reference 5 floor tianfang reply:
these are the two problems, one is the interface definition, one is the internal operation

Interface, the string is the most common, by using the interface between interconnected, one does not use the amount of less than, (the most simple, look at the exchange rate), after don't want to change the interface, use the
string value
Internal calculation, must use BigDecimal, single precision floating point number can only guarantee the accuracy of 6-7, the level of about 10 w, will appear between 0.01 can't continuous said,

BigDecimal using can look at:
https://juejin.im/post/5d81e96b51882507ba2269d8


Bosses, interface definition can give details about yao, BigDecimal read the link let me up a lot of knowledge,

CodePudding user response:

Is in the interface, use the string field transfer amount
  • Related