Lack of fabsf on Solaris (patch included)

Cedric Berger cedric@wireless-networks.com
Thu Jan 25 06:06:00 GMT 2001


Martin Kahlert wrote:
>> On Thu, Jan 25, 2001 at 05:47:23AM -0800, Cedric Berger wrote:
> > Why not simply this:
> >
> > jfloat java::lang::Math::abs(jfloat x)
> > {
> > return x < 0.0F ? -x : x;
> > }
> >
> > And removing all this autoconf mess?
>> Would be nice. But i don't know, if it's correct:
>> Are the float types symmetric?

Yes, they are (bit 31 is the sign bit). 
This could suggest a more efficient code, if the compiler is smart
enough to keep x in a register:
	
 jfloat java::lang::Math::abs(jfloat x)
 {
 return *((uint32_t *)&x) ^ 0x80000000U;
 }
 
> it gets inlined in gcc on some OSes (x86 for example).

Good point, I didn't knew that.
Cedric


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /