Thursday, August 11, 2011

ColdFusion Val() with very small decimal number.

ColdFusion Val() is a very convenient function. Not only it can convert string, it can prevent SQL Injection attacks. Except, don't try to Val() a very tiny decimal point. It's going to cause havoc. Here is an example: Try a normal math function like "0.18 - 0.1800". It should be zero - right? ColdFusion returns 2.31296463464E-016 or 0.000000000000000231296463464 -- which is VERY small. Now, if you Val(0.000000000000000231296463464), you'll get 2.31296463464, and all your calculations are messed up now :)

No comments: