posted 12 years ago

Hi,

As per the method definition provided in sdk,

In all other cases, let s, e, and m be three values that can be computed from the argument:

int s = ((bits >> 31) == 0) ? 1 : -1;

int e = ((bits >> 23) & 0xff);

int m = (e == 0) ?

(bits & 0x7fffff) << 1 :

(bits & 0x7fffff) | 0x800000;

Then the floating-point result equals the value of the mathematical expression s�m�2(e-150).

Output is

s: 1 e: 0 m: 128

9.0E-44

I am able to understand the value of s, e, m. But I cannot understand how f1 is 9.0 e-44. Can anyone explain?

As per the method definition provided in sdk,

In all other cases, let s, e, and m be three values that can be computed from the argument:

int s = ((bits >> 31) == 0) ? 1 : -1;

int e = ((bits >> 23) & 0xff);

int m = (e == 0) ?

(bits & 0x7fffff) << 1 :

(bits & 0x7fffff) | 0x800000;

Then the floating-point result equals the value of the mathematical expression s�m�2(e-150).

Output is

s: 1 e: 0 m: 128

9.0E-44

I am able to understand the value of s, e, m. But I cannot understand how f1 is 9.0 e-44. Can anyone explain?

posted 12 years ago

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch

Getting someone to think and try something out is much more useful than just telling them the answer.

posted 12 years ago

Integer constants with a leading zero are

BTW - If you haven't already found it, here's a good place to go to check your work when you're doing this kind of stuff:

IEEE754 Conversion

Grant

[Eited to remove extraneous newline]

[ October 16, 2005: Message edited by: G Gainey ]

**octal**. Change your 0...0100" to plain "100" and you'll get the value I think you're expecting (1.4E-43).BTW - If you haven't already found it, here's a good place to go to check your work when you're doing this kind of stuff:

IEEE754 Conversion

Grant

[Eited to remove extraneous newline]

[ October 16, 2005: Message edited by: G Gainey ]

In Theory, there is no difference between theory and practice.<br />In Practice, there is no relationship between theory and practice.

posted 12 years ago

You can't use an Integer object, but how about this?

That ought to come out as bits being 4.

See the Integer class and the overloaded parseInt(String s, int radix) method.

CR

[ October 17, 2005: Message edited by: Campbell Ritchie ]

That ought to come out as bits being 4.

See the Integer class and the overloaded parseInt(String s, int radix) method.

CR

[ October 17, 2005: Message edited by: Campbell Ritchie ]

Grant Gainey

Ranch Hand

Posts: 65

posted 12 years ago
In Theory, there is no difference between theory and practice.<br />In Practice, there is no relationship between theory and practice.

Ummm...well, you could do it that way. Hadn't ocurred to me that the OP was just specifying the bit-pattern. I'd probably just do it using hex, in that case:

Grant

Grant