lundi 30 décembre 2019

The argument of the nan() function

Sometimes there is a need to get NaN value (for example, to return it from a function as an error value). С++11 provides the double nan(const char* tagp); function to get NaN see doc. This function gets C-string argument tagp which:

can be used by library implementations to distinguish different NaN values in a implementation-specific manner. If this is an empty string (""), the function returns a generic NaN value

I want to understand this function more deeply. Could someone explain in more detail

  1. What tagp values can be used besides empty string ""? Where can I find a list of possible values?
  2. What happens if the passed tagp argument is not supported by the compiler?
  3. Is it safe to use this implementation-specific function in cross-platform code?

Aucun commentaire:

Enregistrer un commentaire