Why is abs(x)+abs(y) different from sqrt(x*x + y*y)

Advertisements I was making a Physics Engine in C++ when I noticed that when I replace: float absDistance = sqrt(vectorDistance.x * vectorDistance.x + vectorDistance.y * vectorDistance.y); With: float absDistance = abs(vectorDistance.x) + abs(vectorDistance.y) Different things happen. I’m using the library <cmath> I looked at a lot of stack exchanges but I couldn’t find anyone saying… Read More Why is abs(x)+abs(y) different from sqrt(x*x + y*y)

R: Calculate percentage of observations in a column that are below a certain value for panel data

Advertisements I have panel data and I would like to get the percentage of observations in a column (Size) that are below 1 million. My data is the following: structure(list(Product = c("A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "C", "C", "C", "C", "C", "C"), Date = c("02.05.2018", "04.05.2018", "05.05.2018", "06.05.2018",… Read More R: Calculate percentage of observations in a column that are below a certain value for panel data

Why does printf output characters instead of data?

Advertisements Why does printf output characters instead of data? Looking at the code, you can relatively understand what I want to do, but it is unclear why the output is like this #include <vector> #include <string> #include <cstdio> class Person { public: Person(const std::string& name, uint16_t old) : m_Name(name) , m_Old(old) { } public: std::string… Read More Why does printf output characters instead of data?