Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Virtual Machine / April 2009

Tip: Looking for answers? Try searching our database.

Source code for native methods in java

Thread view: 
kb - 21 Apr 2009 12:11 GMT
Hey,

Where can I download the source code for the native methods in java
like the "floatToIntBits" method in Float.java?

I'm actually trying to read/write real data types (float/double), in
binary format on to a stream, across java and c++. For this I was
trying to look at the format that java uses to write float/double on
to the stream.

Does anyone know of any known implementation(s) that handle reading/
writing of real data types in a language and platform independent way.

Thanks
Kb
Reinder Verlinde - 21 Apr 2009 18:46 GMT
In article
<99d4a2cb-6ea2-4e09-b2fc-f2177be1a612@q9g2000yqc.googlegroups.com>,

> Hey,
>
> Where can I download the source code for the native methods in java
> like the "floatToIntBits" method in Float.java?

Not that you need it, but: <http://openjdk.java.net/>

> I'm actually trying to read/write real data types (float/double), in
> binary format on to a stream, across java and c++. For this I was
> trying to look at the format that java uses to write float/double on
> to the stream.

Single-precision IEEE 754 floating-point (32-bit)/double-precision IEEE
754 floating-point (64-bit) (<http://en.wikipedia.org/wiki/IEEE_754>)

> Does anyone know of any known implementation(s) that handle reading/
> writing of real data types in a language and platform independent way.

For true platform independence, that problem is really, really, hard.
AFAIK, your best bet still is ASCII here.

However, for nowadays-almost platform independence, writing IEEE floats
in binary is good enough. You probably will still run into trouble with
endianness (<http://en.wikipedia.org/wiki/Endianness>), but that is easy.

Reinder
Roedy Green - 24 Apr 2009 05:37 GMT
>Hey,
>
>Where can I download the source code for the native methods in java
>like the "floatToIntBits" method in Float.java?

see http://mindprod.com/jgloss/jdk.html for a link to the source code.

see http://mindprod.com/jgloss/iee754.html for the format if you want
to write your own code from scratch or are just curious about the
format.  That entry has an overview of the format and links to
detailed specs.
Signature

Roedy Green Canadian Mind Products
http://mindprod.com

"It is not the strongest of the species that survives, nor the most intelligent that survives. It is the one that is the most adaptable to change."
~ Charles Darwin



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.