I hope you can help me: I have an HTML-PHP software that makes the calculations with 5 decimals extrictly.
The point is, I need it to be 5 decimals always for the calculations; but I want to show only 2 decimals to the user without deleting the other 3 decimals (the 5 decimals have to be in the page always but only the first two decimals visible).Is there a way to do it? I’ll add a picture of what it looks like right now:
it would be nice to have some of the code to formulate a proper answer, but just to think outside the box here:
if I understood correctly the problem is that you want the user to see a 2 decimals version of a variable, but you still wanna keep the original 5 decimals version of that variable and perform calculation on that right?
How about using 2 variables, one for display, and the main one for calculation. They behave like mirroring each other, every time the main variable changes, you also change the display variable
Answered By – Rafael Santos
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0