You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2008/04/29 22:52:37 UTC

svn commit: r652104 [10/29] - in /activemq/activemq-cpp/trunk: ./ m4/ src/examples/ src/examples/consumers/ src/main/ src/main/decaf/ src/main/decaf/internal/ src/main/decaf/internal/net/ src/main/decaf/internal/nio/ src/main/decaf/internal/util/ src/m...

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Long.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Long.cpp?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Long.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Long.cpp Tue Apr 29 13:52:30 2008
@@ -0,0 +1,493 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Long.h"
+#include <decaf/lang/Character.h>
+#include <sstream>
+
+using namespace decaf;
+using namespace decaf::lang;
+
+////////////////////////////////////////////////////////////////////////////////
+Long::Long( long long value ) {
+    this->value = value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Long::Long( const std::string& value ) throw( exceptions::NumberFormatException ) {
+    this->value = parseLong( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Long::compareTo( const Long& l ) const {
+    return this->value < l.value ? -1 : this->value == l.value ? 0 : 1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Long::compareTo( const long long& l ) const {
+    return this->value < l ? -1 : this->value == l ? 0 : 1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Long::bitCount( long long value ) {
+
+    if( value == 0 ) {
+        return 0;
+    }
+
+    unsigned long long uvalue = (unsigned long long)value;
+
+    uvalue = (uvalue & 0x5555555555555555LL) + ((uvalue >> 1) & 0x5555555555555555LL);
+    uvalue = (uvalue & 0x3333333333333333LL) + ((uvalue >> 2) & 0x3333333333333333LL);
+    // adjust for 64-bit integer
+    unsigned int i = (unsigned int)( (uvalue >> 32) + uvalue );
+    i = (i & 0x0F0F0F0F) + ((i >> 4) & 0x0F0F0F0F);
+    i = (i & 0x00FF00FF) + ((i >> 8) & 0x00FF00FF);
+    i = (i & 0x0000FFFF) + ((i >> 16) & 0x0000FFFF);
+    return i;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Long Long::decode( const std::string& value )
+    throw ( exceptions::NumberFormatException ) {
+
+    int length = (int)value.length(), i = 0;
+    if( length == 0 ) {
+        throw exceptions::NumberFormatException(
+            __FILE__, __LINE__,
+            "Long::decode - Zero length string given." );
+    }
+
+    char firstDigit = value[i];
+    bool negative = firstDigit == '-';
+    if( negative ) {
+        if( length == 1 ) {
+            throw exceptions::NumberFormatException(
+                __FILE__, __LINE__,
+                "Long::decode - Invalid length string given.",
+                value.c_str() );
+        }
+        firstDigit = value[++i];
+    }
+
+    int base = 10;
+    if( firstDigit == '0' ) {
+        if( ++i == length ) {
+            return valueOf( 0LL );
+        }
+        if( ( firstDigit = value[i] ) == 'x' || firstDigit == 'X' ) {
+            if ( i == length ) {
+                throw exceptions::NumberFormatException(
+                    __FILE__, __LINE__,
+                    "Long::decode - Invalid length string given.",
+                    value.c_str() );
+            }
+            i++;
+            base = 16;
+        } else {
+            base = 8;
+        }
+    } else if( firstDigit == '#' ) {
+        if( i == length ) {
+            throw exceptions::NumberFormatException(
+                __FILE__, __LINE__,
+                "Long::decode - Invalid length string given.",
+                value.c_str() );
+        }
+        i++;
+        base = 16;
+    }
+
+    long long result = parse( value, i, base, negative );
+    return valueOf( result );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long Long::highestOneBit( long long value ) {
+
+    if( value == 0 ) {
+        return 0;
+    }
+
+    unsigned long long uvalue = (unsigned long long)value;
+
+    uvalue |= (uvalue >> 1);
+    uvalue |= (uvalue >> 2);
+    uvalue |= (uvalue >> 4);
+    uvalue |= (uvalue >> 8);
+    uvalue |= (uvalue >> 16);
+    uvalue |= (uvalue >> 32);
+    return ( uvalue & ~( uvalue >> 1 ) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long Long::lowestOneBit( long long value ) {
+    if( value == 0 ) {
+        return 0;
+    }
+
+    unsigned long long uvalue = (unsigned long long)value;
+    return ( uvalue & (-1 * uvalue) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Long::numberOfLeadingZeros( long long value ) {
+
+    if( value == 0 ) {
+        return 0;
+    }
+
+    unsigned long long uvalue = (unsigned long long)value;
+
+    value |= value >> 1;
+    value |= value >> 2;
+    value |= value >> 4;
+    value |= value >> 8;
+    value |= value >> 16;
+    value |= value >> 32;
+    return Long::bitCount( ~uvalue );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Long::numberOfTrailingZeros( long long value ) {
+    if( value == 0 ) {
+        return 0;
+    }
+
+    unsigned long long uvalue = (unsigned long long)value;
+    return Long::bitCount( (uvalue & (-1 * uvalue)) - 1 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long Long::parseLong( const std::string& value )
+    throw ( exceptions::NumberFormatException ) {
+
+    return Long::parseLong( value, 10 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long Long::parseLong( const std::string& value, int radix )
+    throw ( exceptions::NumberFormatException ) {
+
+    if( radix < Character::MIN_RADIX ||
+        radix > Character::MAX_RADIX ) {
+        throw exceptions::NumberFormatException(
+            __FILE__, __LINE__,
+            "Long::parseLong - Given Radix is out of range." );
+    }
+
+    int length = (int)value.length();
+    int i = 0;
+
+    if( length == 0 ) {
+        throw exceptions::NumberFormatException(
+            __FILE__, __LINE__,
+            "Long::parseLong - Zero length string is illegal." );
+    }
+
+    bool negative = value[i] == '-';
+    if( negative && ++i == length ) {
+        throw exceptions::NumberFormatException(
+            __FILE__, __LINE__,
+            "Long::parseLong - Only a minus given, string is invalid." );
+    }
+
+    return Long::parse( value, i, radix, negative );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long Long::parse( const std::string& value, int offset,
+                       int radix, bool negative )
+    throw ( exceptions::NumberFormatException ) {
+
+    long long max = Long::MIN_VALUE / radix;
+    long long result = 0;
+    long long length = value.length();
+
+    while( offset < length ) {
+        int digit = Character::digit( value[offset++], radix );
+
+        if( digit == -1 ) {
+            throw exceptions::NumberFormatException(
+                __FILE__, __LINE__,
+                "Long::parseLong - String contains no digit characters." );
+        }
+
+        if( max > result ) {
+            throw exceptions::NumberFormatException(
+                __FILE__, __LINE__,
+                "Long::parseLong - Parsed value greater than max for radix." );
+        }
+
+        long long next = result * radix - digit;
+
+        if( next > result ) {
+            throw exceptions::NumberFormatException(
+                __FILE__, __LINE__,
+                "Long::parseLong - Only a minus given, string is invalid." );
+        }
+
+        result = next;
+    }
+
+    if( !negative ) {
+        result = -result;
+        if( result < 0 ) {
+            throw exceptions::NumberFormatException(
+                __FILE__, __LINE__,
+                "Long::parseLong - Value less than zero, but no minus sign." );
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long Long::reverseBytes( long long value ) {
+
+    if( value == 0 ) {
+        return 0;
+    }
+
+    unsigned long long uvalue = (unsigned long long)value;
+
+    long long b7 = (uvalue >> 56);
+    long long b6 = (uvalue >> 40) & 0xFF00ULL;
+    long long b5 = (uvalue >> 24) & 0xFF0000ULL;
+    long long b4 = (uvalue >> 8) & 0xFF000000ULL;
+    long long b3 = (uvalue & 0xFF000000ULL) << 8;
+    long long b2 = (uvalue & 0xFF0000ULL) << 24;
+    long long b1 = (uvalue & 0xFF00ULL) << 40;
+    long long b0 = (uvalue << 56);
+    return ( b0 | b1 | b2 | b3 | b4 | b5 | b6 | b7 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long Long::reverse( long long value ) {
+
+    if( value == 0 ) {
+        return 0;
+    }
+
+    unsigned long long uvalue = (unsigned long long)value;
+
+    // From Hacker's Delight, 7-1, Figure 7-1
+    uvalue = ( uvalue & 0x5555555555555555ULL ) << 1 | (uvalue >> 1) &
+             0x5555555555555555ULL;
+    uvalue = ( uvalue & 0x3333333333333333ULL ) << 2 | (uvalue >> 2) &
+             0x3333333333333333ULL;
+    uvalue = ( uvalue & 0x0F0F0F0F0F0F0F0FULL ) << 4 | (uvalue >> 4) &
+             0x0F0F0F0F0F0F0F0FULL;
+
+    return reverseBytes( uvalue );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long Long::rotateLeft( long long value, int distance ) {
+    unsigned long long i = (unsigned long long)value;
+    int j = distance & 0x1F;
+    return ( i << j ) | ( i >> (-j & 0x1F ) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long Long::rotateRight( long long value, int distance ) {
+    unsigned long long i = (unsigned long long)value;
+    int j = distance & 0x1F;
+    return ( i >> j ) | ( i << (-j & 0x1F ) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Long::signum( long long value ) {
+    return ( value == 0 ? 0 : ( value < 0 ? -1 : 1 ) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Long::toString() const {
+    return Long::toString( this->value, 10 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Long::toString( long long value ) {
+    return Long::toString( value, 10 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Long::toString( long long value, int radix ) {
+
+    if( radix < Character::MIN_RADIX || radix > Character::MAX_RADIX ) {
+        radix = 10;
+    }
+
+    if( value == 0 ) {
+        return "0";
+    }
+
+    int count = 2;
+    long long j = value;
+    bool negative = value < 0;
+
+    if( !negative ) {
+        count = 1;
+        j = -value;
+    }
+
+    while( (value /= radix) != 0 ) {
+        count++;
+    }
+
+    // Save length and allocate a new buffer for the string, add one
+    // more for the null character.
+    int length = count;
+    char* buffer = new char[length + 1];
+
+    do {
+        int ch = (int)( 0 - ( j % radix ) );
+        if( ch > 9 ) {
+            ch = ch - 10 + 'a';
+        } else {
+            ch += '0';
+        }
+        buffer[--count] = (char)ch;
+    } while( (j /= radix) != 0 );
+
+    if( negative ) {
+        buffer[0] = '-';
+    }
+
+    // Ensure there's a null
+    buffer[length] = 0;
+    std::string result( &buffer[0] );
+    delete [] buffer;
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Long::toBinaryString( long long value ) {
+
+    int count = 1;
+    long long j = value;
+
+    if( value < 0 ) {
+        count = 32;
+    } else {
+        while ( (j >>= 1) != 0) {
+            count++;
+        }
+    }
+
+    // Save length and allocate a new buffer for the string, add one
+    // more for the null character.
+    int length = count;
+    char* buffer = new char[length + 1];
+
+    do {
+        buffer[--count] = (char)( (value & 1) + '0' );
+        value >>= 1;
+    } while( count > 0 );
+
+    // Ensure there's a null
+    buffer[length] = 0;
+    std::string result( &buffer[0] );
+    delete [] buffer;
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Long::toOctalString( long long value ) {
+
+    int count = 1;
+    long long j = value;
+
+    if( value < 0 ) {
+        count = 11;
+    } else {
+        while ( (j >>= 3) != 0 ) {
+            count++;
+        }
+    }
+
+    // Save length and allocate a new buffer for the string, add one
+    // more for the null character.
+    int length = count;
+    char* buffer = new char[length + 1];
+
+    do {
+        buffer[--count] = (char)( (value & 7) + '0' );
+        value >>= 3;
+    } while( count > 0 );
+
+    // Ensure there's a null
+    buffer[length] = 0;
+    std::string result( &buffer[0] );
+    delete [] buffer;
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Long::toHexString( long long value ) {
+
+    int count = 1;
+    long long j = value;
+
+    if( value < 0 ) {
+        count = 8;
+    } else {
+        while( (j >>= 4) != 0 ) {
+            count++;
+        }
+    }
+
+    // Save length and allocate a new buffer for the string, add one
+    // more for the null character.
+    int length = count;
+    char* buffer = new char[length + 1];
+
+    do {
+        int t = (int)( value & 15 );
+        if( t > 9 ) {
+            t = t - 10 + 'a';
+        } else {
+            t += '0';
+        }
+        buffer[--count] = (char)t;
+        value >>= 4;
+    } while( count > 0 );
+
+    // Ensure there's a null
+    buffer[length] = 0;
+    std::string result( &buffer[0] );
+    delete [] buffer;
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Long Long::valueOf( const std::string& value )
+    throw ( exceptions::NumberFormatException ) {
+
+    return Long( Long::parseLong( value ) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Long Long::valueOf( const std::string& value, int radix )
+    throw ( exceptions::NumberFormatException ) {
+
+    return Long( Long::parseLong( value, radix ) );
+}

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Long.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Long.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Long.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Long.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,506 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_LANG_LONG_H_
+#define _DECAF_LANG_LONG_H_
+
+#include <decaf/lang/Number.h>
+#include <decaf/lang/Comparable.h>
+#include <decaf/lang/exceptions/NumberFormatException.h>
+#include <string>
+
+namespace decaf{
+namespace lang{
+
+    class DECAF_API Long : public Number,
+                           public Comparable<Long>,
+                           public Comparable<long long> {
+    private:
+
+        // The primitive long long value
+        long long value;
+
+    public:
+
+        /** The size in bits of the primitive long long type */
+        static const int SIZE = 64;
+
+        /** The maximum value that the primitive type can hold */
+        static const long long MAX_VALUE = (long long)0x7FFFFFFFFFFFFFFFLL;
+
+        /** The minimum value that the primitive type can hold */
+        static const long long MIN_VALUE = (long long)0x8000000000000000LL;
+
+    public:
+
+        /**
+         * @param value - the primitive long long to wrap
+         */
+        Long( long long value );
+
+        /**
+         * @param value - the long long formated string to wrap
+         * @thorw NumberFormatException
+         */
+        Long( const std::string& value ) throw( exceptions::NumberFormatException );
+
+        virtual ~Long() {}
+
+        /**
+         * Compares this Long instance with another.
+         * @param l - the Long instance to be compared
+         * @return zero if this object represents the same integer value as the
+         * argument; a positive value if this object represents a value greater
+         * than the passed in value, and -1 if this object repesents a value
+         * less than the passed in value.
+         */
+        virtual int compareTo( const Long& l ) const;
+
+        /**
+         * @param l - the Long object to compare against.
+         * @returns true if the two Integer Objects have the same value.
+         */
+        bool equals( const Long& l ) const {
+            return this->value == l.value;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param l - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const Long& l ) const {
+            return this->value == l.value;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param l - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const Long& l ) const {
+            return this->value < l.value;
+        }
+
+        /**
+         * Compares this Long instance with another.
+         * @param l - the Integer instance to be compared
+         * @return zero if this object represents the same integer value as the
+         * argument; a positive value if this object represents a value greater
+         * than the passed in value, and -1 if this object repesents a value
+         * less than the passed in value.
+         */
+        virtual int compareTo( const long long& l ) const;
+
+        /**
+         * @param l - the Long object to compare against.
+         * @returns true if the two Integer Objects have the same value.
+         */
+        bool equals( const long long& l ) const {
+            return this->value == l;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param l - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const long long& l ) const {
+            return this->value == l;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param l - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const long long& l ) const {
+            return this->value < l;
+        }
+
+        /**
+         * @returns this Long Object as a String Representation
+         */
+        std::string toString() const;
+
+        /**
+         * Answers the double value which the receiver represents
+         * @return double the value of the receiver.
+         */
+        virtual double doubleValue() const {
+            return (double)this->value;
+        }
+
+        /**
+         * Answers the float value which the receiver represents
+         * @return float the value of the receiver.
+         */
+        virtual float floatValue() const {
+            return (float)this->value;
+        }
+
+        /**
+         * Answers the byte value which the receiver represents
+         * @return int the value of the receiver.
+         */
+        virtual unsigned char byteValue() const {
+            return (unsigned char)this->value;
+        }
+
+        /**
+         * Answers the short value which the receiver represents
+         * @return int the value of the receiver.
+         */
+        virtual short shortValue() const {
+            return (short)this->value;
+        }
+
+        /**
+         * Answers the int value which the receiver represents
+         * @return int the value of the receiver.
+         */
+        virtual int intValue() const {
+            return (int)this->value;
+        }
+
+        /**
+         * Answers the long value which the receiver represents
+         * @return long the value of the receiver.
+         */
+        virtual long long longValue() const {
+            return this->value;
+        }
+
+    public:
+
+        /**
+         * Returns the number of one-bits in the two's complement binary
+         * representation of the specified int value. This function is sometimes
+         * referred to as the population count.
+         * @param value - the long long to count
+         * @return the number of one-bits in the two's complement binary
+         * representation of the specified long long value.
+         */
+        static int bitCount( long long value );
+
+        /**
+         * Decodes a String into a Long. Accepts decimal, hexadecimal, and octal
+         * numbers given by the following grammar:
+         *
+         * The sequence of characters following an (optional) negative sign and/or
+         * radix specifier ("0x", "0X", "#", or leading zero) is parsed as by the
+         * Integer.parseInteger method with the indicated radix (10, 16, or 8). This
+         * sequence of characters must represent a positive value or a
+         * NumberFormatException will be thrown. The result is negated if first
+         * character of the specified String is the minus sign. No whitespace
+         * characters are permitted in the string.
+         * @param value - The string to decode
+         * @returns a Long object containing the decoded value
+         * @throws NumberFomatException if the string is not formatted correctly.
+         */
+        static Long decode( const std::string& value )
+            throw ( exceptions::NumberFormatException );
+
+        /**
+         * Returns an long long value with at most a single one-bit, in the position
+         * of the highest-order ("leftmost") one-bit in the specified int value.
+         * Returns zero if the specified value has no one-bits in its two's
+         * complement binary representation, that is, if it is equal to zero.
+         * @param value - the long long to be inspected
+         * @return an long long value with a single one-bit, in the position of the
+         * highest-order one-bit in the specified value, or zero if the specified
+         * value is itself equal to zero.
+         */
+        static long long highestOneBit( long long value );
+
+        /**
+         * Returns an long long value with at most a single one-bit, in the position
+         * of the lowest-order ("rightmost") one-bit in the specified int value.
+         * Returns zero if the specified value has no one-bits in its two's
+         * complement binary representation, that is, if it is equal to zero.
+         * @param value - the long long to be inspected
+         * @return an long long value with a single one-bit, in the position of the
+         * lowest-order one-bit in the specified value, or zero if the specified
+         * value is itself equal to zero.
+         */
+        static long long lowestOneBit( long long value );
+
+        /**
+         * Returns the number of zero bits preceding the highest-order ("leftmost")
+         * one-bit in the two's complement binary representation of the specified
+         * long long value. Returns 64 if the specified value has no one-bits in its
+         * two's complement representation, in other words if it is equal to zero.
+         *
+         * Note that this method is closely related to the logarithm base 2. For
+         * all positive int values x:
+         *
+         *     * floor( log2(x)) = 63 - numberOfLeadingZeros(x)
+         *     * ceil( log2(x)) = 64 - numberOfLeadingZeros(x - 1)
+         *
+         * @param value - the long long to be inspected
+         * @return the number of zero bits preceding the highest-order ("leftmost")
+         * one-bit in the two's complement binary representation of the specified
+         * long long value, or 64 if the value is equal to zero.
+         */
+        static int numberOfLeadingZeros( long long value );
+
+        /**
+         * Returns the number of zero bits following the lowest-order ("rightmost")
+         * one-bit in the two's complement binary representation of the specified
+         * long long value. Returns 64 if the specified value has no one-bits in its
+         * two's complement representation, in other words if it is equal to zero.
+         * @param value - the int to be inspected
+         * @return the number of zero bits following the lowest-order ("rightmost")
+         * one-bit in the two's complement binary representation of the specified
+         * long long value, or 64 if the value is equal to zero.
+         */
+        static int numberOfTrailingZeros( long long value );
+
+        /**
+         * Parses the string argument as a signed decimal long. The characters in the
+         * string must all be decimal digits, except that the first character may be
+         * an ASCII minus sign '-' to indicate a negative value. The resulting long
+         * value is returned, exactly as if the argument and the radix 10 were given
+         * as arguments to the parseLong(java.lang.String, int) method.
+         *
+         * Note that the characters LL or ULL are not permitted to appear at the end
+         * of this string as would normally be permitted in a C++ program.
+         * @param value - String to parse
+         * @return long long value
+         * @throws NumberFormatException on invalid string value
+         */
+        static long long parseLong( const std::string& value )
+            throw ( exceptions::NumberFormatException );
+
+        /**
+         * Returns a Long object holding the value extracted from the specified
+         * string when parsed with the radix given by the second argument. The
+         * first argument is interpreted as representing a signed long in the radix
+         * specified by the second argument, exactly as if the arguments were
+         * given to the parseLong(std::string, int) method. The result is a
+         * Long object that represents the long long value specified by the string.
+         * @param value - String to parse
+         * @param radix - the base encoding of the string
+         * @return long long value
+         * @throws NumberFormatException on invalid string value
+         */
+        static long long parseLong( const std::string& value, int radix )
+            throw ( exceptions::NumberFormatException );
+
+        /**
+         * Returns the value obtained by reversing the order of the bytes in the
+         * two's complement representation of the specified long long value.
+         * @param value - the long long whose bytes we are to reverse
+         * @return the reversed long long.
+         */
+        static long long reverseBytes( long long value );
+
+        /**
+         * Returns the value obtained by reversing the order of the bits in the
+         * two's complement binary representation of the specified long long value.
+         * @param value - the value whose bits are to be reversed
+         * @returns the reversed bits long long.
+         */
+        static long long reverse( long long value );
+
+        /**
+         * Returns the value obtained by rotating the two's complement binary
+         * representation of the specified value left by the specified number
+         * of bits. (Bits shifted out of the left hand, or high-order, side reenter
+         * on the right, or low-order.)
+         *
+         * Note that left rotation with a negative distance is equivalent to right
+         * rotation: rotateLeft(val, -distance) == rotateRight(val, distance). Note
+         * also that rotation by any multiple of 32 is a no-op, so all but the last
+         * five bits of the rotation distance can be ignored, even if the distance
+         * is negative: rotateLeft(val, distance) == rotateLeft(val, distance & 0x1F).
+         * @param value - the long long to be inspected
+         * @param distance - the number of bits to rotate
+         * @return the value obtained by rotating the two's complement binary
+         * representation of the specified value left by the specified number
+         * of bits.
+         */
+        static long long rotateLeft( long long value, int distance );
+
+        /**
+         * Returns the value obtained by rotating the two's complement binary
+         * representation of the specified value right by the specified number
+         * of bits. (Bits shifted out of the right hand, or low-order, side reenter
+         * on the left, or high-order.)
+         *
+         * Note that right rotation with a negative distance is equivalent to left
+         * rotation: rotateRight(val, -distance) == rotateLeft(val, distance). Note
+         * also that rotation by any multiple of 32 is a no-op, so all but the last
+         * five bits of the rotation distance can be ignored, even if the distance is
+         * negative: rotateRight(val, distance) == rotateRight(val, distance & 0x1F).
+         * @param value - the long long to be inspected
+         * @param distance - the number of bits to rotate
+         * @return the value obtained by rotating the two's complement binary
+         * representation of the specified value right by the specified number
+         * of bits.
+         */
+        static long long rotateRight( long long value, int distance );
+
+        /**
+         * Returns the signum function of the specified value. (The return value
+         * is -1 if the specified value is negative; 0 if the specified value is zero;
+         * and 1 if the specified value is positive.)
+         * @param value - the long long to be inspected
+         * @return the signum function of the specified long long value.
+         */
+        static int signum( long long value );
+
+        /**
+         * Converts the long to a String representation
+         * @param long to convert
+         * @return string representation
+         */
+        static std::string toString( long long value );
+
+        /*
+         * Returns a string representation of the first argument in the radix
+         * specified by the second argument.
+         *
+         * If the radix is smaller than Character.MIN_RADIX or larger than
+         * Character.MAX_RADIX, then the radix 10 is used instead.
+         *
+         * If the first argument is negative, the first element of the result is
+         * the ASCII minus character '-'. If the first argument is not
+         * negative, no sign character appears in the result.
+         *
+         * The remaining characters of the result represent the magnitude of the
+         * first argument. If the magnitude is zero, it is represented by a single
+         *  zero character '0'; otherwise, the first character of the
+         * representation of the magnitude will not be the zero character. The
+         * following ASCII characters are used as digits:
+         *
+         *    0123456789abcdefghijklmnopqrstuvwxyz
+         *
+         * @param value - the long long to convert to a string
+         * @param radix - the radix to format the string in
+         * @returns an long long formatted to the string value of the radix given.
+         */
+        static std::string toString( long long value, int radix );
+
+        /**
+         * Returns a string representation of the integer argument as an unsigned
+         * integer in base 16.
+         *
+         * The unsigned integer value is the argument plus 2^32 if the argument is
+         * negative; otherwise, it is equal to the argument. This value is converted
+         * to a string of ASCII digits in hexadecimal (base 16) with no extra leading
+         * 0s. If the unsigned magnitude is zero, it is represented by a single zero
+         * character '0'; otherwise, the first character of the representation of the
+         * unsigned magnitude will not be the zero character. The following characters
+         * are used as hexadecimal digits:
+         *
+         * 		0123456789abcdef
+         *
+         * If uppercase letters are desired, the toUpperCase() method may be called
+         * on the result:
+         * @param value - the long long to be translated to an Octal string
+         * @returns the unsigned long long value as a Octal string
+         */
+        static std::string toHexString( long long value );
+
+        /**
+         * Returns a string representation of the long long argument as an unsigned
+         * long long in base 8.
+         *
+         * The unsigned long long value is the argument plus 2^32 if the argument is
+         * negative; otherwise, it is equal to the argument. This value is converted
+         * to a string of ASCII digits in octal (base 8) with no extra leading 0s.
+         *
+         * If the unsigned magnitude is zero, it is represented by a single zero
+         * character '0'; otherwise, the first character of the representation
+         * of the unsigned magnitude will not be the zero character. The following
+         * characters are used as octal digits:
+         *
+         *      01234567
+         *
+         * @param value - the long long to be translated to an Octal string
+         * @returns the unsigned long long value as a Octal string
+         */
+        static std::string toOctalString( long long value );
+
+        /**
+         * Returns a string representation of the long long argument as an unsigned
+         * long long in base 2.
+         *
+         * The unsigned long long value is the argument plus 2^32 if the argument is
+         * negative; otherwise it is equal to the argument. This value is converted
+         * to a string of ASCII digits in binary (base 2) with no extra leading 0s.
+         * If the unsigned magnitude is zero, it is represented by a single zero
+         * character '0'; otherwise, the first character of the
+         * representation of the unsigned magnitude will not be the zero character.
+         * The characters '0' and '1' are used as binary
+         * digits.
+         * @param value - the long long to be translated to a binary string
+         * @returns the unsigned long long value as a binary string
+         */
+        static std::string toBinaryString( long long value );
+
+        /**
+         * Returns a Long instance representing the specified int value.
+         * @param value - the long long to wrap
+         * @return the new Integer object wrapping value.
+         */
+        static Long valueOf( long long value ) {
+            return Long( value );
+        }
+
+        /**
+         * Returns a Long object holding the value given by the specified
+         * std::string.  The argument is interpreted as representing a signed
+         * decimal long long, exactly as if the argument were given to the
+         * parseLong( std::string ) method. The result is a Integer object that
+         * represents the long long value specified by the string.
+         * @param value - std::string to parse as base 10
+         * @return new Long Object wrapping the primitive
+         * @throws NumberFormatException if the string is not a decimal long long.
+         */
+        static Long valueOf( const std::string& value )
+            throw ( exceptions::NumberFormatException );
+
+        /**
+         * Returns a Long object holding the value extracted from the specified
+         * std::string when parsed with the radix given by the second argument.
+         * The first argument is interpreted as representing a signed long long in the
+         * radix specified by the second argument, exactly as if the argument were
+         * given to the parseLong( std::string, int ) method. The result is a
+         * Long object that represents the long long value specified by the string.
+         * @param value - std::string to parse as base ( radix )
+         * @param radix - base of the string to parse.
+         * @return new Long Object wrapping the primitive
+         * @throws NumberFormatException if the string is not a valid long long.
+         */
+        static Long valueOf( const std::string& value, int radix )
+            throw ( exceptions::NumberFormatException );
+
+    private:
+
+        static long long parse( const std::string& value, int offset,
+                                int radix, bool negative )
+            throw ( exceptions::NumberFormatException );
+
+    };
+
+}}
+
+#endif /*_DECAF_LANG_LONG_H_*/

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Math.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Math.cpp?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Math.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Math.cpp Tue Apr 29 13:52:30 2008
@@ -0,0 +1,517 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <decaf/lang/Math.h>
+#include <decaf/lang/Double.h>
+#include <decaf/lang/Float.h>
+#include <decaf/lang/Integer.h>
+#include <decaf/lang/Long.h>
+#include <decaf/util/Random.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+
+////////////////////////////////////////////////////////////////////////////////
+const double Math::E = 2.718281828459045;
+const double Math::PI = 3.141592653589793;
+
+////////////////////////////////////////////////////////////////////////////////
+float Math::abs( float value ) {
+    return Float::intBitsToFloat( Float::floatToIntBits( value ) & 0x7FFFFFFF );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::abs( double value ) {
+    return Double::longBitsToDouble( Double::doubleToLongBits( value ) & 0x7FFFFFFFFFFFFFFFULL );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::acos( double value ) {
+    return std::acos( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::asin( double value ) {
+    return std::asin( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::atan( double value ) {
+    return std::atan( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::atan2( double x, double y ) {
+    return std::atan2( x, y );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::random() {
+    static util::Random random;
+    return random.nextDouble();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+#ifndef _WIN32
+double Math::cbrt( double value ) {
+
+    if( Double::isNaN( value ) ) {
+        return Double::NaN;
+    } else if( Double::isInfinite( value ) ) {
+        return value;
+    } else if( !( value < 0 || value > 0 ) ) {
+        return value;
+    }
+
+    return ::cbrt( value );
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::cos( double value ) {
+
+    if( Double::isNaN( value ) || Double::isInfinite( value ) ) {
+        return Double::NaN;
+    }
+
+    return std::cos( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::cosh( double value ) {
+
+    if( Double::isNaN( value ) ) {
+        return Double::NaN;
+    } else if( Double::isInfinite( value ) ) {
+        return Double::POSITIVE_INFINITY;
+    } else if( value == 0.0 ) {
+        return 1.0;
+    }
+
+    return std::cosh( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::sin( double value ) {
+
+    if( Double::isNaN( value ) || Double::isInfinite( value ) ) {
+        return Double::NaN;
+    } else if( !( value < 0 || value > 0 ) ) {
+        return value;
+    }
+
+    return std::sin( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::sinh( double value ) {
+
+    if( Double::isNaN( value ) ) {
+        return Double::NaN;
+    } else if( Double::isInfinite( value ) ) {
+        return value;
+    } else if( !( value < 0 || value > 0 ) ) {
+        return value;
+    }
+
+    return std::sinh( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::tan( double value ) {
+
+    if( Double::isNaN( value ) || value < -1.0 ) {
+        return Double::NaN;
+    } else if( !( value < 0 || value > 0 ) ) {
+        return value;
+    }
+
+    return std::tan( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::tanh( double value ) {
+
+    if( Double::isNaN( value ) ) {
+        return Double::NaN;
+    } else if( value == Double::POSITIVE_INFINITY ) {
+        return 1.0;
+    } else if( value == Double::NEGATIVE_INFINITY ) {
+        return -1.0;
+    } else if( !( value < 0 || value > 0 ) ) {
+        return value;
+    }
+
+    return std::tanh( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::sqrt( double value ) {
+
+    if( Double::isNaN( value ) || value < 0.0 ) {
+        return Double::NaN;
+    } else if( value == Double::POSITIVE_INFINITY ) {
+        return Double::POSITIVE_INFINITY;
+    } else if( value == 0.0 || value == -0.0 ) {
+        return Double::NEGATIVE_INFINITY;
+    }
+
+    return std::sqrt( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+#ifndef _WIN32 
+double Math::rint( double value ) {
+
+    if( Double::isNaN( value ) || Double::isInfinite( value ) ) {
+        return value;
+    } else if( value == 0.0 || value == -0.0 ) {
+        return value;
+    }
+
+    return ::rint( value );
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::exp( double value ) {
+
+    if( Double::isNaN( value ) ) {
+        return Double::NaN;
+    } else if( value == Double::POSITIVE_INFINITY ) {
+        return Double::POSITIVE_INFINITY;
+    } else if( value == Double::NEGATIVE_INFINITY ) {
+        return 0.0;
+    }
+
+    return std::exp( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+#ifndef _WIN32 
+double Math::expm1( double value ) {
+
+    if( Double::isNaN( value ) ) {
+        return Double::NaN;
+    } else if( value == Double::POSITIVE_INFINITY ) {
+        return Double::POSITIVE_INFINITY;
+    } else if( value == Double::NEGATIVE_INFINITY ) {
+        return -1.0;
+    } else if( !( value > 0 || value < 0 ) ) {
+        return value;
+    }
+
+    return ::expm1( value );
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+float Math::min( float a, float b ) {
+
+    if( a > b ) {
+        return b;
+    } else if( a < b ) {
+        return a;
+    }
+
+    // if either arg is NaN, return NaN
+    if( a != b ) {
+        return Float::NaN;
+    }
+
+    // min( +0.0,-0.0) == -0.0
+    if( a == 0.0f &&
+        ( (Float::floatToIntBits( a ) | Float::floatToIntBits( b )) & 0x80000000) != 0) {
+
+        return 0.0f * (-1.0f);
+    }
+
+    return a;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::min( double a, double b ) {
+
+    if( a > b ) {
+        return b;
+    } else if( a < b ) {
+        return a;
+    }
+
+    // if either arg is NaN, return NaN
+    if( a != b ) {
+        return Double::NaN;
+    }
+
+    // min( +0.0,-0.0) == -0.0
+    if( a == 0.0 &&
+        ( (Double::doubleToLongBits( a ) | Double::doubleToLongBits( b )) & 0x8000000000000000ULL) != 0 ) {
+        return 0.0 * (-1.0);
+    }
+
+    return a;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+float Math::max( float a, float b ) {
+
+    if( a > b ) {
+        return a;
+    } else if( a < b ) {
+        return b;
+    }
+
+    // if either arg is NaN, return NaN
+    if( a != b ) {
+        return Float::NaN;
+    }
+    // max( +0.0,-0.0) == +0.0
+    if( a == 0.0f &&
+        ( (Float::floatToIntBits( a ) & Float::floatToIntBits( b ) ) & 0x80000000 ) == 0 ) {
+
+        return 0.0f;
+    }
+
+    return a;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::max( double a, double b ) {
+
+    if( a > b ) {
+        return a;
+    } else if( a < b ) {
+        return b;
+    }
+
+    // if either arg is NaN, return NaN
+    if( a != b ) {
+        return Double::NaN;
+    }
+    // max( +0.0,-0.0) == +0.0
+    if( a == 0.0f &&
+        ( (Double::doubleToLongBits( a ) & Double::doubleToLongBits( b ) ) & 0x80000000 ) == 0 ) {
+
+        return 0.0f;
+    }
+
+    return a;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::log( double value ) {
+
+    if( Double::isNaN( value ) || value < 0.0 ) {
+        return Double::NaN;
+    } else if( value == Double::POSITIVE_INFINITY ) {
+        return Double::POSITIVE_INFINITY;
+    } else if( !( value < 0 || value > 0 ) ) {
+        return Double::NEGATIVE_INFINITY;
+    }
+
+    return std::log( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::log10( double value ) {
+
+    if( Double::isNaN( value ) || value < 0 ) {
+        return Double::NaN;
+    } else if( value == Double::POSITIVE_INFINITY ) {
+        return Double::POSITIVE_INFINITY;
+    } else if( !( value < 0 || value > 0 ) ) {
+        return Double::NEGATIVE_INFINITY;
+    }
+
+    return std::log10( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+#ifndef _WIN32
+double Math::log1p( double value ) {
+
+    if( Double::isNaN( value ) || value < -1.0 ) {
+        return Double::NaN;
+    } else if( value == Double::POSITIVE_INFINITY ) {
+        return Double::POSITIVE_INFINITY;
+    } else if( value == -1.0 ) {
+        return Double::NEGATIVE_INFINITY;
+    } else if( !( value < 0 || value > 0 ) ) {
+        return value;
+    }
+
+    return ::log1p( value );
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::ceil( double value ) {
+
+    if( Double::isNaN( value ) || Double::isInfinite( value ) ) {
+        return value;
+    } else if( !( value < 0 || value > 0 ) ) {
+        return value;
+    } else if( value > -1.0 && value < 0.0 ) {
+        return -0.0;
+    }
+
+    return std::ceil( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::floor( double value ) {
+
+    if( Double::isNaN( value ) || Double::isInfinite( value ) ) {
+        return value;
+    } else if( value > 0 || value < 0 ) {
+        return std::floor( value );
+    }
+
+    // +-0.0
+    return value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Math::round( float value ) {
+
+    if( Float::isNaN( value ) ) {
+        return 0;
+    }
+
+    return (int)Math::floor( value + 0.5f );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long Math::round( double value ) {
+
+    if( Double::isNaN( value ) ) {
+        return 0;
+    }
+
+    return (long long)Math::floor( value + 0.5 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+#ifndef _WIN32
+double Math::IEEEremainder( double f1, double f2 ) {
+
+    if( Double::isNaN( f1 ) || Double::isNaN( f2 ) ||
+        Double::isInfinite( f1 ) || !( f2 < 0 || f2 > 0 ) ) {
+        return Double::NaN;
+    } else if( Double::isInfinite( f2 ) ) {
+        return f1;
+    }
+
+    return ::remainder( f1, f2 );
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+float Math::signum( float value ) {
+
+    if( Float::isNaN( value ) ) {
+        return Float::NaN;
+    } else if( value > 0 ) {
+        return 1.0;
+    } else if( value < 0 ) {
+        return -1.0;
+    }
+
+    return value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::signum( double value ) {
+
+    if( Double::isNaN( value ) ) {
+        return Double::NaN;
+    } else if( value > 0 ) {
+        return 1.0;
+    } else if( value < 0 ) {
+        return -1.0;
+    }
+
+    return value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::hypot( double x, double y ) {
+
+    if( Double::isInfinite( x ) || Double::isInfinite( y ) ) {
+        return Double::POSITIVE_INFINITY;
+    } else if( Double::isNaN( x ) || Double::isNaN( y ) ) {
+        return Double::NaN;
+    }
+
+    return std::sqrt( ( x * x ) + ( y * y ) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Math::pow( double base, double exp ) {
+
+    if( !( exp < 0 || exp > 0 ) ) {
+        return 1.0;
+    } else if( Double::isNaN( exp ) ) {
+        return Double::NaN;
+    } else if( Double::isNaN( base ) && ( exp < 0 || exp > 0 ) ) {
+        return Double::NaN;
+    }
+
+    return std::pow( base, exp );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+#ifndef _WIN32 
+float Math::ulp( float value ) {
+
+    if( Float::isNaN( value ) ) {
+        return Float::NaN;
+    } else if( Float::isInfinite( value ) ) {
+        return Float::POSITIVE_INFINITY;
+    } else if( value == Float::MAX_VALUE || value == -Float::MAX_VALUE ) {
+        return (float)pow( 2, 104 );
+    } else if( !( value < 0 || value > 0 ) ) {
+        return Float::MIN_VALUE;
+    }
+
+    value = abs( value );
+    return ::nextafterf( value, Float::MAX_VALUE ) - value;
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+#ifndef _WIN32
+double Math::ulp( double value ) {
+
+    if( Double::isNaN( value ) ) {
+        return Double::NaN;
+    } else if( Double::isInfinite( value ) ) {
+        return Double::POSITIVE_INFINITY;
+    } else if( value == Double::MAX_VALUE || value == -Double::MAX_VALUE ) {
+        return pow( 2, 971 );
+    } else if( !( value < 0 || value > 0 ) ) {
+        return Double::MIN_VALUE;
+    }
+
+    value = abs( value );
+    return ::nextafter( value, Double::MAX_VALUE ) - value;
+}
+#endif

Added: activemq/activemq-cpp/trunk/src/main/decaf/lang/Math.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Math.h?rev=652104&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/lang/Math.h (added)
+++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Math.h Tue Apr 29 13:52:30 2008
@@ -0,0 +1,787 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_LANG_MATH_H_
+#define _DECAF_LANG_MATH_H_
+
+#include <decaf/util/Config.h>
+
+// On some systems there is a min and max macro defined.
+#undef min
+#undef max
+
+namespace decaf{
+namespace lang{
+
+    /**
+     * The class <code>Math</code> contains methods for performing basic
+     * numeric operations such as the elementary exponential, logarithm,
+     * square root, and trigonometric functions.
+     */
+    class DECAF_API Math {
+    public:
+
+        static const double E;
+        static const double PI;
+
+    public:
+
+        Math() {}
+        virtual ~Math() {}
+
+    public:
+
+        /**
+         * Returns the absolute value of an int value. If the argument is not
+         * negative, the argument is returned. If the argument is negative, the
+         * negation of the argument is returned.
+         * @param value - the value to return the abs of
+         * @returns the value if positive, otherwise the negative of value
+         */
+        static int abs( int value ) {
+            return value < 0 ? -value : value;
+        }
+
+        /**
+         * Returns the absolute value of an long long value. If the argument is not
+         * negative, the argument is returned. If the argument is negative, the
+         * negation of the argument is returned.
+         * @param value - the value to return the abs of
+         * @returns the value if positive, otherwise the negative of value
+         */
+        static long long abs( long long value ) {
+            return value < 0 ? -value : value;
+        }
+
+        /**
+         * Returns the absolute value of a float value. If the argument is not
+         * negative, the argument is returned. If the argument is negative,
+         * the negation of the argument is returned. Special cases:
+         *
+         * o If the argument is positive zero or negative zero, the result is
+         *   positive zero.
+         * o If the argument is infinite, the result is positive infinity.
+         * o If the argument is NaN, the result is NaN.
+         *
+         * In other words, the result is the same as the value of the expression:
+         *    Float::intBitsToFloat( 0x7fffffff & Float::floatToIntBits( value ) )
+         *
+         * @param value - the value to return the abs of
+         * @returns the value if positive, otherwise the negative of value
+         */
+        static float abs( float value );
+
+        /**
+         * Returns the absolute value of a double value. If the argument is not
+         * negative, the argument is returned. If the argument is negative,
+         * the negation of the argument is returned. Special cases:
+         *
+         * o If the argument is positive zero or negative zero, the result is
+         *   positive zero.
+         * o If the argument is infinite, the result is positive infinity.
+         * o If the argument is NaN, the result is NaN.
+         *
+         * In other words, the result is the same as the value of the expression:
+         *    Double::longBitsToDouble( 0x7fffffffffffffffULL &
+         *                              Double::doubleToLongBits( value ) )
+         *
+         * @param value - the value to return the abs of
+         * @returns the value if positive, otherwise the negative of value
+         */
+        static double abs( double value );
+
+        /**
+         * Returns the arc cosine of an angle, in the range of 0.0 through pi.
+         * Special case:
+         *
+         *  o If the argument is NaN or its absolute value is greater than 1, then
+         *    the result is NaN.
+         *
+         * @param value - the value to return the arc cosine of.
+         * @returns arc cosine of value in radians.
+         */
+        static double acos( double value );
+
+        /**
+         * Returns the arc sine of an angle, in the range of -pi/2 through pi/2.
+         * Special cases:
+         *
+         *  o If the argument is NaN or its absolute value is greater than 1, then
+         *    the result is NaN.
+         *  o If the argument is zero, then the result is a zero with the same sign
+         *    as the argument.
+         *
+         * @param value - the value to return the arc cosine of.
+         * @returns arc cosine of value in radians.
+         */
+        static double asin( double value );
+
+        /**
+         * Returns the arc tangent of an angle, in the range of -pi/2 through pi/2.
+         * Special cases:
+         *
+         *  o If the argument is NaN, then the result is NaN.
+         *  o If the argument is zero, then the result is a zero with the same sign
+         *    as the argument.
+         *
+         * @param value - the value to return the arc cosine of.
+         * @returns arc tangent of value in radians.
+         */
+        static double atan( double value );
+
+        /**
+         * Converts rectangular coordinates (x, y) to polar (r, theta). This method
+         * computes the phase theta by computing an arc tangent of y/x in the range
+         * of -pi to pi. Special cases:
+         *
+         *  o If either argument is NaN, then the result is NaN.
+         *  o If the first argument is positive zero and the second argument is
+         *    positive, or the first argument is positive and finite and the second
+         *    argument is positive infinity, then the result is positive zero.
+         *  o If the first argument is negative zero and the second argument is
+         *    positive, or the first argument is negative and finite and the second
+         *    argument is positive infinity, then the result is negative zero.
+         *  o If the first argument is positive zero and the second argument is
+         *    negative, or the first argument is positive and finite and the second
+         *    argument is negative infinity, then the result is the double value
+         *    closest to pi.
+         *  o If the first argument is negative zero and the second argument is
+         *    negative, or the first argument is negative and finite and the second
+         *    argument is negative infinity, then the result is the double value
+         *    closest to -pi.
+         *  o If the first argument is positive and the second argument is positive
+         *    zero or negative zero, or the first argument is positive infinity and
+         *    the second argument is finite, then the result is the double value
+         *    closest to pi/2.
+         *  o If the first argument is negative and the second argument is positive
+         *    zero or negative zero, or the first argument is negative infinity and
+         *    the second argument is finite, then the result is the double value
+         *    closest to -pi/2.
+         *  o If both arguments are positive infinity, then the result is the double
+         *    value closest to pi/4.
+         *  o If the first argument is positive infinity and the second argument is
+         *    negative infinity, then the result is the double value closest to 3*pi/4.
+         *  o If the first argument is negative infinity and the second argument is
+         *    positive infinity, then the result is the double value closest to -pi/4.
+         *  o If both arguments are negative infinity, then the result is the double
+         *    value closest to -3*pi/4.
+         *
+         * @param y - the ordinate coordinate
+         * @param x - the abscissa coordinate
+         * @returns the theta component of the point (r, theta) in polar coordinates
+         * that corresponds to the point (x, y) in Cartesian coordinates.
+         */
+        static double atan2( double x, double y );
+
+        /**
+         * Returns the cube root of a double value. For positive finite x,
+         * cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the
+         * negative of the cube root of that value's magnitude. Special cases:
+         *
+         *  o If the argument is NaN, then the result is NaN.
+         *  o If the argument is infinite, then the result is an infinity with the
+         *    same sign as the argument.
+         *  o If the argument is zero, then the result is a zero with the same sign
+         *    as the argument.
+         *
+         * @param value - the double to compute the cube root of
+         * @returns the cube root of value
+         */
+        #ifndef _WIN32
+        static double cbrt( double value );
+        #endif
+
+        /**
+         * Returns the trigonometric cosine of an angle. Special cases:
+         *
+         *   o If the argument is NaN or an infinity, then the result is NaN.
+         *
+         * @param value - an value in radians
+         * @returns the cosine of the argument.
+         */
+        static double cos( double value );
+
+        /**
+         * Returns the hyperbolic cosine of a double value. The hyperbolic cosine
+         * of x is defined to be (ex + e-x)/2 where e is Euler's number.
+         * Special cases:
+         *
+         *  o If the argument is NaN, then the result is NaN.
+         *  o If the argument is infinite, then the result is positive infinity.
+         *  o If the argument is zero, then the result is 1.0.
+         *
+         * @param value - the number whose hyperbolic cosine is to be found
+         * @return the hyperbolic cosine of value
+         */
+        static double cosh( double value );
+
+        /**
+         * Returns the trigonometric sine of an angle. Special case:
+         *
+         *  o If the argument is NaN or an infinity, then the result is NaN.
+         *  o If the argument is zero, then the result is a zero with the same sign
+         *    as the argument.
+         *
+         * @param value - the number whose sin is to be found
+         * @return the sine of value
+         */
+        static double sin( double value );
+
+        /**
+         * Returns the hyperbolic sine of a double value. The hyperbolic sine of x
+         * is defined to be (ex - e-x)/2 where e is Euler's number.
+         * Special cases:
+         *
+         *  o If the argument is NaN, then the result is NaN.
+         *  o If the argument is infinite, then the result is an infinity with
+         *    the same sign as the argument.
+         *  o If the argument is zero, then the result is a zero with the same
+         *    sign as the argument.
+         *
+         * @param value - the number whose hyperbolic sin is to be found
+         * @return the hyperbolic sine of value
+         */
+        static double sinh( double value );
+
+        /**
+         * Returns the trigonometric tangent of an angle. Special cases:
+         *
+         *  o If the argument is NaN or an infinity, then the result is NaN.
+         *  o If the argument is zero, then the result is a zero with the same
+         *    sign as the argument.
+         *
+         * @param value - the number whose tangent is to be found
+         * @return the tangent of value
+         */
+        static double tan( double value );
+
+        /**
+         * Returns the hyperbolic tangent of a double value. The hyperbolic
+         * tangent of x is defined to be (ex - e-x)/(ex + e-x), in other words,
+         * sinh(x)/cosh(x). Note that the absolute value of the exact tanh is
+         * always less than 1. Special cases:
+         *
+         *  o If the argument is NaN, then the result is NaN.
+         *  o If the argument is zero, then the result is a zero with the same
+         *    sign as the argument.
+         *  o If the argument is positive infinity, then the result is +1.0.
+         *  o If the argument is negative infinity, then the result is -1.0.
+         *
+         * @param value - the number whose hyperbolic tangent is to be found
+         * @return the hyperbolic cosine of value
+         */
+        static double tanh( double value );
+
+        /**
+         * Returns the correctly rounded positive square root of a double value.
+         * Special cases:
+         *
+         *  o If the argument is NaN or less than zero, then the result is NaN.
+         *  o If the argument is positive infinity, then the result is positive infinity.
+         *  o If the argument is positive zero or negative zero, then the result is
+         *    the same as the argument.
+         *
+         * Otherwise, the result is the double value closest to the true mathematical
+         * square root of the argument value.
+         * @param value - the value to find the square root of
+         * @param the square root of the argument.
+         */
+        static double sqrt( double value );
+
+        /**
+         * Returns the value of the first argument raised to the power of the second
+         * argument. Special cases:
+         *
+         *  o If the second argument is positive or negative zero, then the result
+         *    is 1.0.
+         *  o If the second argument is 1.0, then the result is the same as the first
+         *    argument.
+         *  o If the second argument is NaN, then the result is NaN.
+         *  o If the first argument is NaN and the second argument is nonzero,
+         *    then the result is NaN.
+         *
+         * @param base - the base
+         * @param exp - the exponent
+         * @return the base raised to the power of exp.
+         */
+        static double pow( double base, double exp );
+
+        /**
+         * Returns the double value that is closest in value to the argument and
+         * is equal to a mathematical integer. If two double values that are
+         * mathematical integers are equally close, the result is the integer
+         * value that is even. Special cases:
+         *
+         *  o If the argument value is already equal to a mathematical integer,
+         *    then the result is the same as the argument.
+         *  o If the argument is NaN or an infinity or positive zero or negative
+         *    zero, then the result is the same as the argument.
+         *
+         * @param value - the value to round to the nearest integer
+         * @returns the rounded value
+         */
+        #ifndef _WIN32
+        static double rint( double value );
+        #endif
+
+        /**
+         * Returns the smaller of two <code>short</code> values. That is,
+         * the result the argument closer to the value of
+         * <code>Short::MIN_VALUE</code>.  If the arguments have the same
+         * value, the result is that same value.
+         * @param a - an argument.
+         * @param b - another argument.
+         * @return the smaller of <code>a</code> and <code>b</code>.
+         */
+        static short min( short a, short b ) {
+            return ( a <= b ? a : b );
+        }
+
+        /**
+         * Returns the smaller of two <code>int</code> values. That is,
+         * the result the argument closer to the value of
+         * <code>Integer::MIN_VALUE</code>.  If the arguments have the same
+         * value, the result is that same value.
+         * @param a - an argument.
+         * @param b - another argument.
+         * @return the smaller of <code>a</code> and <code>b</code>.
+         */
+        static int min( int a, int b ) {
+            return ( a <= b ? a : b );
+        }
+
+        /**
+         * Returns the smaller of two <code>unsigned int</code> values. That is,
+         * the result the argument closer to the value of
+         * <code>Integer::MIN_VALUE</code>.  If the arguments have the same
+         * value, the result is that same value.
+         * @param a - an argument.
+         * @param b - another argument.
+         * @return the smaller of <code>a</code> and <code>b</code>.
+         */
+        static int min( unsigned int a, unsigned int b ) {
+            return ( a <= b ? a : b );
+        }
+
+        /**
+         * Returns the smaller of two <code>long long</code> values. That is,
+         * the result the argument closer to the value of
+         * <code>Long::MIN_VALUE</code>.  If the arguments have the same
+         * value, the result is that same value.
+         * @param a - an argument.
+         * @param b - another argument.
+         * @return the smaller of <code>a</code> and <code>b</code>.
+         */
+        static long long min( long long a, long long b ) {
+            return ( a <= b ? a : b );
+        }
+
+        /**
+         * Returns the smaller of two float values. That is, the result is the
+         * value closer to negative infinity. If the arguments have the same value,
+         * the result is that same value. If either value is NaN, then the result
+         * is NaN. Unlike the numerical comparison operators, this method considers
+         * negative zero to be strictly smaller than positive zero. If one argument
+         * is positive zero and the other is negative zero, the result is negative
+         * zero.
+         * @param a - an argument.
+         * @param b - another argument.
+         * @return the smaller of <code>a</code> and <code>b</code>.
+         */
+        static float min( float a, float b );
+
+        /**
+         * Returns the smaller of two double values. That is, the result is the
+         * value closer to negative infinity. If the arguments have the same value,
+         * the result is that same value. If either value is NaN, then the result
+         * is NaN. Unlike the numerical comparison operators, this method considers
+         * negative zero to be strictly smaller than positive zero. If one argument
+         * is positive zero and the other is negative zero, the result is negative
+         * zero.
+         * @param a - an argument.
+         * @param b - another argument.
+         * @return the smaller of <code>a</code> and <code>b</code>.
+         */
+        static double min( double a, double b );
+
+        /**
+         * Returns the larger of two <code>short</code> values. That is,
+         * the result the argument closer to the value of
+         * <code>Short::MAX_VALUE</code>.  If the arguments have the same
+         * value, the result is that same value.
+         * @param a - an argument.
+         * @param b - another argument.
+         * @return the larger of <code>a</code> and <code>b</code>.
+         */
+        static short max( short a, short b ) {
+            return ( a >= b ? a : b );
+        }
+
+        /**
+         * Returns the larger of two <code>int</code> values. That is,
+         * the result the argument closer to the value of
+         * <code>Integer::MAX_VALUE</code>.  If the arguments have the same
+         * value, the result is that same value.
+         * @param a - an argument.
+         * @param b - another argument.
+         * @return the larger of <code>a</code> and <code>b</code>.
+         */
+        static int max( int a, int b ) {
+            return ( a >= b ? a : b );
+        }
+
+        /**
+         * Returns the larger of two <code>long long</code> values. That is,
+         * the result the argument closer to the value of
+         * <code>Long::MAX_VALUE</code>.  If the arguments have the same
+         * value, the result is that same value.
+         * @param a - an argument.
+         * @param b - another argument.
+         * @return the larger of <code>a</code> and <code>b</code>.
+         */
+        static long long max( long long a, long long b ) {
+            return ( a >= b ? a : b );
+        }
+
+        /**
+         * Returns the greater of two float values. That is, the result is the
+         * argument closer to positive infinity. If the arguments have the same
+         * value, the result is that same value. If either value is NaN, then the
+         * result is NaN. Unlike the numerical comparison operators, this method
+         * considers negative zero to be strictly smaller than positive zero. If
+         * one argument is positive zero and the other negative zero, the result
+         * is positive zero.
+         * @param a - an argument.
+         * @param b - another argument.
+         * @return the larger of <code>a</code> and <code>b</code>.
+         */
+        static float max( float a, float b );
+
+        /**
+         * Returns the greater of two double values. That is, the result is the
+         * argument closer to positive infinity. If the arguments have the same value,
+         * the result is that same value. If either value is NaN, then the result is
+         * NaN. Unlike the numerical comparison operators, this method considers
+         * negative zero to be strictly smaller than positive zero. If one argument
+         * is positive zero and the other negative zero, the result is positive zero.
+         * @param a - an argument.
+         * @param b - another argument.
+         * @return the larger of <code>a</code> and <code>b</code>.
+         */
+        static double max( double a, double b );
+
+        /**
+         * Returns the natural logarithm (base e) of a double  value. Special cases:
+         *
+         *  o If the argument is NaN or less than zero, then the result is NaN.
+         *  o If the argument is positive infinity, then the result is
+         *    positive infinity.
+         *  o If the argument is positive zero or negative zero, then the result
+         *    is negative infinity.
+         *
+         * @param value the value to compute the natural log of.
+         * @returns the natural log of value.
+         */
+        static double log( double value );
+
+        /**
+         * Returns the base 10 logarithm of a double value. Special cases:
+         *
+         *   o If the argument is NaN or less than zero, then the result is NaN.
+         *   o If the argument is positive infinity, then the result is positive
+         *     infinity.
+         *   o If the argument is positive zero or negative zero, then the result is
+         *     negative infinity.
+         *   o If the argument is equal to 10n for integer n, then the result is n.
+         *
+         * @param value - the value to operate on
+         * @returns the long base 10 of value
+         */
+        static double log10( double value );
+
+        /**
+         * Returns the natural logarithm of the sum of the argument and 1. Note that
+         * for small values x, the result of log1p(x) is much closer to the true
+         * result of ln(1 + x) than the floating-point evaluation of log(1.0+x).
+         *
+         * Special cases:
+         *
+         *   o If the argument is NaN or less than -1, then the result is NaN.
+         *   o If the argument is positive infinity, then the result is positive
+         *     infinity.
+         *   o If the argument is negative one, then the result is negative infinity.
+         *   o If the argument is zero, then the result is a zero with the same sign
+         *     as the argument.
+         *
+         * @param value - the value to operate on
+         * @returns the the value ln(x + 1), the natural log of x + 1
+         */
+        #ifndef _WIN32
+        static double log1p( double value );
+        #endif
+
+        /**
+         * Returns the smallest (closest to negative infinity) double value that is
+         * greater than or equal to the argument and is equal to a mathematical
+         * integer. Special cases:
+         *
+         *   o If the argument value is already equal to a mathematical integer,
+         *     then the result is the same as the argument.
+         *   o If the argument is NaN or an infinity or positive zero or negative
+         *     zero, then the result is the same as the argument.
+         *   o If the argument value is less than zero but greater than -1.0, then
+         *     the result is negative zero.
+         *
+         * Note that the value of Math.ceil(x) is exactly the value of -Math.floor(-x).
+         * @param value - the value to find the ceiling of
+         * @returns the smallest (closest to negative infinity) floating-point value
+         * that is greater than or equal to the argument and is equal to a
+         * mathematical integer.
+         */
+        static double ceil( double value );
+
+        /**
+         * Returns the largest (closest to positive infinity) double value that is
+         * less than or equal to the argument and is equal to a mathematical integer.
+         * Special cases:
+         *
+         *    o If the argument value is already equal to a mathematical integer,
+         *      then the result is the same as the argument.
+         *    o If the argument is NaN or an infinity or positive zero or negative
+         *      zero, then the result is the same as the argument.
+         *
+         * @param value - the value to find the floor of
+         * @returns the largest (closest to positive infinity) floating-point value
+         * that less than or equal to the argument and is equal to a mathematical
+         * integer.
+         */
+        static double floor( double value );
+
+        /**
+         * Returns the closest int to the argument. The result is rounded to an
+         * integer by adding 1/2, taking the floor of the result, and casting the
+         * result to type int. In other words, the result is equal to the value
+         * of the expression:  (int)Math.floor( a + 0.5f )
+         *
+         *   o If the argument is NaN, the result is 0.
+         *   o If the argument is negative infinity or any value less than or equal
+         *     to the value of Integer::MIN_VALUE, the result is equal to the value of
+         *     Integer::MIN_VALUE.
+         *   o If the argument is positive infinity or any value greater than or equal
+         *     to the value of Integer::MAX_VALUE, the result is equal to the value of
+         *     Integer::MAX_VALUE.
+         *
+         * @param value - the value to round
+         * @returns the value of the argument rounded to the nearest integral value.
+         */
+        static int round( float value );
+
+        /**
+         * Returns the closest long long to the argument. The result is rounded to
+         * an integer by adding 1/2, taking the floor of the result, and casting the
+         * result to type long long. In other words, the result is equal to the value
+         * of the expression:  (long long)Math.floor(a + 0.5d)
+         *
+         *   o If the argument is NaN, the result is 0.
+         *   o If the argument is negative infinity or any value less than or equal
+         *     to the value of Long::MIN_VALUE, the result is equal to the value of
+         *     Long::MIN_VALUE.
+         *   o If the argument is positive infinity or any value greater than or equal
+         *     to the value of Long::MAX_VALUE, the result is equal to the value of
+         *     Long::MAX_VALUE.
+         *
+         * @param value - the value to round
+         * @returns the value of the argument rounded to the nearest integral value.
+         */
+        static long long round( double value );
+
+        /**
+         * Computes the remainder operation on two arguments as prescribed by the
+         * IEEE 754 standard. The remainder value is mathematically equal to
+         * f1 - f2 × n, where n is the mathematical integer closest to the exact
+         * mathematical value of the quotient f1/f2, and if two mathematical
+         * integers are equally close to f1/f2, then n is the integer that is even.
+         * If the remainder is zero, its sign is the same as the sign of the first
+         * argument. Special cases:
+         *
+         *  o If either argument is NaN, or the first argument is infinite, or the
+         *    second argument is positive zero or negative zero, then the result is
+         *    NaN.
+         *  o If the first argument is finite and the second argument is infinite,
+         *    then the result is the same as the first argument.
+         *
+         * @param f1 - the dividend.
+         * @param f2 - the divisor
+         * @return the IEEE remainder of value
+         */
+        #ifndef _WIN32
+        static double IEEEremainder( double f1, double f2 );
+        #endif
+
+        /**
+         * Returns a double value with a positive sign, greater than or equal to 0.0
+         * and less than 1.0. Returned values are chosen pseudorandomly with
+         * (approximately) uniform distribution from that range.
+         *
+         * When this method is first called, it creates a single new pseudorandom-number
+         * generator; This new pseudorandom-number generator is used thereafter for all
+         * calls to this method and is used nowhere else.
+         *
+         * This method is properly synchronized to allow correct use by more than
+         * one thread. However, if many threads need to generate pseudorandom numbers
+         * at a great rate, it may reduce contention for each thread to have its
+         * own pseudorandom-number generator.
+         * @returns a pseudorandom double greater than or equal to 0.0 and
+         * less than 1.0.
+         */
+        static double random();
+
+        /**
+         * Returns Euler's number e raised to the power of a double value.
+         * Special cases:
+         *
+         *  o If the argument is NaN, the result is NaN.
+         *  o If the argument is positive infinity, then the result is positive infinity.
+         *  o If the argument is negative infinity, then the result is positive zero.
+         *
+         * @param value - the exponent to raise e to
+         * @returns the value e^a, where e is the base of the natural logarithms.
+         */
+        static double exp( double value );
+
+        /**
+         * Returns e^x - 1. Note that for values of x near 0, the exact sum of
+         * expm1(x) + 1 is much closer to the true result of ex than exp(x).
+         * Special cases:
+         *
+         *  o If the argument is NaN, the result is NaN.
+         *  o If the argument is positive infinity, then the result is positive infinity.
+         *  o If the argument is negative infinity, then the result is -1.0.
+         *  o If the argument is zero, then the result is a zero with the same sign as
+         *    the argument.
+         *
+         * @param the value to raise e^x - 1
+         * @returns the value ex - 1.
+         */
+        #ifndef _WIN32
+        static double expm1( double value );
+        #endif
+
+        /**
+         * Returns sqrt(x^2 + y^2) without intermediate overflow or underflow.
+         * Special cases:
+         *
+         * If either argument is infinite, then the result is positive infinity.
+         * If either argument is NaN and neither argument is infinite, then the
+         * result is NaN.
+         *
+         * @param x - an argument
+         * @param y - another argument
+         * @returns the sqrt(x^2 + y^2) without intermediate overflow or underflow
+         */
+        static double hypot( double x, double y );
+
+        /**
+         * Returns the signum function of the argument; zero if the argument is zero,
+         * 1.0f if the argument is greater than zero, -1.0f if the argument is less
+         * than zero.  Special Cases:
+         *
+         *  o If the argument is NaN, then the result is NaN.
+         *  o If the argument is positive zero or negative zero, then the result is
+         *    the same as the argument.
+         *
+         * @param value - the floating-point value whose signum is to be returned
+         * @returns the signum function of the argument
+         */
+        static float signum( float value );
+
+        /**
+         * Returns the signum function of the argument; zero if the argument is zero,
+         * 1.0f if the argument is greater than zero, -1.0f if the argument is less
+         * than zero.  Special Cases:
+         *
+         *  o If the argument is NaN, then the result is NaN.
+         *  o If the argument is positive zero or negative zero, then the result is
+         *    the same as the argument.
+         *
+         * @param value - the floating-point value whose signum is to be returned
+         * @returns the signum function of the argument
+         */
+        static double signum( double value );
+
+        /**
+         * Returns the measure in radians of the supplied degree angle
+         * @param angdeg - an angle in degrees
+         * @return the radian measure of the angle.
+         */
+        static double toRadians( double angdeg ) {
+            return angdeg / 180 * PI;
+        }
+
+        /**
+         * Returns the measure in degrees of the supplied radian angle
+         * @param angrad -  an angle in radians
+         * @return the degree measure of the angle.
+         */
+        static double toDegrees( double angrad ) {
+            return angrad * 180 / PI;
+        }
+
+        /**
+         * Returns the size of an ulp of the argument. An ulp of a float value is
+         * the positive distance between this floating-point value and the float
+         * value next larger in magnitude. Note that for non-NaN x, ulp(-x) == ulp(x).
+         * Special Cases:
+         *
+         *  o If the argument is NaN, then the result is NaN.
+         *  o If the argument is positive or negative infinity, then the result is
+         *    positive infinity.
+         *  o If the argument is positive or negative zero, then the result is
+         *    Float::MIN_VALUE.
+         *  o If the argument is ±Float::MAX_VALUE, then the result is equal to 2^104.
+         *
+         * @param value - the floating-point value whose ulp is to be returned
+         * @returns the size of an ulp of the argument
+         */
+        #ifndef _WIN32
+        static float ulp( float value );
+        #endif
+
+        /**
+         * Returns the size of an ulp of the argument. An ulp of a double value is
+         * the positive distance between this floating-point value and the double
+         * value next larger in magnitude. Note that for non-NaN x, ulp(-x) == ulp(x).
+         * Special Cases:
+         *
+         *  o If the argument is NaN, then the result is NaN.
+         *  o If the argument is positive or negative infinity, then the result is
+         *    positive infinity.
+         *  o If the argument is positive or negative zero, then the result is
+         *    Double::MIN_VALUE.
+         *  o If the argument is ±Float::MAX_VALUE, then the result is equal to 2^971.
+         *
+         * @param value - the floating-point value whose ulp is to be returned
+         * @returns the size of an ulp of the argument
+         */
+        #ifndef _WIN32
+        static double ulp( double value );
+        #endif
+    };
+
+}}
+
+#endif /*_DECAF_LANG_MATH_H_*/