diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2002-03-27 09:05:40 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2002-03-27 09:05:40 +0000 |
commit | 5fc1f0893af6ffe76453ac16817204a866bdeab2 (patch) | |
tree | cdeabe58a614685131198ef72a5fd0eba4fc7a5d /trionan.c | |
parent | db1dc3952517f753974d8db9a7a37b66e77df6fa (diff) | |
download | libxml2-5fc1f0893af6ffe76453ac16817204a866bdeab2.tar.gz |
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.c | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -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 */ |