当前位置:网站首页>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));
}边栏推荐
- Filter the numbers and pick out even numbers from several numbers
- MySQL怎么运行的系列(八)14张图说明白MySQL事务原子性和undo日志原理
- LeetCode-61
- 如何正确在CSDN问答进行提问
- Getting started with typescript
- [2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian
- 【LeetCode】Easy | 20. Valid parentheses
- 4. Object mapping Mapster
- 微信小程序路由再次跳轉不觸發onload
- What is socket? Basic introduction to socket
猜你喜欢

博弈论 AcWing 894. 拆分-Nim游戏

论文阅读报告
![[2020]GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis](/img/20/826cc9d514496955a557439881234d.jpg)
[2020]GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis

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

Genesis builds a new generation of credit system

Vant weave swipecell sets multiple buttons
![[Gaode map POI stepping pit] amap Placesearch cannot be used](/img/4c/55586ffcc2267c477a4532ab51a0c1.png)
[Gaode map POI stepping pit] amap Placesearch cannot be used

Speedtree01 generator properties

2.Oracle-数据文件的添加及管理

20220213-CTF MISC-a_ good_ Idea (use of stegsolve tool) -2017_ Dating_ in_ Singapore
随机推荐
7. Oracle table structure
Vscode configures the typera editor for MD
背包问题 AcWing 9. 分组背包问题
P3265 [jloi2015] equipment purchase
TCP's understanding of three handshakes and four waves
5.Oracle-錶空間
Game theory acwing 892 Steps Nim game
博弈论 AcWing 894. 拆分-Nim游戏
2. Addition and management of Oracle data files
Dataframe (1): introduction and creation of dataframe
Paper reading report
Using handler in a new thread
求组合数 AcWing 887. 求组合数 III
Package webapp or H5 pages into apps
Huawei bracelet, how to add medicine reminder?
Bit of MySQL_ OR、BIT_ Count function
论文阅读报告
Gauss Cancellation acwing 884. Solution d'un système d'équations Xor linéaires par élimination gaussienne
Game theory acwing 894 Split Nim game
NVM Downloading npm version 6.7.0... Error