« first day (824 days earlier)      last day (2028 days later) » 

4:56 AM
can you convert a number between 0-31 into binary (5 bits) with no if statements or loops?
 
n.to_s(2) (ruby)
 
umm that's a built-in function
 
Think about the problem. It's really not that hard.
 
umm it's very hard
my brain is about to pop
 
Probably not an acceptable answer. But you can create an array of all values {"0", "1", "10", "11", "100", 101", ... ,"11111" }. Then index your number into that array.
 
5:08 AM
@StackedCrooked you mean a map
@JennaSloan can you convert a number between 0-31 into binary (5 bits) with no if statements or loops?
 
9 messages moved from Lounge<C++>
 
@Rick yes.
 
@JennaSloan how!!
I am dying trying to figure it out.
 
5:24 AM
Just use the bitwise and operator.
 
@JennaSloan what would that look like 43
 
For the given number n, the first bit would be n&1, the second bit n&2, then n&4, n&8, n&16, ..., n&Math.pow(2, b) where b is the index of the desired bit.
 
@JennaSloan I love your brain!!! :) thank you :)
 
I'm not sure how I feel about the phrase "I love your brain".
It kinda makes you sound like a zombie or something.
 
@JennaSloan omg your right
let me rework that
 
5:38 AM
I̸̯͒ ̷̻̆l̷̝̕ọ̵͝v̷̱̂e̶̙͑ ̴́ͅȳ̶̜ò̶̥u̵̲̅r̵̖̽ ̸̱̐b̴̻̈́ȑ̴̙a̶̡͋i̷͇̓n̴̳̄
 
@JennaSloan you are a genius superhuman mind blow awesomeness problem solving (wo)man!!! whose brain is soo cool it is not eatable :)
 
@Rick Uhh... thanks, I guess?
 
@JennaSloan do you work for like a fortune 500 company?
 
@Rick no, I'm a senior in college
 
@JennaSloan so you are an undergrad in CS?
 
5:53 AM
@Rick until I graduate this December
 
@JennaSloan you have any plans to apply to facebook or google?
 
@Rick nah
 
@JennaSloan so what are you going to do?
 
My plan was to write some code that gets me rich and famous, retiring before I graduate from college.
 
@JennaSloan omg! what's the subject matter?
 
6:03 AM
@Rick for what?
 
@JennaSloan the code that's going to make you rich and famous
 
I don't know, I was kinda hoping that some code I write becomes so popular that I somehow get rich and famous from an open source project.
 
O so your still in the brainstorming phase
@JennaSloan but I don't think open source will make you rich. it might make you famous like Douglas Crockford and get you a job if it turns out to be really useful.
@JennaSloan you can write books about programming, and give talks and seminars. and all the rich nerds of the world will like come and listen. You can be like the Taylor Swift of software.
 
6:31 AM
@JennaSloan this is not working let n= 45
let b = n&Math.pow(2,0)
 
7:08 AM
_parentGS->nextLevel.push_back(childGS);
        deepestLevel.push_back(&(_parentGS->nextLevel[_parentGS->nextLevel.size()-1]));
Will this push an object called "childGS" onto _parentGS->nextLevel and a pointer of it onto deepestLevel?
Or am I interpreting this incorrectly
 
7:33 AM
Is it me, or does the average user of stackoverflow down votes questions when he doesn't understand what is discussed and backs that up by labeling as too broad?
It happens quite often that I ask questions about system calls, assembly code constructions, and very narrow concepts with both OS and architecture backing to end up having my questions labeled too broad by people that mostly don't seem to have read the question before downvoting.
 
nwp
You can counter that by making the question very clear so that even stupid people have an easy way of understanding.
 
@nwp How do you make more clear than that: stackoverflow.com/q/52766388/4429146
Because I can tell you there aren't two ways of doing what the question ask how it is done
Well, there are EXACTLY two ways using interdependent system calls reflink and reflinkat
 
