Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i read a float64 from a file?

Hi friends,

 

I have a problem, i have a program to read a signal from a DAQ and put it in a file and i need to read this file since another program.

 

I read in a float64 format and put with this format in a txt file, How can i read this dates from a file?

 

Thank's.

 

Regards.

0 Kudos
Message 1 of 5
(6,859 Views)

Hello Galdos,

 

I need additional information to give you an answer. What programming language are you using? LabVIEW? C?

 

In addition, if you are reading from a DAQ device using float64 and you are writing into a TXT file… you are missing a lot of information because the float data is transformed/coerced into string with a specific format (finite number of decimal).

 

To read float64 from string file, you need:

1) Read data from the TXT file in a string variable

2) Use a conversion function to change a string into a float64 value.

0 Kudos
Message 2 of 5
(6,852 Views)

Hi Sendia,

 

I'm programming in C, I know if I write a float64 in a txt file I lose a lot of information, but is not a problem, I have the precission that I need, I only use a ten decimals.

 

What is the function to change a string to float?

 

Thank's for you help.

 

Regards.

0 Kudos
Message 3 of 5
(6,849 Views)

What programming environment are you using? And are you using ANSI C, C, C++??

0 Kudos
Message 4 of 5
(6,847 Views)

According to this link, a float64 data is just a Double data:

 

https://www.ni.com/docs/en-US/bundle/labview/page/labview-manager-data-types.html

http://digital.ni.com/public.nsf/allkb/D6BED7D73659C43586256A7300691C26?OpenDocument 

 

… so to transform a string variable to a double/float64 variable, you only need to use the “strtod” function (in any language)

 

http://www.cplusplus.com/reference/clibrary/cstdlib/strtod/

http://c.conclase.net/librerias/?ansifun=strtod

0 Kudos
Message 5 of 5
(6,840 Views)