Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Unimportant

Member
  • Content Count

    1,078
  • Joined

  • Last visited


Reputation Activity

  1. Informative
    Unimportant got a reaction from Hi P in Programming - Real world projects to practice   
    Try to write a C++ console application that plays a wave sound file. (The hard way, not by using the winapi "playsound" function)
    Open the file and parse the header to get the sound format/bitrate, etc. Teaches basic file IO and parsing. Read the contents of the file to memory (hint: std::vector) Use SDL audio to play back the audio. Teaches including and linking against a external library, reading documentation in figuring out how to use said library, etc. Write a neat RAII lock to engage when handling callbacks. Basic sample rate conversion when the wave file sample rate and the sample rate you got from SDL don't match (simple sample duplication/dropping will suffice). That'll get you going for a fair bit.
  2. Informative
    Unimportant got a reaction from fpo in Documentation (best practices discussion. No code)   
    Very, there's often more planning then code-writing going on. More precisely, the objects(classes) and their layout/relation to each other should be worked out before you start coding. You can't just get at it and start writing a bunch of classes haphazardly and only then consider how everything is going to fit together.
    Yes, classes should be lightly coupled, and for some classes that can be done. But in a large project there will be some tight coupling going on whether you like it or not and you better had planned for it.
     
    The actual pitch level isn't of much importance. Rather the fact that there is a elevator, it's pitch can be changed, what elements are affected by changes in the elevator, where does the elevator fit in, who's responsible for it, etc...
    Planning is a team effort over here, so when you're brought into a new project there's not yet been any planning - The team does the planning first before commencing.
    I've never been brought into a existing project where everyone was working without a plan - I don't think such projects would be long-lived anyway.
  3. Agree
    Unimportant got a reaction from RoseLuck462 in India Might Ban Cryptocurrency; Jail Sentences of up to 10 Years for Offenders   
    There are no "issues with the capitalist systems". Off all the systems capitalism is the best one, the problem is that we currently don't have capitalism. (by your own admission: private banks or central banks centrally controlling the money supply IS NOT capitalism #). Bitcoin is actually a attempt to solve that problem in a capitalistic way (decentralising - taking control away from the politbureau).
     
    # And yes, central control of the money is a big problem. Money is the lifeblood of an economy, he who controls it controls the entire economy - One cannot claim capitalism does not work as almost no-one here has ever seen capitalism in action. Capitalism simply cannot exist under a fiat money regime as we have today. So whatever you call the system we have today - it IS NOT capitalism.
  4. Informative
    Unimportant got a reaction from Hi P in C - Unsigned Char (format specifier)   
    The problem isn't in the printing but in the scanf.
     
    The output filename should immediately follow the -o switch:
    gcc -std=c99 -o test.exe test.c That should compile. Even then it might not work as intended however, as the problem would be in the scanf implementation of the runtime library that is being used. I'd not worry about it and just use a regular int and %d.
  5. Informative
    Unimportant got a reaction from Hi P in C - Unsigned Char (format specifier)   
    The hhu modifier was introduced in C99 and did not exist earlier. Using a modern version of gcc with the -std=c99 command line the program works as expected:
    First value: 5 Second value: 10 5 + 10 = 15 You're probably using a compiler/runtime library that does not support the hhu modifier and the second scanf overwrites the first value in memory. Simplest fix is to use a normal int.
  6. Agree
    Unimportant got a reaction from fpo in Documentation (best practices discussion. No code)   
    ...by giving them better names, not by commenting.
  7. Informative
    Unimportant got a reaction from Hi P in Programming - Real world projects to practice   
    Try to write a C++ console application that plays a wave sound file. (The hard way, not by using the winapi "playsound" function)
    Open the file and parse the header to get the sound format/bitrate, etc. Teaches basic file IO and parsing. Read the contents of the file to memory (hint: std::vector) Use SDL audio to play back the audio. Teaches including and linking against a external library, reading documentation in figuring out how to use said library, etc. Write a neat RAII lock to engage when handling callbacks. Basic sample rate conversion when the wave file sample rate and the sample rate you got from SDL don't match (simple sample duplication/dropping will suffice). That'll get you going for a fair bit.
  8. Informative
    Unimportant got a reaction from dhannemon13 in Multiple Questions, Stuck Here   
    First, research how the compilation and linking process works. Once you've done that you can put yourself in the compiler's shoes. Each source file is compiled separately. So when main.c is compiled, it includes complex.h and the function prototypes therein. At no point in time will the compiler see the contents of complex.c while it's compiling main.c. Thus, you should define struct `complex` in the header file complex.h, so the compiler can see it when it's compiling main.c. There is also no need for the `input` char array to be in the struct.
     
    Furthermore, what is this doing in complex.h ?
    mag(complex a); phase(complex a); First of all, they don't have a return type, your compiler should warn for that. In modern C, the canonical way to write things is to explicitly write `void` as a return type when a function returns nothing. In this case, there are no functions `mag` and `phase` in complex.c so remove these prototypes to non-existing functions.
     
    Then, in complex.c:
    struct complex a,b,c; When you've typedef'd the struct there's no need for the struct keyword. These global variables are also never used and should be removed.
     
    complex getcomplex(char *input){ char input[20]; complex a,b; scanf("%s",&input); sscanf(input, "%lf+%lf", &real, &img); } The function `getcomplex` takes a string (pointer to char) as argument, presumably the string to be parsed? Why do you declare a new array, also called input and read user input with scanf? Also, there's only a single complex number to be parsed, so no need for a `a` and a  `b`. You should explicitly point sscanf to the struct members. And you have to actually return the parsed complex.
     
    complex sum(double real, double img){ complex c;  c.real = a.real + b.real; c.img = a.img + b.img;  printf("Hasil operasi penjumlahan bilangan kompleks = %d + %di", c.real, c.img); return (c);  } This function is supposed to sum 2 complex numbers `a` and `b`. Why does it take 2 doubles `real` and `im` as arguments?
    The printf specifier to print doubles is `%lf`, not `%d`.
     
    Similar problems plague the other functions in complex.c
     
    In main.c
    char ch,p,q,r; p = argv[1]; q = argv[2]; r = argv[3]; `argv` is a array of pointers to char, not char.
     
    switch(ch){ case 'sum': sum(getcomplex(q),getcomplex(r)); break; case 'substract': substract(getcomplexA(q),getcomplexB(r)); break; case 'multiply': multiply(getcomplexA(q),getcomplexB(r)); break; case 'divide': divide(getcomplexA(q),getcomplexB(r)); break; } You cannot switch on an entire string. Comparing strings has to be done with a function like `strcmp`. Also, strings require double quotes.
     
    Final modified program, complex.h:
    #ifndef COMPLEX_H_INCLUDED #define COMPLEX_H_INCLUDED typedef struct { double real; double img; } complex; complex getcomplex(const char *input); complex sum(complex a, complex b); complex subtract(complex a, complex b); complex multiply(complex a, complex b); #endif // COMPLEX_H_INCLUDED complex.c:
    #include <stdio.h> #include "complex.h" complex getcomplex(const char *input) { complex a; sscanf(input, "%lf+%lf", &a.real, &a.img); return a; } complex sum(complex a, complex b) { complex c; c.real = a.real + b.real; c.img = a.img + b.img; printf("Hasil operasi penjumlahan bilangan kompleks = %lf + %lfi\n", c.real, c.img); return c; } complex subtract(complex a, complex b) { complex c; c.real = a.real - b.real; c.img = a.img - b.img; printf("Hasil operasi pengurangan bilangan kompleks = %lf - %lfi\n", c.real, c.img); return c; } complex multiply(complex a, complex b) { complex c; c.real = a.real*b.real - a.img*b.img; c.img = a.img*b.real + a.real*b.img; printf("Hasil operasi perkalian bilangan kompleks = %lf + %lfi\n", c.real, c.img); return c; } main.c:
    #include <stdio.h> #include <string.h> #include "complex.h" int main(int argc, char *argv[]) { if (argc < 4 || argc > 5) { printf("Tolong masukan minimal 4 argumen. //ex. namafile arg1 arg2\n"); return 0; } const char operator = argv[1][0]; const char* q = argv[2]; const char* r = argv[3]; switch(operator) { case '+': sum(getcomplex(q),getcomplex(r)); break; case '-': subtract(getcomplex(q),getcomplex(r)); break; case 'x': multiply(getcomplex(q),getcomplex(r)); break; } } The `divide` function was removed and implementing it is left as an exercise.
    Example command line:
    ./test_complex + 5+3i 7+2i output:
    Hasil operasi penjumlahan bilangan kompleks = 12.000000 + 5.000000i  
  9. Informative
    Unimportant got a reaction from dhannemon13 in Extract Two Float/Double Numbers Out of a String on C?   
    #include <stdio.h> int main(void) { const char* exampleString = "-2.2+3i"; double real; double im; if (sscanf(exampleString, "%*[^0123456789]%lf%*[^0123456789]%lf", &real, &im) != 2) { printf("Failed to extract real & im!\n"); return 1; } printf("real: %lf, im: %lf\n", real, im); return 0; }  
  10. Informative
    Unimportant got a reaction from PacketMan in i want to buy a Commodore 64 - what should i look out for and a few other questions.   
    Yes: https://www.c64-wiki.com/wiki/A/V_Jack
    One failure mode is in the power brick, which subsequently fries a lot of chips inside the C64. Some hobbyists have designed protections against this ( https://console5.com/wiki/Commodore_64_Power_Saver ).
    Some common parts like RAM and 74 series glue logic is still readily available. But the custom MOS chips (MOS was Commodore's own chip designer/fab) such as the 6502, PLA's, VIC and SID are getting increasingly rare.
  11. Agree
    Unimportant got a reaction from straight_stewie in RAM speed in programming   
    While you indeed should not be optimizing too much prematurely, *some* hardware behavior should be kept in mind from the very beginning as it can have a great influence on the overall design.
     
    We had a multi-threaded application run glacially slow once, as it turned out due to false sharing. To solve the false sharing issue certain parts of the application's data structure had to be modified. What is the data structure in OOP ? Your object structure. So we had to radically change part of the object structure which, as you're probably well aware, took a lot of refactoring and time (money).
     
    When certain decisions have to be right from the very beginning, because they're too costly too change afterward, then thinking about and making the right decisions from the start isn't premature. The hardware, mostly caching, affects certain such decisions.
     
     
     
  12. Informative
    Unimportant got a reaction from BuckGup in What Component is This?   
    Looks like 0805.
  13. Informative
    Unimportant got a reaction from BuckGup in What Component is This?   
    Looks like a burned SMD resistor (#). The resistor to the right of the circled resistor, under the SOT23 device is in the same circuit and looks burned aswell.
    Measure the SOT23 device for resistance. it's probably shorted all way 'round.
     
    #: The black part of a SMD resistor is the actual resistive material. If it gets burned away the white ceramic carrier comes trough. The scribbles that remain in the middle would've been the ink of the value markings.
    https://www.electronics-notes.com/images/smd-surface-mount-resistor-construction-cross-section-01.svg
  14. Agree
    Unimportant got a reaction from straight_stewie in RAM speed in programming   
    While you indeed should not be optimizing too much prematurely, *some* hardware behavior should be kept in mind from the very beginning as it can have a great influence on the overall design.
     
    We had a multi-threaded application run glacially slow once, as it turned out due to false sharing. To solve the false sharing issue certain parts of the application's data structure had to be modified. What is the data structure in OOP ? Your object structure. So we had to radically change part of the object structure which, as you're probably well aware, took a lot of refactoring and time (money).
     
    When certain decisions have to be right from the very beginning, because they're too costly too change afterward, then thinking about and making the right decisions from the start isn't premature. The hardware, mostly caching, affects certain such decisions.
     
     
     
  15. Like
    Unimportant got a reaction from PAEz in C++ | Can't understand Polymorphism   
    Forgive me for thinking these were 2 completely different things:
    ((Entity*)&hero)->set_attack(5); Entity(hero).set_attack(5); I know better now. Although my compiler produces 2 completely different results. I guess I should compile without the -pedantic flag.
  16. Informative
    Unimportant reacted to straight_stewie in RAM speed in programming   
    There are a few problems with the die shot you posted: That was Ivy Bridge and, if you look closely, you can see that much of the area taken up by the L3 cache is not actually memory, but memory controllers. That's because L3 cache, atleast in Intel chips, usually has a relatively high number of access channels (usually four per section and four sections, so 16 access channels). RAM won't dedicate quite that much space to the memory controllers.


     
    This is a Kaby Lake chip. Much of what you see labelled "L3$" is actually called the "Side Cache" and consists of 64 MB of memory. By my math, the "Side Cache" takes roughly 14.8 mm2 for 64 MB. That's 222 mm2 per gigabyte, which is roughly 1/3 as dense as modern DRAM offerings, which yields roughly 1 gigabyte per 70 mm2.

    So I guess the conclusion of my analysis is that, atleast in terms of die usage, SRAM is competitive with DRAM. Even more so when you factor in the performance improvement.

    However, I can't find a reasonable cost analysis, because SRAM is in very low demand so it's cost is inflated. I'm not an economist, so any price adjustments I could come up with to make an apples to apples comparison on cost would be complete nonsense.
  17. Agree
    Unimportant got a reaction from Breadpudding in RAM speed in programming   
    I'd worry much more about being cache friendly if you need performance.
  18. Agree
    Unimportant got a reaction from Hackentosher in How do parallel battery packs not have issues?   
    Rather importantly, yes! When you connect the batteries together to make a pack they should be balanced. If you put 2 batteries with different charge levels (different voltages) in parallel the 2 batteries will balance themselves, but with no current limit, it would be violent. Once connected in parallel there is no issue - look at them as communicating water vessels.
  19. Agree
    Unimportant got a reaction from Breadpudding in RAM speed in programming   
    I'd worry much more about being cache friendly if you need performance.
  20. Agree
    Unimportant got a reaction from Hackentosher in How do parallel battery packs not have issues?   
    Rather importantly, yes! When you connect the batteries together to make a pack they should be balanced. If you put 2 batteries with different charge levels (different voltages) in parallel the 2 batteries will balance themselves, but with no current limit, it would be violent. Once connected in parallel there is no issue - look at them as communicating water vessels.
  21. Agree
    Unimportant got a reaction from Hackentosher in How do parallel battery packs not have issues?   
    Rather importantly, yes! When you connect the batteries together to make a pack they should be balanced. If you put 2 batteries with different charge levels (different voltages) in parallel the 2 batteries will balance themselves, but with no current limit, it would be violent. Once connected in parallel there is no issue - look at them as communicating water vessels.
  22. Funny
    Unimportant got a reaction from Breadpudding in Operating System Creation   
    That's what AT&T syntax will do to a person.    ( )
  23. Agree
    Unimportant got a reaction from anselmo in Bootable USB with a picture   
    Should work with Rufus, follow this simple guide https://www.thomas-krenn.com/en/wiki/Creating_a_Bootable_DOS_USB_Stick
    Make sure all the settings are the same. You need FAT32 for example as DOS does not know NTFS.
  24. Informative
    Unimportant got a reaction from wasab in C++ | Can't understand Polymorphism   
    Only the Entity part of hero will be copied to entity. All Hero specific fields are lost, "sliced off".
  25. Agree
    Unimportant got a reaction from Minibois in Gameboy corrosion   
    Use an acid, like vinegar, first to neutralise the base alkaline. Once it stops fizzling clean the vinegar off with IPA. Otherwise the corrosion will continue.
×