Programmierung in Ruby

Der Leitfaden der Pragmatischen Programmierer

module Math

Index:

atan2 cos exp frexp ldexp log log10 sin sqrt tan


Das Math-Modul enthält Modul-Funktionen für grundlegende trigonometrische und transzendentale Funktionen. (der Übersetzer: Transzendental sind z.B. die Zahlen PI und e)

Konstanten

E 2.718281828 Wert von e (Basis des natürlichen Logarythmus)
PI 3.141592654 Wert von PI

class methods
atan2 Math.atan2( y, x ) -> aFloat

Errechnet den Arcus-Tangens von y und x. Rückgabe zwischen -PI und PI. (der Übersetzer: Arcus-Tangens ist aber was anderes, ich bin mir nicht ganz sicher, was das hier sei soll)

cos Math.cos( aNumeric ) -> aFloat

Errechnet den Cosinus von aNumeric (in Rad (also von 0 bis 2*PI) ausgedrückt). Rückgabe zwischen -1 und 1.

exp Math.exp( aNumeric ) -> aFloat

Liefert e hoch aNumeric.

frexp Math.frexp( aNumeric ) -> anArray

Liefert ein zwei-elementiges Array ([aFloat, aFixnum]) mit dem normalisierten Faktor und Exponenten von aNumeric (bei Basis 2). Z.B. 120.88 = 0.944375 * 2^7, deshalb Math.frexp(120.88) ==> [0.944375, 7]

ldexp Math.ldexp( aFloat, anInteger ) -> aFloat

Liefert den Wert von aFloat *2anInteger.

log Math.log( aNumeric ) -> aFloat

Liefert den natürlichen Logarythmus von aNumeric.

log10 Math.log10( aNumeric ) -> aFloat

Liefert den 10er-Logarythmus von aNumeric.

sin Math.sin( aNumeric ) -> aFloat

Eerrechnet den Sinus von aNumeric (in Rad (also von 0 bis 2*PI) ausgedrückt). Rückgabe zwischen -1 und 1.

sqrt Math.sqrt( aNumeric ) -> aFloat

Liefert die nicht negative Wurzel von aNumeric. Löst ArgError aus, falls aNumeric kleiner als Null ist.

tan Math.tan( aNumeric ) -> aFloat

Liefert den Tangens von aNumeric (in Rad (also von 0 bis 2*PI) ausgedrückt).


Extracted from the book "Programming Ruby - The Pragmatic Programmer's Guide"
Übersetzung: Jürgen Katins
Für das englische Original:
© 2000 Addison Wesley Longman, Inc. Released under the terms of the Open Publication License V1.0. That reference is available for download.
Diese Lizenz sowie das Original vom Herbst 2001 bilden die Grundlage der Übersetzung
Es wird darauf hingewiesen, dass sich die Lizenz des englischen Originals inzwischen geändert hat.
Für die deutsche Übersetzung:
© 2002 Jürgen Katins
Der Copyright-Eigner stellt folgende Lizenzen zur Verfügung:
Nicht-freie Lizenz:
This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder.
Freie Lizenz:
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".