You can also reverse the order first and calculate from the back.
In the reverse order, use this function strrev.
From the back, use the cycle.
Find the position of the decimal point and calculate the number of decimal places. Is it easy to solve this problem by traveling with strings?
Calculate the value before decimal point and the value after decimal point,