nwp
I don't know what a BTRFS filesystem is. And I agree with "too broad". There are probably uncountable libraries that can do that. An answer would mean you list all possible ways to do this and that means the question is too broad.
And you never even mention system calls in your question.
At the very minimum you need to link to the BTRFS documentation (I now read what it is supposed to do) where it states that it enables COW for file copy. Then you show an example where you use cp or std::filesystem::copy_file or whatever and proof that it did not use COW as advertised in the documentation.
 
@nwp BTRFS is a type of file system, and no, there are no libraries to do the job of the OS. Which is why: if one doesn't know what is discussed one should stay away
 
nwp
7:50 AM
Ideally you also add a way to reproduce. This is a bit difficult in this situation but not impossible. Make a script that installs a minimal linux with BTRFS that copies a file and then checks if the file got copied or cowed so people have a chance to reproduce your issue.
 
Hello
There's an answer that said this: "C++ has both stack allocation and heap allocation and you must overload your operators to handle all situations and not cause memory leaks. Difficult indeed. Java, however, has a single storage allocation mechanism and a garbage collector, which makes operator overloading trivial"
Is that last sentence true? Does single storage allocation and garbage collection make operator overloading trivial?
 
@nwp first, C++ standard never states that typical file copy should be COW when possible. Then if you take a look in the GCC and Clang compiler standard library and filesystem libraries, you will find only placeholders for copy on write that do not perform any different operation. Furthermore, I asked for a guaranteed way to use copy on write which is not even related to copy of a file when you get at the operating system level
 
nwp
@MiroslavCetojevic Java doesn't have operator overloading.
@MiroslavCetojevic That's not true. You handle allocations with constructors and destructors, not with operators. And there are no separate constructors and destructors for heap and stack.
 
nwp
@MiroslavCetojevic It's a quote from a book that gets partially corrected. It's also a very old question from a time when SO users upvoted all kinds of garbage.
And the comment below also says to discard the comment because the author didn't know what he was talking about.
 
8:07 AM
@nwp so is implementing operator overloading not related to memory management at all? I don't even know if it's related in C++, since I started learning it in the last couple weeks.
 
nwp
@LudovicZenohateLagouardette That's why you need to link to the documentation of BTRFS so that such misunderstandings don't happen. Who has to implement the COW? Is it the file system and the programs don't need to know (which I think is likely, but apparently wrong)? Do all programs have to manually activate COW on every file copy through special system calls (seems unlikely, but apparently what you expect. Add a quote from the documentation)?
@MiroslavCetojevic They are unrelated for regular operator overloading like operator <. There is an operator new that you can overload, but that is very uncommon. I have never done that, so I'm not sure of the exact semantics, but the documentation doesn't look like it separates stack and heap allocations.
If you intend to learn C++ check one of the books from this list.
 
@nwp quote to the gcc filesystem implementation github.com/gcc-mirror/gcc/tree/master/libstdc%2B%2B-v3/src/… where no implementation uses the reflink family system calls and hence do not perform CoW
 
nwp
What does that mean? That special system calls are unnecessary? That there is a bug in libstdc++ because they don't use the system calls?
 
8:28 AM
@nwp: I'm going through C++ Primer.
 
@MiroslavCetojevic This sentence is weird and sounds wrong, but I can't say "it's wrong" with 100% confidence because it's kind of hard to tell what the author could have meant
@LudovicZenohateLagouardette cp is a part of coreutils and it's open source, so you can look at their source code to see how they did it
 
8:44 AM
@milleniumbug: well, it sounded like in C++ operator overloading has to take into account memory management (heap vs stack), which I'm not familiar with (yet) as far as C++ goes.
 
8:55 AM
@milleniumbug I already know the answer now, it is just a meta issue
 
 
8 hours later…
4:36 PM
I where can I learn on deploying my own apps to windows
the entire reg/program files/shared local/app data etc etc
 
 
6 hours later…
10:11 PM
@Dariusz google
 
I know this is a very general question, but it's not particularly helpful answer, considering it's 6h after asking it
after 6h you decided that the best course of action is to respond with "google it"
heck, I wouldn't even mind if it was 2 minutes after
@Dariusz I can't help much either, but you should head to MSDN and look for the descriptions of the special directories and registry hives
 
10:50 PM
my bad
 

« first day (824 days earlier)      last day (2028 days later) »