×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)


                         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

RE: ******Double Assignment - Large numbers********

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.

RE: ******Double Assignment - Large numbers********

include <stdio.h>
include <float.h>
main()
{
printf("Max digits in double:%d\n",DBL_DIG);
printf("Max digits in double mantissa:%d\n",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.

RE: ******Double Assignment - Large numbers********

(OP)
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.

RE: ******Double Assignment - Large numbers********

i'm looking for a program wich write * in place of other letter , you know , like it's done when entring a password

RE: ******Double Assignment - Large numbers********

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("\nEnter  password: ");
   while( (password[n]=getch())!='\r')
      {
      printf("*");
      n++;
      }
   password[n]='\0';
   printf("\nyou entered....: %s",password);
   }

RE: ******Double Assignment - Large numbers********

(OP)
shahzad :

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


Regards

Jagan

RE: ******Double Assignment - Large numbers********

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close