当前位置:网站首页>Written examination notes
Written examination notes
2022-07-05 06:34:00 【Silent moon cold moon】
Catalog
Under what circumstances a === a - 1
How to avoid adjacent repetition when randomly selecting array elements ?
How to get integer and decimal parts of a number gracefully ?
How to correctly judge whether a string is a numeric value ?
Preface
Unfamiliar language , Continue to learn , Prepare knowledge points first .
Under what circumstances a === a - 1
1. ±Infinity,Infinity The value of adding and subtracting with any finite number is Infinity
2. A larger number , such as 1e45, To be exact , It's more than Number.MAX_SAFE_INTEGER Number of numbers , It exceeds the integer precision range
3.NaN no way .
How to avoid adjacent repetition when randomly selecting array elements ?
1. Remember the last selected element , To judge whether or not to repeat .
2. After selection , Temporarily delete the selected element , Select again and then add and delete the next element .
3. Before each choice n-1 term , After selection , Match the selected item with n Item exchange . Select before the first time n Elements .
4. Before each choice n-1 term , After selection , Match the selected item with n Item exchange , Discard the first selected element .
How to get integer and decimal parts of a number gracefully ?
Integer
1.parseInt(string, radix)``
This method is a method to convert a string to an integer , It has two parameters , The first parameter represents the string to be converted , If the parameter is not a string , Then convert it to a string . The second parameter is the cardinality, i.e. hexadecimal , The default is 10.
2.Math Method :Math.round It's round ,Math.ceil It's round up ,Math.floor It's rounding down . Positive and negative judgment number , That is floor; Negative namely ceil. Easy way : Math.trunc, There is no need to judge the positive and negative .
3. utilize Bit or “|” Operation to round ( The limited data length is 32).
4. Yes 1 Subtract after taking the mold .
Take decimals
1. Get an integer and subtract .
2. Yes 1 modulus .
How to correctly judge whether a string is a numeric value ?
be used isNumeric To judge the legitimacy of user input .
function isNumeric(obj) {
return !Number.isNaN(parseFloat(obj))
&& Number.isFinite(Number(obj));
}
边栏推荐
- Sum of three terms (construction)
- Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022
- [2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields
- 求组合数 AcWing 889. 满足条件的01序列
- Relevant information of National Natural Science Foundation of China
- Genesis builds a new generation of credit system
- Series of how MySQL works (VIII) 14 figures explain the atomicity of MySQL transactions and the principle of undo logging
- June 29, 2022 daily
- Nested method, calculation attribute is not applicable, use methods
- Operator priority, one catch, no doubt
猜你喜欢
将webApp或者H5页面打包成App
how to understand the “model independent.“
'mongoexport 'is not an internal or external command, nor is it a runnable program or batch file.
求组合数 AcWing 889. 满足条件的01序列
The “mode“ argument must be integer. Received an instance of Object
3. Oracle control file management
7.Oracle-表结构
Genesis builds a new generation of credit system
Record of problems in ollvm compilation
NVM Downloading npm version 6.7.0... Error
随机推荐
Suppose a bank's ATM machine, which allows users to deposit and withdraw money. Now there is 200 yuan in an account, and both user a and user B have the right to deposit and withdraw money from this a
C Primer Plus Chapter 15 (bit operation)
vsCode创建自己的代码模板
【高德地图POI踩坑】AMap.PlaceSearch无法使用
how to understand the “model independent.“
2022-5-the fourth week daily
Chapter 6 relational database theory
Genesis builds a new generation of credit system
Gauss Cancellation acwing 884. Solution d'un système d'équations Xor linéaires par élimination gaussienne
TCP's understanding of three handshakes and four waves
安装OpenCV--conda建立虚拟环境并在jupyter中添加此环境的kernel
Adg5412fbruz-rl7 applies dual power analog switch and multiplexer IC
Redis-01.初识Redis
Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022
Time is fast, please do more meaningful things
Operator priority, one catch, no doubt
H5 模块悬浮拖动效果
How to make water ripple effect? This wave of water ripple effect pulls full of retro feeling
博弈论 AcWing 893. 集合-Nim游戏
Financial risk control practice -- feature derivation based on time series