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 8401219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:44:58+00:00 2026-06-09T21:44:58+00:00

I am transferring data over to a slave device from an iPhone where the

  • 0

I am transferring data over to a slave device from an iPhone where the transmission requires a 16 bit data value. Now I have a floating-point value that I need to transfer, but how do I know how large it is, and how is it represented in hex?

The hex-represenation is needed because I may need to switch the lower and upper nibbles.

  • 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-06-09T21:45:00+00:00Added an answer on June 9, 2026 at 9:45 pm

    If you want to know the details, look up the IEEE floating-point standard on the web. But to represent it in hex, simply generate the number, obtain the individual bytes, and generate their hex representation. The two things you need to know are the length of the value (eg, sizeof(double)) and whether it’s stored “big-endian” or “little-endian”. iOS devices are always “little-endian”, meaning that the least-significant byte of the value has the lowest memory address.

    A straight-forward way to obtain the bytes is to create a C union of float or double and an appropriate-length array of unsigned char. Store the float value into the union and then retrieve the unsigned char bytes for conversion to hex. You can also use casts of the appropriate pointer types to perform this “aliasing”.

    union {
        float f;
        double d;
        unsigned char c[8];
    } foo;
    
    foo.d = 3.14156;
    for(int i=0;i<8;i++) printf("%02X",foo.c[i]);
    

    For Java users, where unions and aliasing are not an option, there are these class methods on Float and Double:

    Float.floatToRawIntBits(floatValue)
    Double.doubleToRawLongBits(doubleValue)
    

    And their inverses

    Float.intBitsToDouble(intValue)
    Double.longBitsToDouble(longValue)
    

    Note that these do not do a cast-like conversion (4.1 float will not be converted to 4 int, eg), but instead they transfer the bit patterns unchanged from float to integer formats.

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

Sidebar

Related Questions

I have been using the Bluetooth chat example for transferring data over Bluetooth from
I'm working on transferring data from one database to another. For this I have
I'm transferring a reasonably large image over a local network from an iPhone to
I tested the performance of transferring data from a program to another over socket
We are currently transferring our websites from Windows 2003 (32-bit) to Windows 2008 (64-bit)
I'm working with a GPS module that is transferring data to my mac over
I am trying to send and receive data over USB, my device, the Acer
I'm having issues transferring lazy loaded data over the wire using WCF and NHibernate.
I have a chart in excel that represents some value over a one day
I have a question about transferring data through Intent() to a MapView. String coorx

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.