Relative Content

Tag Archive for c++arraysmath

why am getting nan on performing below operation?

#include <bits/stdc++.h> using namespace std; int main() { int a[2] = {-1,1}; for (int i=0; i<2; i++){ cout<<exp(log(-1)-log(a[i])); cout<<endl; } return 0; } output :- nan nan I am expecting output:- [1,-1] I am trying to perform division using exp and log properties c++ arrays math New contributor Harsh Gola is a new contributor to […]