MVC: Get Float from database, the decimal becomes different?

Viewed 80

In database, the data type of a field "Cost" is "float" There is a record with "Cost" 300.88 After getting into DTO, the Cost becomes 300.87999988

The type of Cost variable in DTO is "double" After passing DTO to view, it displays 300.88 correctly.

When saving the record, it is required to compare with database record. The program treat it as that the value is modified. (300.88 vs 300.87999988)

0 Answers
Related