Hello. I make the algorithm of the exchange, which determines the required amount and the coefficient of 2 players based on the amount and coefficient of 1 player. The algorithm is on both JS and PHP.
var mt = { //ΠΠΏΡΠ΅Π΄Π΅Π»ΡΠ΅Ρ ΠΊΠΎΡΡ. 2 ΠΈΠ³ΡΠΎΠΊΠ° findOtherRatio: function(ratioOtherPlayer){ return ratioOtherPlayer / (ratioOtherPlayer - 1) }, //ΠΠΏΡΠ΅Π΄Π΅Π»ΡΠ΅Ρ ΠΏΡΠΈΠ±ΡΠ»Ρ 1 ΠΈΠ³ΡΠΎΠΊΠ° - ΡΡΠΎ ΡΠ°ΠΊΠΆΠ΅ ΡΠ²Π»ΡΠ΅ΡΡΡ Π½ΡΠΆΠ½ΠΎΠΉ, ΡΡΠ°ΡΡΠΎΠ²ΠΎΠΉ ΡΡΠΌΠΌΠΎΠΉ 2 ΠΈΠ³ΡΠΎΠΊΠ° findProfit: function(start, ratio){ return start * ratio - start; }, //Π‘ΡΠΌΠΌΠ° Π²ΡΠ²ΠΎΠ΄Π° ΠΈΠ³ΡΠΎΠΊΠ° findOutcome: function(start, ratio){ return start * ratio; } }; Everything is considered almost true. But the problem is that in many cases the numbers look like the thousandths, millionths ... And as soon as I want to give a presentable look to the numbers, namely, a maximum of 2 digits after the decimal point, the numbers are no longer equal (1 playerβs withdrawal! = 2 playersβs ).
For example: imagine that 1 player put 736 rubles for 1.55
var cof2Player = mt.findOtherRatio(1.55).toFixed(2) var money2Player = mt.findProfit(736,1.55).toFixed(2) mt.findOutcome(money2Player, cof2Player).toFixed(2) // 1141.54 mt.findOutcome(736, 1.55).toFixed(2) // 1140.80 Is there any way around this? How do different exchanges solve this? After all, they do not show the coefficients "3.8571428571428563" to players.