I am trying to collect some edge cases for floating-point arithmetic. The thing is, my attempt with printf is not showing me what I want:
#include <cmath>
#include <stdio.h>
#include <complex>
int main() {
double x = -0;
auto y = sqrt(x);
printf("x %f y %f \n", x, y);
return 1;
}
Per IEEE, squareRoot(-0) is -0, but this will print out both x and y to be 0.
Any suggestions on how I can achieve what I want? Would it be through compiler flags or something different?