This is the mail archive of the
java-discuss@sources.redhat.com
mailing list for the Java project.
Re: Lack of fabsf on Solaris (patch included)
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