Libraries
Bigrat Source Code
 previous   up   next 

Types
bigRational
Rational numbers represented with bigInteger numerator and denominator.

bigRational

const type: bigRational

Rational numbers represented with bigInteger numerator and denominator. The values of the type bigRational are finite and periodical decimal numbers. BigRational literals do not exist. Although bigRational operations cannot overflow, it can happen that there is not enough memory to represent a bigRational value. In this case the exception MEMORY_ERROR is raised.


Operator Summary
bigRational
(in bigInteger: numerator) / (in bigInteger: denominator)
Create a bigRational number from its numerator and denominator.
bigRational
+ (in bigRational: number)
Plus sign for bigRational numbers.
bigRational
- (in bigRational: number)
Minus sign, negate a bigRational number.
bigRational
(in bigRational: summand1) + (in bigRational: summand2)
Add two bigRational numbers.
bigRational
(in bigRational: minuend) - (in bigRational: subtrahend)
Compute the subtraction of two bigRational numbers.
bigRational
(in bigRational: factor1) * (in bigRational: factor2)
Multiply two bigRational numbers.
bigRational
(in bigRational: dividend) / (in bigRational: divisor)
Compute the division of two bigRational numbers.
void
(inout bigRational: number) +:= (in bigRational: delta)
Increment a bigRational number by a delta.
void
(inout bigRational: number) -:= (in bigRational: delta)
Decrement a bigRational number by a delta.
void
(inout bigRational: number) *:= (in bigRational: factor)
Multiply a bigRational number by a factor and assign the result back to number.
void
(inout bigRational: number) /:= (in bigRational: divisor)
Divide a bigRational number by a divisor and assign the result back to number.
bigRational
(in bigRational: base) ** (in integer: exponent)
Compute the exponentiation of a bigRational base with an integer exponent.
boolean
(in bigRational: number1) = (in bigRational: number2)
Check if two bigRational numbers are equal.
boolean
(in bigRational: number1) <> (in bigRational: number2)
Check if two bigRational numbers are not equal.
boolean
(in bigRational: number1) < (in bigRational: number2)
Check if number1 is less than number2.
boolean
(in bigRational: number1) > (in bigRational: number2)
Check if number1 is greater than number2.
boolean
(in bigRational: number1) <= (in bigRational: number2)
Check if number1 is less than or equal to number2.
boolean
(in bigRational: number1) >= (in bigRational: number2)
Check if number1 is greater than or equal to number2.
bigRational
(attr bigRational) conv (in integer: number)
Return the conversion of an integer to a bigRational.
bigRational
(attr bigRational) conv (in bigInteger: number)
Return the conversion of a bigInteger to a bigRational.
string
(in bigRational: number) digits (in integer: precision)
Convert a bigRational number to a string in decimal fixed point notation.
string
(in bigRational: number) sci (in integer: precision)
Convert a bigRational number to a string in scientific notation.
bigRational
(attr bigRational) parse (in string: stri)
Convert a string to a bigRational number.

Function Summary
integer
compare (in bigRational: number1, in bigRational: number2)
Compare two bigRational numbers.
integer
hashCode (in bigRational: number)
Compute the hash value of a bigRational number.
bigRational
rat (in bigInteger: number)
Return the conversion of a bigInteger to a bigRational.
bigRational
bigRational (in integer: number)
Return the conversion of an integer to a bigRational.
bigRational
bigRational (in bigInteger: number)
Return the conversion of a bigInteger to a bigRational.
bigRational
abs (in bigRational: number)
Compute the absolute value of a bigRational number.
bigInteger
floor (in bigRational: number)
Return a bigRational number truncated towards negative infinity.
bigInteger
ceil (in bigRational: number)
Return a bigRational number rounded up towards positive infinity.
bigInteger
trunc (in bigRational: number)
Return a bigRational number truncated towards zero.
bigInteger
round (in bigRational: number)
Round a bigRational number to the nearest bigInteger.
bigRational
round10 (in bigRational: number, in integer: precision)
Round a bigRational number with a decimal precision.
string
str (in bigRational: number)
Convert a bigRational number to a string.
string
literal (in bigRational: number)
Convert a bigRational number to a bigRational literal.
string
fraction (in bigRational: number)
Convert a bigRational to a string with a fraction.
bigRational
bigRational (in var string: stri)
Convert a string to a bigRational number.

Operator Detail

/

const func bigRational: (in bigInteger: numerator) / (in bigInteger: denominator)

Create a bigRational number from its numerator and denominator.

Returns:
the created bigRational value.

+

const func bigRational: + (in bigRational: number)

Plus sign for bigRational numbers.

Returns:
its operand unchanged.

-

const func bigRational: - (in bigRational: number)

