On Jan 31, 2013, at 10:40 AM, Oliver Brodwolf wrote: >>> >>> $cost:=50 >>> $rate:=18.15 >>> $fee:= $cost*$rate/100 >>> $fee_rounded:=Round($fee;2) >
Remember, you are dealing with floating point numbers and they are not exact and you will get different results with different implementations. If you are dealing in money in FP alone, you will not be exact all the time, no matter how hard you try. Why you are getting two different results may be a problem, but I put the above, converted to Ruby and got: 1.9.3-p327 :026 > cost=50 => 50 1.9.3-p327 :027 > rate=18.15 => 18.15 1.9.3-p327 :028 > fee= cost*rate/100 => 9.075 1.9.3-p327 :029 > rfee = fee.round(2) => 9.07 Thinking Ruby is also wrong, I added and intermediate variable feep 1.9.3-p327 :032 > cost=50 => 50 1.9.3-p327 :033 > rate=18.15 => 18.15 1.9.3-p327 :034 > feep = cost*rate => 907.4999999999999 1.9.3-p327 :035 > fee= cost*rate/100 => 9.075 1.9.3-p327 :036 > rfee = fee.round(2) => 9.07 907.4999999999999 rounded to 2 is 907.7 Just one of those weird FP internal rounding problems. Steve _______________________________________________ Active4D-dev mailing list [email protected] http://list.aparajitaworld.com/listinfo/active4d-dev Archives: http://active4d-nabble.aparajitaworld.com/
