You are not logged in.
I have problem with standard library in c++ - cmath:
#include <iostream>
#include <cmath>
#include <cfloat>
#include <climits>
using namespace std;
int main() {
long double max = LDBL_MAX;
long double val = max/100000;
long double root1 = sqrt(max);
perror("root1");
long double root2 = sqrt(val);
perror("root2");
cout<<max<<endl;
cout<<val<<endl;
cout<<root1<<endl;
cout<<root2<<endl;
getchar();
return 0;
}Result is:
root1: Error 0 root2: Error 0 1.18973e+4932 1.18973e+4927 Inf Inf
And I don't know why - no "result is too large" or some other errors and sqrt are Infs - why? I tried also sqrtl() function but results are the same.
I tried using math.h instead of cmath but without results. (I had to test this code on shell on some linux, cause dev cpp on my windows seems to be bugged and can't printf long double = LDBL_MAX (it prints inf)
Offline
Okay it's interesting but:
my number is printed and it's a valid long double number < LDBL_MAX
when I use sqrt(my number) - it should return a number smaller than my number
but it returns inf...
Offline