Minus sign, negate a bigRational number.

Returns:
the negated value of the number.

+

const func bigRational: (in bigRational: summand1) + (in bigRational: summand2)

Add two bigRational numbers.

Returns:
the sum of the two numbers.

-

const func bigRational: (in bigRational: minuend) - (in bigRational: subtrahend)

Compute the subtraction of two bigRational numbers.

Returns:
the difference of the two numbers.

*

const func bigRational: (in bigRational: factor1) * (in bigRational: factor2)

Multiply two bigRational numbers.

Returns:
the product of the two numbers.

/

const func bigRational: (in bigRational: dividend) / (in bigRational: divisor)

Compute the division of two bigRational numbers.

Returns:
the quotient of the division.
Raises:
NUMERIC_ERROR - If a division by zero occurs.

+:=

const proc: (inout bigRational: number) +:= (in bigRational: delta)

Increment a bigRational number by a delta.


-:=

const proc: (inout bigRational: number) -:= (in bigRational: delta)

Decrement a bigRational number by a delta.


*:=

const proc: (inout bigRational: number) *:= (in bigRational: factor)

Multiply a bigRational number by a factor and assign the result back to number.


/:=

const proc: (inout bigRational: number) /:= (in bigRational: divisor)

Divide a bigRational number by a divisor and assign the result back to number.


**

const func bigRational: (in bigRational: base) ** (in integer: exponent)

Compute the exponentiation of a bigRational base with an integer exponent.

Returns:
the result of the exponentiation.

=

const func boolean: (in bigRational: number1) = (in bigRational: number2)

Check if two bigRational numbers are equal.

Returns:
TRUE if both numbers are equal, FALSE otherwise.

<>

const func boolean: (in bigRational: number1) <> (in bigRational: number2)

Check if two bigRational numbers are not equal.

Returns:
FALSE if both numbers are equal, TRUE otherwise.

<

const func boolean: (in bigRational: number1) < (in bigRational: number2)

Check if number1 is less than number2.

Returns:
TRUE if number1 is less than number2, FALSE otherwise.

>

const func boolean: (in bigRational: number1) > (in bigRational: number2)

Check if number1 is greater than number2.

Returns:
TRUE if number1 is greater than number2, FALSE otherwise.

<=

const func boolean: (in bigRational: number1) <= (in bigRational: number2)

Check if number1 is less than or equal to number2.

Returns:
TRUE if number1 is less than or equal to number2, FALSE otherwise.

>=

const func boolean: (in bigRational: number1) >= (in bigRational: number2)

Check if number1 is greater than or equal to number2.

Returns:
TRUE if number1 is greater than or equal to number2, FALSE otherwise.

conv

const func bigRational: (attr bigRational) conv (in integer: number)

Return the conversion of an integer to a bigRational.


conv

const func bigRational: (attr bigRational) conv (in bigInteger: number)

Return the conversion of a bigInteger to a bigRational.


digits

const func string: (in bigRational: number) digits (in integer: precision)

Convert a bigRational number to a string in decimal fixed point notation. The number is rounded to the specified number of digits (precision). Halfway cases are rounded away from zero. Except for a precision of zero the representation has a decimal point and at least one digit before and after the decimal point. Negative numbers are preceded by a minus sign (e.g.: "-1.25"). If all digits in the result are 0 a possible negative sign is omitted.

1_/64_ digits 7     returns "0.0156250"
1_/64_ digits 4     returns "0.0156"
1_/64_ digits 2     returns "0.02"
355_/113_ digits 6  returns "3.141593"
22_/7_ digits 0     returns "3"
-1_/2_ digits 1     returns "-1"
1_/0_ digits 5      returns "Infinity"
-1_/0_ digits 6     returns "-Infinity"
0_/0_ digits 7      returns "NaN"
-1_/2048_ digits 3  returns "0.000"
Parameters:
precision - Number of digits after the decimal point. If the precision is zero the decimal point is omitted.
Returns:
the string result of the conversion.
Raises:
RANGE_ERROR - If the precision is negative.

sci

const func string: (in bigRational: number) sci (in integer: precision)

Convert a bigRational number to a string in scientific notation. Scientific notation uses a decimal significand and a decimal exponent. The significand has an optional sign and exactly one digit before the decimal point. The fractional part of the significand is rounded to the specified number of digits (precision). Halfway cases are rounded away from zero. The fractional part is followed by the letter e and an exponent, which is always signed. The value zero is never written with a negative sign.

