How to simulate NaN (not a number) - values for testing purposes

 

In some cases, it is necessary to simulate NaN (not a number) values for testing purposes (f.e. if you want to test, how your business logic is able to handle such values (they could come from PLCs in case of errors).

Here is a code-sample for generating a NaN-value (-1.#QNAN0) with a Control-Script:

main()

{

blob source;

int len, pos;

string s;

float value;

 

s = "7F,FF,FF,FF";

 

source = s;

 

len = 4;

pos = 0;

 

blobGetValue(source, pos, value, len, FALSE);

 

DebugN(isnan(value));

//this will result into a TRUE output

 

dpSet("System1:TestValue.", value);

//Is some other Script is connected to this DPE, it must be able to handle this value

 

}

Date added:
Last revised:
Hits:
14.240
Version:
ALL Versions
Rating:
Rating: 0.0. 0 vote(s). No rating done at all.
Your vote was '' (0 of 5) You are an anonymous user.
You may log on to do personalized votings
Click the rating bar to rate this item Please log on to do ratings
Tags:
Engineering, Special Functions / Features