Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6675087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:48:38+00:00 2026-05-26T03:48:38+00:00

I am communicating with some device and this device sending me data as unsigned

  • 0

I am communicating with some device and this device sending me data as unsigned bytes. And I need to convert these bytes to float in Java. Is there any way?

Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:48:38+00:00Added an answer on May 26, 2026 at 3:48 am

    Yes. Float.intBitsToFloat takes 32 bits as an int and converts it to a float.

    All you need to do first is convert your four bytes to an int using the normal shift and or operations appropriate to the endianness of your data. For example,

    float f = Float.intBitsToFloat(
        (barr[0] & 0xff)
        | ((barr[1] & 0xff) << 8)
        | ((barr[2] & 0xff) << 16)
        | ((barr[7] & 0xff) << 24));
    

    You can also use FloatBuffer depending on how you are receiving the data.

    public abstract FloatBuffer asFloatBuffer()
    

    Creates a view of this byte buffer as a float buffer.

    Note, that "the device [is] sending me data as unsigned bytes" is not true. The data is sending you bytes, and Java represents them as signed bytes. Java does not have an unsigned byte type.

    http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

    byte: The byte data type is an 8-bit signed two’s complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to know if there is any embedded DBMS (preferably in Java and
I am looking at device to device communications and need some direction. I have
When the device I am communicating with sends binary data, I can recover most
I need to do some communications over a serial port in Ruby. From my
I am involved in a venture that will port some communications, parsing, data handling
I need to implement some form of communication mechanism in my application, to send
I need some help in resolving an issue I'm facing an with communication of
I need to write a kernel module that is not a device driver. That
We've been bashing our heads off of this one all morning. We've got some
I'm writing some software that automatically connects a Bluetooth device using the Windows Bluetooth

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.