Seed7 - The extensible programming language
Seed7 FAQ Manual Screenshots Examples Libraries Algorithms Download Links
Libraries AES ARC4 Array ASN.1 Bigfile Bigint Bigrat Bin32 Bin64 Bitdata Bitmapfont Bitset Bitsetof Boolean Browser Bstring Bytedata Cards Category CC config Cgi Cgi dialog Char Charsets Cipher Clib_file Color CLI Commands Complex Console Crc32 Deflate DES Dialog Dir Draw Duration Echo Editline Enable_input Enable_io Enable_output Encoding Environment External_file File File system Float Font Forloop Ftp Getf Gethttp Gethttps Graph Graph_file Gzip Hash Hashsetof Hmac Html_ent Httpserv Idxarray Image Inflate Inflate file Inifile Integer Keybd Line Listener LZW Make Math Msgdigest Null_file Osfiles Picture utility Pixmap_file Pixmapfont PKCS #1 Poll Process Progs Propertyfile Rational Reference Ref_list Scanfile Scanstri Set Shell Smtp Sockbase Socket SQL base Stdio Strifile String Stritext Subrange Tar Text Time TLS/SSL Triple DES Unicode Utf16 Utf8 Vectorfont 3D Vector Wildcard Window Wrinum X.509 Xmldom Xml_ent Zip
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 var 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
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.
bigRational
min (in bigRational: value1, in bigRational: value2)
Determine the minimum of two bigRational numbers.
bigRational
max (in bigRational: value1, in bigRational: value2)
Determine the maximum of two bigRational numbers.
string
str (in bigRational: number)
Convert a bigRational number to a string.

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 - When 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 exponentation.

=

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 preceeded by a minus sign (e.g.: "-1.25"). When 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. When the precision is zero the decimal point is omitted.
Returns:
the string result of the conversion.
Raises:
RANGE_ERROR - When 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. When the precision is zero the decimal point is omitted.
Returns:
the string result of the conversion.
Raises:
RANGE_ERROR - When the precision is negative.

parse

const func bigRational: (attr bigRational) parse (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 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 - When 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.


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.

min

const func bigRational: min (in bigRational: value1, in bigRational: value2)

Determine the minimum of two bigRational numbers.

Returns:
the minimum of the two numbers.

max

const func bigRational: max (in bigRational: value1, in bigRational: value2)

Determine the maximum of two bigRational numbers.

Returns:
the maximum of the two numbers.

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 preceeded 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.


 previous   up   next