Previous Page Next Page Contents

Dom::Rational -- the field of rational numbers

Introduction

Dom::Rational is the field of rational numbers represented by elements of the domains DOM_INT or DOM_RAT.

Creating Elements

Dom::Rational(x)

Parameters

x - an integer or a rational number

Categories

Cat::QuotientField(Dom::Integer

), Cat::DifferentialRing, Cat::OrderedSet

Related Domains

Dom::Complex, Dom::Float, Dom::Numerical, Dom::Rational, Dom::Real

Details

Method denom: denominator of a rational number

Method diff: differentiates

Method numer: numerator of the rational number

Method random: random number generation

Method retract: retract to an integer element

Method convert: conversion of objects

Method convert_to: conversion to other domains

Method testtype: type checking

Example 1

Creating some rational numbers using Dom::Rational. This example also shows that Dom::Rational is a faēcade domain.

>> Dom::Rational(2/3) ; domtype(%) 
                                    2/3
      
                                  DOM_RAT
>> Dom::Rational(2.0)
      Error: illegal arguments [Dom::Rational::new]

Example 2

By tracing the method Dom::Rational::testtype we can see the interaction between testtype and Dom::Rational::testtype.

>> prog::trace(Dom::Rational::testtype):
   delete x:
   testtype(x, Dom::Rational);
   testtype(3/4, Dom::Rational);
   prog::untrace(Dom::Rational::testtype):
      enter 'Dom::Rational::testtype'        with args   : x, Dom::Rational
      leave 'Dom::Rational::testtype'        with result : FAIL
      
                                   FALSE
      enter 'Dom::Rational::testtype'        with args   : 3/4, Dom::Rational
      leave 'Dom::Rational::testtype'        with result : TRUE
      
                                   TRUE

Super-Domain

Dom::Numerical

Axioms

Ax::canonicalRep

, Ax::systemRep, Ax::canonicalOrder, Ax::efficientOperation("_divide"), Ax::efficientOperation("_mult"), Ax::efficientOperation("_invert")

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000