当前位置:网站首页>Why is this an undefined behavior- Why is this an undefined behavior?
Why is this an undefined behavior- Why is this an undefined behavior?
2022-07-05 02:36:00 【Bustling city 】
problem :
My answer to this question was this function: I am right. The answer to this question It's this function :
inline bool divisible15(unsigned int x) { //286331153 = (2^32 - 1) / 15 //4008636143 = (2^32) - 286331153 return x * 4008636143 <= 286331153;}
It perfectly worked on my machine with VS2008 compiler, however here it doesn't work at all. It is completely applicable to my machine and VS2008 compiler , but ad locum It doesn't work at all .
Does anyone has an idea, why it I get different results on different compilers? Does anyone have an idea , Why do I get different results on different compilers ?unsigned
overflow isn't undefined behavior.unsigned
Overflow is not an undefined behavior .
Important note: after some test it was confirmed it is faster than taking the remainder of the division by 15. (However not on all compilers) Important note : After some testing , Make sure it's better than dividing the remainder of the division by 15 faster .( But not on all compilers )
Solution :
Reference resources : https://stackoom.com/en/question/1GUVX边栏推荐
- Can you really learn 3DMAX modeling by self-study?
- 数据库和充值都没有了
- How to make a cool ink screen electronic clock?
- 8. Commodity management - commodity classification
- LeetCode 314. Binary tree vertical order traversal - Binary Tree Series Question 6
- ELFK部署
- Design and implementation of community hospital information system
- A label colorful navigation bar
- Which common ports should the server open
- A label making navigation bar
猜你喜欢
Introduce reflow & repaint, and how to optimize it?
Cut! 39 year old Ali P9, saved 150million
【LeetCode】106. Construct binary tree from middle order and post order traversal sequence (wrong question 2)
Practical case of SQL optimization: speed up your database
Practice of tdengine in TCL air conditioning energy management platform
Three properties that a good homomorphic encryption should satisfy
Missile interception -- UPC winter vacation training match
[uc/os-iii] chapter 1.2.3.4 understanding RTOS
Video display and hiding of imitation tudou.com
Android advanced interview question record in 2022
随机推荐
Go RPC call
Rabbit MQ message sending of vertx
"C zero foundation introduction hundred knowledge and hundred cases" (72) multi wave entrustment -- Mom shouted for dinner
[Yu Yue education] National Open University spring 2019 0505-22t basic nursing reference questions
RichView TRVStyle MainRVStyle
Traditional chips and AI chips
使用druid連接MySQL數據庫報類型錯誤
Leetcode takes out the least number of magic beans
Practice of tdengine in TCL air conditioning energy management platform
When to catch an exception and when to throw an exception- When to catch the Exception vs When to throw the Exceptions?
Using druid to connect to MySQL database reports the wrong type
ICSI 311 Parser
Chinese natural language processing, medical, legal and other public data sets, sorting and sharing
Design of kindergarten real-time monitoring and control system
Visual studio 2019 set transparent background (fool teaching)
. Net starts again happy 20th birthday
8. Commodity management - commodity classification
Icu4c 70 source code download and compilation (win10, vs2022)
LeetCode --- 1071. Great common divisor of strings problem solving Report
【LeetCode】111. Minimum depth of binary tree (2 brushes of wrong questions)