www.digitalmars.com         C & C++   DMDScript  

c++ - Warning 24: number is not representable

reply "Steve Hall" <sthall lorrexinc.com> writes:
#include <stdio.h>
#include <math.h>

int main(){
long double a = powl(2, 2000);
printf("%Lg = 2^2000 = %Lg\n", (long double) (1.14813e+602), a);
return 0;
}

Why printf doesn't accept directly the value 1.14813e+602?

Steve
Aug 26 2003
next sibling parent Ilya Minkov <midiclub 8ung.at> writes:
Steve Hall wrote:
 Why printf doesn't accept directly the value 1.14813e+602?
Because printf (as any varargs function) expects doubles, which have a maximum decimal exponent of roughly 308, yours is twice as big. See \dm\include\float.h for further limits and details. -eye
Aug 26 2003
prev sibling parent "Walter" <walter digitalmars.com> writes:
Try putting an 'L' suffix on the number.

"Steve Hall" <sthall lorrexinc.com> wrote in message
news:bigqng$eo0$1 digitaldaemon.com...
 #include <stdio.h>
 #include <math.h>

 int main(){
 long double a = powl(2, 2000);
 printf("%Lg = 2^2000 = %Lg\n", (long double) (1.14813e+602), a);
 return 0;
 }

 Why printf doesn't accept directly the value 1.14813e+602?

 Steve
Aug 26 2003