Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Source code for native methods in java

5 views
Skip to first unread message

kb

unread,
Apr 21, 2009, 7:11:43 AM4/21/09
to
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

unread,
Apr 21, 2009, 1:46:15 PM4/21/09
to
In article
<99d4a2cb-6ea2-4e09...@q9g2000yqc.googlegroups.com>,
kb <kbha...@gmail.com> wrote:

> 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

unread,
Apr 24, 2009, 12:37:46 AM4/24/09
to
On Tue, 21 Apr 2009 04:11:43 -0700 (PDT), kb <kbha...@gmail.com>
wrote, quoted or indirectly quoted someone who said :

>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.
--
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

0 new messages