What makes sense depends on what your application needs to achieve:
- do the internal operations need to discern unassigned values from values that are the result of processing?
- do you need to distinguish unassigned, infinite, underflow, zero, or NaN values? Do you need to properly represent these states in output too? (see
http://www.cplusplus.com/reference/cmath/fpclassify/[
^] for more info)
- can the internal processes even deal with unassigned numbers or do they always need a valid value? If so, is there a reasonable default value for unassigned numbers?
- Is there a need to reproduce exactly the same output as you are reading if nothing is changed?
- are there any range limitations that you can take advantage of for the purpose of defining magic numbers that represent certain states such as being unassigned?
The most general solution would be to maintain a separate flag for each value that indicates its current state. The advantage is that you can define an arbitrary number of states and use it for any specific type, without restrictions. The disadvantages are the added requirements for memory, processing, and code.
A second option would be to (ab)use any of the other possible states of a variable as an indicator. The disadvantage is the inability to discern whether a variable in that state was simply unassigned or arrived at that value through processing.
A third option would be to define a specific normal value that represents the unassigned state: this obviously only works, if you can make sure that value is not within the normal valid range of values for any variable of that type. It is therefore not that practical, in most cases. It is also somewhat tricky to exactly compare a floating point value to a given constant.