Convert double precision float string to a number

I am a newbie with Labview.
I have a GPIB link with a vector voltmeter and I receive the data as a double precision float string (IEEE standard 754-1985). I would like it to be recognized as a number, but I can't find the proper conversion function. The string to convert is 8 byte long. Does anyone have an idea how to do it? Thank you!

Asumming your data is big-endian, you should be able to simply typecast it to a DBL (see attache LV 7.0 example).
(It is possible that your DBL string is little-endian, in this case it will be slightly more complicated. Let us know )Message Edited by altenbach on 05-27-2005 04:49 PM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
StringToDBL.vi ‏23 KB

Similar Messages

  • Converting double to float

    This problem only occurs when dealing with large numbers or numbers with a lot of fraction digits.
    Here is an example:
    double d = 7.1E9;
    float f1 = (float)d;
    float f2 = new Float(d).floatValue();
    System.out.println( d + " " + f1 + " " + f2);
    The result is:
    7.1E9 7.1000003E9 7.1000003E9
    I tried other ways of converting to float (using DecimalFormat) but unfortunately nothing works. The resulting float is not the same as the original double.
    Any ideas?
    Thanks.
    Igor.

    float is only 32 bit while double is 64 bit, so you can easily get differences like that.
    Is it a problem? If you results gets inaccurate you should stay with double or use BigDecimal if you really care about the precision. If it's because you want to round the result of before you display it, you can use DecimalFormat.

  • Do numerical indicators display extended precision floats correctly?

    I'm using windows XP sp2 on a new computer with a new intel processor, nothing weird. I'm displaying an extended precision floating point number using a numeric indicator that is set to display an extended data type with thirty digits of precision. I expect to see at least 19 or 20 significant digits out of my extended precision float, but the numeric indicator only ever displays 17 significant digits before going to a trail of zeros. Does the display routine that converts the float to a display string use double precision or what?
    global variables make robots angry

    Yes, I understand what you are saying and you are completely correct. The problem I have is not that I expect a mathematically perfect representation of a number, but rather that LabVIEW calculates and produces an 80-bit extended precision number on my computer and then appears to convert it to a 64-bit representation of that number before displaying it!
    If you convert the extended precision value into an unflattened string in order to attempt to access the binary representation of the data, you’ll find that it is represented by 80-bits. This is a 64-bit fraction plus a 15-bit exponent plus one bit for the sign. Delightfully, the flatten to string function appears to scramble the bits into “noncontiguous” pieces, so about all I can tell for certain is that we have, as expected, an 80-bit extended precision number in memory. The documentation for the other number-to-Boolean array and bit manipulation functions I looked at (even the exponent-mantissa function) all claim to only be able to handle a maximum input of a 64-bit number (double precision float max) -correct me if I’m wrong on this one, because I’d really like to be able to see the contiguous binary representation of 80-bit extended floats.
    It turns out though that what you said about not being able to tell whether we have twenty digits of precision without bit fiddling is not true at all. If you look at the program I wrote, you can prove with simple addition and subtraction that beyond the shadow of a doubt the extended numbers are being stored and calculated with twenty digits of precision on my computer yet being displayed with less precision.
    As you can plainly see in the previous example I sent:
    A =          0.1111111111
    B =         0.00000000001111111111
    A+B=C= 0.11111111111111111111
    We know that
    C-A=B
    The actual answer we get is
    C-A=0.00000000001111111110887672
    Instead of the unattainable ideal of
    C-A=0.00000000001111111111
    The first nineteen digits of the calculated answer are exactly correct. The remainder of the actual answer is equal to 88.7672% of the remainder of the perfect answer, so we effectively have 19.887672 digits of accuracy.
    That all sounds well and good until you realize that no individual number displayed on the front panel seems to be displayed with more than 16-17 significant digits of accuracy.
    As you see below, the number displayed for the value of A+B was definitely not as close to being the right answer as the number LabVIEW stores internally in memory.
    A+B=0.11111111111111111111 (the mathematically ideal result)
    A+B=0.111111111111111105     (what LabVIEW displays as its result)
    We know darned well that if the final answer of A+B-A was accurate to twenty digits, then the intermediate step of A-B did not have a huge error in the seventeenth or eighteenth digit! The value being displayed by LabVIEW is not close to being the value in the LabVIEW variable because if it were then the result of the subtract operation would be drastically different!
    0.11111111111111110500       (this is what LabVIEW shows as A+B)  
    0.11111111110000000000       (this is what we entered and what LabVIEW shows for A)
    0.00000000001111110500    (this is the best we can expect for A+B-A)
    0.00000000001111111110887672 this is what LabVIEW manages to calculate.
    The final number LabVIEW calculates magically has extra accuracy conjured back into it somehow! It’s more than 1000 times more accurate than a perfect calculation using the corrupted value of A+B that the display shows us – the three extra digits give us three orders of magnitude better resolution than should be possible unless LabVIEW is displaying a less accurate version of A+B than is actually being used!
    This would be like making a huge mistake at the beginning of a math problem, and then making a huge mistake at the end and having them cancel each other out. Except imagine getting that lucky on every answer on every question. No matter what numbers I plug into my LabVIEW program, the intermediate step of A+B has only about 16-17 digits of accuracy, but miraculously the final step of A+B-A will have 19-20 digits of accuracy. The final box at the bottom of the program shows why.
    If you convert the numbers to double and use doubles to calculate the final answer, you only get 16-17 digits of accuracy. That’s no surprise because 16 digits of accuracy is about as good as you’re gonna do with a 64-bit floating point representation. So it’s no wonder all the extended numbers I display appear to only have the same accuracy as a 64-bit representation because the display routine is using double precision numbers, not extended precision.
    This is not cool at all. The indicator is labeled as being able to accept an extended precision number and it allows the user to crank out a ridiculous number of significant digits. There is no little red dot on the input wire telling me, ‘hey, I’m converting to a less accurate representation here, ok!’ Instead, the icon shows me ‘EXT’ for ‘Hey, I’m set to extended precision!’
    The irony is that the documentation for the addition function indicates that it converts input to double. It obviously can handle extended.
    I’ve included a modified version of the vi for you to tinker with. Enter some different numbers on the front panel and see what I mean.
    Regardless of all this jazz, if someone knows the real scoop on the original question, please end our suffering: Can LabVIEW display extended floating point numbers properly, or is it converting to double precision somewhere before numerals get written to the front panel indicator?
    Message Edited by Root Canal on 06-09-2008 07:16 PM
    global variables make robots angry
    Attachments:
    numerical display maxes out at double precision 21.vi ‏17 KB

  • ARM Luminary TCP debug double precision numbers

    Hi,
    I'm working with Labview and a LM3S8962 Luminary evaluation board.
    I'm debugging with TCP port and when I use double precision float variables I see some like random numbers on my front panel indicators or on my probe points (i.e. 1.5664325e34.....-12.452244e128) for those variables, but at the same time I'm printing the numbers on the board LCD display and they are shown ok. If I do all the opperations on double precision and then convert the result number to single presicion to display it...then indicators and probes works fine. Also if I do debug with USB ULINK JTAG all works ok on single, double and extended presicion.
    Have anybody experienced something like that?
    I'm missing some TCP configuration perhaps? 
    Regards,
    Matthuz

    Hello Kevin, thank you for your reply.
    I'm attaching a little demo to show you what is going on. If I set the debug options to use ULink all works nice, but it doesn't with TCP.
    It could be something with the signal generator that I'm using?
    Attachments:
    Test_Double.zip ‏16 KB

  • Help with double and float

    I added the (float) after the = in both and it fixed the top and not the bottom. "cant convert double to float" (as well as the answer to this, if somone could correct my terminology as well it would be appretiated. thanks in advance)
    float torontoF = (float)(torontoC * 1.8) + 32;
         System.out.print (torontoF);
    x      float stockholmC = (float)(stockholmF ? 32)* .5556;
         System.out.print (stockholmF);

    Reposted and answered at:
    http://forum.java.sun.com/thread.jspa?threadID=5219089
    Do not reply here.

  • Convert Double to String and Specify Precision

    Hi.....
    Can anyone tell me what class/method I would use if I want to convert a double to a string and need the ability to specify the precision?
    Thanks,
    Christine

    DecimalFormat

  • How to convert a String data to Double or Float???? Thank you

    I need to convert String data to Double or Float , please help me about it. Thank you very muh!
    String a=Integer.parseInt("1234"); convert to integer.

    I found it but do not know if it is ok
    float a= Float.valueof(String to
    convert).floatValue();
    may be it can be!!!
    Thank you !!!!How did parseInt lead you do valueOf?
    Look for something more consistent. A pattern.As I said earlier, it depends if he wants an object or a primitive.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Formatting a string with time stamp and double precision numbers

    %s\t%f\r%f
    This is a format string that I have in old code that I've decided to change.  Problem is I cannot make sense of the string codes in my own old code! Let me explain what I want, and hopefully someone can explain how to do it.
    I am using the format into string subvi to merge a time stamp (formatted as %m%d%Y%H%M%S%5u) and two different double precision numbers.  This string is then wired into the Write Characters to File subvi so that I can record data as a .txt file, and open it in either Matlab or Excel.  There is a minor problem with the string format above because in excel the first time stamp entry is blank, and the first loop only gives the two double precision numbers withouth the time stamp - the time stamp appears in the next loop (probably a looping issue and not due to the string format, but if you see differently please let me know).  Now what I want to do is 1. potentially fix that problem and 2. add some more doubles. 
    1. Is there a string format issue that is evident that I am not seeing that causes the time stamp to be formatted into the string after a carriage return?  Or should I be looking at looping issues?
    2. How do I add another one - three floating point numbers (double precision)?  Are the \'s marking different numbers in this string constant?  Or is it the %?  I can't find any information about the \'s, but I see that % begins the format specifier. 
    Ideally, I want these data in the following columns:  Date, Time(absolute), FP, FP, FP, carriage return for the next loop (FP is floating point double precision number).
    Thanks,
    Brad

    Hi JonN,
    Here there is no need of string concordinate function (in your code), the same result you can find if you connect the output of the format string to shift register, and shift register in data to initialize string connector in format into string function.
    <<KUDOS ARE WELCOME>>
    ELECTRO SAM
    For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.
    - John 3:16

  • Converting a binary string to a number...

    Hi guys,
    I'm trying to convert a binary string into a decimal integer. I'm not sure if LabVIEW has a VI that does that. I haven't found one yet. Basically, say I have the string '0101'. I want to convert that to the value '5'. Or say I'm using hex, I want '10101111' to be converted to 'AF'. So that's my dilemma. I'm hoping I'm not going to have to make my own VI. Thanks a lot!
    -Mike

    LabVIEW has exactly what you want even if it can be hard to find it.
    To convert a binary text string like "0101" to a decimal value can easily be done using the Scan Value function found under the String/Number conversion section. If you provide the format %b to it (not mentioned in the manual) you will get the decimal value of your binary string.
    Also, on your front panel you can change the format of your numerical indicators by right clicking on it and selecting Format & Precision. If you have a numerical indicator you can set it do display the numbers in e.g. hexadecimal form.
    However, if you want to convert a number to a hexadecimal text string you can use the Number to Hexadecimal String function also found under the String/Number conversion section.
    I
    attached a simple example, Conversions.vi, that shows how it works. I hope this helps. /Mikael
    Attachments:
    conversions.vi ‏14 KB

  • Converting Double to String without exponent

    Hi all,
    I am reading some values from Excelsheet using apache POI library. I have large numbers that need to stored into database as string and not numbers. hence, while reading the excelsheet values, i convert these number.. and the are received as double. While converting double into string I noticed that some values are represented in exponential form.. I would like to avoid this and have pure number values in the form of string,,..
    Can anybody tell me how to do it?
    Thanks in advance,
    Abdel Olakara

    java.text.DecimalFormat

  • Converting array of Double Precision values to U16 for MODBUS

    Hello,
    I am trying to send over pressure and temperature information via the Input Register array in MODBUS TCP.  My question is, how to I properly send over an array of double precision values without loosing my data?
    For example, my array of data looks like:
    12.0001
    32.001
    0.00051234
    0.0014838
    1.02
    12.0232
    31.920
    Thanks so much.

    Thank you Ravens Fan for replying.
    I missed one extra point of data.  Below is what I'd like to send:
    12.0001
    32.001
    0.00051234
    0.0014838
    1.02
    12.0232
    31.920
    2046
    The array above is an array of double precision values.  I will convert that array to an array of single precision floating data to reduce data size.
    Since I have eight pieces of single precision floating point data now, I will need to write to 16 registers correct?  What is the best method to split up each piece of data into two consecutive registers?
    Attached is a Slave Send Data.VI that I want to send this data through.  The end goal is to have a Master PC (not using labview, but a MODBUS utility) to read my MODBUS TCP message from the "Slave Send Data.vi" 
    Thanks
    Attachments:
    Slave Send Data.vi ‏15 KB

  • Converting a Double To A String

    Is it possible to convert a double to a string. I need to retrieve a double value from an array and display it as a label in an applet.
    How do I convert the double value to a string so that I can use it in the applet as a label?
    Thanks

    try this.
    double mydbl = 0;
    String mystr = null;
    mysstr=mydbl+"".trim();
    Paulthis one is nice paul, but it is also possible to do it that way:
    double d = 0;
    String dStr = Double.toString(d);see also API for classes Boolean, Character, Integer, Byte, Float, Short
    all primitives can easyli be turned int for in which you can print them out.

  • Not able to convert string attribute to number and date please help me out

    not able to convert string attribute to number and date attribute. While using string to date conversion it shows result as failure.As I am reading from a text file. please help me out

    Hi,
    You need to provide an example value that's failing and the date formats in the reference data you're using. It's more than likely you don't have the correct format in your ref data.
    regards,
    Nick

  • Newbie Converting double to string

    I am very new to Java Programming, but I am trying to convert a double to a string
    Here is some code of what I am trying to do:
          String output = "";
          Word words[] = new Word[ 7 ];
                        Then I add the "words" to the array
          for ( int i = 0; i < words.length; i++ ) {
             output += words[ i ].toString();
                      output +="\nListed :" + Double.toString(words[ i ].listings()) + "\n";
         return output; the listings method is type double. I think I can use toString to convert a double to a string but am not sure how to go about doing it.
    Any help is very appreciated.
    Thanks.

    I am very new to Java Programming, but I am trying to
    convert a double to a string
    Here is some code of what I am trying to do:
    String output = "";
    Word words[] = new Word[ 7 ];
    Then I add the "words" to the array
    for ( int i = 0; i < words.length; i++ ) {
    output += words[ i ].toString();
    output +="\nListed :" + Double.toString(words[ i
    ].listings()) + "\n";
    return output;the listings method is type double. I think I can use
    toString to convert a double to a string but am not
    sure how to go about doing it.
    Any help is very appreciated.
    Thanks.Wrong:
    Double.toString(words[ i ].listings())
    Right:
    words[ i ].listings().toString()

  • Converting double to String

    I am looking for a way to convert double to String.
    I think that I have to use wrapper like Double class and use toString(double d), but I am not sure how to do it.
    Since toString() is static method, I do not have to have an instance of the Double class, so I was wondering what's the correct way to do it.
    I need something like this:
    String MyString = new String (String1.concat ( My_doubleNumber.Double.toString() ) );
    Any Suggestions?
    Thanks!!!

    WOW thanks a lot. These are definately better than what I thought of doing originally.
    In case I need to use the wrapper class somewhere else, I am just wondering what would be a proper use of Double and String?

Maybe you are looking for

  • Re: Profit Center Reporting

    Hi Friends, Iam new to ABAP/4 programming. I need to define reports in Profit center by using other Application components like SD,MM,Plant etc. 1. Can i create the report using Report Painter or WR? 2.Can u tell me the list of libraries used in prof

  • "Could not be copied because an error occured. There is not enough memory."

    Hello, I recently got an iPad 64gb. And have since been loading all of my Comic backups onto it (Via Cloudreaders). I've got 32.5gb used and 26.4gb Free. Every 20-30 issues or so I get an error that says "Comic book name here" cannot be copied becaus

  • Making a Directory with alumni information...Templates to use?

    I am making a directory with alumni information for my high school reunion. In one part of the book, I want to list bio information along with a current pix. In the back of the book, I want to alphabetize everyone's name and address and then cross-re

  • Outer Glow problem

    Hi, I'm using outer glow effect. When it reaches certain blur values, it draw a strange borders outside the object. I can't find a solution. Example:

  • ITunes 9.1.1 Problems !!

    Since V9 update none of my ipods have conencted to my computer they were all fine before. I have 2 iPod Classics, 1 iPod Touch & 1 iPod Nano. They don't show up in Windows or iTunes. Anyone else with the same problems ?? I have tryed ALL troubleshoot