cvectorstruct

What does #QNANO signify or mean in C?


#include<stdio.h>
#include<math.h>

int n;

struct vector
{
  int dir[100];
};
int dot(struct vector v1, struct vector v2)
{
  int dp,j;
  dp=0;
  for(j=0;j<n;j++)
  {
    dp = dp + (v1.dir[j]*v2.dir[j]);
  }
return dp;
}
float cosine(int vdot, float v1mod, float v2mod)
{
  float cos1, vdo = vdot;
  cos1 = (vdot/(v1mod*v2mod));
  return cos1;
}
  float modul(struct vector v1)
{
  int j;
  float v1mod;
  float deg = 0;
  for(j=0; j<n; j++)
   {
     deg = deg + ((v1.dir[j])*(v1.dir[j]));
   }
 v1mod = sqrt(deg);
}
int main()
  {
    int j;
    scanf("%d", &n);
    struct vector v1;
    struct vector v2;
    for(j=0;j<n;j++)
      {
         scanf("%d", &v1.dir[j]);
      }
    for(j=0;j<n;j++)
      {
         printf("%d/", v1.dir[j]);
      }
    printf("\n");

    for(j=0;j<n;j++)
      {
         scanf("%d", &v2.dir[j]);
      }
    for(j=0;j<n;j++)
      {
         printf("%d/", v2.dir[j]);
      }
         printf("\n");

    int vdot;

    float v1mod, v2mod, cos2;

    vdot = dot(v1,v2);
    printf("%d\n", vdot);

    v1mod = modul(v1);
    printf("%f\n", v1mod);

    v2mod = modul(v2);
    printf("%f\n", v2mod);

    cos2 = cosine(vdot, v1mod, v2mod);

    printf("cosine = %f\n", cos2);
  }

When we compile the code, the output for cosine is showing "1.#QNANO. I checked all the websites, but no where did I find the right reason for the occurrence of the error. Also can some one specify how many such more error types are there . **The bug in the code is intentional.


Solution

  • The Q probably means it's a quiet not-a-number. The O might mean overflow.

    What exact platform and compiler did you use?