cast variable to int vs round() function

In case of casting a float/double value to int, you generally loose the fractional part due to integer truncation. This is quite different from rounding as we would usually expect, so for instance 2.8 ends up as 2 with integer truncation, just as 2.1 would end up as 2. Update: Another source of potential (gross) … Read more

Making an array of random ints

You are never assigning the values inside the test2 array. You have declared it but all the values will be 0. Here’s how you could assign a random integer in the specified interval for each element of the array: int Min = 0; int Max = 20; // this declares an integer array with 5 … Read more

How to properly instantiate os.FileMode

My fix has been to define my own constants as I couldn’t find any in os or syscall: const ( OS_READ = 04 OS_WRITE = 02 OS_EX = 01 OS_USER_SHIFT = 6 OS_GROUP_SHIFT = 3 OS_OTH_SHIFT = 0 OS_USER_R = OS_READ<<OS_USER_SHIFT OS_USER_W = OS_WRITE<<OS_USER_SHIFT OS_USER_X = OS_EX<<OS_USER_SHIFT OS_USER_RW = OS_USER_R | OS_USER_W OS_USER_RWX = OS_USER_RW … Read more

unsigned int (c++) vs uint (c#)

C++ and C# are different languages. They have different rules for handling type promotion in the event of comparisons. In C++ and C, they’re usually compared as if they were both unsigned. This is called “unsigned preserving”. C++ and C compilers traditionally use “unsigned preserving” and the use of this is specified in the C++ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)