mardi 8 février 2022

wrong addition of float type

Today I'm facing a really weird issue. I'm working at a simple project to display some data in a table with billing information provided by a REST-API. Because of the missing backend I backed up on a random generated array. That's working pretty perfect and everything just looks fine. BUT... one small thing seems like witchcraft, I simply want to sum up every billing to display the total amount on top of the table, but Typescript seems to have a really really weird way of handling float/int/string type conversion, I think. Here is a small Pic of my console log, it displays the row object and the sum.

 enter image description here

I want to sum up every value and for gods sake I don't know how Typescript is adding up 3876.61 plus 8.03 to 3884.6400000000003, but... how can I get rid of that? Is rounding the only possible solution?




Aucun commentaire:

Enregistrer un commentaire