|
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. |
Hahahaha that is simply BRILLIANT.
This one is so true:
// somedev1 - 6/7/02 Adding temporary tracking of Login screen // somedev2 - 5/22/07 Temporary my ass
|
So, I have one assignment left on my homework and I can't figure it out. It's an introduction course to C.
First half of the task was to make a program that lets the user enter 5 digits. The program will then sum them all together and write it out on one line. I figured that one out:
+ Show Spoiler + #include <stdio.h>
int main(void)
{
int a,b,c,d,e; scanf("%d %d %d %d %d",&a,&b,&c,&d,&e); int sum = a*10000+b*1000+c*100+d*10+e; printf("Summan blir %d", sum);
return 0;
}
The second half of the task is to make a program that lets the user enter a 5-digit number; For example: If you enter 12345, the program should write it out as 1, 2, 3, 4, 5. I cant figure this last part out.
|
You should use basic math to get those numbers. + Show Spoiler +25461/10000=2 25461%10000/1000=5...)
|
On September 22 2014 23:37 Isualin wrote:You should use basic math to get those numbers. + Show Spoiler +25461/10000=2 25461%10000/1000=5...)
You could also accept input as a string and go from there with strstr.
|
On September 22 2014 23:21 _Grazze_ wrote:So, I have one assignment left on my homework and I can't figure it out. It's an introduction course to C. First half of the task was to make a program that lets the user enter 5 digits. The program will then sum them all together and write it out on one line. I figured that one out: + Show Spoiler + #include <stdio.h>
int main(void)
{
int a,b,c,d,e; scanf("%d %d %d %d %d",&a,&b,&c,&d,&e); int sum = a*10000+b*1000+c*100+d*10+e; printf("Summan blir %d", sum);
return 0;
}
The second half of the task is to make a program that lets the user enter a 5-digit number; For example: If you enter 12345, the program should write it out as 1, 2, 3, 4, 5. I cant figure this last part out. You could read it in as one number and then separate each digit from the number using mod and division.
|
Thanks guys, I got it to work!
This is what I did:
+ Show Spoiler +
#include <stdio.h>
int main(void)
{
int a; printf("Please insert five digits"); scanf("%d", &a); int sum = a/10000; int sum1 = a%10000/1000; int sum2 = a%1000/100; int sum3 = a%100/10; int sum4 = a%10; printf("Summan blir %d, %d, %d, %d, %d", sum, sum1, sum2, sum3, sum4);
system("PAUSE"); return 0;
}
I have to write system("PAUSE"); because I program in Windows at my PC at home. Otherwise the execution window closes down.
|
On September 23 2014 03:06 _Grazze_ wrote:Thanks guys, I got it to work! This is what I did: + Show Spoiler +
#include <stdio.h>
int main(void)
{
int a; printf("Please insert five digits"); scanf("%d", &a); int sum = a/10000; int sum1 = a%10000/1000; int sum2 = a%1000/100; int sum3 = a%100/10; int sum4 = a%10; printf("Summan blir %d, %d, %d, %d, %d", sum, sum1, sum2, sum3, sum4);
system("PAUSE"); return 0;
}
I have to write system("PAUSE"); because I program in Windows at my PC at home. Otherwise the execution window closes down. You should not use sum1 sum2 as variable names for them, naming things right is really important. This is not about the class but for you and people you will work with.
|
Maybe Num1 is better, as in Number1, 2 3 4 etc
|
On September 23 2014 03:06 _Grazze_ wrote:Thanks guys, I got it to work! This is what I did: + Show Spoiler +
#include <stdio.h>
int main(void)
{
int a; printf("Please insert five digits"); scanf("%d", &a); int sum = a/10000; int sum1 = a%10000/1000; int sum2 = a%1000/100; int sum3 = a%100/10; int sum4 = a%10; printf("Summan blir %d, %d, %d, %d, %d", sum, sum1, sum2, sum3, sum4);
system("PAUSE"); return 0;
}
I have to write system("PAUSE"); because I program in Windows at my PC at home. Otherwise the execution window closes down. You could also run the program from windows cmd then it doesn't matter that the program exits, you still have the terminal window
|
Hi guys, so I am doing some c++. Basically I have a file with coordinates of points, which I read out and write in another file. For that I use sscanf and put them in a vector. My problem is that some point are right, for example I read out 2.0479 to 2.0479 but sometimes 2.047 becomes 2.0469999. Coul anyone help me please? thanks for reading
|
On September 23 2014 05:49 Saumure wrote:Hi guys, so I am doing some c++. Basically I have a file with coordinates of points, which I read out and write in another file. For that I use sscanf and put them in a vector. My problem is that some point are right, for example I read out 2.0479 to 2.0479 but sometimes 2.047 becomes 2.0469999. Coul anyone help me please? thanks for reading
Are you using floats instead or doubles for this? You can also try the setprecision thingie, so it won't round up your numbers (you can also read on fixed, scientific etc. at the bottom of the linked page).
In general, floats are evil.
|
On September 23 2014 06:17 Manit0u wrote:
In general, floats are evil.
I'd like to take a moment to really elaborate on this statement. You see, most generalizations that X feature is bad, or Y feature is evil are overreacting to one or two bad experiences with the feature. In this case, floating point arithmetic really is hard.
I'll begin by mentioning the biggest problem, portability. When using floating point arithmetic, in just about any language, it will do one or more of the following to each floating point number in your program:
software floating point - The software links with a floating point library to provide arithmetic functions that are typically slow and imprecise
compile-time folding - The compiler will try to do as much floating point arithmetic as possible
hardware floating point - The software links with libraries that pass the floating point arithmetic to hardware peripherals such as the GPU or a vectorizer
All three of these will yield different results for each calculation depending on the rounding modes and representation, and won't explicitly mention which one it decided to use. More recent languages may likely use whatever it thinks is the best option, software floating point for everything, but this results in slower arithmetic and a loss of compile-time optimizations.
If your compiler is built using software floating point libraries, but you link with a hardware floating point library for your game engine, then have compiler optimizations turned on, some of your floating point arithmetic will be compiled in using the truncation and rounding modes that the compiler has, and some of the floating point arithmetic will b the result of the hardware rounding modes and truncation. Small changes to your program could change the optimizations and drastically affect the results of your arithmetic.
Isn't it a bit ridiculous that you have to know what libraries your compiler was built with to understand your programs behavior? Furthermore, some compilers are linked with hardware floating point libraries, which means that compiling on one machine could yield different results than compiling on a different machine.
There are, of course, other factors when dealing with floating point numbers, such as speed of calculations (which can change drastically between builds and targets) and understanding special floating point capabilities of your target, since every SoC and CPU built changes what they support and how to round by default.
So, yes, Manitou is absolutely correct, floating point is evil. Most simple programs written using floating point arithmetic will probably be okay, but if you need any sort of reliable build or accurate results then floating point calculations become a minefield of possible issues.
On September 23 2014 06:17 Manit0u wrote:Show nested quote +On September 23 2014 05:49 Saumure wrote:Hi guys, so I am doing some c++. Basically I have a file with coordinates of points, which I read out and write in another file. For that I use sscanf and put them in a vector. My problem is that some point are right, for example I read out 2.0479 to 2.0479 but sometimes 2.047 becomes 2.0469999. Coul anyone help me please? thanks for reading Are you using floats instead or doubles for this? You can also try the setprecision thingie, so it won't round up your numbers (you can also read on fixed, scientific etc. at the bottom of the linked page).
The floating point representation has a hard time representing every single decimal floating point value, and can round or truncate in one of a few ways. This rounding happens in the conversion between binary to decimal. Seeing a floating point value off by .000001 is not bad. If you need to compare floats, check to make sure they are different by less than 1/2^8 or so.(0.002). There are IEEE standard for just how far off a representation is allowed to be (off the top of my head, a float can be 1/2^12 off).
Better yet, just set the resolution of your pixels such that they all land on whole numbers, and store everything in longs instead. For example, a pixel at location 2.0479, 2.1148 could be represented as 20479, 21148, where everything is multiplied by 10000. It's a good practice to get into.
|
Looking for some advice on the situation I'm in. Any input would be appreciated. I'm getting more and more frustrated by it every day and not sure what to do.
I work in a very small company (~12 people total), and only work with 1 other developer now (the other developer recently left and the boss decided not to replace him). For the first month I helped out a lot with getting used to our systems, showing resources available, our internal wiki which details a lot of our development standards and how to deal with situations with our systems that come up a lot, and even just walking her through how to troubleshoot some of the common issues we face. It's now the third month in and every day she is asking me to help her figure out some problem. The problems she's facing really is a matter of being good with a debugger and being a good problem solver and troubleshooter. She is sorely lacking in those last two qualities. Her programming skills also are woefully inadequate - she commonly writes repeated code across multiple files and her code is very inefficient. Every day I see a check-in of like 5 files with code copy and pasted across them all with maybe one or two line changes, or just a parameter change. It's just awful. I know I sound overly harsh, but it's just me and her in development.
Additionally, she lies to my boss about the situation with her code. She knows in our sandbox environment she ran into an issue that she later ran into production with her code, and told my boss the problem didn't occur when she tested it. Today we had a meeting and she lied to my boss again when he asked her if she was 100% confident a problem was because of a specific reason. She has no idea what is causing the problem, and we all know it. My boss kept trying to get her to admit that she isn't confident with the cause of the issue or how to even troubleshoot it, and she just walked around the issue. I could see his frustration and my headache was growing as well.
I'm tempted to email my boss telling him she needs to be replaced or moved to a different department or assigned different responsibilities. But honestly, her lack of integrity and accountability makes me want to push towards recommending firing her. But I don't know how to do this professionally.
HELPPPPP I hate working there because of working with her. I miss my old friend that left for a better opportunity recently (the previous developer).
|
Leave the company if you can, you seem to think you're a pretty decent developer, given the market it shouldn't be a problem to find another opportunity with better co-workers and more room to grow professionally.
|
If you're friends with her and not just coworkers then I would ask to talk to her and go over some of the problems you see she's having and ask what's up because you're worried this is having a negative effect at work, and see if she wants some more help doing stuff (friends right). Otherwise yeah you need to tell your boss and tell them you can't continue working there in these conditions.
|
|
On September 23 2014 10:47 Blisse wrote: If you're friends with her and not just coworkers then I would ask to talk to her and go over some of the problems you see she's having and ask what's up because you're worried this is having a negative effect at work, and see if she wants some more help doing stuff (friends right). Otherwise yeah you need to tell your boss and tell them you can't continue working there in these conditions. I dunno, maybe I'm paranoid.
I would not recommend talking to her, mostly because the last couple paragraphs read like an HR minefield. If you have a co-worker who is straight up lying about things, you start treading in very dangerous waters. I get that you probably don't have HR at a 12 person company, but if you think the problems are as bad as you describe, talk to your boss. Stuff like this is your boss's job to deal with. If you don't feel comfortable, you don't have to directly talk about deceitful behavior, but bring up changes that would have to happen to make accountability like this not be possible in the first place:
* instate code reviews, so you can't just check random-ass code into head without having another dev sign off on it. Also this provides a good way to give direct feedback on code quality and help others improve. * you could probably stand to have better test infrastructure, if it is true that your tests fail to catch stuff that happens in production (this is not always possible, but you'd be surprised how close you can get tests to catch real problems). Are your tests run automatically when stuff is checked in (maybe even before)?
Whatever you do, I would recommend having the discussion with your boss in person and not over email, because again, HR minefield.
Also, ask your friend for a recommendation to whatever place they went to. While your work environment might improve, I personally would not bet on it.
|
On September 23 2014 09:05 EscPlan9 wrote:Looking for some advice on the situation I'm in. Any input would be appreciated. I'm getting more and more frustrated by it every day and not sure what to do. I work in a very small company (~12 people total), and only work with 1 other developer now (the other developer recently left and the boss decided not to replace him). For the first month I helped out a lot with getting used to our systems, showing resources available, our internal wiki which details a lot of our development standards and how to deal with situations with our systems that come up a lot, and even just walking her through how to troubleshoot some of the common issues we face. It's now the third month in and every day she is asking me to help her figure out some problem. The problems she's facing really is a matter of being good with a debugger and being a good problem solver and troubleshooter. She is sorely lacking in those last two qualities. Her programming skills also are woefully inadequate - she commonly writes repeated code across multiple files and her code is very inefficient. Every day I see a check-in of like 5 files with code copy and pasted across them all with maybe one or two line changes, or just a parameter change. It's just awful. I know I sound overly harsh, but it's just me and her in development. Additionally, she lies to my boss about the situation with her code. She knows in our sandbox environment she ran into an issue that she later ran into production with her code, and told my boss the problem didn't occur when she tested it. Today we had a meeting and she lied to my boss again when he asked her if she was 100% confident a problem was because of a specific reason. She has no idea what is causing the problem, and we all know it. My boss kept trying to get her to admit that she isn't confident with the cause of the issue or how to even troubleshoot it, and she just walked around the issue. I could see his frustration and my headache was growing as well. I'm tempted to email my boss telling him she needs to be replaced or moved to a different department or assigned different responsibilities. But honestly, her lack of integrity and accountability makes me want to push towards recommending firing her. But I don't know how to do this professionally. HELPPPPP I hate working there because of working with her. I miss my old friend that left for a better opportunity recently (the previous developer). so your boss recognizes she is inept and you are the only other developer? I'd go talk to him directly and explain that the situation is unacceptable -- not because of her incompetence per se but because she refuses to recognize the incompetence, which puts development schedules behind and also leads to unnecessary uncertainty.
|
Thank you very much for help help everybody
|
Thanks for all the input everyone. I really appreciate it.
On September 23 2014 10:37 CatNzHat wrote: Leave the company if you can, you seem to think you're a pretty decent developer, given the market it shouldn't be a problem to find another opportunity with better co-workers and more room to grow professionally.
I agree, I have been revising my resume and started applying again recently. My friend that left the company is letting me use him as a reference, though he says the company he is with does not have another opening at this time to help me out there.
On September 23 2014 10:47 Blisse wrote: If you're friends with her and not just coworkers then I would ask to talk to her and go over some of the problems you see she's having and ask what's up because you're worried this is having a negative effect at work, and see if she wants some more help doing stuff (friends right). Otherwise yeah you need to tell your boss and tell them you can't continue working there in these conditions.
Not friends with her. She just happens to work here. We only talk work-related matters and never talk/see each other otherwise. To clarify that...
I have gone over with her multiple times the most common problem of hers is not recognizing when she needs to refactor code. Especially with the most simple kind - when you find yourself copy and pasting code essentially. She still routinely checks in repeated code within the same file or across multiple files. I IM her letting her know her code is doing the same thing but she rarely actually changes it. I sometimes just make the change myself to the code and commit it and tell her afterwards that is what I meant. And after months of this, I've just given up hope on her "getting it" so I just tell her "whatever works" and give up.
It's tough to just talk with my boss about this since well his office is like 30 feet away from where she sits, so she will certainly over hear it. That's why I was thinking email? But I'm seeing many of you tell me to talk with him personally.
On September 23 2014 13:37 phar wrote: I would not recommend talking to her, mostly because the last couple paragraphs read like an HR minefield. If you have a co-worker who is straight up lying about things, you start treading in very dangerous waters. I get that you probably don't have HR at a 12 person company, but if you think the problems are as bad as you describe, talk to your boss. Stuff like this is your boss's job to deal with. If you don't feel comfortable, you don't have to directly talk about deceitful behavior, but bring up changes that would have to happen to make accountability like this not be possible in the first place:
* instate code reviews, so you can't just check random-ass code into head without having another dev sign off on it. Also this provides a good way to give direct feedback on code quality and help others improve. * you could probably stand to have better test infrastructure, if it is true that your tests fail to catch stuff that happens in production (this is not always possible, but you'd be surprised how close you can get tests to catch real problems). Are your tests run automatically when stuff is checked in (maybe even before)?
Indeed, we do not really have HR here. Our "HR" person is also a manager of a department and the fiance of the CEO, who also is my boss (and everyone's boss). He's even the one that we as developers report to directly! We have no Development Manager / Supervisor / whatever. Just two developers and we report to the CEO.
I agree with your suggestions on code reviews and a better test infrastructure. For reasons I will not get into a lot of detail here, we have a minimalistic testing environment, and the only people who we could get to regularly unit test were me and the one developer who left. About Code Reviews, I'm cringing already thinking of going over all of her code. Remember we are the only two developers so we often have dozens of tasks on our plate and then daily random issues to check in on and put fires out.
|
|
|
|