解释double/int, 24/5= -4.8
时间: 2023-12-17 14:02:36 浏览: 28
`double/int`是除法运算,其中一个操作数是浮点数,另一个操作数是整数。在这种情况下,整数会被隐式转换成浮点数,然后进行浮点数除法。因此,`24/5`的结果是4.8(浮点数)。
但是,题目中的运算结果是`-4.8`,这是不正确的。如果要得到这个结果,可能是因为在计算时将24和5的位置颠倒了,即进行了`5/24`的除法,然后再将结果取相反数得到`-4.8`。但是,正确的24除以5的结果应该是4.8。
相关问题
为什么double/int, 24/5= -4.8 int/double, 24/5= 4.8结果不同
`double/int`的结果是浮点数,而`int/double`的结果也是浮点数。这是因为在浮点数与整数进行运算时,整数会被隐式转换成浮点数,然后进行浮点数除法。因此,无论是`double/int`还是`int/double`,结果都是浮点数,而不是整数。
在`double/int`中,24被除以5得到的是4.8,但由于5是整数,因此它会被隐式转换成5.0,整个表达式的结果是4.8/5.0,即0.96。由于0.96是浮点数,因此最终结果也是浮点数。如果将其取相反数,结果为-0.96。
在`int/double`中,24是整数,因此它会被隐式转换成24.0,整个表达式的结果是24.0/5,即4.8。由于4.8是浮点数,因此最终结果也是浮点数。
../dlib-19.22/dlib/all/../bigint/../vectorstream/vectorstream.h:31:34: error: invalid use of dependent type ‘dlib::vectorstream::vector_streambuf<CharType>::size_type’ size_type read_pos = 0; // buffer[read_pos] == next byte to read from buffer ^ In file included from ../dlib-19.22/dlib/all/../svm/../global_optimization.h:8:0, from ../dlib-19.22/dlib/all/../svm/auto.cpp:7, from ../dlib-19.22/dlib/all/source.cpp:87: ../dlib-19.22/dlib/all/../svm/../global_optimization/find_max_global.h:284:47: error: default argument missing for parameter 8 of ‘template<class funct, class ... Args> std::pair<long unsigned int, dlib::function_evaluation> dlib::impl::find_max_global(double, dlib::thread_pool&, std::vector<_RealType>&, std::vector<dlib::function_spec>, std::chrono::nanoseconds, dlib::max_function_calls, double, Args&& ...)’ std::pair<size_t,function_evaluation> find_max_global ( ^ ../dlib-19.22/dlib/all/../svm/../global_optimization/find_max_global.h:303:47: error: default argument missing for parameter 7 of ‘template<class funct, class ... Args> std::pair<long unsigned int, dlib::function_evaluation> dlib::impl::find_max_global(double, dlib::thread_pool&, std::vector<_RealType>&, std::vector<dlib::function_spec>, std::chrono::nanoseconds, double, Args&& ...)’ std::pair<size_t,function_evaluation> find_max_global ( ^ make[3]: *** [../dlib-19.22/dlib/all/libRNA_concentrations_la-source.lo] Error 1 make[3]: Leaving directory `/storage/denghua/anaconda3/lib/python3.8/site-packages/ViennaRNA-2.5.0/src/ViennaRNA' make[2]: *** [install-recursive] Error 1 make[2]: Leaving directory `/storage/denghua/anaconda3/lib/python3.8/site-packages/ViennaRNA-2.5.0/src/ViennaRNA' make[1]: *** [install-recursive] Error 1 make[1]: Leaving directory `/storage/denghua/anaconda3/lib/python3.8/site-packages/ViennaRNA-2.5.0/src' make: *** [install-recursive] Error 1
这是一个编译错误,可能是因为您正在使用的是不兼容的编译器或依赖库版本。建议您尝试以下解决方法:
1. 检查您的编译器版本是否符合ViennaRNA的要求。ViennaRNA要求使用GCC 4.8或更高版本的编译器。如果您的编译器版本过低,建议升级到符合要求的版本。
2. 确保您已经正确安装了ViennaRNA所需的所有依赖库,并且这些库的版本也符合要求。您可以查看ViennaRNA的官方文档以获取详细的依赖库要求。
3. 尝试在不同的操作系统或环境中编译ViennaRNA,看看问题是否仍然存在。如果问题仅在特定环境中出现,那么可能是该环境中的某些设置或依赖库版本不兼容。
4. 如果以上方法都无法解决问题,您可以尝试联系ViennaRNA的开发团队或社区,看看是否有其他用户遇到了类似的问题,并且是否有解决方案可用。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)