当前位置:网站首页>[internationalization] decimal point and comma of application development
[internationalization] decimal point and comma of application development
2022-07-24 08:12:00 【sirria1】
Antecedents feed : Many countries express decimals , It is not a universal decimal point '.', Instead, use a comma ','. This seemingly harmless setting , Sometimes fatal bug.
The story : A domestic game developer is google play On the shelves of a game app, The main release area is Southeast Asia , Everything was fine for the first few days . Suddenly one day , A player released a game video with a major BUG, The attack of players has doubled several times , The attack speed has also accelerated a lot , The originally difficult level , He walked past , Planners who don't know the truth , Crying in the toilet .. And as a BUG The procedures of manufacturing experts , A steady expression like a dog , In fact, I'm already in a panic , The hand that knocks code is shaking . For several days , No clue ,BOSS After knowing , fly into a rage , Give an ultimatum ,24 The battle must be resolved within hours ( No BUG), or , All staff dog belt ..
This story is pure fiction , any similarity , It's a coincidence , Of course, some plots still happen .
Intermediate screening ( Have you checked the unknown ..) Things are not on the table , Let's go straight to the conclusion . Cause this BUG The culprit of , It is the comma mentioned in the preceding paragraph that indicates the decimal point . Because some countries ( Like France , Germany , Brazil , Indonesia, etc ) Have this special hobby , Lead to players in this area , By default, the mobile phone environment is set according to this area . so what , Games generally have configuration data , For example, some battle elements are set , Skill Bonus , Kung Fu or something , When the configuration , Decimals are used , Then read it into the program , It is directly converted to decimal in local format , such as 3.1415926 Was turned into 3,1415926 So . In some languages, the comma operator can also perform operations , Some languages , Or interface , When it comes to data like this , The application may collapse directly , This will lead to various unexpected operating results .
terms of settlement :
Found the reason , It can be traced after processing :
1. Since it is caused by decimals , Then don't use decimals , This is simple and rough , Actually, game operation , It is better to perform integer operation , Decimal operations , Different programming languages will differ , There may be inconsistencies in accuracy , There is also a performance problem , There are some CPU, Decimal operations are not as fast as integers .
2. In a word, it is caused by the program running in different environments , Some areas can operate normally , Such as China , Japan, etc , Then set the operating environment as an area that can run according to the decimal point , The more common one is to set it as an English speaking country , such as C# You can call the interface CultureInfo.CreateSpecificCulture(string) To set . Although such a setting can solve this problem , But there are also hidden dangers that cannot be localized .
3. Turn it directly in the place of use , This... , laborious .
边栏推荐
- [database] complete SQL statement
- 【游戏合集】手机都要被塞爆了,6款优质Pygame游戏合集降临~(附源码)
- Semantic slam: Probabilistic Data Association for semantic slam
- Jetson AgX Orin source change
- P1305新二叉树题解
- CNN-VINS
- 【线性代数】深入理解矩阵乘法、对称矩阵、正定矩阵
- *Yolo5 learning * data experiment based on yolo5 face combined with attention model se
- nacos报错: ERROR Nacos failed to start, please see D:\nacos\logs\nacos.log for more details.
- Vidar-Team战队专访:AS WE DO, AS YOU KNOW.
猜你喜欢

QT | string generation QR code function

Android kotlin uses a coroutine instead of a callback function (suspendcoroutine usage)

As skillfully uses idea annotation to improve collaboration / development efficiency
![[Beijiao] image processing: basic concepts, image enhancement, morphological processing, image segmentation](/img/b3/76d2bcdf4b9769fb6308b7dac9ceb5.jpg)
[Beijiao] image processing: basic concepts, image enhancement, morphological processing, image segmentation
![[redis] how much do you know about bloom filter and cuckoo filter?](/img/f0/8bcbe82bd6d412e68d85450f5894e3.png)
[redis] how much do you know about bloom filter and cuckoo filter?

【MATLAB】(三)MATLAB在高等数学中的应用

MySQL 啥时候用表锁,啥时候用行锁?

Assembly | screen display numbers

学习笔记总结篇(一)

Avoid pitfalls and stay away from PUA in the workplace. You need to know the common routines and scripts of PUA!
随机推荐
What is the NFT concept.. Fully understand NFT market, technology and cases
Vidar-Team战队专访:AS WE DO, AS YOU KNOW.
加密熊市:有人大举扩张 有人裁员收缩
Intelligent robots and intelligent systems (Professor Zheng Zheng of Dalian University of Technology) -- 2. Mobile Robot Perception
Recognition and storage of Graphs
P1739 expression bracket matching problem solution
1005. Maximized array sum after K negations
Learning dynamic Siamese network for visual object tracking full text translation
EZDML逆向工程导入数据库分析实操教程
Autojs article proficient in detailed explanation of autojs script tutorial
生成模型与判别模型
图新地球:如何导入修改了高程基准(椭球)的CAD文件
Image feature SIFT (scale invariant feature transform)
避坑,职场远离PUA,PUA常见的套路与话术你得了解一下!
FPGA integrated project - image edge detection system
Decision tree - ID3, C4.5, cart
A knight's journey
The code is tired. Stop and enjoy the top color matching~
MySQL -- subquery scalar subquery
Introduction to webmethods