Convert IEEE754 to binary integer

Hi everybody,
First of all I'm sorry, because I think I've added this post before in a wrong forum.
My problem is that I'm trying to compress a set of data in IEEE754 format and little endian. The first thing I want to do is convert this data in binary integers an then crop the resolutions of those integer numbers.
I've tried the next code:
in = new DataInputStream(new FileInputStream(file));
out = new DataOutputStream(new FileOutputStream("toInteger.bin"));
+while (true) { // exception deals catches EOF+
out.writeInt((int)in.readDouble());
+}+
but the results are not what I want.
Does anybody know how can I do it?
Thank you in advance

It's not a compilation failure, the problem is that the program seems to take the first 4 bytes of a double number and deprecate the remaining 4. Most of my data have four trailing zero bytes, i.e., they are really single-precision values, so when I make the conversion I only obtain zeros:
00 00 00 00 00 23 bd 40 -> 00 00 00 00
00 00 00 00 00 ba bb 40 -> 00 00 00 00
c3 f5 28 5c c2 bd 15 41 -> 80 00 00 00
And this is not very useful.
By the way, tschodt, you have reason, the ByteBuffer class is very helpful in my program I'm already using it.

Similar Messages

  • Converting characters to binary

    Could anyone give me an idea how to convert characters to binary, and vice verse?
    It's like those hex and binary editors out there.

    See if this helps you out
    char c = 'a';
    String binaryString = Integer.toBinaryString(c);
    char translatedChar =
    (char)Integer.parseInt(binaryString, 2);
    System.out.println(binaryString);
    System.out.println(translatedChar);
    Thanks. It worked.

  • How to convert string to an integer in SQL Server 2008

    Hi All,
    How to convert string to an integer in sql server,
    Input : string str="1,2,3,5"
    Output would be : 1,2,3,5
    Thanks in advance.
    Regards,
    Sunil

    No, you cannot convert to INT and get 1,2,3 BUT you can get
    1
    2
    3
    Is it ok?
    CREATE FUNCTION [dbo].[SplitString]
             @str VARCHAR(MAX)
        RETURNS @ret TABLE (token VARCHAR(MAX))
         AS
         BEGIN
        DECLARE @x XML 
        SET @x = '<t>' + REPLACE(@str, ',', '</t><t>') + '</t>'
        INSERT INTO @ret
            SELECT x.i.value('.', 'VARCHAR(MAX)') AS token
            FROM @x.nodes('//t') x(i)
        RETURN
       END
    ----Usage
    SELECT * FROM SplitString ('1,2,3')
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Converting float to binary

    Hi,
    I was wondering if anyone knew of a way to convert a float value (as ascii) to a binary value?
    I need a program that will take in a number of floating values from a file, convert the values to binary and then write out these values in another file, 4 bytes at a time.
    I know that you can convert decimals to binary with an easy function but i've searched for float to binary and came up with nothing.
    any help would be really appreciated,
    cheers!

    One of the Java's problems is that you can easily get lost in the sea of Javadocs...
    java.io.DataOutputStream
    writeFloat(float v)
    Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the underlying output stream as a 4-byte quantity, high byte first.
    java.io.DataInputStream
    readFloat
    public float readFloat()
    throws IOException
    Reads four input bytes and returns a float value. It does this by first constructing an int value in exactly the manner of the readInt method, then converting this int value to a float in exactly the manner of the method Float.intBitsToFloat. This method is suitable for reading bytes written by the writeFloat method of interface DataOutput.

  • How to convert image to binary format

    Hi all,
      We have developed an Employee search  mobile web application in .net which is hosted on an exposed IP server, we need to show the employee data along with the image of the employee on mobile.
    When we run this application through our desktop we are able to see the image of the employee since we are doing this through <b>intranet</b> , but when we try to access the same from any mobile device we are able to see only the data but no image, since we are doing this through <b>internet(exposed server).</b>
    Please suggest some way to get this image,
    is there any<b> function module in ABAP</b> which can <b>convert image to binary format</b>
    so that we <b>export binary data</b> to .net application

    Hei evryone!
    CAn anyone pls help me on how to solve this error:
    java.security.AccessControlException: access denied (java.security.SecurityPermission insertProvider.SunJCE)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkSecurityAccess(Unknown Source)
         at sun.plugin.security.ActivatorSecurityManager.checkSecurityAccess(Unknown Source)
         at java.security.Security.check(Unknown Source)
         at java.security.Security.insertProviderAt(Unknown Source)
         at java.security.Security.addProvider(Unknown Source)
         at CryptoTest.processFile(SwingApplet.java:68)
         at CryptoTest.<init>(SwingApplet.java:65)
         at SwingApplet.init(SwingApplet.java:39)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Is it allright for a swing code to access local resources? like in my case i want my swing app to decrypt and encrypt an image file but when i tried to access the method for decrypting and encrypting i got this error message on my console. Do i have to make my code signed before i could write/read a file on my hard drive?
    Any help / suggestions would be much appreciated.Thanks!

  • How to convert pdf  to binary

    hi all,
       how to convert pdf  to binary .
    regards,
    sheetal

    refer this -
    http://www.geocities.com/rmtiwari/main.html?http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/Z_RMTIWARI_XSTRING_TEXT_CONVER.html

  • Converting ASCII as Binary... Transposed?

    Hello friends!
    I am building a VI to break apart a string of characters and convert each to binary code.   Please see the attached example.   When verifying the input string against the output boolean array, I notice that each 8bit code is transposed from left to right when compared against any standard ASCII to Binary table.   Am I understand that binary is usually read from right to left?   My concern is how other systems will translate this code after it is transferred.   The main question is this:  Do I leave it be, or transpose it before data transfer?
    Any advice or comments would be greatly appreciated!
    Thanks,
    Zach
    Solved!
    Go to Solution.
    Attachments:
    example_strobe_1.vi ‏7 KB

    Remember you are looking at an array.  Index 0 of an array (which corresponds to bit 0 of the number) will be to the left.  As long as you are just doing standard computer functions and bit manipulations, don't worry about it.
    If you are doing something where you want to graphically show on the front panel to a user what the bits look like and have the 0th bit on the right, then you will need to manipulate the array so that the 0th bit will be in index 7 and the 7th bit will be in index 0, and so on.

  • Converting ASCII to Binary

    Hello I need some help.
    I need to convert the ASCII data to Binary form. Like if i have the character 'A' and its ASCII is 65 then its binary would be 01000001.
    If there is any function/method available in java to convert ascii to binary, i would be really thanful.

    Hello I need some help.
    I need to convert the ASCII data to Binary form. Like
    if i have the character 'A' and its ASCII is 65 then
    its binary would be 01000001.
    If there is any function/method available in java to
    convert ascii to binary, i would be really thanful.
    byte ascii = 65;
    String binresult = "";
    for(int i=0;i<8;i++) {
      if(ascii%(2^i)=0) binresult += "0";
      else binresult += "1";
    }

  • How to convert a varchar to integer datatype in obiee Answers?

    Hi Gurus,
    I tried using cast to convert a varchar to integer type eg.
    cast (column as integer) in fx in answers but its not working.
    Can we use to_number function in answers?
    Also do we have any other way of changing the datatype of a column rather than changing it in
    Physical layer of the rpd.
    Thanks
    Ashish Gupta

    Always first choice should be BI instead of porting a function on DB side.
    As Lakshmipathi said do that.
    It would be always nice to share what you see instead of "Not working"
    have fun

  • How to convert XML to Binary in OSB Message flow

    Dear All,
    Can you please help me in converting XML to Binary in OSB Message flow.
    Please help.
    Thanks,

    ah ok, then you have to apply a transformation from XML to some fixed length format, EDI style
    probably you have 2 options: the traditional MFL
    http://docs.oracle.com/cd/E13159_01/osb/docs10gr3/consolehelp/mfls.html
    or the (probably) more supported nXSD with a JCA adapter
    http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/nfb.htm
    I will let you digest this info and then we can continue.
    There are a number of threads in this forum on whether one technology is better than the other (as usual, google can assist you)

  • How to convert a double to integer ?

    Hi,
    how do convert an output of a pow(2,n) method of Math class to integer. Since this pow(x double, y bouble) gives an output of type double, how do i convert this output to integer if i want the value returned as an integer ?
    thanks
    aron

    By casting (but note that this may not yield the results you want)...
    class Test {
         public static void main(String[] argv) {
              double a = 5.5;
              double b = 6.6;
              int c = (int)(a + b);
              System.out.println(c);
    }

  • Hi I would like to know if you can convert decimal to binary using actionscript 3.0?

    Hi I would like to know if you can convert decimal to binary using actionscript 3.0?

    Hi thanks for the response Ive tried to implement the code as you stated but it is not outputting please if you could check the following code and let me know where Ive gone wrong that would be much appreciated Thanks!.
    miles_txt.addEventListener(KeyboardEvent.KEY_DOWN,convertKilometres);
    miles_txt.restrict ="0-9";
    function convertKilometres (k:KeyboardEvent):void {
    var miles:Number;
    var kilometres:Number;
    if (k.keyCode == Keyboard.ENTER){
    miles=Number(miles_txt.text);
    kilometres=miles* 1.609344;
    kilometres_txt.text = kilometres.toPrecision(2);
    kilometreConvert_txt.addEventListener(KeyboardEvent.KEY_DOWN,convertKiloToMile);
    kilometreConvert_txt.restrict = "0-9";
    function convertKiloToMile(k:KeyboardEvent):void{
    var kilometreConvert:Number;
    var milesAnswer:Number;
    if (k.keyCode==Keyboard.ENTER) {
    kilometreConvert=Number(kilometreConvert_txt.text);
    milesAnswer=kilometreConvert* 0.621371192;
    milesAnswer_txt.text = milesAnswer.toPrecision(2);
    binary_txt.addEventListener(KeyboardEvent.KEY_DOWN, checkEnterKey2);
    function checkEnterKey2(e:KeyboardEvent):void{
    if(binary_txt.text != '' && e.keyCode == Keyboard.ENTER){
    decimal_txt.text=binaryToDecimal(binary_txt.text).toString();
    function binaryToDecimal(s:String):Number{
    var n:Number = 0
    for(var i:int=0;i<s.length;i++){
    n+=Number(s.substr(i,1))<<(s.length-1-i)
    return n;
    function decimalToBinary(n:Number):String{
    return n.toString(2);
    return_btn.addEventListener(MouseEvent.CLICK, goBackToCalculator);
    function goBackToCalculator(e:Event):void
    mybuttonSound.play();
    gotoAndStop("Calculator");
    clear_btn.addEventListener(MouseEvent.CLICK,clearField);
    function clearField(e:MouseEvent):void{
      mybuttonSound.play();
      miles_txt.text ="";
      kilometres_txt.text ="";
      milesAnswer_txt.text ="";
      kilometreConvert_txt.text ="";
      binary_txt.text ="";
      decimal_txt.text ="";

  • Convert Excel to Binary

    Dear All,
    Has anyone experience convert excel to binary ?
    For example, I have an excel file in my PC then I would like to set it as attachment in mail using CL_DOCUMENT_BCS. Attachment in this class only have two version, as text or as hexadecimal.
    In order to create hexadecimal content I need a binary format, i will use function SCMS_BINARY_TO_XSTRING.
    The problem is, how to convert excel to binary format.
    Thanks in advance.
    Rgds,
    Deny

    code snippet .
    data: xml_tab1 type solix_tab .
    call function 'GUI_UPLOAD'
        exporting
          filename            = filename
          filetype            = 'BIN'
          has_field_separator = ' '
          header_length       = 0
        importing
          filelength          = size
        tables
          data_tab            = xml_tab1
        exceptions
          others              = 1.
    call method document->add_attachment
                exporting
                  i_attachment_type    = 'XLS'
                  i_attachment_subject = atta_sub
                  i_att_content_hex    = xml_tab1.

  • Convert WDT to binary

    In the niHSDIO pallette there is a "convert binary to WDT" but there isn't a "convert WDT to binary". Has anyone done this? Trying to save some time.
    kph

    Hi!
    I am working on finding an answer/explanation for having one vs. the other. In the meantime, I found a function under Programming>>Waveform>>Digital Waveform>>Digital Conversion called Digital to Binary which converts a digital waveform or set of digital data to a binary array of unsigned integers.
    Regards,
    Tica
    Applications Engineer
    National Instruments

  • Error on select when using value converted from varchar to integer (with isnumeric in where)

    Hi,
    Why is it, that when I convert a varchar into integer and filter it to numeric only that I get the Error 'Conversion failed when converting the nvarchar value '...' to data type int.'
    Here is a short SQL witch shows the Error:
    create table tTest(ID int, sText nvarchar(15))
    insert into tTest
    select 1, null
    insert into tTest
    select 2, 'q'
    go
    select distinct ID, sText, convert(int,sText) AS ID2 from tTest where isnumeric(sText) = 1
    go
    SELECT DISTINCT TOP 100 PERCENT
    ID
    FROM
    (select distinct ID, sText, cast(sText as int) AS ID2 from tTest where isnumeric(sText) = 1) v1
    WHERE
    id2 = 1
    go
    drop table tTest
    As a workaround I replaced the case with 'cast(case when isnumeric(sText) = 1 then sText else null end as int)', but this rater unexpected.
    It works fine in a short query, but if I create a view with the SQL from V1 then the error is unexpected, since I only know that if I view the source of the view

    >'cast(case when isnumeric(sText) = 1 then sText else null
    ISNUMERIC is not 100% accurate.
    BOL: "ISNUMERIC returns 1 for some characters that are not numbers, such as plus (+), minus (-), and valid currency symbols such as the dollar sign ($). For a complete list of currency symbols, see money and smallmoney (Transact-SQL)."
    LINK: http://technet.microsoft.com/en-us/library/ms186272.aspx
    ISNUMERIC examples:
    http://sqlusa.com/bestpractices/isnumeric/
    Kalman Toth Database & OLAP Architect
    Free T-SQL Scripts
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

Maybe you are looking for

  • My IPOD is not being recognised by my Alpine CDE113BT Headunit

    My IPOD is not being recognised by my Alpine CDE 113BT Headunit. I have reset both my IPOD & Headunit & still not connection. I have tried one other Ipod & I Phone with no problems. An Error Message - 01 came on the display the last time it was conne

  • Histograms with preview images in Bridge

    I don,t think this feature exists but it would be great to have a Histogram which shows clipping next to preview images in the bridge (something you can turn on and of in the menu) without having to go into Raw converter or photoshop. I also have a q

  • FM for validating date coming from a file

    HI All, I have to validate date that needs to be validated before passing it to DB. Is der any FM for same I tried CONVERT_DATE_TO_INTERNAL. But it accepts date only in one specified format.

  • Focus Traversal Problem

    Hello, I implemented my own focus traversal policy provider for a JPanel. It appears to be working fine except for one of my components (a JTextArea contained in a JScrollPane). If I ctrl+tab out of the JTextArea, my custom FTP is never used. I am st

  • Requesting Help Modifying a Flash Site

    I have a Flash Web site for a small literary journal and am trying to switch over to my hosting service's mailing list manager for sending out newsletters. I see the HTML code for setting this up (available from my host), but do not know how to get i