Take a look at line 203.  I use PDataType.DECIMAL.toObject() to create a BigDecimal with proper normalization applied to be used for actual comparison.  I do that to ensure the same truncation and rounding is applied to BigDecimal so that equality check works right.