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

  • SEARCH
  • Home
  • 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 8222791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:23:52+00:00 2026-06-07T14:23:52+00:00

I’m porting a program originally written in VB.NET to Java. I’m reading from a

  • 0

I’m porting a program originally written in VB.NET to Java. I’m reading from a file which stores 32 bit floats in little endian order.

The original program does this:

Dim br As BinaryReader = ...
Dim f_vb As Single = br.ReadSingle

Java is big endian, so I reverse the bytes before converting to a float.

RandomAccessFile raf = // ...
int i = raf.readInt();
int bigEndian = Integer.reverseBytes(i);
float f_java = Float.intBitsToFloat(bigEndian);

As far as I can tell, f_vb and f_java contain the same bits. That is, BitConverter.ToInt32 on f_vb and Float.floatToIntBits (and floatToRawIntBits) on f_java give the same thing. However, the floats are not equal. For example, let bigEndian == 0x4969F52F. Java will report 958290.94, and VB.NET will report 958290.938. I’m guessing this comes from a difference in the way the JVM and CLR handle floating point numbers, but I don’t know enough about floating point issues to figure out why. This loss of precision is causing trouble down the line, so I’d like to identify the source.

  • 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-07T14:23:53+00:00Added an answer on June 7, 2026 at 2:23 pm

    The exact value represented by those bits is 958290.9375. It may be that whatever you used to display the value in Java, which displayed “958290.94”, rounds by default to two decimal places or eight significant figures, and whatever you used in VB.NET, which displayed “958290.938”, rounds by default to three decimal places or nine significant figures. Alternatively, one of them may be poor at converting floating-point to decimal for display.

    If there are options to display more digits, try them. Alternately, construct the value 958290.9375, subtract it from the f_java, and test whether the result is exactly zero. It should be.

    The single-precision floating-point numbers nearest 958290.9375 are 958290.875 and 958291. Neither of those could be displayed as “958290.94” or “958290.938” by any halfway decent formatter, so it is very unlikely the float you have is anything other than 958290.9375.

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

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported

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.