1_/64_ sci 4     returns "1.5625e-2"
1_/64_ sci 3     returns "1.563e-2"
1_/64_ sci 2     returns "1.56e-2"
355_/113_ sci 6  returns "3.141593e+0"
22_/7_ sci 0     returns "3e+0"
-1_/2_ sci 1     returns "-5.0e-1"
1_/0_ sci 5      returns "Infinity"
-1_/0_ sci 6     returns "-Infinity"
0_/0_ sci 7      returns "NaN"
-1_/2048_ sci 3  returns "-4.883e-4"
-0_/1_ sci 2     returns "0.00e+0"
Parameters:
precision - Number of digits after the decimal point. If the precision is zero the decimal point is omitted.
Returns:
the string result of the conversion.
Raises:
RANGE_ERROR - If the precision is negative.

parse

const func bigRational: (attr bigRational) parse (in string: stri)

Convert a string to a bigRational number. The string must contain a fraction (e.g.: "3/5") or a decimal number (e.g.: "1.25"). In a fraction numerator and denominator are separated with a slash (/). A decimal number can have repeating decimals, which are enclosed in parentheses ("e.g.: "0.(3)"). The repeating decimals are not allowed to start before the decimal point.

bigRational parse "3/5"         returns   3_ /   5_
bigRational parse "1.25"        returns   5_ /   4_
bigRational parse "0.(3)"       returns   1_ /   3_
bigRational parse "1.23(45)"    returns 679_ / 550_
bigRational parse "3.(142857)"  returns  22_ /   7_
bigRational parse "0.(846153)"  returns  11_ /  13_
Returns:
the bigRational result of the conversion.
Raises:
RANGE_ERROR - If stri contains not a valid bigRational value.

Function Detail

compare

const func integer: compare (in bigRational: number1, in bigRational: number2)

Compare two bigRational numbers.

Returns:
-1, 0 or 1 if the first argument is considered to be respectively less than, equal to, or greater than the second.

hashCode

const func integer: hashCode (in bigRational: number)

Compute the hash value of a bigRational number.

Returns:
the hash value.

rat

const func bigRational: rat (in bigInteger: number)

Return the conversion of a bigInteger to a bigRational.


bigRational

const func bigRational: bigRational (in integer: number)

Return the conversion of an integer to a bigRational.


bigRational

const func bigRational: bigRational (in bigInteger: number)

Return the conversion of a bigInteger to a bigRational.


abs

const func bigRational: abs (in bigRational: number)

Compute the absolute value of a bigRational number.

Returns:
the absolute value.

floor

const func bigInteger: floor (in bigRational: number)

Return a bigRational number truncated towards negative infinity.


ceil

const func bigInteger: ceil (in bigRational: number)

Return a bigRational number rounded up towards positive infinity.


trunc

const func bigInteger: trunc (in bigRational: number)

Return a bigRational number truncated towards zero.


round

const func bigInteger: round (in bigRational: number)

Round a bigRational number to the nearest bigInteger. Halfway cases are rounded away from zero.

Returns:
the rounded value.

round10

const func bigRational: round10 (in bigRational: number, in integer: precision)

Round a bigRational number with a decimal precision. Halfway cases are rounded away from zero.

Returns:
the rounded value.

str

const func string: str (in bigRational: number)

Convert a bigRational number to a string. The number is converted to a string with a decimal representation (e.g.: "1.25"). The representation has a decimal point and at least one digit before and after the decimal point. Negative numbers are preceded by a minus sign (e.g.: "-1.25"). The decimal number can have repeating decimals, which are enclosed in parentheses ("e.g.: "0.(3)"). The repeating decimals will not start before the decimal point.

Returns:
the string result of the conversion.

literal

const func string: literal (in bigRational: number)

Convert a bigRational number to a bigRational literal.

Returns:
the bigRational literal.

fraction

const func string: fraction (in bigRational: number)

Convert a bigRational to a string with a fraction.

fraction(bigRational("0.(3)"))  returns  "1/3"
Returns:
the string with the corrresponding fraction.

bigRational

const func bigRational: bigRational (in var string: stri)

Convert a string to a bigRational number. The string must contain a fraction (e.g.: "3/5") or a decimal number (e.g.: "1.25"). In a fraction numerator and denominator are separated with a slash (/). A decimal number can have repeating decimals, which are enclosed in parentheses ("e.g.: "0.(3)"). The repeating decimals are not allowed to start before the decimal point.

bigRational("3/5")         returns   3_ /   5_
bigRational("1.25")        returns   5_ /   4_
bigRational("0.(3)")       returns   1_ /   3_
bigRational("1.23(45)")    returns 679_ / 550_
bigRational("3.(142857)")  returns  22_ /   7_
bigRational("0.(846153)")  returns  11_ /  13_
Returns:
the bigRational result of the conversion.
Raises:
RANGE_ERROR - If stri contains not a valid bigRational value.


 previous   up   next