Originally posted by: Calvin Sun Hainan
CRF data:
#SECURITY;Security_ID;Security_Description;Unit_Price_USD
SECURITY;"ISIN:EUR";"EUR";1.37340000
I used Double.parseDouble() to parse in the above Unit_Price_USD and then store it as a double value in java. In Java if I print the value out with ceil or floor it is OK. Then I use the java function provided by IBM IloOplDataHandler.addNumItem(Unit_Price_USD) to read the above value 1.3734 into OPL. It seems that the problem happens here when it converts the double value to float. In OPL, I have the following tuple:
tuple TSecurity {key string securityId;string securityDescription;float unitPriceUsd;};
When I try to do floor(unitPriceUsd * 10000) within OPL script, it gives me 13733.
If I do a writeln (Math.ceil(s.unitPriceUsd * 10000) - s.unitPriceUsd * 10000); in OPL script. It gives me the following strange value.
1.818989403545857e-012
It looks to me OPL script is using 32-bit precision here.
#DecisionOptimization#OPLusingCPLEXOptimizer