I have operation like this:
const amount = 100;
const rate = 0.32123;
const a = amount * rate;
a // 32.123000000000005
const b = a / rate;
b // 100.00000000000001
I need numbers to be the same after convert. How can i achieve this? Both way convert is required. I have many currencies. Each currency have convert rate for internal currency (lets call it myCurr). I cannot convert immediately one currency into another (except internal) because i have convert ratings only for internal currency. So i need firstly convert currency A to internal currency (A * rate1) then i need to convert A to target currency by dividing it to rate2. But doing so, sometimes leads to lose precision. Is there any alternative for amount * rate1 / rate2?