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

Similar Messages

  • Converting a binary string into a JPEG image in Crystal Reports 2008

    Hi Gang
    Iu2019m having problems converting a binary string into an image in Crystal Reports 2008
    I have JPEG images stored in ECC.  ECC stores the data in binary format.
    Iu2019m using the ECC function module SKWF_PHIO_CONTENT_ACCESS_GET to retrieve the data.  This function module has an export table, FILE_CONTENT_BINARY, which returns several lines of data.  Each line contains a maximum of 1,024 characters.
    When I drop the T_ FILE_CONTENT_BINARY.LINE field into my Crystal Report detail section, I wind up with a report that displays all the lines in FILE_CONTENT_BINARY table.  (in my case, 19 lines are displayed.)
    I created a formula to collect all the data into a single string.
    whileprintingrecords;
    stringvar data:= data & {SKWF_PHIO_CONTENT_ACCESS_GET.T_FILE_CONTENT_BINARY.LINE}
    I added the formula to the detail section and itu2019s doing a great job collecting the data.
    I then inserted a picture object in the report footer, opened the format editor, navigated to the u201Cpictureu201D tab, and inserted a formula for the u201Cgraphics locationu201D.
    whileprintingrecords;
    stringvar data:=data;
    data
    My clever idea turned out to be a disappointment . . . . my picture object is blank.
    Does anyone have a solution for converting a binary string into a JPEG image?

    Save the JPEG in a format CR supports. Refer to the help file for the file types.

  • Convert Raw Binary String to InputStream

    Hi i want to upload a {color:#003366}JPG image file{color} in a {color:#003366}BLOB{color} field in database. At first i was using {color:#003366}AJA{color}X to send file {color:#003366}path{color} to the {color:#003366}servlet{color} creating a {color:#003366}file Object{color} from it, then {color:#003366}FileInputStream{color} from it, and finally passing it to {color:#003366}preparedstatement.setBinaryStream({color}) method. It worked great. But since{color:#003366} Firefox 3{color} stopped sending full path to database i have to use another method.
    So instead of sending image path i used {color:#ff0000}nsIDOMFile{color} property of Firefox 3. It has a method {color:#003366}getAsBinary(){color} which Returns a DOMString containing the file's data in {color:#003366}raw binary{color} format. Now i access this {color:#003366}string{color} from servlet using{color:#003366} request.getParameter(){color} method which creates a {color:#003366}String containing bit code of the image file{color} (I suppose). Now how to convert this string to {color:#003366}InputStream{color} so that i can store this in BLOB field in database using prepared statement.
    Right now I am using following code but it doesn't seem to work.
    String image=request.getParameter("image");
        try{
          InitialContext context = new InitialContext();
          dsource = (DataSource)context.lookup("java:comp/env/jdbc/DataSource");
          con = dsource.getConnection();
          ps = con.prepareStatement("SOME STATEMENT");
          ByteArrayInputStream imagestream = new ByteArrayInputStream(image.getBytes());
          ps.setBinaryStream(1, imagestream, imagestream.available());
          int i = ps.executeUpdate();Edited by: Wonder01 on Oct 22, 2008 12:24 PM

    Yeah i came across that too. But these show either iframes hack method (which really isn't ajax) or else writing large pieces of code just to generate the binary stream of the file, then manually creating multipart/form-data request were the only options until Firefox 3 introduced nsIDOMFile. See this and read first few lines (you'll understand what i mean). So i send request in the form of a parameter containing Raw Binary format of the file
    Now going over to the servlet side i need to somehow accept this parameter and insert in database. First i need to know how should i receive this on servlet (By using request.getParameter() or some other method). And secondly, how to convert that to either a byte array or InputStream. I searched for it and think this might be useful. This page shows 1.) how to convert an array of raw binary data into an array of ASCII 0 and 1 characters and 2.) how to convert a String to byte array where each char of the String represents an ASCII '0' or '1'. But what i nedd is slightly different, I need to convert a String containing Raw Binary into byte array.
    And thanks for the information on the file paths. It was really helpful

  • Mail Excel as attachment with input as binary string

    Hi Experts ,
    I want to design BAPI which will have one string as import parameter.
    I will get binary data in this string.
    Now i want to mail this binary data string as excel attachment.
    Anyody knows how to convert this binary string to internal table and then send this as attachment?
    Thanks & Regards ,
    JIgar.

    check these sample programs
    BCS_EXAMPLE*

  • Converting a Hexadecimal String to a Binary String

    Hello NG,
    I would like to convert an 8 Bit Hexadecimal String (example C0034000)
    to it´s equivalent in binary (in this case---> 1100 0000 0000 0011...
    and so on), I didn´t find any possible way to do this. I´am not
    talking about the simple representation on the front pannel. Some
    Postings say that this ist possible with the "Format Value" Function
    adding an "%b" to the entring, but in my case it does not function.
    Could someone help me, thanks in advance!

    > I would like to convert an 8 Bit Hexadecimal String (example C0034000)
    > to it´s equivalent in binary (in this case---> 1100 0000 0000 0011...
    > and so on), I didn´t find any possible way to do this. I´am not
    > talking about the simple representation on the front pannel. Some
    > Postings say that this ist possible with the "Format Value" Function
    > adding an "%b" to the entring, but in my case it does not function.
    The task here is to convert a string to a different string. The easiest
    way to do this is to convert the string to a numer, then format the
    number as a binary string.
    On the string palette the Scan from String using %x can be used to
    change a hex string into a numeric integer. The Format to String with
    %b and other nodes can take a numeric i
    nteger and return a string of
    binary characters. These two nodes wired together with the correct
    constants should do what you want.
    Greg McKaskle

  • Converting a binary number to a list of integers

    I need to convert a binary number to a list of the values of the bit possitions that make up that number. I.e. 1 = 1; 3=2,1; 7=1,2,4.
    Does anyone know of Java API functions that could accomplish this, I couldn't find any, or a function that can do this?

    This reminds me of my programming homework assignments...
    There are some very efficient ways to do this - but I can't remember them off the top of my head. I can guarantee they will have been posted several hundred times before. This will work:
    class BitMask {
        private byte mask = 1;
        public void printBitFields(int a) {
         System.out.print(a + " =");
         for(i = 0 ; (a & Integer.MAX_VALUE) != 0 ; i++) {
             if((a & mask) == 1)
              System.out.print(" " + ((int) java.lang.Math.pow(2,i)));
             a >>= 1;
         System.out.println();
        public final static void main(String args[]) {
         BitMask bm = new BitMask();
         bm.print(1);
         bm.print(18);
         bm.print(19); // etc...
    }

  • Binary String convertion.

    I've question on binary string convert to array of text/number.
    I'm tried to use GPIB read to retrieve a trace of Maxhold data (n number
    of frequency) from ESMI Spectrum Analyzer. however, those data always
    come out to binary string. So is there anyway i can convert Binary
    string --> ascii (in my case, array of number/text), or to retrieve
    readable data from the Spectrum Analyzer.
    Very appreciate for help.
    Jacky Wong

    I've question on binary string convert to array of text/number.
    I'm tried to use GPIB read to retrieve a trace of Maxhold data (n number
    of frequency) from ESMI Spectrum Analyzer. however, those data always
    come out to binary string. So is there anyway i can convert Binary
    string --> ascii (in my case, array of number/text), or to retrieve
    readable data from the Spectrum Analyzer.
    Very appreciate for help.
    Jacky Wong

  • 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

  • How can I convert a U32 array into binary string?

    Hi
    I would like to find an efficient way to convert an array of 8192 U32 into a single binary string!!!
    the solution below  last 550 ms on an RT target to convert 8192 U32.
    The same code running on Labview (not RT) last 100ms. I don't understand why there is such a difference.
    I've tryed to replace the inner loop and convert by a format string whith U32 on entry and %032b as parameter but it lasted same time.
    Thanks a lot

    Your picture of your code didn't come through. You can't link to a picture that's on your computer, as a server on the internet cannot access your computer to display the picture for others to see. You have to upload the picture as an attachment. Then, if you want to actually display the picture in the message you have to edit your post, insert a picture, and when it asks for the URL you enter the URL of the picture. You can get the URL when viewing the message, as the link is within the message itself.
    As for your question, can you just use the TypeCast function?

  • Converting scientific notation string to number?

    This is raising an error:
    > ToNumber (u201C2.75E-05u201D)
    How do you convert scientific notation strings to numbers?
    This is coming from XML. I can probably have the XML written so that it's not scientific notation.
    Tim

    Here's a not-so-pretty way:
    Local StringVar Array x;
    Local StringVar mantissa;
    Local StringVar exponent := "0";
    // Split into mantissa and exponent parts.
    x:= Split("24.2233E+2", "e", 2, 1);
    mantissa := x[1];
    If (UBound(x) = 2)
    Then
        exponent := x[2];
    // CDbl cannot interpret leading positive sign, so removie
    If Left(mantissa, 1) = "+"
    Then
        mantissa := Right(mantissa, Length(mantissa) - 1);
    If Left(exponent, 1) = "+"
    Then
        exponent := Right(exponent, Length(exponent) - 1);
    // Compute number
    CDbl(mantissa) * 10 ^ CDbl(exponent);
    Sincerely,
    Ted Ueda

  • How to convert binary string to ascii

    Hi,
    See i have a string like this,
    String str = "10011100110001011001110011000101";
    Now i want to find exact ascii value of the binary string.
    Thanks in advance.

    First want to convert these bits to corresponding
    characters and then have to find ascii of the same.... corresponding to what? I think converting these "bits" to the corresponding chars is the whole story. But what about the original format?
    Guessing mode on ... does this help?
    String input = "...";
    StringBuffer result = new StringBuffer();
    for (int i = 0;i < input.length();i += 8) {
      result.append((char) Integer.parseInt(input.substring(i, i + 8), 2));
    System.out.println(result);

  • Converting String to the Number

    Dear Members,
    I'm new to OAF.
    I have a requirement in which I need to convert a string to the number.
    Can any one please help me how to achieve this in OAF?
    Regards.

    Please import oracle.jbo.domain.Number;
    Then include the conversion in a try catch block
    try
    Number numValue = new Number (stringVal);
    catch(SQLException e)
    e.printStackTrace();
    Regards
    Sumit

  • Convert signal to binary string

    Hi all : I get waveform signal (square signal) from scope .. and  I want to convert this signal  to binary string …   Can I do that in labview 8.5
    thanks

    elyan a écrit:
    Hi all : I get waveform signal (square signal) from scope .. and  I want to convert this signal  to binary string …  
    Hello,
    Is that what you want to do ?
    http://img514.imageshack.us/my.php?image=scopetost​ringls7.jpg
    sage Edité par tinnitus le 12-31-2008 05:35 AM
    Message Edité par tinnitus le 12-31-2008 05:36 AM
    CLAD / Labview 2011, Win Xp
    Mission d'une semaine- à plusieurs mois laissez moi un MP...
    RP et Midi-pyrénées .Km+++ si possibilité de télétravail
    Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
    Don't forget to valid a good answer / pensez à valider une réponse correcte

  • Decoding binary strings from 10 bit A/D converter

    Hi all,
    I'm working on a project for school that requires me to take data from an A/D converter ( the A/D is on a Motorola HCS12 microcontroller) and send it to a PC running LABVIEW to decode the binary string into a numerical value.  The value will be plugged into an equation.  I planned on using the serial port on the PC for the comm port.  Are there any examples available or any advice to get me started in the right direction. 
    While I have programmed with LABVIEW in the past (academically) I am not proficient.  And this type of interfacing I have not done before, only GPIB.
    The A/D is 10 bit.  How quick LABVIEW decodes the binary string and returns a value is not important. 
    If any more info. is needed let me know.    

    Be confident. That should not be a big problem, since you'll get the help of the LV community
    The most difficult part will be to establish the communication with your micro-controler. But if you can do that with Windows hyperterminal, then you are nearly done ! There are examples of serial com in the examples shipped with LV.
    The string to decimal conversion will not be a problem, whatever the string format : the conversion is done using functions also shipped with LV.
    Hope to see you soon with more specific questions.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • UCCX: unable to convert string into a number

    Hi all,
    I used the Get Digit String to pull a 4 digital numbers (stored as variable sYear) from a caller, this number is obviously stored as a string. Then i used 'set iYear=sYear' to conver this string to an integer.
    I debuged the script, when I entered number of year without following #, it worked fine. If I entered number of year and followed by #, i got the message 'unable to conver string into a number'. Can someone help me with that?
    Thanks a lot.

    Hi Reena,
    The UCCX version is 10.5.1.
    I found the problem. It works after i changed input length to 5.  'The terminating key overrides the Maximum Input Length to terminate input'.
    Thanks.

Maybe you are looking for

  • Java exec spawns command window

    Hello, I am using JRE 1.4.2 (Eclipse runtime environment). Whenever I execute the following command: System.getRuntime().exec("<some command>"); I am getting a Command Window that pops up while the process executes and closes afterwords. Is there any

  • I have the Insurance Plan..but old Phone (Samsung Saga I-770)

     I've had insurance for 2 years. It looks like they don't even sell that model on the Verizon Website or store. It's been lost, will Verizon send me the exact same model  or give me a choice for replacement?

  • Error Code: 86000108 - New Lumia 640

    Can someone advise on this recurrent problem?  I cannot sync with hotmail.com - no email, contacts or calenders on a new Lumia 640.   I cannot figure it out. I have tried to reset the phone, clicked and unclicked sync email and performed multiple har

  • How do I get rid of the question marks?

    All my thumbnails have question marks in the upper corner.  These pictures do not load.  In fact, I get an error message (file not found) for each one.  So far, I have no pictures to log in with.  Any suggestions?---Doc

  • Select from 1 table only if a value does not exist

    Hello all, I'm having problems devising a single select statement to accomplish a single return value. I have tried variations of DECODE and COALESCE, but it's escaping me. I have two tables that are as follows: NAME ID, FULLNAME 1, Senior 2, Junior