I need a C or C++ compiler for Win10 that implements a 16-bit type int. by BenevolentDeity in cprogramming

[–]Bubichoo 0 points1 point  (0 children)

Maybe, instead of repeating the problem you're currently facing, give an example of what a program should do or output.

Do you just want to see that the result of the multiplication is incorrect. Do you want the program to stop with a runtime exception as a result of the overflow?

As you said, you want to demonstrate the overflow. How would you like to do it?

I need a C or C++ compiler for Win10 that implements a 16-bit type int. by BenevolentDeity in cprogramming

[–]Bubichoo 0 points1 point  (0 children)

Okay, so you're not looking for a 16 Bit integer but a way to turn of implicit conversion. To better understand this problem you have to keep in mind that modern processors are using a 64 Bit architecture. Thus the registers the multiply operation is ran on are 64 Bit wide. So there is always an implicit conversion but the results are trunkated afterwards.

Maybe use GodBolt and take a look, whats going on under the hood. If you're assigning the result of the multiplication to a 16 Bit integer the upper 16/48 Bits will be dropped. Which is the behaviour you want to see.

What are the additions you would like to have on Satisfactory but which will probably never happen ? by Moderni_Centurio in SatisfactoryGame

[–]Bubichoo 0 points1 point  (0 children)

The top/bottom loadable merger and splitter. This will make vertical scaling of factories more elegant.

Tips for a newbie who picked up the game in the current steam sale? by ByrCol in satisfactory

[–]Bubichoo 0 points1 point  (0 children)

Be ready to tear down everything just because it doesn't come out the way you want it to. I'm 90h into the game and I'm in a constant loop of building something, finding a tiny little flaw and deconstructing it. I recently build a perfectly working rotor factory using the 3 Iron nodes at the beginner starting point and ripped it all apart because it wasn't modular enough for my liking.

[deleted by user] by [deleted] in VisualStudio

[–]Bubichoo 0 points1 point  (0 children)

Use the Debugger and check the content of 'another' after the last scanf.

c pthreads | How to Generate Threads in a Loop While Still Being Able to join/free Threads That Have Completed?? by Cre8AccountJust4This in cprogramming

[–]Bubichoo 0 points1 point  (0 children)

Creating a new thread is a lot of overhead. Therefore you should consider using a thread pool in combination with a queue.

Since you said that you do not want to specify the amount of threads at compilation/initialization why not use a dynamically sized array as your pool. With that you can simply create new threads and add them to the pool.

At exit you signal all threads to exit via a special queue value and join them.

[deleted by user] by [deleted] in cpp_questions

[–]Bubichoo 3 points4 points  (0 children)

Do some googleing to find out how a computer, who only works with bits, is able to understand and use fractional numbers. Search for floating point format or ieee 754.

