当前位置:网站首页>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.
边栏推荐
- second uncle
- Nmap 操作手册 - 完整版
- 情人节浪漫3D照片墙【附源码】
- Modify Postman installation path
- MYSQL Keyword Explain Analysis
- "Youth Pie 2": The new boyfriend stepped on two boats, and the relationship between Lin Miaomiao and Qian Sanyi warmed up
- How is the tree structure of the device tree reflected?
- test
- 初出茅庐的小李第113篇博客项目笔记之机智云智能浇花器实战(2)-基础Demo实现
- Basic usage concepts of vim
猜你喜欢
Ordinary users cannot access HGFS directory
[Search topic] After reading the inevitable BFS solution to the shortest path problem
leetcode6132. 使数组中所有元素都等于零(简单,周赛)
二舅
MYSQL logical architecture
项目越写越大,我是这样做拆分的
对无限debugger的一种处理方式
IDEA modifies the annotation font
Summary of mobile page optimization in seconds
Replacing the Raspberry Pi Kernel
随机推荐
Elastic Stack的介绍
This map drawing tool is amazing, I recommend it~~
IDEA修改注释字体
这个地图绘制工具太赞了,推荐~~
初出茅庐的小李第112篇博客项目笔记之机智云智能浇花器实战(1)-基础Demo实现
Software Testing Weekly (Issue 82): In fact, all those who are entangled in making choices already have the answer in their hearts, and consultation is just to get the choice that they prefer.
Inheritance Considerations
MYSQL two-phase commit
[Getting Started Tutorial] Rollup Module Packager Integration
《少年派2》:新男友竟脚踩两只船,林妙妙与钱三一感情回温
更换树莓派内核
Which interpolation is better for opencv to zoom in and out??
【搜索专题】看完必会的BFS解决最短路问题攻略
Flutter “Hello world“ 程代码
Flutter "Hello world" program code
剑指offer专项突击版第16天
IDEA无法识别module(module右下角没有蓝色小方块)
MySQL modifies SQL statements to optimize performance
对无限debugger的一种处理方式
ARM 交叉编译