Ammar
I just realized that the while loop is not required.
Ammar
#include <stdio.h> #include <stdint.h> int main() { uint64_t tmp; uint64_t i = 20ull; tmp = (i & -16); i = tmp + ((tmp < i) << 4); printf("%ld", i); }
Ammar
It takes 4 instructions: https://godbolt.org/z/rM4v79
Ammar
*Edited.
Nils
It takes 4 instructions: https://godbolt.org/z/rM4v79
Well turns out my solution takes just 2 😉
Nils
but thx
Anonymous
Hi guys my teacher asked me to write program in c++ : 1_ask number of circles 2_calc area of circles with function 3_return it at the end sorted high to low I will apretiate if anyone help (Sry for bad eng)
Ammar
No, I meant the struct memchunk_free. I wonder the sizeof it. It isn't defined in that file.
Ammar
Oh I see, thanks.
Sara
Please is there any one have an idea about design and implement simple compiler?
Dima
How's your assembly knowledge?
you can write a really simple compiler without assembly knowledge tho
Sara
How's your assembly knowledge?
I have no knowledge, but the requirement is to implement it in ubuntu using yacc and lex tool, but I don’t know from where I should start
Anonymous
Is there an off topic group guys
Avique
I have no knowledge, but the requirement is to implement it in ubuntu using yacc and lex tool, but I don’t know from where I should start
you may acquire a book or read some material found about them. For example, some results in the search: https://html.duckduckgo.com/html?q=yacc%20book
Anonymous
Yes
link
Anonymous
link
U r already there
WELBECK
Hello i am a new beginner here
Don Peter Joseph
https://pastebin.com/2MZKDeyY
Don Peter Joseph
https://pastebin.com/2MZKDeyY
quick sort code. can anyone suggest where i have gone wrong?
Don Peter Joseph
enter the no of elements in array:4 enter the elements: enter element at 0:1 enter element at 1:3 enter element at 2:2 enter element at 3:4 the unsorted list is : 1 3 2 4the sorted array is : 1 3 3 4
Anonymous
/unmute Andre
Dima
lol
Luca
guys is there any good tutorial to use cmake on visualstudio
Alex
what is the issue?
Nils
Use rand()
Pogos
I am very sorry, that i bothered everyone Hi, everyone i am new in c/c++ and honestly i dont now how to describe problem (i read a lot about pointers, and how it works but, i can't explain my log in this situation) Can you explain how it works here ?
Iakovos
Hello guys I have a question, which of the following should sort complete faster using selection sort?(1st array is random numbers, 2nd array is an ascending array) a) 5,1,72,28,59 b) 1,2,3,4,5.... I read in forums that case b) should be faster but for some weird reason I get case a) to be faster. Any ideas why this happens?
Iakovos
own function, classic selection sort, I need to sort in asc order
Alex
provide code of your func
Iakovos
hastebin.com/axifoponih.properties
Iakovos
Don't mind unsigned int declaration, I use in large arrays
WELBECK
Hello i am a new beginner here. What is good here ?
ברני
Henry
Can you get me chidinma please we are from same country
Dima
lol
ברני
😐
Henry
😐
Lols
Alex
How can I implement that
add if before swap
Iakovos
Didn't actually make a difference
Alex
are array sizes equal?
Tangent Alpha
Anyone can help?
you need to write your own code
Pavel
Anyone can help?
What kind of help do you need? If you have troubles with your solution you can paste your code (use pastebin or a similar service for that) and ask your questions.
Iakovos
are array sizes equal?
Even with the same numbers, but one is in random order and one in ascending as I told you
Alex
do you have equal time or asc array is slower?
su
Even with the same numbers, but one is in random order and one in ascending as I told you
wikipedia can help you figure out why worst cases worse that average cases averages
Iakovos
write time which you have
For 100.000 elements: Random array time: 9.333 sec Ascending array time: 9.800sec
Alex
For 100.000 elements: Random array time: 9.333 sec Ascending array time: 9.800sec
thats pretty close, profile your code line by line. maybe most of the time you spend on IO or reading from memory
Pavel
For 100.000 elements: Random array time: 9.333 sec Ascending array time: 9.800sec
Not a significant difference, how many times you've run your benchmark?
Iakovos
A lot, only 2 out of 10 times random array is slower than ascending
Iakovos
It should because there is branch prediction
Iakovos
Low level stuff
su
It should because there is branch prediction
no we are talking about theoretical advances, not real world evaluation
Iakovos
I'm actually testing it and I give you the results as it displays
Alex
A lot, only 2 out of 10 times random array is slower than ascending
probably your performance issue is not about data difference
su
Well, it can be theoretically because of branch prediction
branch predicton is not something we are taking into account in O math
Iakovos
I am running the comparisons in C right now, so practical there is a difference as branch prediction takes place, right?
olli
Well, it can be theoretically because of branch prediction
I would expect potential cache misses to have a bigger impact, and that's where selection sort is really bad.
Iakovos
I even try it in descending order array right now( like this: 5,4,3,2,1 but with 100.000 elements again) and its even slower than the above cases, I mean wth is wrong??