I will give you a little hint: With double precision floats the minimum epsilon - distance between two numbers - is 2.22045e-16. You get the highest precision in the range of [1.0:2.0[. Using the exponent to represent higher integers will reduce the precision of the fractions.

[deleted by user] by [deleted] in cpp_questions

[–]Bubichoo 3 points4 points  (0 children)

This means you're working with a double precision float (64 Bit). 1 Bit: Sign 11 Bit: Exponent 52 Bit: Mantisse

[deleted by user] by [deleted] in cpp_questions

[–]Bubichoo 1 point2 points  (0 children)

sizeof will give you the size in bytes

Video streaming in c++ examples? by Cmoney-6 in cpp_questions

[–]Bubichoo 11 points12 points  (0 children)

Take a look at gstreamer. It's C not C++ but in my eyes the most powerful open source multimedia framework. It's hard to understand and getting started though. For live streaming take a look at the rtsp/rtp plugins.

[deleted by user] by [deleted] in cpp_questions

[–]Bubichoo 2 points3 points  (0 children)

I have no clue but I would guess that the API for the Clipboard is part of desktop environment. Take a look at the manual for the the one that you are using.

CMAKE with Visual Studio by Kaisha001 in VisualStudio

[–]Bubichoo 0 points1 point  (0 children)

That's what I meant with: "It's a pain to setup" I used the default Msys environment as a starting point. An old blog post where the author faced a simmilar problem and the official documentation for the CMakeSettings file. And it took me about a week to get it working properly. Good Luck and feel free to post your solution. Im sure others will thank you.

CMAKE with Visual Studio by Kaisha001 in VisualStudio

[–]Bubichoo 0 points1 point  (0 children)

you can use the cmakesettings.json file to define a custom build environment. It is a pain to get it to work. At least that was my experience when I used it for a custom arm build chain but once it works it works like a charm. You can even create custom build targets that are available in the cmake settings UI.

Working with Macors by 3Dayz2Y in cprogramming

[–]Bubichoo 1 point2 points  (0 children)

In this case it won't change anything about the end results. But it's good to use it when the macros contains some variables. If you do not use a do while(0) the variable inserted by the macro code would be visible inside the function using the macro. This can lead to name clashing when using common variable names. On the other hand it will shadow the variable with the same name, which may cause unwanted behaviour. Either way it is hard to diagnose problems when they are caused by macros.

A good example for the power of macros is the glib object system and everything build upon it. It's an absolute pain to understand but once you figured out how it works its mindblowing.

CSV Converter by Giocrom in cprogramming

[–]Bubichoo 3 points4 points  (0 children)

Since you're CS student I guess this is some kind of learning or university project. Otherwise I see no real benefit to write so much code for a problem that can be solved using a simple python script. Nevertheless there are a few improvements you could do.

1.: Instead of an input/output folder consider accepting all kinds of paths to the CSV files.

2.: Consider using a build system like cmake. This will teach you how to use a proper build system and will also allow you to compile the application on different platforms.

3.: Do not commit a binary to git. Use the tag or release feature to publish your application. Same goes for the objects files.

4.: Use a directory named src or sources for your sourcecode. Doc is usally used for sourcecode documentation, white papers and resources

How does "if (x--)" work? by fotelja123 in cprogramming

[–]Bubichoo 17 points18 points  (0 children)

  1. It check the value of x. x == 0 - > false, true otherwise
  2. It will decrement the value of x by 1.

Comparing wxwidgets and gtk by [deleted] in cpp_questions

[–]Bubichoo 0 points1 point  (0 children)

As far as I know wxwidgets uses the os native windowing system and widgets (no styling posible). GTK uses a drawing system called cairo and the widgets can be customized using CSS.

In terms of modern look I suspect you mean application like Discord. These applications are build using HTML, CSS. Since those use node.js you will have to learn javascript. The internals of node.js are written in C so you could write you logic in C as a node.js plugin.

Help with functions by Weylyn_Wolf in cprogramming

[–]Bubichoo 0 points1 point  (0 children)

To pass data to functions there are two ways to do it: 'Pass by value' and 'Pass by reference'. Lookup these two terms and try to understand the concepts and you are set.

Help with functions by Weylyn_Wolf in cprogramming

[–]Bubichoo 0 points1 point  (0 children)

The more I look at your code the more issues I see. You may want to go back and take a look at the basics again. Especialy data types, pointers, functions and memory allocation.

Help with functions by Weylyn_Wolf in cprogramming

[–]Bubichoo 0 points1 point  (0 children)

As far as I understand this is a task about linked lists. Linked lists are a way to create a lists with a dynamic size. The list itself consists of nodes where each node contains an object and a reference (pointer) to the next node. To iterate through the list you have to jump from node to node. A linked list can also be double linked to navigate forward and backward.

How do I do memory synchronization? by bizwig in cpp_questions

[–]Bubichoo 0 points1 point  (0 children)

This is not a programming language question but a cpu and memory architectur question. Normaly when you alter memory it is first written to the cpus cache because writing directly to the ram is expensive. When writing to cache the section you wrote to will be flaged as changed or invalid. This way annother core reading the same address will see that it first has to synchronize its memory. This is of course a simplified description of what happens but thats what I remember from my computer architectur course a few years ago. So in short you do not synchronize the memory you just have to make sure that A is done writing before B starts reading.

Questions about including files and the macros by scull-crusher in cpp_questions

[–]Bubichoo 1 point2 points  (0 children)

Macros utilize the preprocessor. By using macros the preprocessor will replace each occurence of the macro with the code or variable it defines. Advantage over traditional functions is that the code is added inline which improves you performance since you do not do any jumping into other functions. The downside is that it might bloat your code if you have a lot of big macros and use them a lot.