<i id='qYV50'><tr id='qYV50'><dt id='qYV50'><q id='qYV50'><span id='qYV50'><b id='qYV50'><form id='qYV50'><ins id='qYV50'></ins><ul id='qYV50'></ul><sub id='qYV50'></sub></form><legend id='qYV50'></legend><bdo id='qYV50'><pre id='qYV50'><center id='qYV50'></center></pre></bdo></b><th id='qYV50'></th></span></q></dt></tr></i><div id='qYV50'><tfoot id='qYV50'></tfoot><dl id='qYV50'><fieldset id='qYV50'></fieldset></dl></div>
  • <small id='qYV50'></small><noframes id='qYV50'>

      <bdo id='qYV50'></bdo><ul id='qYV50'></ul>
    <legend id='qYV50'><style id='qYV50'><dir id='qYV50'><q id='qYV50'></q></dir></style></legend>

    <tfoot id='qYV50'></tfoot>

      1. 1.#QNAN错误C++

        时间:2023-08-28
              <tbody id='kZEmL'></tbody>

            <tfoot id='kZEmL'></tfoot>

          1. <legend id='kZEmL'><style id='kZEmL'><dir id='kZEmL'><q id='kZEmL'></q></dir></style></legend>

            <small id='kZEmL'></small><noframes id='kZEmL'>

              • <bdo id='kZEmL'></bdo><ul id='kZEmL'></ul>

                  <i id='kZEmL'><tr id='kZEmL'><dt id='kZEmL'><q id='kZEmL'><span id='kZEmL'><b id='kZEmL'><form id='kZEmL'><ins id='kZEmL'></ins><ul id='kZEmL'></ul><sub id='kZEmL'></sub></form><legend id='kZEmL'></legend><bdo id='kZEmL'><pre id='kZEmL'><center id='kZEmL'></center></pre></bdo></b><th id='kZEmL'></th></span></q></dt></tr></i><div id='kZEmL'><tfoot id='kZEmL'></tfoot><dl id='kZEmL'><fieldset id='kZEmL'></fieldset></dl></div>
                  本文介绍了1.#QNAN错误C++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是编程新手,正在尝试编写新程序.在检查我的程序时,它返回错误代码 1.#QNAN.我曾尝试隔离变量并研究答案,但找不到任何解决方案.

                  I am new to programming and trying to write a new program. While checking through my program it is returning the error code 1.#QNAN. I have tried isolating the variable and researching for answers but cannot find any solutions.

                  我的代码:

                   // This is a program to decide what culvert should be properly used for a specific installation
                  // using given measurements and data
                  //
                  #include <cstdio>
                  #include <cstdlib>
                  #include <iostream>
                  #include <string>
                  
                  using namespace std;
                  // initializing functions 
                  double slope_function();
                  double cbasin();
                  // initializing classes: Subdivisions specs
                  
                  //intitializing global variables
                  double edge_road =0;
                  double up_stream  =0;
                  double down_stream =0;
                  double tbm =0.0;
                  
                  //double culv_length =0;
                  double slope = 0.0 ;
                  char street_name[1001];
                  int min_culv = 15;
                  double up_strm_culv =0;
                  double dwn_strm_culv =0;
                  
                  
                  int main (int nNumberofArgs, char* pszArgs[])
                  {
                      cout<< "This program will allow the surveyor to double check their calculations
                  ";
                      cout << "in deciding what size, type, and requirements are allowed for the
                  ";
                      cout << "installation of culverts in Terrebonne Parish.
                  
                  ";
                  
                  
                  
                  // begin input
                     cout << "what is the name of the street
                  where the culverts will be installed: ";
                     cin.getline (street_name,1000);
                     cout << endl;
                     cout << "What is the Benchmark: ";
                     cin >> tbm;
                     cout << endl;
                     cout << "What is the elevation of the edge of the road: ";
                     cin >> edge_road;
                     cout << endl;
                     cout << "What is the up-stream culvert size: ";
                     cin >> up_strm_culv;
                     cout << endl;
                     cout << "What is the culverts up-stream inverted elevation: ";
                     cin >> up_stream;
                     cout << endl;
                     cout << "What is the down-stream culvert size: ";
                     cin >> dwn_strm_culv;
                     cout << endl;
                     cout << "What is the culverts down-stream inverted elevation: ";
                     cin >> down_stream;
                     cout << endl;
                     cout << "What is the length of culvert requested: ";
                     cin >> culv_length;
                  
                  
                     cout << "Your slope is : "; 
                     cout << slope_function();
                     cout << endl;
                     cout << street_name;
                     cout << endl;
                     cout << cbasin();
                  
                  
                      cout << endl;
                    // wait until user is ready before terminating program
                    // to allow the user to see the program results 
                    system ("pause");
                    return 0;
                  }  
                  
                  // slope function 
                  double slope_function()
                  {
                      double riseoverrun = 0.0;
                      slope = (up_stream - down_stream)/ culv_length;
                      return slope;
                  }
                  
                  
                  // Catch Basin function
                  double cbasin ( )
                  {
                      double cb = 0;
                      cb = culv_length / 60;
                      cout << endl;
                      cout << "You need ";
                     cout << cb;
                     cout << " catch basins for this job.";
                     cout << endl;
                  }
                  

                  推荐答案

                  1#QNAN 是安静的 NAN"的字符串表示.NAN"是非数字",仅适用于浮点数和双精度数.

                  1#QNAN is a string representation for a "quiet NAN". A "NAN" is "not-a-number" and applies only to floats and doubles.

                  NAN 实际上对于表示空"值非常有用(而不是选择一些真正的数字并希望最好,您不需要该数字的自然含义).

                  NANs can be very useful actually for representing "null" values (rather than picking some genuine number and hoping for the best you don't need that number for its natural meaning).

                  如果运算无效"(例如取负数的对数),某些数学运算可以返回 NAN.

                  Some mathematical operations can return a NAN if the operation is "not valid" (eg taking the log of a negative number).

                  您可以使用

                  double d = std::numeric_limits<double>::quiet_NaN();
                  

                  对 NAN 的任何比较操作(==、<= 等)都会返回 false,甚至将其与自身的相等性进行比较,除了 != 总是返回 true(即使与自身进行比较).

                  Any comparison operation (==, <= etc) on a NAN returns false, even comparing its equality to itself, except for != which always returns true (even when comparing to itself).

                  (您代码中的实际错误似乎是一个返回 double 但没有 return 语句的函数).

                  (The actual bug in your code appears to be a function that returns double but has no return statement).

                  这篇关于1.#QNAN错误C++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:C++ 社区是否就何时应该使用异常达成普遍共识? 下一篇:在 C++ 中处理错误的正确方法是什么

                  相关文章

                  <small id='rqulq'></small><noframes id='rqulq'>

                  <legend id='rqulq'><style id='rqulq'><dir id='rqulq'><q id='rqulq'></q></dir></style></legend>
                  1. <i id='rqulq'><tr id='rqulq'><dt id='rqulq'><q id='rqulq'><span id='rqulq'><b id='rqulq'><form id='rqulq'><ins id='rqulq'></ins><ul id='rqulq'></ul><sub id='rqulq'></sub></form><legend id='rqulq'></legend><bdo id='rqulq'><pre id='rqulq'><center id='rqulq'></center></pre></bdo></b><th id='rqulq'></th></span></q></dt></tr></i><div id='rqulq'><tfoot id='rqulq'></tfoot><dl id='rqulq'><fieldset id='rqulq'></fieldset></dl></div>
                    <tfoot id='rqulq'></tfoot>

                        <bdo id='rqulq'></bdo><ul id='rqulq'></ul>