Mailing List Archive


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

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



On Wed, 26 Jul 2006 18:05:48 +0200
Michal Hajek <hajek1@example.com> wrote:

> > > char result_normal_plus[17]="00000000000000000";
> > 
> > If that is global, keep in mind that result_normal_plus will 
> > initialized only _once_. 
>  
> yes, thank you for pointing that out. But I consider the inicialization
> as a side issue for the time being :)

As long as the result is treated as a binary data and ibrd() always puts
enough data in result_normal_plus[], initialization is not needed. If
it's a string, you only need to make sure it's zero terminated at ibcnt.

> Since later I put "end of string" mark at position 10
> ...
> double) to the right place in the string (kind of saying "from this
> point on take the following 8 characters as a double floating point
> number").
> ...
> So I use the information to cut the string in the right place. 
> Sometimes it could be 0, if something goes wrong with the devices on
> gpib bus or the bus itself.

You are confusing us here! The data is ASCII or binary? I guess if the
device returns an ascii header, the rest must be ascii too.

> > Did reading in ASCII, then converting with atof() work correctly? 
> 
> yes, it works well. No problem. 

Since atof takes a string, we are dealing with a string representation of
a double here.
So instead of
  printf("*presult: %.12f \n",*presult);
you should use:
 printf("result: %s\n", presult);
Because it's a string.


> > How much time does it take to do it _correctly_? 
> well, I intend to run a measurement in a loop. One such loop has about
> four atof() and whole together takes about 0.8 seconds to finish. 

As long as you are not dealing with thousands of measurments per second,
I really doubt that it would make any difference in speed.


Attachment: signature.asc
Description: PGP signature


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links