当前位置:网站首页>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边栏推荐
- February database ranking: how long can Oracle remain the first?
- [download white paper] does your customer relationship management (CRM) really "manage" customers?
- Application and Optimization Practice of redis in vivo push platform
- Spark SQL learning bullet 2
- Spoon inserts and updates the Oracle database, and some prompts are inserted with errors. Assertion botch: negative time
- Pgadmin 4 V6.5 release, PostgreSQL open source graphical management tool
- When to catch an exception and when to throw an exception- When to catch the Exception vs When to throw the Exceptions?
- [uc/os-iii] chapter 1.2.3.4 understanding RTOS
- [understanding of opportunity -38]: Guiguzi - Chapter 5 flying clamp - warning one: there is a kind of killing called "killing"
- tuple and point
猜你喜欢
Unpool(nn.MaxUnpool2d)
Chinese natural language processing, medical, legal and other public data sets, sorting and sharing
【LeetCode】222. The number of nodes of a complete binary tree (2 mistakes)
Variables in postman
[200 opencv routines] 99 Modified alpha mean filter
openresty ngx_lua執行階段
【LeetCode】404. Sum of left leaves (2 brushes of wrong questions)
Official announcement! The third cloud native programming challenge is officially launched!
Visual studio 2019 set transparent background (fool teaching)
Application and Optimization Practice of redis in vivo push platform
随机推荐
Collection of gmat750 wrong questions
Practical case of SQL optimization: speed up your database
Uniapp navigateto jump failure
Which common ports should the server open
Kotlin - 协程 Coroutine
Traditional chips and AI chips
Timescaledb 2.5.2 release, time series database based on PostgreSQL
RichView TRVStyle MainRVStyle
Spoon inserts and updates the Oracle database, and some prompts are inserted with errors. Assertion botch: negative time
Pytest (4) - test case execution sequence
openresty ngx_lua执行阶段
From task Run get return value - getting return value from task Run
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
Kotlin - coroutine
如何做一个炫酷的墨水屏电子钟?
. Net starts again happy 20th birthday
Elfk deployment
ICSI 311 Parser
Process scheduling and termination
CAM Pytorch