Conversion from byte array to float.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Conversion from byte array to float.

Hybrid View

  1. #1
    madhusudhan Guest

    Conversion from byte array to float.


    Hi All,
    I have a byte array of size 4 whuch should be converted to its float value.
    I am able to this kind of conversion (byte array) to integer primitive but

    its difficult to apply the samme..
    Thanx in adv,
    madhu



  2. #2
    Paul Clapham Guest

    Re: Conversion from byte array to float.

    A better solution to this problem would be to create a float value in the
    first place instead of creating a byte array and then trying to convert it.
    However, here's an answer to your question:

    DataInputStream dis = new DataInputStream(new
    ByteArrayInputStream(yourByteArray));
    float f = dis.readFloat();

    But as I said, it would be better to use a DataInputStream and readFloat()
    to create the value in the first place. And the same is true for integers.

    PC2

    "madhusudhan" <madhu_sri@indya.com> wrote in message
    news:3b0cd07a$1@news.devx.com...
    >
    > Hi All,
    > I have a byte array of size 4 whuch should be converted to its float

    value.
    > I am able to this kind of conversion (byte array) to integer primitive

    but
    >
    > its difficult to apply the samme..
    > Thanx in adv,
    > madhu
    >
    >




  3. #3
    Rajkamal Gopinath Guest

    Re: Conversion from byte array to float.


    Hi

    How does the decimal portion is stored in the byte array of size 4



    "madhusudhan" <madhu_sri@indya.com> wrote:
    >
    >Hi All,
    > I have a byte array of size 4 whuch should be converted to its float value.
    > I am able to this kind of conversion (byte array) to integer primitive

    but
    >
    >its difficult to apply the samme..
    >Thanx in adv,
    >madhu
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center