| 537 | } |
| 538 | |
| 539 | bool HalfsDiffer(const half expected, const half actual, const int tolerance) |
| 540 | { |
| 541 | // TODO: Make this faster |
| 542 | |
| 543 | // (These are ints rather than shorts to allow subtraction below.) |
| 544 | const int aimBits = HalfForCompare(expected); |
| 545 | const int valBits = HalfForCompare(actual); |
| 546 | |
| 547 | if (expected.isNan()) |
| 548 | { |
| 549 | return !actual.isNan(); |
| 550 | } |
| 551 | else if (actual.isNan()) |
| 552 | { |
| 553 | return !expected.isNan(); |
| 554 | } |
| 555 | else if (expected.isInfinity()) |
| 556 | { |
| 557 | return aimBits != valBits; |
| 558 | } |
| 559 | else if (actual.isInfinity()) |
| 560 | { |
| 561 | return aimBits != valBits; |
| 562 | } |
| 563 | else |
| 564 | { |
| 565 | if (abs(valBits - aimBits) > tolerance) |
| 566 | { |
| 567 | return true; |
| 568 | } |
| 569 | } |
| 570 | return false; |
| 571 | } |
| 572 | |
| 573 | } // namespace OCIO_NAMESPACE |
| 574 | |