当前位置:网站首页>Character encoding and floating point calculation precision loss problem
Character encoding and floating point calculation precision loss problem
2022-08-01 03:32:00 【Zhou Zhou hehe】
1. Character encoding
Characters are encoded in the computer memory using the unicode character set, that is, characters occupy two bytes.
unicode includes Chinese, Korean and other characters. The reason why it replaces the ascll code set is that its character set only includes uppercase and lowercase English characters, numbers and other characters, excluding Chinese, Korean and other characters. unicode is an internationally unified character set.
Characters are stored and transmitted in UTF-8 encoding in many cases in file and network transmission, which can save space and transmission efficiency.
Unicode and utf-8 are automatically converted in file input and output and network transmission.
The default encoding of the window operating system is gbk encoding. For example, to run java files, you need to use the javac -encoding utf-8 command to compile, otherwise there will be garbled characters when running. The java files are encoded in utf-8, so the compilation command needs to use utf-8 for parsing, otherwise there will be an error
Note: The file stored in what encoding has to be parsed with that encoding. The above is a good example.
2. Loss of precision
In java and python, the conversion of floating-point decimal to binary may cause the situation that binary cannot be accurately represented, and the operation result will be inaccurate., such as println(0.1+0.2), the result is 0.3000000004.
In other words, if binary cannot be accurately represented, may have inaccurate operation results.
边栏推荐
- Solve the problem that Excel opens very slowly after installing MySQL
- Game Security 03: A Simple Explanation of Buffer Overflow Attacks
- HCIP(15)
- The bigger and bigger the project is, I split it like this
- 785. Quick Sort
- MYSQL-Batch insert data
- leetcode6132. 使数组中所有元素都等于零(简单,周赛)
- opencv 缩小放大用哪种插值更好??
- pdb drug comprehensive database
- You need to know the TCP wave four times
猜你喜欢

By CSDN, torn

How to get started with YOLO?How to implement your own training set?

软件测试面试(三)

被 CSDN,伤透了心

软件测试周刊(第82期):其实所有纠结做选择的人心里早就有了答案,咨询只是想得到内心所倾向的选择。

Solve the problem that when IDEA creates a new file by default, right-click, new, there is no XML file

second uncle

IDEA修改注释字体

移动端页面秒开优化总结

Summary of MVCC
随机推荐
Raspberry pie arm version of GCC installed configuration and environment variables
[Search topic] After reading the inevitable BFS solution to the shortest path problem
Browser download shortcut to desktop (PWA)
Nmap 操作手册 - 完整版
Euler system (euleros): upgrade Mysql
移动端页面秒开优化总结
Basic use of vim - command mode
leetcode6132. 使数组中所有元素都等于零(简单,周赛)
IDEA无法识别module(module右下角没有蓝色小方块)
Ordinary users cannot access HGFS directory
MySQL modifies SQL statements to optimize performance
Compiled on unbutu with wiringPi library and run on Raspberry Pi
【 Make YOLO Great Again 】 YOLOv1 v7 full range with large parsing (Neck)
一个service层需要调用另两个service层获取数据,并组装成最后的数据,数据都是list,缓存如何设计?
Soft Exam Senior System Architect Series: Basic Knowledge of System Development
leetcode6132. Make all elements in an array equal to zero (simple, weekly)
By CSDN, torn
普通用户无法访问hgfs目录
[SemiDrive source code analysis] series article link summary (full)
The IDEA can't find or unable to load The main class or Module "*" must not contain The source root "*" The root already belongs to The Module "*"