I write code in LINUX RHEL 64bit, and use C++98.
I have an array of floating point values, and I wanted to 'mark' some values to be 'invalid'. One possible solution is to use another bit-array to tell if the corresponding value is valid.
I was wondering if we can use any special double value. The link Why does IEEE 754 reserve so many NaN values? says that there are lot of NaN values. Can we use any value reserved for my problem?
- I only need one bit in the payload to indicate if a double value is 'valid' in terms of my definition. The input double value can contain NaN, but I assume it would not use any payload.
- the double values will be saved into a file in a binary mode (saving double values bit by bit).
- then the code also reads data from the file in a binary mode
- For each double value read from the file, we first check if it is valid by the bit set in payload before doing any other calculation.