I am trying to switch for example: input 54321.987, then 4 and 2 should switch, so output would be 52341.987. 54321.777 should become 52341.777. If it is 2345.777 it should
I just wrote this:
double swapDigits(double in) { return in + ((int)(in / 10) % 10 - (int)(in / 1000) % 10) * 990.0; }