Results 1 to 2 of 2

Thread: extremely small numbers

  1. #1
    jim mcnamara
    Guest
    Do only double precision arithmetic. It's getting rounded if you convert to single precision.
    Code:
    const double g=.0000000000667;
    double whatever, result
    float someval;
    result = whatever * g * convert(someval);
    Note that most implementations of C and C++ don't do a good job of casting single to double - that's why:

    Code:
    double convert(float in){
            double tmp;
            char start[25], *end;
            memset(start,0x00, sizeof(start));
            sprintf(start,"%f",in);
            end=s;
            return strtod(s,&end);
    
    }

  2. #2
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    thanks! I'll give that a run

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width