Tuana
Homework Write a program that describes integers -9999 to +9999 with their pronunciation.
Tuana
use switch and case
Amu
Ok, but what does it do, tho? You need to multithread something
a thread safe queue that we implement ourselves
Tuana
How can I find a shortcut instead of typing one by one?
Amu
Ok, so what's the problem?
mainly on how to make sure i’m using lock semantics properly. May I dm you the pdf of the problem?
Anonymous
This
For me it is impossible to have any book on this list .... I am from Cuba so you know and well here everything is blocked
Anonymous
For me it is impossible to have any book on this list .... I am from Cuba so you know and well here everything is blocked
Just pirate it. Only losers support the authors that put hours upon hours into making a book
Mar!o
https://www.youtube.com/channel/UCntBraan1IywawH8HaM9a7w/videos I've opened a YT channel for hacking, reverse engineering and general low level programming in x86-64 assembly, ARM64, C and C++ 20. Might be worth a look if someone is interested in these fields... I'm not sure if this counts as advertising and if it does I'm sorry and feel free to delete my message.
Laopigo
How to generate a random double between DBL_MIN and DBL_MAX in C?
Max
I am so sorry who can help me with 6 exercises today ?😊
Max
It is school exercises 😁
Ahmed
I don't know if the following is considered a personal message. Is anyone interested in learning C++ together? As in discussions and tasks and reading done together? I get bored reading a book or watching videos alone.
Pavel
How to generate a random double between DBL_MIN and DBL_MAX in C?
https://stackoverflow.com/questions/55766058/how-can-i-generate-random-doubles-in-c
Laopigo
https://stackoverflow.com/questions/55766058/how-can-i-generate-random-doubles-in-c
None of this examples answer my question. The solution with filling double with random bytes is incorrect, since I would like to generate the values ​​from DBL_MIN to DBL_MAX excluding nan, inf etc :(
Anonymous
Hi guys! I need to learn about how to employ time in c++. For exmple diley,sleep,timer... Can you help me?
olli
How to generate a random double between DBL_MIN and DBL_MAX in C?
assuming RAND_MAX is 1^31-1 and you're referring to DBL_MIN and DBL_MAX as biggest and smallest normalized values you could do something like this double randDouble() { union { struct { unsigned long long m : 52; unsigned long long e : 11; unsigned long long s : 1; }; unsigned long long ull; double d; } X; X.ull = rand(); X.ull <<= 0x1FLLU; X.ull |= rand(); X.s = (X.ull & (1LLU << 60)) != 0; X.e = 1 + (rand() % 0x7FEU); return X.d; }
Anshul
https://pastebin.com/2Rb1dn7B
Anshul
i want to know what is the need of these 3 things. why dont we use just one way
Shikha
Anyone know c language
olli
i want to know what is the need of these 3 things. why dont we use just one way
because what you want to achieve might differ. If you ever only care about finding an exact match (same price and title) just use the first approach. However there might be a case where you don't know or don't care about the price but want to find a book with a certain title, in this case you can use a custom comparator and the generic search function. The second and third differ on how you want to use it, either you have to select the comparator at compile time (2) or you can also have it being selected dynamically via a function pointer (3).
olli
bruh what you did with X.ull «= 0x1FLLU what's 0x1FLLU here? I mean i don't know how to work wih registers in either C or cpp so asking out of curiosity
0x1FLLU is just another way of writing (unsigned long long)31. Most libraries implement rand() returning a number between 0 and 2,147,483,647 which is 31 bits of data. Since a double is 64 bits on most platforms we need multiple rand() invocations. At first we assign the 31 bits to the a 64 bit variable and then shift it 31 bits to the left so we can fill up the lower 31 bits with the next result from rand() unsigned long long x; x = rand(); // fill the lower 31 bits with data x <<= 0x1FLLU; // move the data 31 bits to the left x |= rand(); // add another 31 bits of data now we have 62 bits of "random" data which is enough for the 53 bit of mantissa and the sign.
Anshul
I am not able to understand it
Anonymous
How do 2 and 3 differ
2 and 3 are different in that 2 is more generic and can accept any callable while 3 takes in only functions
Антон
which part is UB?
All of the language
Anshul
2 and 3 are different in that 2 is more generic and can accept any callable while 3 takes in only functions
I can't understand. 2 can take object of some class, 3 can take some function. But at the end both do the exactly same thing
Anonymous
which part is UB?
Setting X.e and returning X.d
Anonymous
All of the language
A language is a definition lol, wdym?
olli
Setting X.e and returning X.d
iirc the question was about C and it does allow type punning (in comparison to C++). But I agree, not the best style either way. I think it's easier to show the idea that way than using a couple of masks and memcpy.
Anonymous
I can't understand. 2 can take object of some class, 3 can take some function. But at the end both do the exactly same thing
2 can take any callable - it can be a class with an overloaded operator () or a normal function or a lambda or the result of a call to std::bind or the result of std::mem_fn
Anshul
2 can take any callable - it can be a class with an overloaded operator () or a normal function or a lambda or the result of a call to std::bind or the result of std::mem_fn
If I pass a function to 2 and if it can work then why do we even use 3. I mean it's more easier to use 2 instead. In 3 I need to create a function pointer, tell the return type and argument as well, but in case of 2 I just write Comapre cmp and it's done.
Anonymous
iirc the question was about C and it does allow type punning (in comparison to C++). But I agree, not the best style either way. I think it's easier to show the idea that way than using a couple of masks and memcpy.
Yes type punning is allowed explicitly in C11 as implementation defined behavior because it can also result in a trap representation. But your code should work as expected on all implementations. I do prefer the answer given in Stackoverflow though.
Anonymous
If I pass a function to 2 and if it can work then why do we even use 3. I mean it's more easier to use 2 instead. In 3 I need to create a function pointer, tell the return type and argument as well, but in case of 2 I just write Comapre cmp and it's done.
Yes 2 is preferred. 3 is just a more specific case of 2. But however there is a problem with template bloating in 2 with your template being instantiated for every different callable that you call it with. This problem is not there with option 3.
Anonymous
What's template bloating
Multiple instantiations of your template which leads to a code bloat i.e. an increase in the size of object file generated. This is not a serious problem however. So 2 should be the preferred way
Anshul
Multiple instantiations of your template which leads to a code bloat i.e. an increase in the size of object file generated. This is not a serious problem however. So 2 should be the preferred way
Okay and is there this thing too? If yes can you elaborate it please. "The second and third differ on how you want to use it, either you have to select the comparator at compile time (2) or you can also have it being selected dynamically via a function pointer (3)."
Anshul
But I am not able to understand it😅 Only the part that I quoted
Anonymous
But I am not able to understand it😅 Only the part that I quoted
It says that in the case of option 2, the comparator is fixed at compile time. The compiler knows what your comparison object is at the time of instantiation of the template. So there is a chance of inlining to make it more efficient. In the option 3, your function just takes in a function pointer and it has no idea what it is going to be called with and hence all calls are resolved at runtime with little opportunities for optimization
Anonymous
Anyway I gotta go now. If you have any questions just ask them here. Someone else might answer or I will answer later
Ali
Did you have resource for c programming
Ali
Pdf or video
Ali
Yes
Ali
Thanks mans
Lxjxjxhks
although in the beginning user hasn't been prompted to give the value card_name[0], but in the condition , we check its value while(card_name[0]!='X'),if card_name doesn't have a value how can it check against some value https://dpaste.org/yd2Y
Lxjxjxhks
Can someone tell me how it works?
محذوف بلا عودة بإذن الله
Hi
محذوف بلا عودة بإذن الله
Guys Anyone know about finite state machines?
Anonymous
Just ask. Worst case, nobody answers. When you are asking to ask instead of just asking, you might miss ppl who actually know
محذوف بلا عودة بإذن الله
Oh ok
محذوف بلا عودة بإذن الله
Design a finite-state automaton for the alphabet Σ = {a, b} that accepts any sequence ending with at least two a or two b. Draw the state diagram, remember to show the start state and the state (s) acceptable.
محذوف بلا عودة بإذن الله
Maybe someone knows about Big O?
Ludovic 'Archivist'
But in works only on cpu with IEEE 754 floating point standard
It also gives you the worst distribution in existence
Ludovic 'Archivist'
But in works only on cpu with IEEE 754 floating point standard
The way GCC libstdc++ does it is: generate a uniformly distributed float between -1 and 1, then scale it between your low and high bounds. The reasoning is that 50% of all the space of ieee 754 space is between -1 and 1 anyway
Ludovic 'Archivist'
to get the uniform real, you generate a random mantissa, then for each next bit of your rng output you lower the exponent by 1 if it is 1 and stop whenever you get a 0
Ludovic 'Archivist'
That is, in this way it is possible to generate only half of the possible variants?
yes, but at least you will get a uniform distribution that can then be resampled and transformed
Vova
Hi. Maybe someone will help me. I have some troubles with output array. I searched the internet, but in vain, can`t find it. I want to print array from k position to k+1(to the left). For example, arr[ ] = { 1, 2, 3, 4, 5}. We have choosen 3. After it arr[ ] = {3, 2, 1, 5, 4}. There was an idea to deduce an array, beginning from this element and to the firs element, and further to continue from the end of an array, however I was faced with one problem, I do not know how to set the first element of an array. a [0] does not work, I have already tried I will be very grateful for your help
Anonymous
It also gives you the worst distribution in existence
Floating point numbers using IEEE 754 Standard are by nature not uniformly distributed. The question was to generate all possible representations of floating point numbers with equal likelihood. I think the solution provided by ollirz does just that. Admittedly the uniform real distribution in the C++ standard library does a better job.
محذوف بلا عودة بإذن الله
So what is your question
I do not understand how to do the states. Especially the initial state
محذوف بلا عودة بإذن الله
Maybe you could help me design that?