Comparing floating point numbers in C

To determine whether it’s close enough to zero that it will print as 0.000000 to six decimal places, something like: fabs(d) < 0.0000005 Dealing with small inaccuracies in floating-point calculations can get quite complicated in general, though. If you want a better idea what value you’ve got, try printing with %g instead of %f.

MySQL monthly Sale of last 12 months including months with no Sale

Thanks for @pankaj hint, Here i resolved it via this query… SELECT SUM(IF(month=”Jan”, total, 0)) AS ‘Jan’, SUM(IF(month=”Feb”, total, 0)) AS ‘Feb’, SUM(IF(month=”Mar”, total, 0)) AS ‘Mar’, SUM(IF(month=”Apr”, total, 0)) AS ‘Apr’, SUM(IF(month=”May”, total, 0)) AS ‘May’, SUM(IF(month=”Jun”, total, 0)) AS ‘Jun’, SUM(IF(month=”Jul”, total, 0)) AS ‘Jul’, SUM(IF(month=”Aug”, total, 0)) AS ‘Aug’, SUM(IF(month=”Sep”, total, 0)) … Read more

How to remove rows with any zero value

There are a few different ways of doing this. I prefer using apply, since it’s easily extendable: ##Generate some data dd = data.frame(a = 1:4, b= 1:0, c=0:3) ##Go through each row and determine if a value is zero row_sub = apply(dd, 1, function(row) all(row !=0 )) ##Subset as usual dd[row_sub,]

Is 0 a decimal literal or an octal literal?

Yes, 0 is an Octal literal in C++. As per the C++ Standard: 2.14.2 Integer literals [lex.icon] integer-literal: decimal-literal integer-suffixopt octal-literal integer-suffixopt hexadecimal-literal integer-suffixopt decimal-literal: nonzero-digit decimal-literal digit octal-literal: 0 <——————–<Here> octal-literal octal-digit