round() for float in C++

Editor’s Note: The following answer provides a simplistic solution that contains several implementation flaws (see Shafik Yaghmour’s answer for a full explanation). Note that C++11 includes std::round, std::lround, and std::llround as builtins already. There’s no round() in the C++98 standard library. You can write one yourself though. The following is an implementation of round-half-up: double … Read more

Formatting Decimal places in R

Background: Some answers suggested on this page (e.g., signif, options(digits=…)) do not guarantee that a certain number of decimals are displayed for an arbitrary number. I presume this is a design feature in R whereby good scientific practice involves showing a certain number of digits based on principles of “significant figures”. However, in many domains … Read more

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