i want to test some code to make sure it handles NAN, INF and -INF inputs properly.
i know there exists functions that return NAN, INF and -INF, but as a Double:
unit IEEE754;
...
function NAN: Double;
function PositiveInfinity: Double;
function NegativeInfinity: Double;
Except in my case i need to test when a Currency is one of these three edge-case values. Unfortunatly you cannot convert any of these to a Double:
Test(NAN);
procedure Test(const Value: Currency);
...
There's an EInvalidOp Invalid floating point operation exception when converting a Double NAN to a Currency.
Is it possible to assign a NAN to a Currency?
Perhaps, rather than it being possible to assign a NAN to a Currency, it is instead not possible - and i can just ignore this edge case.
Can i ignore this edge case?
Is it possible to "Set a Currency value to NAN, INF or -INF?"
{ David Heffernan says it's impossible for a currency to contain INF,-INF or NAN.
So there's no need to test for it.
http://stackoverflow.com/questions/7096966/set-a-currency-value-to-nan-inf-or-inf
//Handle NaN, where exponent is -32767
test(NAN, 'NAN');
//Handle +inf, where exponent is 32767 and Negative is true
test(PositiveInfinity, 'INF');
//Handle -inf, where expondent is 32767 and Negative is true
test(NegativeInfinity, '-INF');
}