当前位置:网站首页>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 when IDEA creates a new file by default, right-click, new, there is no XML file
- win10 fixed local IP
- 更换树莓派内核
- <JDBC> 批量插入 的四种实现方式:你真的get到了吗?
- device node结构体转换成platform_device结构体
- Flink deploys and submits jobs
- 二舅
- Flink 部署和提交job
- MYSQL two-phase commit
- [Search topic] After reading the inevitable BFS solution to the shortest path problem
猜你喜欢
win10 固定本机IP
让你的 Lottie 支持文字区域内自动换行
设备树的树形结构到底是怎样体现的?
Talking about hardware device computing storage and data interaction
How to download the Keil package
IDEA无法识别module(module右下角没有蓝色小方块)
[Message Notification] How about using the official account template message?
项目越写越大,我是这样做拆分的
Replacing the Raspberry Pi Kernel
Summary of JVM interview questions (continuously updated)
随机推荐
[uniCloud] Application and Improvement of Cloud Objects
Nmap manuals - the full version
[Data analysis] Based on matlab GUI student achievement management system [including Matlab source code 1981]
设备树的树形结构到底是怎样体现的?
Take you to experience a type programming practice
手写二叉查找树及测试
HCIP(14)
每周小结(*67):为什么不敢发表观点
带你体验一次类型编程实践
The 16th day of the special assault version of the sword offer
【消息通知】用公众号模板消息怎么样?
大佬们,MySQL cdc source在增量过程中回收 replication slave 和 r
MYSQL master-slave replication
HCIP(15)
Elastic Stack的介绍
Talking about hardware device computing storage and data interaction
初出茅庐的小李第112篇博客项目笔记之机智云智能浇花器实战(1)-基础Demo实现
指定set 'execution.savepoint.path'后,重启flinksql报这个错是啥
初出茅庐的小李第113篇博客项目笔记之机智云智能浇花器实战(2)-基础Demo实现
MYSQL query interception optimization analysis