当前位置:网站首页>Double to int precision loss
Double to int precision loss
2022-07-06 11:25:00 【%xiao Q】
Let's first look at the phenomenon of precision loss :
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double a = 74.46;
int b = a * 100;
cout << "a: " << a << " b: " << b <<endl;
return 0;
}
result :
solve : Use rounding method
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double a = 74.46;
int b = round(a * 100);
cout << "a: " << a << " b: " << b << endl;
return 0;
}
result :
边栏推荐
- QT creator support platform
- AcWing 1294. Cherry Blossom explanation
- QT creator design user interface
- [蓝桥杯2020初赛] 平面切分
- 安装numpy问题总结
- Mtcnn face detection
- Error connecting to MySQL database: 2059 - authentication plugin 'caching_ sha2_ The solution of 'password'
- MySQL主从复制、读写分离
- Ansible实战系列一 _ 入门
- [download app for free]ineukernel OCR image data recognition and acquisition principle and product application
猜你喜欢

打开浏览器的同时会在主页外同时打开芒果TV,抖音等网站

Did you forget to register or load this tag 报错解决方法

Rhcsa certification exam exercise (configured on the first host)

About string immutability

PHP - whether the setting error displays -php xxx When PHP executes, there is no code exception prompt

Face recognition_ recognition
![[download app for free]ineukernel OCR image data recognition and acquisition principle and product application](/img/1b/ed39a8b9181660809a081798eb8a24.jpg)
[download app for free]ineukernel OCR image data recognition and acquisition principle and product application

Unable to call numpy in pycharm, with an error modulenotfounderror: no module named 'numpy‘

How to configure flymcu (STM32 serial port download software) is shown in super detail

Data dictionary in C #
随机推荐
MySQL completely uninstalled (windows, MAC, Linux)
Machine learning -- census data analysis
數據庫高級學習筆記--SQL語句
Software testing and quality learning notes 3 -- white box testing
JDBC原理
Install mongdb tutorial and redis tutorial under Windows
MySQL master-slave replication, read-write separation
ImportError: libmysqlclient. so. 20: Cannot open shared object file: no such file or directory solution
Software I2C based on Hal Library
Learning question 1:127.0.0.1 refused our visit
记某公司面试算法题:查找一个有序数组某个数字出现的次数
Basic use of redis
Windows下安装MongDB教程、Redis教程
机器学习笔记-Week02-卷积神经网络
neo4j安装教程
L2-007 家庭房产 (25 分)
Aborted connection 1055898 to db:
Solution: log4j:warn please initialize the log4j system properly
AcWing 1294.樱花 题解
打开浏览器的同时会在主页外同时打开芒果TV,抖音等网站