[#2367] Standard libraries — Dave Thomas <dave@...>

From ruby-dev summary:

60 messages 2004/02/11

[#2397] PATCH: deprecate cgi-lib, getopts, importenv, parsearg from standard library — Gavin Sinclair <gsinclair@...>

Index: cgi-lib.rb

15 messages 2004/02/12

[#2465] PATCH: OpenStruct#initialize to yield self — Gavin Sinclair <gsinclair@...>

This is a common approach I use to object initialization; I don't know

24 messages 2004/02/19

Re: Problems in mathn, rational, complex, matrix

From: Mathieu Bouchard <matju@...>
Date: 2004-02-01 18:15:07 UTC
List: ruby-core #2324
On Sun, 1 Feb 2004, Gavin Sinclair wrote:

> On Sunday, February 1, 2004, 7:02:31 PM, Mathieu wrote:
> > You have to do Matrix[[7.0,6.0],[3.0,9.0]], or the equivalent thing with
> > Rationals. For the determinant to be meaningful, the Matrix must not be
> > filled with Integers.

A number like 1.0 is mathematically an Integer too. However, in a language
like Ruby, the class of an Object is an information that distinguishes 1.0
from 1 (although 1.0==1) and that plays a role in determining the
operation to use. To instruct the Matrix class to use Float#/, you have to
replace your integers of class Integer (eg: 7) by integers of class
Float (eg: 1.0). Likewise if you want it to use Rational#/, you have to
replace them by integers of class Rational (that is, with denominator 1,
Rational(7,1)).

> I'd say that Ruby should do the same thing, however it is implemented.
> It is not Ruby's custom to expose computers' limitations on
> mathematics (e.g. overflow errors).

huh?

Ruby pretty much exposes overflow errors of Float in the same way as C
would do (IEEE standard). It doesn't expose overflow errors on Integers,
_because_ its Integers are arbitrary-precision, but you still can get
problems like out-of-memory errors and insanely long computations.

________________________________________________________________
Mathieu Bouchard                       http://artengine.ca/matju


In This Thread

Prev Next