[Solved] Comparing 2 different scenarios on 2 different architectures when finding the max element of an array

I think you’re really trying to ask about branchless vs. branching ways to do m = max(m, array[i]). C compilers will already compile the if() version to branchless code (using cmov) depending on optimization settings. It can even auto-vectorize to a packed compare or packed-max function. Your 0.5 * abs() version is obviously terrible (a … Read more

[Solved] How to put a hex value into a 24 bit struct

If you have control of your input format, i.e. you can guarantee it will always be something like 0xabc, then you can try: const char input[] = “0xabc”; uint32_t tmp; sscanf(input, “0x%x”, &tmp); struct cmd cmdid; cmdid.a = (tmp & 0xFF0000U) >> 16; cmdid.b = (tmp & 0xFF00U) >> 8; cmdid.c = (tmp & 0xFFU); … Read more

[Solved] How to filter data based on maximum datetime value in each day [closed]

With data like: public class Data { public String Name { get; set; } public DateTime TimeStamp { get; set; } public Data(String name, DateTime timeStamp) { this.Name = name; this.TimeStamp = timeStamp; } public override string ToString() { return String.Format(“{0} at {1}”, this.Name, this.TimeStamp); } } You can use: var source = new Data[] … Read more

[Solved] stored procedures instead of forms

You’re describing Web Forms, which is another part of ASP.NET, but not part of ASP.NET MVC. The calling of stored procedures has nothing to do with any of these technologies. Some people choose to put such calls in their Controller or Code-Behind rather than having it in a separate data layer. 2 solved stored procedures … Read more

[Solved] Why Can’t Read The File(doesn’t display the data)?

If opening iFile fails then the call to read will also fail and the body of the while loop will never execute. You should check the file opens successfully before using it: ifstream iFile(“shippingAddresses.dat”, ios::binary); if (!iFile) { std::cout << “open failed\n”; return; } while (iFile.read((char *)this, sizeof(*this))) { display_adress(); } Note that iFile.close(); is … Read more

[Solved] How to create a test run/plan for a C++ Program? [closed]

For unit tests, you would typically use a unit-test framework such as CppUnit: For each class, you create a series of test; For each method to be tested, you develop a dedicated test; Each test verifies some assertions using functions or macros such as CPPUNIT_ASSERT, CPPUNIT_FAIL, CPPUNIT_ASSERT_THROW; It’s often useful to make the tester class … Read more

[Solved] Is my program ready for FFT?

What does the data in my List is representing in its current form? In its current form, you are getting the raw byte sequence from the file, except from the header which you are removing explicitly. The mapping between raw bytes and the corresponding data sample value is in general non-trivial, and varies according to … Read more