What's the easiest way to solve my HTTP rounding error issue?

I have a table of numbers. When I print them out they return things like 0.832, 0.03, 0.324, etc…

But when I run them through HTTP encode they come out like this.

I was wondering what’s the easiest solution to fix this? Currently I’m just thinking of multiplying the value by 1000 before export then dividing by 1000 after export.

2 Likes

Your current solution is the way that I would do it. And I think that’s the only way.

Multiply by *1000 and store them as integers, then divide them by 1000 upon loading if you want to preserve only 3 decimals. Right now you store and load them as floats so you get float values (with potentially a lot of decimal values). You won’t have that issue with integers since they are explicitly stored as integers.

2 Likes

That’s what I just suggested though. I appreciate the help but I’m trying to find alternatives.

1 Like

You could try converting the actual bytes of the float to chars. I’m not sure exactly what that algorithm would entail right now because I honestly should be sleeping, but that is an idea.

That, or you could try string.formatting all the numbers yourself and putting them in a mirrored object called something like “requestModel” which would just have strings in place of floats.