当前位置:网站首页>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 :
边栏推荐
- MySQL other hosts cannot connect to the local database
- Ansible practical series I_ introduction
- Database advanced learning notes -- SQL statement
- What does usart1 mean
- 引入了junit为什么还是用不了@Test注解
- Introduction to the easy copy module
- 01 project demand analysis (ordering system)
- neo4j安装教程
- Basic use of redis
- LeetCode #461 汉明距离
猜你喜欢

Basic use of redis

QT creator specify editor settings

MySQL主從複制、讀寫分離

When you open the browser, you will also open mango TV, Tiktok and other websites outside the home page

QT creator create button

UDS learning notes on fault codes (0x19 and 0x14 services)

02-项目实战之后台员工信息管理

自动机器学习框架介绍与使用(flaml、h2o)

QT creator runs the Valgrind tool on external applications
C语言读取BMP文件
随机推荐
neo4j安装教程
[蓝桥杯2020初赛] 平面切分
连接MySQL数据库出现错误:2059 - authentication plugin ‘caching_sha2_password‘的解决方法
PHP - whether the setting error displays -php xxx When PHP executes, there is no code exception prompt
Software I2C based on Hal Library
01项目需求分析 (点餐系统)
MySQL主從複制、讀寫分離
学习问题1:127.0.0.1拒绝了我们的访问
Neo4j installation tutorial
About string immutability
Windows下安装MongDB教程、Redis教程
One click extraction of tables in PDF
Database advanced learning notes -- SQL statement
Classes in C #
QT creator custom build process
Copie maître - esclave MySQL, séparation lecture - écriture
How to set up voice recognition on the computer with shortcut keys
ES6 Promise 对象
Use dapr to shorten software development cycle and improve production efficiency
人脸识别 face_recognition