Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

******Double Assignment - Large numbers********

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0


Hi ,

I am encountering a queer problem in a c program.

main()
{
double fld1;
fld1=2299595420;
Prinf("\n passed field value is %.0f ",fld1);
}

It gives an output of value -1995371876. However i want to see the
actual value of 299595420.
This works fine if i cange the value to either 129959520 or increase
the value to more than 10 digits. I found that it fails to give the
assined value only when there are 10 digits with the starting digit as
2.

Can any of you please help as i am using this in a c routine. I have
tried using 10.0f etc.

Thanks in advance

Jags
 
hmmm, try maybe an unsigned double. That may be an overflow problem, but if 39959420 works, it's not. Also, post the OS and compiler and architecture you're using, that'll help, as the size of a double is machine dependent.

MWB As always, I hope that helped!

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
include <stdio.h>
include <float.h>
main()
{
printf(&quot;Max digits in double:%d\n&quot;,DBL_DIG);
printf(&quot;Max digits in double mantissa:%d\n&quot;,DBL_MANT_DIG);

}
Do this and you will know your limit.
By ANSI C DBL_DIG >= 10.
Exact value set in float.h for your system.
 
The OS is sunSolaris 5.6.

Lim's program gave me the result DBL_DIG = 15 and DBL_MANT_DIG=53.

The program does not work for 10 digit number starting with 2 or greater numbers.
however it works fine for fine for figures less or more than 10 digits.

Can anyone suggest how to resolve this problem.

 
i'm looking for a program wich write * in place of other letter , you know , like it's done when entring a password
 
dear gjnath,
I copied your program as its in a newfile and copiled to see its results, but it did'nt give me any problem.

and dear doors
your program is here

#include <stdio.h>
#include <conio.h>

main()
{
char *password; // a pointer string
int n=0;
printf(&quot;\nEnter password: &quot;);
while( (password[n]=getch())!='\r')
{
printf(&quot;*&quot;);
n++;
}
password[n]='\0';
printf(&quot;\nyou entered....: %s&quot;,password);
}
 
shahzad :

Thanks for the input. I'll have figure out why the same programe does not work in the particulat env.


Regards

Jagan
 
Try making it unsigned, see if that helps...

MWB. As always, I hope that helped!

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top