Round down
PDI or other applications will round up numbers when limits digits by default. However, we need rounding down instead of rounding up. Both Javascript and Database scripts can do it. For example, if you like to round down to two digits, what you can do is: new_number = floor(old_number*100)/100 Remmeber: if you do the above method in PDI, you might need mask the new number with '#. We tested the script in Mysql. It runs OK. However, we do not recommend you use the method in Javascript. Because we found some inaccuracy happened in Javascript multiply. e.g. 2.28*100=227.99999999999997 If you are expert of Javascript and know how to solve the problem, you can try it in Javascript if you like. We suggest do it in sql. It is safer and quicker.
on 09/11/2009 at 09:53