I have the two following algorithms that work as intended with real values (etc the variables "c", "s", "a" etc as well as the answar having normal values such as "0.1", "1", "1.5", "2", "2.5"...)
$$\frac{\sqrt{c^2 + 2sa + s^2T^2 + 2scT }- c}{s}-T$$
$$= E -\frac{1}{2}sT^2 + sTb \frac{1}{2}sb^2-cT + cb$$
In my project, I have to implement these two algorithms into a programming language which have no decimal support. The programming language do however still have precision support. In this language, a complete or "full" value is 10^18. That means for example that the real value "2" is 2*10^18 in the programming language, and that the real value "0.2" is 0.2*10^18 in the programming language.
This means that the values above, as well as the algorithm return value, needs to be up-scaled by 10^18. The problem with this, is that the algorithm breaks (returns wrong answer value) once this is done, hence needs to be somewhat reworked.
My team-members already managed to scale the first algorithm by scaling up the variables (c, s, a, T by *1e18) and using this formula; $$\frac{\sqrt{c^2 + 2sa + (s/1e18)^2T^2 + 2(s/1e18)cT }- c}{s/1e18}-T$$
But we're unable to rework to scale up the second algorithm for it to work properly. Could anyone give a hand? Any help is highly appreciated.
For this kind of implementation problem, it's usually simpler if you introduce a different notation for the "up-scaled" representation values. Let $\hat c=c\times 10^{18}$, $\hat s=s\times 10^{18}$, same with $\hat a$, $\hat b$, $\hat T$ and $\hat E$.
Then let $N=E -\frac{1}{2}sT^2 + sTb \frac{1}{2}sb^2-cT + cb$ and $\hat N=N\times 10^{18}$. You just need to re-express the expression of $\hat N$ with respect to your other variables.