* [Qemu-devel] [6050] fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero()
@ 2008-12-15 17:14 Aurelien Jarno
2008-12-15 17:48 ` Andreas Färber
2008-12-18 15:15 ` Laurent Desnogues
0 siblings, 2 replies; 5+ messages in thread
From: Aurelien Jarno @ 2008-12-15 17:14 UTC (permalink / raw)
To: qemu-devel
Revision: 6050
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6050
Author: aurel32
Date: 2008-12-15 17:14:20 +0000 (Mon, 15 Dec 2008)
Log Message:
-----------
fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero()
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Modified Paths:
--------------
trunk/fpu/softfloat-native.h
trunk/fpu/softfloat.h
Modified: trunk/fpu/softfloat-native.h
===================================================================
--- trunk/fpu/softfloat-native.h 2008-12-15 17:14:12 UTC (rev 6049)
+++ trunk/fpu/softfloat-native.h 2008-12-15 17:14:20 UTC (rev 6050)
@@ -258,6 +258,21 @@
return -a;
}
+INLINE float32 float32_is_infinity(float32 a)
+{
+ return fpclassify(a) == FP_INFINITE;
+}
+
+INLINE float32 float32_is_neg(float32 a)
+{
+ return a < 0.0;
+}
+
+INLINE float32 float32_is_zero(float32 a)
+{
+ return fpclassify(a) == FP_ZERO;
+}
+
INLINE float32 float32_scalbn(float32 a, int n)
{
return scalbnf(a, n);
@@ -350,6 +365,21 @@
return -a;
}
+INLINE float64 float64_is_infinity(float64 a)
+{
+ return fpclassify(a) == FP_INFINITE;
+}
+
+INLINE float64 float64_is_neg(float64 a)
+{
+ return a < 0.0;
+}
+
+INLINE float64 float64_is_zero(float64 a)
+{
+ return fpclassify(a) == FP_ZERO;
+}
+
INLINE float64 float64_scalbn(float64 a, int n)
{
return scalbn(a, n);
@@ -437,6 +467,21 @@
return -a;
}
+INLINE floatx80 floatx80_is_infinity(floatx80 a)
+{
+ return fpclassify(a) == FP_INFINITE;
+}
+
+INLINE floatx80 floatx80_is_neg(floatx80 a)
+{
+ return a < 0.0;
+}
+
+INLINE floatx80 floatx80_is_zero(floatx80 a)
+{
+ return fpclassify(a) == FP_ZERO;
+}
+
INLINE floatx80 floatx80_scalbn(floatx80 a, int n)
{
return scalbnl(a, n);
Modified: trunk/fpu/softfloat.h
===================================================================
--- trunk/fpu/softfloat.h 2008-12-15 17:14:12 UTC (rev 6049)
+++ trunk/fpu/softfloat.h 2008-12-15 17:14:20 UTC (rev 6050)
@@ -281,6 +281,21 @@
return make_float32(float32_val(a) ^ 0x80000000);
}
+INLINE int float32_is_infinity(float32 a)
+{
+ return (float32_val(a) & 0x7fffffff) == 0x7ff80000;
+}
+
+INLINE int float32_is_neg(float32 a)
+{
+ return float32_val(a) >> 31;
+}
+
+INLINE int float32_is_zero(float32 a)
+{
+ return (float32_val(a) & 0x7fffffff) == 0;
+}
+
#define float32_zero make_float32(0)
/*----------------------------------------------------------------------------
@@ -335,6 +350,21 @@
return make_float64(float64_val(a) ^ 0x8000000000000000LL);
}
+INLINE int float64_is_infinity(float64 a)
+{
+ return (float64_val(a) & 0x7fffffffffffffffLL ) == 0x7ff0000000000000LL;
+}
+
+INLINE int float64_is_neg(float64 a)
+{
+ return float64_val(a) >> 63;
+}
+
+INLINE int float64_is_zero(float64 a)
+{
+ return (float64_val(a) & 0x7fffffffffffffffLL) == 0;
+}
+
#define float64_zero make_float64(0)
#ifdef FLOATX80
@@ -384,6 +414,21 @@
return a;
}
+INLINE int floatx80_is_infinity(floatx80 a)
+{
+ return (a.high & 0x7fff) == 0x7fff && a.low == 0;
+}
+
+INLINE int floatx80_is_neg(floatx80 a)
+{
+ return a.high >> 15;
+}
+
+INLINE int floatx80_is_zero(floatx80 a)
+{
+ return (a.high & 0x7fff) == 0 && a.low == 0;
+}
+
#endif
#ifdef FLOAT128
@@ -435,6 +480,21 @@
return a;
}
+INLINE int float128_is_infinity(float128 a)
+{
+ return (a.high & 0x7fffffffffffffffLL) == 0x7fff000000000000LL && a.low == 0;
+}
+
+INLINE int float128_is_neg(float128 a)
+{
+ return a.high >> 63;
+}
+
+INLINE int float128_is_zero(float128 a)
+{
+ return (a.high & 0x7fffffffffffffffLL) == 0 && a.low == 0;
+}
+
#endif
#else /* CONFIG_SOFTFLOAT */
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [6050] fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero()
2008-12-15 17:14 [Qemu-devel] [6050] fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero() Aurelien Jarno
@ 2008-12-15 17:48 ` Andreas Färber
2008-12-15 22:07 ` Aurélien Jarno
2008-12-18 15:15 ` Laurent Desnogues
1 sibling, 1 reply; 5+ messages in thread
From: Andreas Färber @ 2008-12-15 17:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Aurélien Jarno
Hi,
Am 15.12.2008 um 18:14 schrieb Aurelien Jarno:
> Revision: 6050
> http://svn.sv.gnu.org/viewvc/?
> view=rev&root=qemu&revision=6050
> Author: aurel32
> Date: 2008-12-15 17:14:20 +0000 (Mon, 15 Dec 2008)
>
> Log Message:
> -----------
> fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero()
>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Doesn't IEEE 754 have both a positive and a negative zero?
> +INLINE float32 float32_is_neg(float32 a)
> +{
> + return a < 0.0;
> +}
I would assume that 0.0 == -0.0 so this would not indicate a negative
zero as negative. Is that intended?
Andreas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [6050] fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero()
2008-12-15 17:48 ` Andreas Färber
@ 2008-12-15 22:07 ` Aurélien Jarno
0 siblings, 0 replies; 5+ messages in thread
From: Aurélien Jarno @ 2008-12-15 22:07 UTC (permalink / raw)
To: qemu-devel
On Mon, Dec 15, 2008 at 06:48:27PM +0100, Andreas Färber wrote:
> Hi,
>
> Am 15.12.2008 um 18:14 schrieb Aurelien Jarno:
>
>> Revision: 6050
>> http://svn.sv.gnu.org/viewvc/?
>> view=rev&root=qemu&revision=6050
>> Author: aurel32
>> Date: 2008-12-15 17:14:20 +0000 (Mon, 15 Dec 2008)
>>
>> Log Message:
>> -----------
>> fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero()
>>
>> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
>
> Doesn't IEEE 754 have both a positive and a negative zero?
>
>> +INLINE float32 float32_is_neg(float32 a)
>> +{
>> + return a < 0.0;
>> +}
>
> I would assume that 0.0 == -0.0 so this would not indicate a negative
> zero as negative. Is that intended?
>
This is true, however I doubt it will make a difference given the use
of this function (for sure it doesn't make any difference given the
current use). I have fixed it for the sake of correctness, but the
resulting code is now probably slower.
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [6050] fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero()
2008-12-15 17:14 [Qemu-devel] [6050] fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero() Aurelien Jarno
2008-12-15 17:48 ` Andreas Färber
@ 2008-12-18 15:15 ` Laurent Desnogues
2008-12-18 22:54 ` Aurelien Jarno
1 sibling, 1 reply; 5+ messages in thread
From: Laurent Desnogues @ 2008-12-18 15:15 UTC (permalink / raw)
To: qemu-devel
On Mon, Dec 15, 2008 at 6:14 PM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> Revision: 6050
> http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6050
> Author: aurel32
> Date: 2008-12-15 17:14:20 +0000 (Mon, 15 Dec 2008)
>
> Log Message:
> -----------
> fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero()
>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
[...]
> Modified: trunk/fpu/softfloat.h
> ===================================================================
> --- trunk/fpu/softfloat.h 2008-12-15 17:14:12 UTC (rev 6049)
> +++ trunk/fpu/softfloat.h 2008-12-15 17:14:20 UTC (rev 6050)
> @@ -281,6 +281,21 @@
> return make_float32(float32_val(a) ^ 0x80000000);
> }
>
> +INLINE int float32_is_infinity(float32 a)
> +{
> + return (float32_val(a) & 0x7fffffff) == 0x7ff80000;
This should be == 0x7f800000.
Laurent
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [6050] fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero()
2008-12-18 15:15 ` Laurent Desnogues
@ 2008-12-18 22:54 ` Aurelien Jarno
0 siblings, 0 replies; 5+ messages in thread
From: Aurelien Jarno @ 2008-12-18 22:54 UTC (permalink / raw)
To: qemu-devel
On Thu, Dec 18, 2008 at 04:15:10PM +0100, Laurent Desnogues wrote:
> On Mon, Dec 15, 2008 at 6:14 PM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> > Revision: 6050
> > http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6050
> > Author: aurel32
> > Date: 2008-12-15 17:14:20 +0000 (Mon, 15 Dec 2008)
> >
> > Log Message:
> > -----------
> > fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero()
> >
> > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> [...]
> > Modified: trunk/fpu/softfloat.h
> > ===================================================================
> > --- trunk/fpu/softfloat.h 2008-12-15 17:14:12 UTC (rev 6049)
> > +++ trunk/fpu/softfloat.h 2008-12-15 17:14:20 UTC (rev 6050)
> > @@ -281,6 +281,21 @@
> > return make_float32(float32_val(a) ^ 0x80000000);
> > }
> >
> > +INLINE int float32_is_infinity(float32 a)
> > +{
> > + return (float32_val(a) & 0x7fffffff) == 0x7ff80000;
>
> This should be == 0x7f800000.
>
Thanks, I have fixed this in revision 6088.
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-12-18 22:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-15 17:14 [Qemu-devel] [6050] fp: add floatXX_is_infinity(), floatXX_is_neg(), floatXX_is_zero() Aurelien Jarno
2008-12-15 17:48 ` Andreas Färber
2008-12-15 22:07 ` Aurélien Jarno
2008-12-18 15:15 ` Laurent Desnogues
2008-12-18 22:54 ` Aurelien Jarno
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.