当前位置:网站首页>[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 .
边栏推荐
- Qt|字符串生成二维码功能
- Wechat applet subscription message development process
- Learn - use do... While loop according to the formula e=1+1/1+ 1/2!+ 1/3!+…+ 1/n! Calculate the value of E (accuracy is 1e-6)
- About the big hole of wechat applet promise
- Digital twin demonstration project -- Talking about simple pendulum (4) IOT exploration
- nacos报错: ERROR Nacos failed to start, please see D:\nacos\logs\nacos.log for more details.
- *Project recurrence * project implementation of thesis based on contextbasedemotionrecognitionusingematicdataset
- Detailed explanation of VAO
- Detailed explanation of wechat applet page configuration and sitemap configuration parameters
- Stack / heap / queue question brushing (Part 2)
猜你喜欢

QT | string generation QR code function

rbm 对比散度

我在微软的这六个月

MySQL --- 子查询 - 标量子查询

Database | simple hospital patient appointment system based on opengauss
![[matlab] (IV) application of MATLAB in linear algebra](/img/c8/97fddb4105008990173247b1b4a155.png)
[matlab] (IV) application of MATLAB in linear algebra

13.Unity2D 横版 可上下左右移动的双向平台(双向行走+可移动+单独判定)+随机平台生成

Kubernetes:(一)基本概念

FPGA综合项目——图像边缘检测系统

Generative model and discriminant model
随机推荐
EZDML reverse engineering import database analysis practical operation tutorial
Digital twin demonstration project -- Talking about simple pendulum (2) vision exploration and application scenarios
图的认识与存储
[MySQL] installation tutorial and master-slave configuration
Decision tree - ID3, C4.5, cart
CNN-VINS
*Project recurrence * project implementation of thesis based on contextbasedemotionrecognitionusingematicdataset
Hegong sky team vision training Day2 - traditional vision, opencv basic operation
【线性代数】深入理解矩阵乘法、对称矩阵、正定矩阵
学习-用do…while循环按公式e=1+1/1!+1/2!+1/3!+…+1/n!计算 e 的值(精度为 1e-6)
Use of animation expert motionlayout layout
jmeter中JSON提取器使用
Intelligent robots and intelligent systems (Professor Zhengzheng of Dalian University of Technology) -- 4. Autonomous robots
Continuous learning, lifelong learning, episodic memory, memory module paper summary -- gradient episodic memory promotes continuous learning
[target detection] IOU (intersection and combination ratio)
abstract class
A Knight‘s Journey题解
Figure New Earth: how to import CAD files with modified elevation datum (ellipsoid)
Uva572 oil deposits problem solution
RBM contrast divergence