|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On February 16 2013 01:49 YiSunsin wrote:Show nested quote +On February 16 2013 00:50 wherebugsgo wrote: He didn't say that programming is not important, and your indication that "it isn't worth learning any of the things you mention" is completely wrong. The most sought-after applicants in EECS fields right out of university are generally those who have the strongest fundamental skills. This is particularly true for the better jobs. If you want to have any sort of impact beyond a simple coding job then everything outside of programming is very very important. That would be soooo nice if only it was true.
It is true where I go to school, and where I intend to work/pursue research. (Silicon Valley)
Here at Berkeley basically everyone in the CS department learns how to program well. If you haven't learned that by the time you're through this program you basically didn't learn anything.
One of the data structures professors is notorious for drilling style into the heads of programmers. The code has to be readable by his standards (i.e. functions have a max length of 60 some lines, lines have a max length of 80 chars, no magic numbers, have to add spaces before and after all transitive operations, all methods and classes must be commented, and many other things.) or you cannot submit it (the system forces a style check prior to compilation) That alone forces you to learn to code efficiently, concisely, and readably.
IMO at any half decent school you should be able to learn how to program well if you pay attention and are motivated. The bigger problem is for those who learn on their own, but to be honest I would expect them to be lacking in other skills, not programming skills. Generally people who are interested enough to learn how to program on their own at least have the motivation to learn programming specifically. From a personal experience, seeing people come in from outside schools during summer, this generally holds true.
I have had multiple professors (and some fellow students and job interviewers and company representatives) stress that it's not necessarily all about what languages you know-if you need to learn a language you can do it. Programming skill carries over from language to language. It's sort of common sense, really; programming ideals transcend beyond the languages themselves.
On February 16 2013 04:00 darkness wrote:Guys I need your help. I currently have this code: int main(void) { /* input variables */ float a, b; int n; /* division = a/b */ long double division; int answer;
/* get input */ scanf("%f %f %d", &a, &b, &n);
// calculate a/b division = (long double)a / (long double)b; answer = (int)(division * pow(10, n)) % 10;
printf("%Lf\n", division);
/* output */ printf("%d\n", answer); /* successful execution */ return 0; }
But it doesn't work properly when I write: 8 60000 5 In other words, 8/60000 returns this: -bash-4.1$ ./a.out 8 60000 5 0.000133 <--- incorrect result of 8/60000 3 The goal of the program is to find the n-th digit after the decimal point, but the real problem right now is it doesn't calculate precisely. According to MS Calc, the result should be: 1,3333333333333333333333333333333e-4
uhhh
isn't 0.000133 exactly the same as 1.33 * 10^-4?
Not really sure what the problem is lol
On February 16 2013 01:04 delHospital wrote:Show nested quote +On February 16 2013 01:00 wherebugsgo wrote:On February 16 2013 00:56 aurum510 wrote:On February 15 2013 14:16 Kambing wrote:On February 15 2013 13:17 aurum510 wrote: I don't really call discrete math mathematics either, as opposed to simple mind numbing logic.
Discrete math and logic is mathematics. It's actually the "other" branch of mathematics that you don't explore until college (which is arguably backwards because logic benefits the everyday student much more than calculus). And in many ways, discrete math is the foundations on which all other math is built on. Consequently it plays a big role in computer science and its importance cannot be understated. On February 15 2013 13:17 aurum510 wrote: It's pretty friggen hard to find a job with a CS degree that doesn't involve programming. Maybe some sort of theoretical research at a university, but that's about it (excluding the aforementioned architects and possibly some network jobs). Such jobs exist, e.g., technology-focused entrepreneurship, technology-focused law practice (esp. around software patents), software development product managers, UX designers, tech writers, or education. Ok I agree with you, discrete math is math of course, but what I'm saying is that I could have definitely skipped it in college and not missed a single thing. The theory of computation was much more important in my mind, but still not very useful for the average computer science graduate. so you're saying you never use boolean operators or logic gates? Come on, you don't need to be proficient with Stirling numbers to use boolean operators...
it was obviously a contrived example :p
On February 16 2013 01:06 aurum510 wrote:Show nested quote +On February 16 2013 00:50 wherebugsgo wrote:On February 15 2013 13:17 aurum510 wrote:On February 15 2013 12:56 Abductedonut wrote:On February 15 2013 12:18 Cyx. wrote: Hey guys, I'm currently taking a year off of university and I'm going back into second-year software engineering next year. I have a decent grasp of some of the basics of the programming I'm going to be learning next year (a university course in C++ last year and some hobby programming in Python in highschool and C++/Python in university) but I want to get a bit of a head start on some of the topics I'm going to be learning next year like pointers, sorting algorithms, basic Java programming... basically second-year CS courses.
Are there any good places on the internet to help me get the kind of head start I want? At this point I'm basically reduced to reading my roommate's textbooks (he's in the second year of the program right now) and working through his old lab exercises and stuff from the fall, which is actually pretty good practice except that I have a hard time just picking up his textbook and figuring out what I want to be looking at unless he's right there with me. Also, as someone who's planning on being a civil engineer, not a software engineer, he doesn't really understand a lot of the stuff on the level that I want to and even he and the textbook combined can't really give me everything I need.
I know it's a bit of a broad question so any help you can give is appreciated =) I'm basically looking for anything that has some explanation of the stuff I'm going to be looking at next year but most importantly some exercises and things I can be doing - it's really hard to apply a lot of the things I see without that concrete 'write a piece of code that does X' component. I hate to sound like a douche, but being a computer scientist and a software engineer isn't all about programming. Programming is a secondary concern for computer scientists. It's phase two. If you want to learn how to program, there are thousands of tutorials and programming guides online. If you're feeling like a pirate, you could even pirate some books. And they're all great for programming. In short, if you want to program, just program. Learning how to program is linear only for a short while. You're on your own from there. If you want a TRUE CS education, you're going to have to broaden your horizons as to what computer science really is. You need to learn math, physics, electrical engineering, and computer science. (Look at MIT's degrees... why do you think their only degree program is EECS?) Don't worry too much about programming. Programming is pretty easy. Focus on math. Math is at the center of being a computer scientist. Learn calculus 1,2,3, linear algebra and differential equations. Take discrete math as a learn linear algebra. Take a statistics class. (It's pointless learning algorithms if you don't know discrete math and statistics) If you get good at solving difficult math problems, you will get good at solving difficult computer science problems. As I'm writing this I realize it's getting too long. There's too much to say about learning CS. Just check out MIT's opencourseware. It's good. http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/ You definitely do sound like a douche. While programming isn't all of what a CS/SE student should focus on, it's not worth any effort to learn any of the things you mention. I don't think I've met a software engineer who has used any calculus, linear algebra, or differential equations in their life. I don't really call discrete math mathematics either, as opposed to simple mind numbing logic. Algorithms is also important to software engineers, but honestly, once you recognize when to use what algorithms, it's pretty straightforward. And unless you're doing embedded systems, you don't need physics or electrical engineering in any way. Find me a software engineer who makes a living doing something other than programming... And basically all software architects were software engineers at some point... programming. It's pretty friggen hard to find a job with a CS degree that doesn't involve programming. Maybe some sort of theoretical research at a university, but that's about it (excluding the aforementioned architects and possibly some network jobs). he may have come off like a douche, but you come off pretty naive. He didn't say that programming is not important, and your indication that "it isn't worth learning any of the things you mention" is completely wrong. The most sought-after applicants in EECS fields right out of university are generally those who have the strongest fundamental skills. This is particularly true for the better jobs. If you want to have any sort of impact beyond a simple coding job then everything outside of programming is very very important. At most good schools you will learn programming no matter what if you do EECS. In general I would say that you would learn Python, and at least two of Java/C/C++ just by taking classes. I know I did-I have a strong grasp of Scheme, Python, Java, and C just by taking the core classes. You'd probably also have the opportunity/be required to learn HTML, Javascript, mobile app development, scripting, etc. Once you take the core classes you don't need to learn how to program. You can pretty much pick up a language and learn it within a month or less. Language to language it's mostly syntax and minor other differences; learning to code in a different language after you've already learned the basics of good programming practices is simply about opening a reference text and hammering out the details. The core logic will all be there already. As for what the guy was asking about in the first place, for second year EECS courses, usually only one or two of them are heavily coding-based. For example discrete mathematics, circuit theory and digital signals theory are all 1st/2nd year courses and none of them have any programming at all. They're also core. For third year courses such as algorithms, AI, and computer security, the programming is secondary or even tertiary to what you are actually learning. I'm taking an AI course right now and it's done in Python. From a programming perspective I'm not using anything that I didn't learn in my first two CS classes; all you truly need from a programming perspective is a background in object oriented programming and data structures. Everything else is all search algorithms, trees, optimization, probability, etc. e: I may be considerably biased though, seeing as I am lucky to be a part of one of the best EECS programs in the country (or even the world) here at Berkeley. Oh please. I work as an embedded SE, and I can honestly say even I don't use any physics I learned in college. I don't use algorithms hardly at all (maybe a table of some sort now and then). I don't use discrete math. I don't use any sort of advanced mathematics beyond algebra. I don't use AI in any way (nor do much of anyone in the field). Security is about learning the algorithms and nothing else, which you can learn at any time in a few hours by opening a book. You're still in your undergrad, so you are very biased. While it is important to understand those theory classes, they are useless in the end. The guy was asking about what he should study in his off year. I would never recommend opening a theory book and studying it, as it's not useful outside of understanding. There is almost no implementation of it unless you're writing a compiler or doing theoretical research. I got my masters at University of Chicago (also very good), and I can honestly say the only useful thing I learned in my masters was about parallel programming, some advanced operating systems and computer architecture, and that's about it. P.S. It doesn't matter if you go to Berkley or a barely known state school, you learn the same thing. Schools are ranked by their research, not their academics now. Schools in Europe are always really low on the rankings, but that's only because the professors are there to teach, not to do research all the time (in fact, most of the schools prohibit professors from doing research while teaching, so they actually focus on teaching). I've had so many professors who have to teach one class a semester to stay employed to do their research and just give 1-3 exams and that's it. You leave those classes and know you've learned nothing. In fact, I'd much rather go to UC Davis than Berkley, as I would actually learn more. I got my undergrad at UW-Milwaukee (100th ranked in US, not very good), but I learned a lot more from the teachers there than I did at University of Chicago.
Having attended classes at community college, a completely unknown public university in Michigan (Oakland University), UofM Ann Arbor, and Berkeley, I can quite confidently say that Berkeley eclipses them all in terms of how much I have learned. Rigor matters. A fucking lot.
Secondly, I never mentioned physics because physics is not a prerequisite for a CS major at most schools. It isn't here. Only circuit theory is, and that's an EE class (the physics E+M classes are heavily calculus and theory based-EE circuit theory is not, it's very minimally theoretical and quite the opposite)
Also course material itself is not always relevant directly, but it often is very useful indirectly too. If this guy is studying in university as he says, who's to say that all he needs is programming?
The point of a university degree is to obtain a well-rounded education. If all he learns is programming, then he's pigeonholed. What if he doesn't want to be a code monkey? If he wants to do anything else then literally all the other classes are imperative. In fact, I would argue that if he wants to move anywhere up on the ladder then programming is his least concern. Programming will come naturally (IMO)
|
On February 16 2013 04:12 wherebugsgo wrote:Show nested quote +On February 16 2013 01:49 YiSunsin wrote:On February 16 2013 00:50 wherebugsgo wrote: He didn't say that programming is not important, and your indication that "it isn't worth learning any of the things you mention" is completely wrong. The most sought-after applicants in EECS fields right out of university are generally those who have the strongest fundamental skills. This is particularly true for the better jobs. If you want to have any sort of impact beyond a simple coding job then everything outside of programming is very very important. That would be soooo nice if only it was true. It is true where I go to school, and where I intend to work/pursue research. (Silicon Valley) Here at Berkeley basically everyone in the CS department learns how to program well. If you haven't learned that by the time you're through this program you basically didn't learn anything. One of the data structures professors is notorious for drilling style into the heads of programmers. The code has to be readable by his standards (i.e. functions have a max length of 60 some lines, lines have a max length of 80 chars, no magic numbers, have to add spaces before and after all transitive operations, all methods and classes must be commented, and many other things.) or you cannot submit it (the system forces a style check prior to compilation) That alone forces you to learn to code efficiently, concisely, and readably. IMO at any half decent school you should be able to learn how to program well if you pay attention and are motivated. The bigger problem is for those who learn on their own, but to be honest I would expect them to be lacking in other skills, not programming skills. Generally people who are interested enough to learn how to program on their own at least have the motivation to learn programming specifically. From a personal experience, seeing people come in from outside schools during summer, this generally holds true. I have had multiple professors (and some fellow students and job interviewers and company representatives) stress that it's not necessarily all about what languages you know-if you need to learn a language you can do it. Programming skill carries over from language to language. It's sort of common sense, really; programming ideals transcend beyond the languages themselves.
It's pretty normal to have the data structures professor making very strict requirements. That's usually where people drop out if they will drop out of school.
And if you read what he said, he said nothing about knowing many programming languages being good. Ask any professional, no matter what experience or what age, if he/she likes the code he/she wrote 5 years ago. It will almost always be a resounding "no", because programming is a lifelong process of learning. Programming skills carry from language to language, but learning those skills takes a lifetime. Hell, I guarantee your data structures professor will not like the code he/she wrote 5 years ago, even though he/she has had years and years to refine the exact same code.
Anyway, come back to me in 5 years when you have a job. I mean, if all you want to do is know everything about Computer Science, those classes are very important. But if you want to perhaps make a living, you're going to have to sit your ass in front of a computer and code away or think about how you're going to code away for at least half of your hours every week. Hell, even the architecture people at my company are coding half of their hours each week when not writing documents or talking to people.
|
On February 16 2013 02:41 mcc wrote:Show nested quote +On February 16 2013 02:27 aurum510 wrote:On February 16 2013 02:14 mcc wrote:On February 16 2013 01:32 YiSunsin wrote:On February 16 2013 01:06 aurum510 wrote:On February 16 2013 00:50 wherebugsgo wrote:On February 15 2013 13:17 aurum510 wrote:On February 15 2013 12:56 Abductedonut wrote:On February 15 2013 12:18 Cyx. wrote: Hey guys, I'm currently taking a year off of university and I'm going back into second-year software engineering next year. I have a decent grasp of some of the basics of the programming I'm going to be learning next year (a university course in C++ last year and some hobby programming in Python in highschool and C++/Python in university) but I want to get a bit of a head start on some of the topics I'm going to be learning next year like pointers, sorting algorithms, basic Java programming... basically second-year CS courses.
Are there any good places on the internet to help me get the kind of head start I want? At this point I'm basically reduced to reading my roommate's textbooks (he's in the second year of the program right now) and working through his old lab exercises and stuff from the fall, which is actually pretty good practice except that I have a hard time just picking up his textbook and figuring out what I want to be looking at unless he's right there with me. Also, as someone who's planning on being a civil engineer, not a software engineer, he doesn't really understand a lot of the stuff on the level that I want to and even he and the textbook combined can't really give me everything I need.
I know it's a bit of a broad question so any help you can give is appreciated =) I'm basically looking for anything that has some explanation of the stuff I'm going to be looking at next year but most importantly some exercises and things I can be doing - it's really hard to apply a lot of the things I see without that concrete 'write a piece of code that does X' component. I hate to sound like a douche, but being a computer scientist and a software engineer isn't all about programming. Programming is a secondary concern for computer scientists. It's phase two. If you want to learn how to program, there are thousands of tutorials and programming guides online. If you're feeling like a pirate, you could even pirate some books. And they're all great for programming. In short, if you want to program, just program. Learning how to program is linear only for a short while. You're on your own from there. If you want a TRUE CS education, you're going to have to broaden your horizons as to what computer science really is. You need to learn math, physics, electrical engineering, and computer science. (Look at MIT's degrees... why do you think their only degree program is EECS?) Don't worry too much about programming. Programming is pretty easy. Focus on math. Math is at the center of being a computer scientist. Learn calculus 1,2,3, linear algebra and differential equations. Take discrete math as a learn linear algebra. Take a statistics class. (It's pointless learning algorithms if you don't know discrete math and statistics) If you get good at solving difficult math problems, you will get good at solving difficult computer science problems. As I'm writing this I realize it's getting too long. There's too much to say about learning CS. Just check out MIT's opencourseware. It's good. http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/ You definitely do sound like a douche. While programming isn't all of what a CS/SE student should focus on, it's not worth any effort to learn any of the things you mention. I don't think I've met a software engineer who has used any calculus, linear algebra, or differential equations in their life. I don't really call discrete math mathematics either, as opposed to simple mind numbing logic. Algorithms is also important to software engineers, but honestly, once you recognize when to use what algorithms, it's pretty straightforward. And unless you're doing embedded systems, you don't need physics or electrical engineering in any way. Find me a software engineer who makes a living doing something other than programming... And basically all software architects were software engineers at some point... programming. It's pretty friggen hard to find a job with a CS degree that doesn't involve programming. Maybe some sort of theoretical research at a university, but that's about it (excluding the aforementioned architects and possibly some network jobs). he may have come off like a douche, but you come off pretty naive. He didn't say that programming is not important, and your indication that "it isn't worth learning any of the things you mention" is completely wrong. The most sought-after applicants in EECS fields right out of university are generally those who have the strongest fundamental skills. This is particularly true for the better jobs. If you want to have any sort of impact beyond a simple coding job then everything outside of programming is very very important. At most good schools you will learn programming no matter what if you do EECS. In general I would say that you would learn Python, and at least two of Java/C/C++ just by taking classes. I know I did-I have a strong grasp of Scheme, Python, Java, and C just by taking the core classes. You'd probably also have the opportunity/be required to learn HTML, Javascript, mobile app development, scripting, etc. Once you take the core classes you don't need to learn how to program. You can pretty much pick up a language and learn it within a month or less. Language to language it's mostly syntax and minor other differences; learning to code in a different language after you've already learned the basics of good programming practices is simply about opening a reference text and hammering out the details. The core logic will all be there already. As for what the guy was asking about in the first place, for second year EECS courses, usually only one or two of them are heavily coding-based. For example discrete mathematics, circuit theory and digital signals theory are all 1st/2nd year courses and none of them have any programming at all. They're also core. For third year courses such as algorithms, AI, and computer security, the programming is secondary or even tertiary to what you are actually learning. I'm taking an AI course right now and it's done in Python. From a programming perspective I'm not using anything that I didn't learn in my first two CS classes; all you truly need from a programming perspective is a background in object oriented programming and data structures. Everything else is all search algorithms, trees, optimization, probability, etc. e: I may be considerably biased though, seeing as I am lucky to be a part of one of the best EECS programs in the country (or even the world) here at Berkeley. Oh please. I work as an embedded SE, and I can honestly say even I don't use any physics I learned in college. I don't use algorithms hardly at all (maybe a table of some sort now and then). I don't use discrete math. I don't use any sort of advanced mathematics beyond algebra. I don't use AI in any way (nor do much of anyone in the field). Security is about learning the algorithms and nothing else, which you can learn at any time in a few hours by opening a book. You're still in your undergrad, so you are very biased. While it is important to understand those theory classes, they are useless in the end. The guy was asking about what he should study in his off year. I would never recommend opening a theory book and studying it, as it's not useful outside of understanding. There is almost no implementation of it unless you're writing a compiler or doing theoretical research. I got my masters at University of Chicago (also very good), and I can honestly say the only useful thing I learned in my masters was about parallel programming, some advanced operating systems and computer architecture, and that's about it. I basically had the same problem  While at school, I was told to study hard discrete math, algorithms, data structures .. even algorithmics for NP problems, advanced computability theory etc. I truly believed that I could learn how to program in short period, but knowledge that I was getting would last and benefit me (I would land better/more qualified jobs - yeah). I may call it The blindness of theoretical CS. What I know now is complete opposite - you can learn math and algos quickly (any research paper is comprehensible after all, if you stare long enough), but learning programming might take you 5 years AT LEAST. Fundamental problem is this - knowing programming language /= being good programmer. So yes, you can learn new 10 languages per year (or even more quickly), yet you may suck at programming so hard ...  That`s basically my problem - I can do fancy stuff with math, I know syntax of programming languages, I know how to use it, yet creating efficient, bug-free, ellegant and maintainable code is an art, which I don`t master yet. Btw. if you see spirited and talented CS grad that believes discrete math will make him substantially better - just don`t crush his dreams, because he is doing what he believes in, and that`s what matters. He will eventually find out  Or maybe, just maybe, both are true ? Most people objected to him saying that those topics are of no use for a programmer. Yes, for 90% of programmers they are of little to no use. But there are many non-academic jobs that require you to know both. You need practice to become a good programmer, but that is something school won't teach you anyway. What they can teach you is how to think about abstract issues and some topics of computer science. Person who learned discrete math, complexity and computability and all those other "useless" topics WILL be (statistically) better than the one who did not. Both will require extensive programming practice to become good programmers, most of it out of school, but the first will also have learned how to properly think about problems. And if he is lucky he might get one of those jobs where you are not a coding monkey from the get go. This is true as well, many jobs do require more than just "coding". But as I was responding to someone who told a person taking a year off of school to study theory and not coding, I believe my response was accurate. I don't think telling a second year university student to look at theory is a good idea. I think even anyone with some experience can tell you that. Trying to keep up on your studies while taking a year off by reading theory books is a really really bad idea. I do believe there are many extremely important advanced courses in computer science that do involve some theory, but they also involve implementing those theoretical ideas. Well I disagree with you as he will not learn how to be a good programmer by doing pet projects (he might but that would be a rare occurance). Team projects and "real-life" projects are the lessons that teach you how to be a good programmer in the sense that you talk about. It is very unlikely he will have opportunity to do so. Much better to spend the time on learning non-programming things that interest him and do programming only as far as necessary to realize those things. For example, interested in neural networks, learn about them and program some. And so on.
So your idea of a "pet project" is a valid publication that he can put on his resume for job/university applications? But instead he should be programming artificial neural networks? Ok...
|
On February 16 2013 04:26 aurum510 wrote:Show nested quote +On February 16 2013 04:12 wherebugsgo wrote:On February 16 2013 01:49 YiSunsin wrote:On February 16 2013 00:50 wherebugsgo wrote: He didn't say that programming is not important, and your indication that "it isn't worth learning any of the things you mention" is completely wrong. The most sought-after applicants in EECS fields right out of university are generally those who have the strongest fundamental skills. This is particularly true for the better jobs. If you want to have any sort of impact beyond a simple coding job then everything outside of programming is very very important. That would be soooo nice if only it was true. It is true where I go to school, and where I intend to work/pursue research. (Silicon Valley) Here at Berkeley basically everyone in the CS department learns how to program well. If you haven't learned that by the time you're through this program you basically didn't learn anything. One of the data structures professors is notorious for drilling style into the heads of programmers. The code has to be readable by his standards (i.e. functions have a max length of 60 some lines, lines have a max length of 80 chars, no magic numbers, have to add spaces before and after all transitive operations, all methods and classes must be commented, and many other things.) or you cannot submit it (the system forces a style check prior to compilation) That alone forces you to learn to code efficiently, concisely, and readably. IMO at any half decent school you should be able to learn how to program well if you pay attention and are motivated. The bigger problem is for those who learn on their own, but to be honest I would expect them to be lacking in other skills, not programming skills. Generally people who are interested enough to learn how to program on their own at least have the motivation to learn programming specifically. From a personal experience, seeing people come in from outside schools during summer, this generally holds true. I have had multiple professors (and some fellow students and job interviewers and company representatives) stress that it's not necessarily all about what languages you know-if you need to learn a language you can do it. Programming skill carries over from language to language. It's sort of common sense, really; programming ideals transcend beyond the languages themselves. It's pretty normal to have the data structures professor making very strict requirements. That's usually where people drop out if they will drop out of school. And if you read what he said, he said nothing about knowing many programming languages being good. Ask any professional, no matter what experience or what age, if he/she likes the code he/she wrote 5 years ago. It will almost always be a resounding "no", because programming is a lifelong process of learning. Programming skills carry from language to language, but learning those skills takes a lifetime. Hell, I guarantee your data structures professor will not like the code he/she wrote 5 years ago, even though he/she has had years and years to refine the exact same code.
right, but that doesn't mean it's the only thing that matters!
He was asking about what classes to take, and I already showed how in your second or third year a heavily coding-based class is only maybe one or two out of your 3-4.
The core is generally heavily coding based, and that's a max of 4 semesters usually. The rest is all field-specific. The simple fact is you won't graduate with a CS degree if you do nothing but code. It's just not possible.
If he finds his programming skills to be lacking or inadequate or whatever, then he should be spending time coding outside of class, or for fun, not saying "screw this other shit since I'll never use it anyway" when he doesn't even know that to begin with.
e: and for fun obviously what would be most productive would be to join a project that he is interested in, that he can later use for his experience/resume/whatever
|
0.000133 exactly the same as 1.33 * 10^-4? -- yes, it is, but I'm still confused. I'm asked for 'more precision'. Maybe GMP? But then again, I have no idea how to do this in C GMP: division = (double)a / (double)b; answer = (int)(division * pow(10, n)) % 10;
The C module I'm taking really lacks explanation for such matter.
|
On February 16 2013 04:38 darkness wrote: 0.000133 exactly the same as 1.33 * 10^-4? -- yes, it is, but I'm still confused. I'm asked for 'more precision'. Maybe GMP? But then again, I have no idea how to do this in C GMP: division = (double)a / (double)b; answer = (int)(division * pow(10, n)) % 10;
The C module I'm taking really lacks explanation for such matter.
were you trying to get the 6th digit or the 5th digit?
You returned the 6th digit.
E: I should say, you returned the number with precision to the 6th digit.
|
On February 16 2013 04:40 wherebugsgo wrote:Show nested quote +On February 16 2013 04:38 darkness wrote: 0.000133 exactly the same as 1.33 * 10^-4? -- yes, it is, but I'm still confused. I'm asked for 'more precision'. Maybe GMP? But then again, I have no idea how to do this in C GMP: division = (double)a / (double)b; answer = (int)(division * pow(10, n)) % 10;
The C module I'm taking really lacks explanation for such matter. were you trying to get the 6th digit or the 5th digit? You returned the 6th digit. E: I should say, you returned the number with precision to the 6th digit.
The 5th one. Strange because it usually works for smaller numbers. E.g. 8 13 5 input
I think there's actually a bug or something. It says -8 when typing 8 13 10
|
Google overflow. Like I mentioned several times already.
|
On February 16 2013 04:12 wherebugsgo wrote:Show nested quote +On February 16 2013 01:49 YiSunsin wrote:On February 16 2013 00:50 wherebugsgo wrote: He didn't say that programming is not important, and your indication that "it isn't worth learning any of the things you mention" is completely wrong. The most sought-after applicants in EECS fields right out of university are generally those who have the strongest fundamental skills. This is particularly true for the better jobs. If you want to have any sort of impact beyond a simple coding job then everything outside of programming is very very important. That would be soooo nice if only it was true. It is true where I go to school, and where I intend to work/pursue research. (Silicon Valley) Here at Berkeley basically everyone in the CS department learns how to program well. If you haven't learned that by the time you're through this program you basically didn't learn anything. One of the data structures professors is notorious for drilling style into the heads of programmers. The code has to be readable by his standards (i.e. functions have a max length of 60 some lines, lines have a max length of 80 chars, no magic numbers, have to add spaces before and after all transitive operations, all methods and classes must be commented, and many other things.) or you cannot submit it (the system forces a style check prior to compilation) That alone forces you to learn to code efficiently, concisely, and readably. IMO at any half decent school you should be able to learn how to program well if you pay attention and are motivated. The bigger problem is for those who learn on their own, but to be honest I would expect them to be lacking in other skills, not programming skills. Generally people who are interested enough to learn how to program on their own at least have the motivation to learn programming specifically. From a personal experience, seeing people come in from outside schools during summer, this generally holds true.
Just to put it out there - we are talking about programming skills that take lifetime to learn, do you think setting 80 char ruler in editor is one of them ? 
So, let me clarify. To get a good job in CS (say as a programmer), it is necessary, BUT NOT SUFFICIENT, condition to go through painful process of learning math, data structures etc. Nobody says they are useless - because if you don`t know it, you are behind. Note that it is NOT the case that if you know them, you are ahead (and will therefore land a good job). Makes sense ?
As for programming - you cannot learn programming at school, (almost) no matter how good the school is (this is not to say schools are equal. Better scool is better, like yours). First, scale of real world applications is orders of magnitude bigger, and you will face problems you wouldn`t believe would be problems at all. I think eventually the difference is pretty simple - while at school, you focus on the problem and you are isolated from environment. In practice, there is almost never the right answer to the problems in programming because you are making choices with incomplete information. It takes years of practice and experience to make educated "decision" on what is the best tool/paradigm/design/optimisation/ etc. Also, programming skills is not only knowledge you learn (thats easy part) but those hacker habits that come with years.
Of course there is exception to every rule and yes, you can learn some programming at school, if you take internship program in some big company and code something important for them (e.g. http://bird.network.cz/ originally school project supported by top level domain maintainer and research center - example from my area). BUT, you never learn how to program only by doing class projects.
Also, let me say that I have actually a good friend, who is a big deal in theoretical CS - he studies both CS and Math unnder two most renowned professors in this country. His bachelor thesis consultant was pioneer in Quantum computing and cryptography. He passed like 80% of courses at our faculty (no idea how he could study that much). We both got internship at big company and guess what ? When I talked to him, he felt embarrased, that people he teased at school are actually way better with anything in practice than he is. And he quit 
So, nobody`s saying that knowing math is not good just don`t make a big deal out of it or you will be disappointed.
|
On February 16 2013 02:14 mcc wrote:Show nested quote +On February 16 2013 01:32 YiSunsin wrote:On February 16 2013 01:06 aurum510 wrote:On February 16 2013 00:50 wherebugsgo wrote:On February 15 2013 13:17 aurum510 wrote:On February 15 2013 12:56 Abductedonut wrote:On February 15 2013 12:18 Cyx. wrote: Hey guys, I'm currently taking a year off of university and I'm going back into second-year software engineering next year. I have a decent grasp of some of the basics of the programming I'm going to be learning next year (a university course in C++ last year and some hobby programming in Python in highschool and C++/Python in university) but I want to get a bit of a head start on some of the topics I'm going to be learning next year like pointers, sorting algorithms, basic Java programming... basically second-year CS courses.
Are there any good places on the internet to help me get the kind of head start I want? At this point I'm basically reduced to reading my roommate's textbooks (he's in the second year of the program right now) and working through his old lab exercises and stuff from the fall, which is actually pretty good practice except that I have a hard time just picking up his textbook and figuring out what I want to be looking at unless he's right there with me. Also, as someone who's planning on being a civil engineer, not a software engineer, he doesn't really understand a lot of the stuff on the level that I want to and even he and the textbook combined can't really give me everything I need.
I know it's a bit of a broad question so any help you can give is appreciated =) I'm basically looking for anything that has some explanation of the stuff I'm going to be looking at next year but most importantly some exercises and things I can be doing - it's really hard to apply a lot of the things I see without that concrete 'write a piece of code that does X' component. I hate to sound like a douche, but being a computer scientist and a software engineer isn't all about programming. Programming is a secondary concern for computer scientists. It's phase two. If you want to learn how to program, there are thousands of tutorials and programming guides online. If you're feeling like a pirate, you could even pirate some books. And they're all great for programming. In short, if you want to program, just program. Learning how to program is linear only for a short while. You're on your own from there. If you want a TRUE CS education, you're going to have to broaden your horizons as to what computer science really is. You need to learn math, physics, electrical engineering, and computer science. (Look at MIT's degrees... why do you think their only degree program is EECS?) Don't worry too much about programming. Programming is pretty easy. Focus on math. Math is at the center of being a computer scientist. Learn calculus 1,2,3, linear algebra and differential equations. Take discrete math as a learn linear algebra. Take a statistics class. (It's pointless learning algorithms if you don't know discrete math and statistics) If you get good at solving difficult math problems, you will get good at solving difficult computer science problems. As I'm writing this I realize it's getting too long. There's too much to say about learning CS. Just check out MIT's opencourseware. It's good. http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/ You definitely do sound like a douche. While programming isn't all of what a CS/SE student should focus on, it's not worth any effort to learn any of the things you mention. I don't think I've met a software engineer who has used any calculus, linear algebra, or differential equations in their life. I don't really call discrete math mathematics either, as opposed to simple mind numbing logic. Algorithms is also important to software engineers, but honestly, once you recognize when to use what algorithms, it's pretty straightforward. And unless you're doing embedded systems, you don't need physics or electrical engineering in any way. Find me a software engineer who makes a living doing something other than programming... And basically all software architects were software engineers at some point... programming. It's pretty friggen hard to find a job with a CS degree that doesn't involve programming. Maybe some sort of theoretical research at a university, but that's about it (excluding the aforementioned architects and possibly some network jobs). he may have come off like a douche, but you come off pretty naive. He didn't say that programming is not important, and your indication that "it isn't worth learning any of the things you mention" is completely wrong. The most sought-after applicants in EECS fields right out of university are generally those who have the strongest fundamental skills. This is particularly true for the better jobs. If you want to have any sort of impact beyond a simple coding job then everything outside of programming is very very important. At most good schools you will learn programming no matter what if you do EECS. In general I would say that you would learn Python, and at least two of Java/C/C++ just by taking classes. I know I did-I have a strong grasp of Scheme, Python, Java, and C just by taking the core classes. You'd probably also have the opportunity/be required to learn HTML, Javascript, mobile app development, scripting, etc. Once you take the core classes you don't need to learn how to program. You can pretty much pick up a language and learn it within a month or less. Language to language it's mostly syntax and minor other differences; learning to code in a different language after you've already learned the basics of good programming practices is simply about opening a reference text and hammering out the details. The core logic will all be there already. As for what the guy was asking about in the first place, for second year EECS courses, usually only one or two of them are heavily coding-based. For example discrete mathematics, circuit theory and digital signals theory are all 1st/2nd year courses and none of them have any programming at all. They're also core. For third year courses such as algorithms, AI, and computer security, the programming is secondary or even tertiary to what you are actually learning. I'm taking an AI course right now and it's done in Python. From a programming perspective I'm not using anything that I didn't learn in my first two CS classes; all you truly need from a programming perspective is a background in object oriented programming and data structures. Everything else is all search algorithms, trees, optimization, probability, etc. e: I may be considerably biased though, seeing as I am lucky to be a part of one of the best EECS programs in the country (or even the world) here at Berkeley. Oh please. I work as an embedded SE, and I can honestly say even I don't use any physics I learned in college. I don't use algorithms hardly at all (maybe a table of some sort now and then). I don't use discrete math. I don't use any sort of advanced mathematics beyond algebra. I don't use AI in any way (nor do much of anyone in the field). Security is about learning the algorithms and nothing else, which you can learn at any time in a few hours by opening a book. You're still in your undergrad, so you are very biased. While it is important to understand those theory classes, they are useless in the end. The guy was asking about what he should study in his off year. I would never recommend opening a theory book and studying it, as it's not useful outside of understanding. There is almost no implementation of it unless you're writing a compiler or doing theoretical research. I got my masters at University of Chicago (also very good), and I can honestly say the only useful thing I learned in my masters was about parallel programming, some advanced operating systems and computer architecture, and that's about it. I basically had the same problem  While at school, I was told to study hard discrete math, algorithms, data structures .. even algorithmics for NP problems, advanced computability theory etc. I truly believed that I could learn how to program in short period, but knowledge that I was getting would last and benefit me (I would land better/more qualified jobs - yeah). I may call it The blindness of theoretical CS. What I know now is complete opposite - you can learn math and algos quickly (any research paper is comprehensible after all, if you stare long enough), but learning programming might take you 5 years AT LEAST. Fundamental problem is this - knowing programming language /= being good programmer. So yes, you can learn new 10 languages per year (or even more quickly), yet you may suck at programming so hard ...  That`s basically my problem - I can do fancy stuff with math, I know syntax of programming languages, I know how to use it, yet creating efficient, bug-free, ellegant and maintainable code is an art, which I don`t master yet. Btw. if you see spirited and talented CS grad that believes discrete math will make him substantially better - just don`t crush his dreams, because he is doing what he believes in, and that`s what matters. He will eventually find out  Or maybe, just maybe, both are true ? Most people objected to him saying that those topics are of no use for a programmer. Yes, for 90% of programmers they are of little to no use. But there are many non-academic jobs that require you to know both. You need practice to become a good programmer, but that is something school won't teach you anyway. What they can teach you is how to think about abstract issues and some topics of computer science. Person who learned discrete math, complexity and computability and all those other "useless" topics WILL be (statistically) better than the one who did not. Both will require extensive programming practice to become good programmers, most of it out of school, but the first will also have learned how to properly think about problems. And if he is lucky he might get one of those jobs where you are not a coding monkey from the get go. Couldn`t agree more.
|
so, as I am learning the basics of C, the rest of my school year will be spent learning Objective C and doing some app development, with the final project being to make an actual app. Next year the course option is an AP course introducing us to Java. I'm totally going to sign up, and probably study some more Java and C in the coming Summer. 
Had some fun with some of the programs and quizzes we've done so far! And I can't help but thank you guys for the help I've gotten. I am so glad this thread was made
|
On February 16 2013 06:17 YiSunsin wrote:Show nested quote +On February 16 2013 04:12 wherebugsgo wrote:On February 16 2013 01:49 YiSunsin wrote:On February 16 2013 00:50 wherebugsgo wrote: He didn't say that programming is not important, and your indication that "it isn't worth learning any of the things you mention" is completely wrong. The most sought-after applicants in EECS fields right out of university are generally those who have the strongest fundamental skills. This is particularly true for the better jobs. If you want to have any sort of impact beyond a simple coding job then everything outside of programming is very very important. That would be soooo nice if only it was true. It is true where I go to school, and where I intend to work/pursue research. (Silicon Valley) Here at Berkeley basically everyone in the CS department learns how to program well. If you haven't learned that by the time you're through this program you basically didn't learn anything. One of the data structures professors is notorious for drilling style into the heads of programmers. The code has to be readable by his standards (i.e. functions have a max length of 60 some lines, lines have a max length of 80 chars, no magic numbers, have to add spaces before and after all transitive operations, all methods and classes must be commented, and many other things.) or you cannot submit it (the system forces a style check prior to compilation) That alone forces you to learn to code efficiently, concisely, and readably. IMO at any half decent school you should be able to learn how to program well if you pay attention and are motivated. The bigger problem is for those who learn on their own, but to be honest I would expect them to be lacking in other skills, not programming skills. Generally people who are interested enough to learn how to program on their own at least have the motivation to learn programming specifically. From a personal experience, seeing people come in from outside schools during summer, this generally holds true. Just to put it out there - we are talking about programming skills that take lifetime to learn, do you think setting 80 char ruler in editor is one of them ?  So, let me clarify. To get a good job in CS (say as a programmer), it is necessary, BUT NOT SUFFICIENT, condition to go through painful process of learning math, data structures etc. Nobody says they are useless - because if you don`t know it, you are behind. Note that it is NOT the case that if you know them, you are ahead (and will therefore land a good job). Makes sense ?
That's not what the other guy was saying.
I think you're replying to the wrong person here; I don't disagree with anything you've said.
On February 16 2013 06:17 YiSunsin wrote:As for programming - you cannot learn programming at school, (almost) no matter how good the school is (this is not to say schools are equal. Better scool is better, like yours). First, scale of real world applications is orders of magnitude bigger, and you will face problems you wouldn`t believe would be problems at all. I think eventually the difference is pretty simple - while at school, you focus on the problem and you are isolated from environment. In practice, there is almost never the right answer to the problems in programming because you are making choices with incomplete information. It takes years of practice and experience to make educated "decision" on what is the best tool/paradigm/design/optimisation/ etc. Also, programming skills is not only knowledge you learn (thats easy part) but those hacker habits that come with years. Of course there is exception to every rule and yes, you can learn some programming at school, if you take internship program in some big company and code something important for them (e.g. http://bird.network.cz/ originally school project supported by top level domain maintainer and research center - example from my area). BUT, you never learn how to program only by doing class projects. Also, let me say that I have actually a good friend, who is a big deal in theoretical CS - he studies both CS and Math unnder two most renowned professors in this country. His bachelor thesis consultant was pioneer in Quantum computing and cryptography. He passed like 80% of courses at our faculty (no idea how he could study that much). We both got internship at big company and guess what ? When I talked to him, he felt embarrased, that people he teased at school are actually way better with anything in practice than he is. And he quit  So, nobody`s saying that knowing math is not good just don`t make a big deal out of it or you will be disappointed.
right but there's nothing you can do in school to learn any of those things.
His original question was, "what should I plan on taking next semester," not "what do I need to succeed at programming."
You can't graduate CS without taking those classes, so all of these points are completely moot. You need those classes and doing well in those classes can only help you. If you fuck up those classes the only thing you have to fall back on is your programming ability, which as we've already pointed out, only improves depending on your ability and motivation in school; it's dependent later more on what types of projects you join and experience (something I'm not disputing.)
But hey, that'll happen no matter what. Relearning fundamentals like theory is extra work when you could have simply done it in school in the first place.
|
On February 16 2013 00:11 Rixxe wrote: Does anyone have any experience with Oracle at all? Curious how different it is to SAS or SQL, and what plus sides it might have to it from people that deal with the 11g database on a daily basis. Also as far as i can figure out, you can use PL\SQL to query the database, but does it have any other languages that can be used with it?
Generic Question: Seems to be a lot less people learning 'data' languages, or working with databases these days from what i've read. Why do people think that is? I do almost exclusively PL/SQL at the moment.
SQL is pretty much SQL regardless of the flavor. PL/SQL incorporates SQL, but adds additional capabilities around it. Ideally you still try to do as much in SQL as you can to let the optimizer do its magic and to cut down on context switching (PL/SQL -> SQL or vice versa). It's much more efficient to do a single update with a few case statements than to iterate all the results (even in bulk collections) and do calculations inside the loop. Sometimes you can't avoid it, though.
There are a number of differences / nuances from SAS. As I understand it, SAS has three levels of "missingness," while Oracle just has the one (an empty field is always just null*). I haven't really worked with SAS enough personally to itemize the differences.
* There may be a database option you can use to preserve empty strings, but by default they become NULL.
You can call Java classes through SQL procedures pretty seamlessly. If your Oracle instance is on a Unix/Linux server, you can write a Java procedure that can then execute various other programs (e.g. run a Perl script) -- beware of security issues. I guess a Windows server could still do that, but I haven't tried.
Anyway:
DECLARE V_PERCENT_INCREASE NUMBER(4,1) := .1; BEGIN FOR CUR_REC IN (SELECT * FROM EMPLOYEES) LOOP UPDATE EMPLOYEES SET EMPLOYEE_SALARY = EMPLOYEE_SALARY * V_PERCENT_INCREASE WHERE EMPLOYEE_ID = CUR_REC.EMPLOYEE_ID; END LOOP; END;
This is an example in how NOT to code PL/SQL. I couldn't think of a better example, sorry . Basically this is a simple implicit cursor that would iterate the imaginary EMPLOYEES table and update each record one by one, when you could just perform the same action much more efficiently without the use of PL/SQL.
DECLARE V_PERCENT_INCREASE NUMBER(4,1) := .1; BEGIN UPDATE EMPLOYEES SET EMPLOYEE_SALARY = EMPLOYEE_SALARY * V_PERCENT_INCREASE; END;
Or let's get more complex:
Create a temporary table, a java class, and a PL/SQL procedure used to call that java class.
create global temporary table DIR_LIST ( filename varchar2(255) ) on commit delete rows /
create or replace and compile java source named "DirList" as import java.io.*; import java.sql.*;
public class DirList { public static void getList(String directory) throws SQLException { File path = new File( directory ); String[] list = path.list(); String element; for(int i = 0; i < list.length; i++) { element = list[i]; #sql { INSERT INTO DIR_LIST (FILENAME) VALUES (:element) }; } } } /
create or replace procedure get_dir_list( p_directory in varchar2 ) as language java name 'DirList.getList( java.lang.String )'; /
BEGIN GET_DIR_LIST('SOME_DIRECTORY');
UPDATE EMPLOYEES SET EMPLOYEE_SALARY = EMPLOYEE_SALARY * .1 WHERE EMPLOYEE_FILE IN ( SELECT FILENAME FROM DIR_LIST ) END;
This is an arbitrary example where you're looking in a particular directory (using Java) to see if an employee's file is there and, if so, updating their salary.
Maybe this will shed some light on things. It's hard to come up with decent examples on the fly.
Also, one of the major "plus sides" of using PL/SQL directly is that if you can get things into efficient statements, then you can process enormous datasets in relatively small amounts of time and often do so with less overhead or security issues. It also helps you to separate your data or business layers, since your front end just has to call the existing procedure.
|
On February 16 2013 04:12 wherebugsgo wrote:Show nested quote +On February 16 2013 04:00 darkness wrote:Guys I need your help. I currently have this code: int main(void) { /* input variables */ float a, b; int n; /* division = a/b */ long double division; int answer;
/* get input */ scanf("%f %f %d", &a, &b, &n);
// calculate a/b division = (long double)a / (long double)b; answer = (int)(division * pow(10, n)) % 10;
printf("%Lf\n", division);
/* output */ printf("%d\n", answer); /* successful execution */ return 0; }
But it doesn't work properly when I write: 8 60000 5 In other words, 8/60000 returns this: -bash-4.1$ ./a.out 8 60000 5 0.000133 <--- incorrect result of 8/60000 3 The goal of the program is to find the n-th digit after the decimal point, but the real problem right now is it doesn't calculate precisely. According to MS Calc, the result should be: 1,3333333333333333333333333333333e-4 uhhh isn't 0.000133 exactly the same as 1.33 * 10^-4?
On February 16 2013 04:38 darkness wrote: 0.000133 exactly the same as 1.33 * 10^-4? -- yes, it is, but I'm still confused. I'm asked for 'more precision'. Maybe GMP? But then again, I have no idea how to do this in C GMP: division = (double)a / (double)b; answer = (int)(division * pow(10, n)) % 10;
The C module I'm taking really lacks explanation for such matter.
Hey, you need to read up on ieee 754. A computer*** doesn't actually represent a decimal number in decimal. It represents it in binary using ieee 754. This destroys a lot of precision. Please read earlier posts in this thread from a few pages back for the correct approach to dark's problem:
On February 14 2013 09:38 delHospital wrote:Show nested quote +On February 14 2013 06:34 darkness wrote:On February 14 2013 04:36 CountChocula wrote:On February 14 2013 04:29 darkness wrote:On February 14 2013 02:56 supereddie wrote:On February 13 2013 13:10 AmericanUmlaut wrote:On February 13 2013 07:43 darkness wrote:On February 13 2013 05:32 supereddie wrote:On February 13 2013 04:18 darkness wrote:Hey guys, thanks for helping me last time. I have another thing that I struggle with. Say you have a double variable with this value: double value = a / b; let's say 'value = 2.283214570' after division 'a' and 'b' are both integers. Now, my problem is that I need to print the n-th digit of this double variable. E.g. n = 2 Then output would be '8' because it's the 2nd digit after decimal point. I've thought about double -> string, but my implementation doesn't work for integers that are up to 60000 which is a requirement. Just use math? Multiply 'value' with 10^decimalnumber (so you have 228.3214570). Take the int part of it (=228). Do it again with decimalnumber - 1 and take int part: 22. Multiply by 10 = 220. Then just substract the two: 228 - 220 = 8  Something like double value = a / b; // 2.283214570 double x = Math.Truncate(value * Math.Pow(10, decimalnumber)); // 228 double y = Math.Truncate(value * Math.Pow(10, decimalnumber - 1)) * 10; // 220 double digit = x - y; // 228 - 220 = 8;
Be careful about overflows etc. Awesome. This code only needs slight modification to make it work though. Math.Truncate = trunc in C Math.Pow = pow in C But yeah, this is irrelevant.  Thanks. Edit: Actually, it seems I've forgotten to say it's for C, but yeah... it's obvious how to fix this.  Edit 2: You may also want to change 'digit' to: int digit = (int)x - (int)y; because it's more natural for this scenario. That's a lot more complicated than it needs to be: int(value * pow(10, decimalnumber)) % 10
2.283214570 * 100 => 228.3214570 cast to int => 228 228 mod 10 => 8 Edit: Forgot to include "value" in the above :-/ Doh, ofcourse! How could I forget about the mod operator  Also, I am wondering now why my double 'value' sas only 6 decimal digits. This is what I do: int a, b; double value; scanf("%d %d", &a, &b); value = (double)a / (double) b; <---- only 6 decimal digits (e.g. 8/13) Even if I change 'int' to 'float, it is still the same. the double has a lot higher precision than gets displayed. printf will display 6 digits after the decimal point by default. if you want to display more decimal digits, you have to specify i.e. printf("%.9f", value) will give you 9 digits after the decimal point. int(value * pow(10, n)) % 10 you just need the one line that AmericanUmlaut provided. it does 3 things in this order: 1. multiply value by 10^n where n refers to the n'th digit you want (look up what pow function does if you don't know) 2. cast to int - he uses a different notation than the one you use. (int) x and int(x) mean the same thing 3. do % 10 which in math means "mod 10" 1. 2.283214570 * 100 => 228.3214570 2. cast to int => 228 3. 228 mod 10 => 8 Thanks. However, there may be a bug. It says -8 for decimalnumber >= 10. I guess there aren't enough decimal places? (int)(value * pow(10, decimalnumber)) % 10 Edit: C language Edit 2: My lecturer replied with: The precision requirement is very high, so built-in variables are not good enough. Could you give me a hint what to look for? GMP? I'd just write my own division function that works like long division and stops after finding the decimalnumber-th digit.
And my explanation of why the pow(10,...) solution that American Umlaut proposed fails if you have a high requirement of precision:
On February 14 2013 13:03 phar wrote:Show nested quote +On February 13 2013 13:10 AmericanUmlaut wrote:On February 13 2013 07:43 darkness wrote:On February 13 2013 05:32 supereddie wrote:On February 13 2013 04:18 darkness wrote:Hey guys, thanks for helping me last time. I have another thing that I struggle with. Say you have a double variable with this value: double value = a / b; let's say 'value = 2.283214570' after division 'a' and 'b' are both integers. Now, my problem is that I need to print the n-th digit of this double variable. E.g. n = 2 Then output would be '8' because it's the 2nd digit after decimal point. I've thought about double -> string, but my implementation doesn't work for integers that are up to 60000 which is a requirement. Just use math? Multiply 'value' with 10^decimalnumber (so you have 228.3214570). Take the int part of it (=228). Do it again with decimalnumber - 1 and take int part: 22. Multiply by 10 = 220. Then just substract the two: 228 - 220 = 8  Something like double value = a / b; // 2.283214570 double x = Math.Truncate(value * Math.Pow(10, decimalnumber)); // 228 double y = Math.Truncate(value * Math.Pow(10, decimalnumber - 1)) * 10; // 220 double digit = x - y; // 228 - 220 = 8;
Be careful about overflows etc. Awesome. This code only needs slight modification to make it work though. Math.Truncate = trunc in C Math.Pow = pow in C But yeah, this is irrelevant.  Thanks. Edit: Actually, it seems I've forgotten to say it's for C, but yeah... it's obvious how to fix this.  Edit 2: You may also want to change 'digit' to: int digit = (int)x - (int)y; because it's more natural for this scenario. That's a lot more complicated than it needs to be: int(value * pow(10, decimalnumber)) % 10
2.283214570 * 100 => 228.3214570 cast to int => 228 228 mod 10 => 8 Edit: Forgot to include "value" in the above :-/ I like this solution, assuming that we don't have to solve cases where iee754 fails. For example on the edge case of the original question of 1/60000 = 1.66666666666666674653622670643E-5, you get a failure for most values of n > 20, because you lose the precision. So if the requirement includes handling a or b > 60000 and n > 20, americanumlaut's solution fails. (or if the requirement is a, b ~3 and n > 60,000, it also fails - weren't exactly clear on which is which). If the requirement is only b ~ 60000 and n < 20, you're probably ok, but you might want to check the power multiplication edge cases, because you'll lose some precision there too. I like del's solution better, and it's probably what the prof is going for in this case. If the integer requirements are only up to 60k, you won't have any precision problems if you roll your own long division, whereas a 64 bit double isn't sufficient.
*** by "a computer" we're talking about the language of dark's problem, which is something like c, c++, java, or whatever the hell. There do exist programming languages in which you usually work with arbitrary precision, and there exist libraries for others that let you do arbitrary precision (e.g. java.math.bigdecimal), but those are probably out of scope.
|
Hey guys, I'm writing an extra credit program in C++ for my Discrete Structures class that involves taking a propositional logic formula and determining if it is a tautology or not. The user inputs the formula as a string using letters for variables and numbers for logic operations. 0 is negation, 1 is AND, 2 is OR, 3 is XOR, 4 is "implies", 5 is "is equivalent to."
For example, ( (A5B) 5 ( (A4B) 1 (B4A) ) ) is "((A is equivalent to B) is equivalent to ((A implies B) and (B implies A)))"
So the algorithm I have written out would process the string from left to right, keeping track of where the nearest left parentheses is until the right parentheses is reached. At that point, it will call a function to process the statement within the parentheses and replace the bracketed statement with T or F and rescan the string for the next statement. So for example, after the first iteration of the above formula, it would become (T 5 ( (A4B) 1 (B4A) ) ).
This feels very messy to me because I would have to repeat this process for every interpretation in the truth table. I have researched expression trees as a cleaner solution, but I am not quite sure how I could even begin to properly parse the formula to construct the tree. Processing it the way I described above seems like it would not work because you would have to construct the trees from the subtrees up to the root, then connect them. Does anyone have any resources or ideas of how I could approach this problem? I think this is a very interesting challenge and I am not looking for source code, just ideas and guidance. Thanks.
|
On February 16 2013 14:08 ambikalx wrote: Hey guys, I'm writing an extra credit program in C++ for my Discrete Structures class that involves taking a propositional logic formula and determining if it is a tautology or not. The user inputs the formula as a string using letters for variables and numbers for logic operations. 0 is negation, 1 is AND, 2 is OR, 3 is XOR, 4 is "implies", 5 is "is equivalent to."
For example, ( (A5B) 5 ( (A4B) 1 (B4A) ) ) is "((A is equivalent to B) is equivalent to ((A implies B) and (B implies A)))"
So the algorithm I have written out would process the string from left to right, keeping track of where the nearest left parentheses is until the right parentheses is reached. At that point, it will call a function to process the statement within the parentheses and replace the bracketed statement with T or F and rescan the string for the next statement. So for example, after the first iteration of the above formula, it would become (T 5 ( (A4B) 1 (B4A) ) ).
This feels very messy to me because I would have to repeat this process for every interpretation in the truth table. I have researched expression trees as a cleaner solution, but I am not quite sure how I could even begin to properly parse the formula to construct the tree. Processing it the way I described above seems like it would not work because you would have to construct the trees from the subtrees up to the root, then connect them. Does anyone have any resources or ideas of how I could approach this problem? I think this is a very interesting challenge and I am not looking for source code, just ideas and guidance. Thanks. I don't know much about Discrete Structures, but following the logic of what you described, you could do it more efficiently as a recursive function. Have the function break it down into individual chunks within parenthesis and aggregate each chunk back up. Instead of looking for the first closed parenthesis, it would simply call itself on any open parenthesis passing the remainder of the string. It would continue to do that until it gets its first closed parentheses, evaluate it, and pass the evaluation back up.
|
On February 16 2013 14:08 ambikalx wrote: Hey guys, I'm writing an extra credit program in C++ for my Discrete Structures class that involves taking a propositional logic formula and determining if it is a tautology or not. The user inputs the formula as a string using letters for variables and numbers for logic operations. 0 is negation, 1 is AND, 2 is OR, 3 is XOR, 4 is "implies", 5 is "is equivalent to."
For example, ( (A5B) 5 ( (A4B) 1 (B4A) ) ) is "((A is equivalent to B) is equivalent to ((A implies B) and (B implies A)))"
So the algorithm I have written out would process the string from left to right, keeping track of where the nearest left parentheses is until the right parentheses is reached. At that point, it will call a function to process the statement within the parentheses and replace the bracketed statement with T or F and rescan the string for the next statement. So for example, after the first iteration of the above formula, it would become (T 5 ( (A4B) 1 (B4A) ) ).
This feels very messy to me because I would have to repeat this process for every interpretation in the truth table. I have researched expression trees as a cleaner solution, but I am not quite sure how I could even begin to properly parse the formula to construct the tree. Processing it the way I described above seems like it would not work because you would have to construct the trees from the subtrees up to the root, then connect them. Does anyone have any resources or ideas of how I could approach this problem? I think this is a very interesting challenge and I am not looking for source code, just ideas and guidance. Thanks. Just a small idea, maybe change the representation to prefix or postfix notation if allowed by the assignment So something like : 5(5AB)(1(4AB)(4BA)). Infix notation is terrible, I have no idea why it is used everywhere, it is so unfriendly for us programmers 
But of course you can parse the infix notation also to create the expression tree recursively or without recursion. Just realize what are the invariants at each step. When you are examining (sub)formula there are 3 possibilities 1) it starts with 0 so 0X - just put the 0 at the root of the expression tree and parse X and put it as a subtree 2) it is in the form of (X) - well parse X and you have a tree 3) it is in the form of X{1/2/3/4/5}Y - put the number as the root of the expression tree and parse X and Y and put it as its two subtrees
Note that I assumed that every subformula is in brackets. If it is not the case, you have to make it more complex and possibly include operator priorities.
|
On February 16 2013 14:08 ambikalx wrote: Hey guys, I'm writing an extra credit program in C++ for my Discrete Structures class that involves taking a propositional logic formula and determining if it is a tautology or not. The user inputs the formula as a string using letters for variables and numbers for logic operations. 0 is negation, 1 is AND, 2 is OR, 3 is XOR, 4 is "implies", 5 is "is equivalent to."
For example, ( (A5B) 5 ( (A4B) 1 (B4A) ) ) is "((A is equivalent to B) is equivalent to ((A implies B) and (B implies A)))"
So the algorithm I have written out would process the string from left to right, keeping track of where the nearest left parentheses is until the right parentheses is reached. At that point, it will call a function to process the statement within the parentheses and replace the bracketed statement with T or F and rescan the string for the next statement. So for example, after the first iteration of the above formula, it would become (T 5 ( (A4B) 1 (B4A) ) ).
This feels very messy to me because I would have to repeat this process for every interpretation in the truth table. I have researched expression trees as a cleaner solution, but I am not quite sure how I could even begin to properly parse the formula to construct the tree. Processing it the way I described above seems like it would not work because you would have to construct the trees from the subtrees up to the root, then connect them. Does anyone have any resources or ideas of how I could approach this problem? I think this is a very interesting challenge and I am not looking for source code, just ideas and guidance. Thanks. Wikipedia has a decent example of a recursive descent parser: http://en.wikipedia.org/wiki/Recursive_descent_parser
Its a fairly easy parser type to write by hand, and (assuming all operators have equal precedence) it shouldn't be too hard to create one for this particular use case.
|
On February 16 2013 04:12 wherebugsgo wrote:Show nested quote +On February 16 2013 01:49 YiSunsin wrote:On February 16 2013 00:50 wherebugsgo wrote: He didn't say that programming is not important, and your indication that "it isn't worth learning any of the things you mention" is completely wrong. The most sought-after applicants in EECS fields right out of university are generally those who have the strongest fundamental skills. This is particularly true for the better jobs. If you want to have any sort of impact beyond a simple coding job then everything outside of programming is very very important. That would be soooo nice if only it was true. It is true where I go to school, and where I intend to work/pursue research. (Silicon Valley) Here at Berkeley basically everyone in the CS department learns how to program well. If you haven't learned that by the time you're through this program you basically didn't learn anything. One of the data structures professors is notorious for drilling style into the heads of programmers. The code has to be readable by his standards (i.e. functions have a max length of 60 some lines, lines have a max length of 80 chars, no magic numbers, have to add spaces before and after all transitive operations, all methods and classes must be commented, and many other things.) or you cannot submit it (the system forces a style check prior to compilation) That alone forces you to learn to code efficiently, concisely, and readably. IMO at any half decent school you should be able to learn how to program well if you pay attention and are motivated. The bigger problem is for those who learn on their own, but to be honest I would expect them to be lacking in other skills, not programming skills. Generally people who are interested enough to learn how to program on their own at least have the motivation to learn programming specifically. From a personal experience, seeing people come in from outside schools during summer, this generally holds true. I have had multiple professors (and some fellow students and job interviewers and company representatives) stress that it's not necessarily all about what languages you know-if you need to learn a language you can do it. Programming skill carries over from language to language. It's sort of common sense, really; programming ideals transcend beyond the languages themselves. You should really hold a full time job before you start talking as if you know that world. You simply don't realize how many people come out of school with a CS degree and no fucking clue how to code properly (which, btw, has almost nothing to do with strict formatting rules. You can easily write some pretty fucking stupid code that passes a formatter). You don't realize how useless a lot of your professors would be at doing non-academic work. And you seemingly don't realize that when other people in this thread mention "learning to program," they don't mean "learning what the syntax of a language is."
Programming skill is the single most important thing for being hired by any software company. Any theoretical stuff you actually need will come up naturally and you can learn it then; no point in wasting your time learning things just because you might need them "some day". Here's my advice to anyone still in school wondering how they should spend their time: Skip all of your classes, other than doing projects and taking tests. In all this new-found free time, pick a project that interests you and work on it until its either done or you lose interest. If you ever encounter a part of your project that you think is done sub-optimally, research ways in which it can be done better. Implement those. Be very critical of your own work, don't give in to laziness. Rinse, repeat with new projects until you get your degree. Apply for jobs with your wonderful portfolio of projects. Done.
This strategy worked wonderfully for me, and my only regret from college is that I didn't spend *more* time working on my own projects. College is likely one of the only times in your life where you'll have time, motivation, and a lack of financial pressure all at once. Don't squander that opportunity learning some stuff that probably won't be useful to you. Like I said, if you truly need it, there's nothing stopping you from learning it when you do.
|
|
|
|
|
|
|
|