NumericCompare compares two *apd.Decimal values handling NaN separately.
(ab, bb *apd.Decimal)
| 185 | |
| 186 | // NumericCompare compares two *apd.Decimal values handling NaN separately. |
| 187 | func NumericCompare(ab, bb *apd.Decimal) int { |
| 188 | if (ab.Form == apd.NaN && bb.Form == apd.NaN) || |
| 189 | (ab.Form == apd.Infinite && bb.Form == apd.Infinite && ab.Negative == bb.Negative) { |
| 190 | return 0 |
| 191 | } |
| 192 | if ab.Form == apd.NaN { |
| 193 | return 1 |
| 194 | } |
| 195 | if bb.Form == apd.NaN { |
| 196 | return -1 |
| 197 | } |
| 198 | return ab.Cmp(bb) |
| 199 | } |