result type Float can't be cast to the desired output type __int64
时间: 2023-09-22 09:11:00 浏览: 77
This error occurs when you try to cast a floating-point value (type float) to an integer value (type __int64), which is not possible without losing precision.
To fix this error, you need to either change the output type to a float or use a different type of integer that can handle the precision of the floating-point value. You can also round or truncate the floating-point value before casting it to an integer to avoid losing precision.
Here's an example of how to round a float value to an integer before casting it:
```
float my_float = 3.14159;
__int64 my_int = static_cast<__int64>(round(my_float));
```
This will round the float value to the nearest integer and then cast it to type __int64 without losing precision.
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)