I generated two matrices of 1000 x 1000: First Matrix: O and #. Second Matrix: O and B. Using the following code, the first matrix took 8.52 se
Continue ReadingWhy Is Subtracting These Two Times (In 1927) Giving a Strange Result?
If I run the following program, which parses two date strings referencing times one second apart and compares them: public static void main(String[]
Continue ReadingWhy Is Char[] Preferred Over String for Passwords?
In Swing, the password field has a getPassword() (returns char[]) method instead of the usual getText() (returns String) method. Similarly, I have com
Continue ReadingWith C arrays, why is it the case that a[5] == 5[a]?
As Joel points out in Stack Overflow podcast #34, in C Programming Language (aka: K & R), there is mention of this property of arrays in C: a[5] =
Continue ReadingBjarne Stroustrup: Why I Created C++
https://www.youtube.com/watch?v=JBjjnqG0BP8
Continue ReadingWhy doesn’t GCC optimize a*a*a*a*a*a to (a*a*a)*(a*a*a)?
I am doing some numerical optimization on a scientific application. One thing I noticed is that GCC will optimize the call pow(a,2) by compiling it in
Continue ReadingC++: Why is one loop so much slower than two loops?
Suppose a1, b1, c1, and d1 point to heap memory and my numerical code has the following core loop. const int n=100000 for(int j=0;j<n;j++){
Continue ReadingC++: Why does changing 0.1f to 0 slow down performance by 10x?
Why does this bit of code, const float x[16] = { 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1,
Continue ReadingWhy is processing a sorted array faster than an unsorted array?
Here is a piece of C++ code that seems very peculiar. For some strange reason, sorting the data miraculously makes the code almost six times faster.
Continue ReadingWhy Your Advanced Spam Filter Isn’t Enough
SOURCE
Continue Reading