aboutsummaryrefslogtreecommitdiffstats
path: root/trionan.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2002-03-27 09:05:40 +0000
committerDaniel Veillard <veillard@src.gnome.org>2002-03-27 09:05:40 +0000
commit5fc1f0893af6ffe76453ac16817204a866bdeab2 (patch)
treecdeabe58a614685131198ef72a5fd0eba4fc7a5d /trionan.c
parentdb1dc3952517f753974d8db9a7a37b66e77df6fa (diff)
downloadandroid_external_libxml2-5fc1f0893af6ffe76453ac16817204a866bdeab2.tar.gz
android_external_libxml2-5fc1f0893af6ffe76453ac16817204a866bdeab2.tar.bz2
android_external_libxml2-5fc1f0893af6ffe76453ac16817204a866bdeab2.zip
Added Igor Zlatkovic as official maintainer Albert Chin pointed that
* AUTHORS HACKING: Added Igor Zlatkovic as official maintainer * python/Makefile.am python/tests/Makefile.am: Albert Chin pointed that $(datadir) should be used for docs Daniel
Diffstat (limited to 'trionan.c')
-rw-r--r--trionan.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/trionan.c b/trionan.c
index 0f70f5a3..59e63a9f 100644
--- a/trionan.c
+++ b/trionan.c
@@ -145,6 +145,11 @@ static const char rcsid[] = "@(#)$Id$";
static TRIO_CONST double internalEndianMagic = 7.949928895127363e-275;
+/* Mask for the sign */
+static TRIO_CONST unsigned char ieee_754_sign_mask[] = {
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
/* Mask for the exponent */
static TRIO_CONST unsigned char ieee_754_exponent_mask[] = {
0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@@ -155,6 +160,11 @@ static TRIO_CONST unsigned char ieee_754_mantissa_mask[] = {
0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
+/* Bit-pattern for negative zero */
+static TRIO_CONST unsigned char ieee_754_negzero_array[] = {
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
/* Bit-pattern for infinity */
static TRIO_CONST unsigned char ieee_754_infinity_array[] = {
0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@@ -207,6 +217,37 @@ trio_is_special_quantity(double number,
return is_special_quantity;
}
+/**
+ Get the sign value
+
+ @return 1 for negative, 0 for positive
+*/
+TRIO_PUBLIC int
+trio_get_sign(double number)
+{
+ unsigned int i;
+ unsigned char current;
+ int sign = (1 == 1);
+
+ for (i = 0; i < (unsigned int)sizeof(double); i++) {
+ current = ((unsigned char *)&number)[TRIO_DOUBLE_INDEX(i)];
+ sign
+ &= ((current & ieee_754_sign_mask[i]) == ieee_754_sign_mask[i]);
+ }
+ return sign;
+}
+
+/**
+ Generate negative zero
+
+ @return Floating-point representation of negative zero.
+*/
+TRIO_PUBLIC double
+trio_nzero(void)
+{
+ return trio_make_double(ieee_754_negzero_array);
+}
+
#endif /* USE_IEEE_754 */