I've written a program in C and Im using cJSON to encapsulate data and send up to Firebase.
I simply want the number to be a number so I can do some calculations on it in Firebase.
This is where it gets messy.
double 24.9
This gives back
24.899999999999999
So eg,
round((399 / 16.0) * 10.0) / 10.0 = 24.8999999
I only want one decimal place, I want 24.9, I need it to be represented as a number. Looks like I might just have to do a sprintf() and use a RAW in cJSON. Unless there's another way in C to keep my 24.9 as 24.9.
This question is not enquring about how floating point works. I am aware of issues. I have not however seen a suitable method to solve it.