当前位置:网站首页>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));
}
边栏推荐
- 求组合数 AcWing 887. 求组合数 III
- Bit of MySQL_ OR、BIT_ Count function
- 2.Oracle-数据文件的添加及管理
- Relevant information of National Natural Science Foundation of China
- Game theory acwing 891 Nim games
- Knapsack problem acwing 9 Group knapsack problem
- 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
- Huawei bracelet, how to add medicine reminder?
- Redis-02. Redis command
- La redirection de l'applet Wechat ne déclenche pas onload
猜你喜欢
LSA Type Explanation - detailed explanation of lsa-2 (type II LSA network LSA) and lsa-3 (type III LSA network Summary LSA)
栈 AcWing 3302. 表达式求值
[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields
[Gaode map POI stepping pit] amap Placesearch cannot be used
什么是套接字?Socket基本介绍
容斥原理 AcWing 890. 能被整除的数
Alibaba established the enterprise digital intelligence service company "Lingyang" to focus on enterprise digital growth
数据库Mysql全部
中国剩余定理 AcWing 204. 表达整数的奇怪方式
7. Oracle table structure
随机推荐
Ffmpeg build download (including old version)
[BMZCTF-pwn] ectf-2014 seddit
Operator priority, one catch, no doubt
Record the process of configuring nccl and horovod in these two days (original)
MPLS experiment
Inclusion exclusion principle acwing 890 Divisible number
Redis-02. Redis command
C Primer Plus Chapter 15 (bit operation)
2022-5-第四周日报
Find the combination number acwing 888 Find the combination number IV
Client use of Argo CD installation
AE tutorial - path growth animation
[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields
Series of how MySQL works (VIII) 14 figures explain the atomicity of MySQL transactions and the principle of undo logging
June 29, 2022 daily
栈 AcWing 3302. 表达式求值
H5内嵌App适配暗黑模式
RecyclerView的应用
2022 winter vacation training game 5
2048项目实现