Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] issues with format of double (or IEEE754)



>>>>> "Michal" == Michal Hajek <hajek1@example.com> writes:

    Michal> char result_normal_plus[17]="00000000000000000";

Initialize this to a number whose IEEE 754 representation you know,
then print it without reading from the device.  That will tell you
whether doubles in memory are IEEE 754 doubles.

    Michal> presult= result_normal_plus+2;

Have you tried

    result_normal_plus[2] = '\0';
    printf ("header = '%s'\n", result_normal_plus);

yet to make sure the alignment is what you expect, and the device is
producing the header properly?

    Michal> where presult is a pointer to double, eg. defined as:
    Michal> double *presult;

    Michal> The problem is that if I print the number:

    Michal> printf("*presult: %.12f \n",*presult);

Well, if you're not getting bus errors, I guess alignment doesn't
matter.  This kind of casting is normally an excellent way to get into
real trouble, though.

    Michal> Or maybe suggest a more clever [3] way of getting the
    Michal> result from nanovoltmeter?

If you believe the documentation, you should just compute the number
yourself either using atof or a direct computation (do you really
think the nanovoltmeter gives you more than 32 bits of accuracy?)




-- 
School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links