This site's content was compiled from 1993 to 2006. Beyond that, Google is your friend.

Factorial Based Numbers

Maintainer

Nicolas Waquier

Description

A library for handling big numbers, where common numbers (INTEGER, REAL, DOUBLE) are not appropriate.

Note that the main class is "eencoded", i.e. no source code is provided and the encrypted file can only be processed by TowerEiffel.

Categories

Versions

Links

Features

class FACTORIAL
the BIG INTEGER class
class F_TEST
to test the cluster

Short Form

indexing

        calculus, precision;
        names: fb, big_integers;
        size: dynamic;
       
class interface FACTORIAL

ancestors

        FACTORIAL
                COMPARABLE_NUMERIC
                        COMPARABLE
                                PART_COMPARABLE
                        NUMERIC

feature summary

        infix "*" (other : like Current) : like Current
        infix "+" (other : like Current) : like Current
        prefix "+" : like Current
        infix "-" (other : like Current) : like Current
        prefix "-" : like Current
        infix "/" (other : like Current) : like Current
        infix "<" (other : like Current) : BOOLEAN
        infix "<=" (other : like Current) : BOOLEAN
        infix ">" (other : like Current) : BOOLEAN
        infix ">=" (other : like Current) : BOOLEAN
        infix "^" (exp : INTEGER) : like Current
        abs : like Current
        compare (other : like Current) : INTEGER
        copy (other : like Current)
        from_integer (i : INTEGER)
        gcd (other : like Current) : like Current
        greatest_common_divisor (other : like Current) : like Current
        integer_representable : BOOLEAN
        is_equal (other : like Current) : BOOLEAN
        make
        manifest (entry : ARRAY [INTEGER])
        max (other : like Current) : like Current
        min (other : like Current) : like Current
        one : FACTORIAL
        out : STRING
        setup (other : like Current)
        sign : INTEGER
        to_integer : INTEGER
        valid_divisor (other : like Current) : BOOLEAN
        zero : FACTORIAL

creation

        make, from_integer, setup, manifest

inherited features

        -- From COMPARABLE:
        infix "<=", compare, max, min
        -- From PART_COMPARABLE:
        infix ">", infix ">="
        -- From NUMERIC:
        prefix "+"

feature specification

        -- Creation
        make
                        -- create a new FB number, set it to zero.
        setup (other : like Current)
                        -- create a new FB number regarding other.
        manifest (entry : ARRAY [INTEGER])
                        -- create a new FB number from a manifest-array of integers.
        from_integer (i : INTEGER)
                        -- create a new FB number from integer i.

feature specification

        -- info
        is_equal (other : like Current) : BOOLEAN
                        -- compare other with Current.
                require
                        other_not_void : other /= void;
        out : STRING
                        -- New string containing a printable representation of Current.
        sign : INTEGER
                        -- the sign of Current.
                ensure
                        negative_condition : (Result = (- 1)) = (Current < zero);
                        zero_condition : (Result = 0) = (not ((Current < zero) or (Current > zero)));
                        positive_condition : (Result = 1) = (Current > zero);
        integer_representable : BOOLEAN
        to_integer : INTEGER
                        -- conversion of Current to an integer.
                require
                        not_too_big : integer_representable;

feature specification

        -- related factorial based numbers
        one : FACTORIAL
                        -- '1'
        zero : FACTORIAL
                        -- '0'
        abs : like Current
                        -- the absolute value of Current
                ensure
                        same_as_negative : (Current < zero) = (compare (- Result) = 0);
                        same_if_positive : (Current >= zero) = (compare (Result) = 0);
        gcd,
        greatest_common_divisor (other : like Current) : like Current
                        -- the GCD between Current and other.

feature specification

        -- comparison
        infix "<" (other : like Current) : BOOLEAN
                        -- Is Current less than other?
                require
                        other /= void
                ensure
                        other_not_less_or_equal : Result = (not (other <= Current));
                        consistent : Result implies (not (other <= Current));
                        not_reflexive : (Current = other) implies (not Result);
                        other_not_less_or_equal : Result = (not (other <= Current));
                        consistent : Result implies (not (other <= Current));
                        not_reflexive : (Current = other) implies (not Result);

feature specification

        -- operations
        infix "+" (other : like Current) : like Current
                        -- Sum of Current and other
                require
                        other /= void
        infix "-" (other : like Current) : like Current
                        -- Difference between Current  and other
                require
                        other /= void
        prefix "-" : like Current
                        -- Unary subtraction applied to Current
        infix "*" (other : like Current) : like Current
                        -- multiplication
                require
                        other_not_void : other /= void;
        infix "/" (other : like Current) : like Current
                        -- division
                        -- not implemented
                require
                        other_not_void : other /= void;
                        valid_divisor : valid_divisor (other);
        infix "^" (exp : INTEGER) : like Current
                        -- not implemented
                require
                        non_negative_exponent : exp >= 0;

feature specification

        -- other
        valid_divisor (other : like Current) : BOOLEAN
                        -- not implemented
                require
                        other_not_void : other /= void;
        copy (other : like Current)
                        -- set Current a copy of other
                require
                        other_not_void : other /= void;
                        conformance : other.conforms_to (Current);
                ensure
                        result_is_equal : is_equal (other);

end interface -- class FACTORIAL

Supported compilers

Platforms

Licensing

Google
 
Web eiffelzone.com