[#28501] rb_gc_call_finalizer_at_exit() の実行中かどうかを知りたい — Hidetoshi NAGAI <nagai@...>
永井@知能.九工大です.
6 messages
2006/04/03
[#28502] Re: rb_gc_call_finalizer_at_exit() の実行中かどうかを知りたい
— Yukihiro Matsumoto <matz@...>
2006/04/03
まつもと ゆきひろです
[#28509] Rational — Tadayoshi Funaba <tadf@...>
ふなばです。
49 messages
2006/04/05
[#28510] Re: Rational
— keiju@... (石塚圭樹)
2006/04/05
けいじゅ@いしつかです.
[#28512] Re: Rational
— Tadayoshi Funaba <tadf@...>
2006/04/05
ふなばです。
[#28515] Re: Rational
— keiju@... (石塚圭樹)
2006/04/05
けいじゅ@いしつかです.
[#28522] Re: Rational
— Tadayoshi Funaba <tadf@...>
2006/04/06
ふなばです。
[#28523] Re: Rational
— Yukihiro Matsumoto <matz@...>
2006/04/06
まつもと ゆきひろです
[#28526] Re: Rational
— Tadayoshi Funaba <tadf@...>
2006/04/06
ふなばです。
[#28530] Re: Rational
— Tadayoshi Funaba <tadf@...>
2006/04/09
ふなばです。
[#28513] Re: Rational
— Shin-ichiro HARA <sinara@...>
2006/04/05
原です。
[#28514] Re: Rational
— keiju@... (石塚圭樹)
2006/04/05
けいじゅ@いしつかです.
[#28517] Re: Rational
— Yukihiro Matsumoto <matz@...>
2006/04/06
まつもと ゆきひろです
[#28520] Re: Rational
— keiju@... (石塚圭樹)
2006/04/06
けいじゅ@いしつかです.
[#28521] Re: Rational
— Yukihiro Matsumoto <matz@...>
2006/04/06
まつもと ゆきひろです
[#28525] Re: Rational
— keiju@... (石塚圭樹)
2006/04/06
けいじゅ@いしつかです.
[#28527] Re: Rational
— Shin-ichiro HARA <sinara@...>
2006/04/06
原です。
[#28536] Re: Rational
— Shin-ichiro HARA <sinara@...>
2006/04/10
原です。
[#28537] Re: Rational
— keiju@... (石塚圭樹)
2006/04/10
けいじゅ@いしつかです.
[#28545] Re: Rational
— Shin-ichiro HARA <sinara@...>
2006/04/11
原です。
[#28546] Re: Rational
— Yukihiro Matsumoto <matz@...>
2006/04/11
まつもと ゆきひろです
[#28547] Re: Rational
— keiju@... (石塚圭樹)
2006/04/11
けいじゅ@いしつかです.
[#28548] Re: Rational
— Yukihiro Matsumoto <matz@...>
2006/04/11
まつもと ゆきひろです
[#28563] Proxy authentication patches for open-uri and rubygems — "Tadashi Kadowaki" <tadakado@...>
門脇と申します。
3 messages
2006/04/15
[#28569] rational 1.01 — Shin-ichiro HARA <sinara@...>
原です。
16 messages
2006/04/16
[#28571] Re: rational 1.01
— Tadayoshi Funaba <tadf@...>
2006/04/16
ふなばです。
[#28572] Re: rational 1.01
— Shin-ichiro HARA <sinara@...>
2006/04/16
原です。
[#28573] Re: rational 1.01
— Tadayoshi Funaba <tadf@...>
2006/04/16
ふなばです。
[#28574] Re: rational 1.01
— Shin-ichiro HARA <sinara@...>
2006/04/16
原です。
[#28575] Re: rational 1.01
— Shin-ichiro HARA <sinara@...>
2006/04/17
原です。
[#28576] Re: rational 1.01
— Tadayoshi Funaba <tadf@...>
2006/04/17
ふなばです。
[#28578] Re: rational 1.01
— Tadayoshi Funaba <tadf@...>
2006/04/17
ふなばです。
[#28584] Re: rational 1.01
— Shin-ichiro HARA <sinara@...>
2006/04/18
原です。
[#28589] Float#div and Float#divmod [AGAIN] — Shin-ichiro HARA <sinara@...>
原です。
16 messages
2006/04/23
[#28590] Re: Float#div and Float#divmod [AGAIN]
— Yukihiro Matsumoto <matz@...>
2006/04/23
まつもと ゆきひろです
[#28591] Re: Float#div and Float#divmod [AGAIN]
— Shin-ichiro HARA <sinara@...>
2006/04/23
[#28592] Re: Float#div and Float#divmod [AGAIN]
— Yukihiro Matsumoto <matz@...>
2006/04/23
まつもと ゆきひろです
[ruby-dev:28532] Re: Rational
From:
Yukihiro Matsumoto <matz@...>
Date:
2006-04-09 16:44:11 UTC
List:
ruby-dev #28532
In message "Re: [ruby-dev:28531] Re: Rational"
on Mon, 10 Apr 2006 01:26:10 +0900, Shin-ichiro HARA <sinara@blade.nagaokaut.ac.jp> writes:
|
|原です。
|
|>ふなばです。
|>
|>rational/rationalize の話をしたので、原さんの rational 1.00 の
|>Rational(aFloat) と比べてみました。
|
|おお、ありがとうございます。ふなばさんのコードは参考にさせて
|いただきます。
|
|>rationalize のほうは、モノにもよりますが、rational の10倍前後遅いみた
|>いですね。なんか難しいことをしているのでしょうか。これを to_r にするの
|>は少し厳しいのかも。とりあえず、僕がみたかぎりでは、rational のほうが
|>普通っぽいようです。
|
|すいません、rationalize というのを知らないのですが、
|これは何を求める関数なのでしょう?
CommonLispには浮動小数点数を有理数に変換する関数が二つあって、
rationalは高速だが不正確(というかなんというか)で、
rationalizeは低速だがより直観的(というかなんというか)な結果
を返すそうです。以下、CLtL2からの引用です。
---
rational number
rationalize number
Each of these functions converts any non-complex number to a rational number. If the
argument is already rational, it is returned. The two functions differ in their treatment
of floating-point numbers.
rational assumes that the floating-point number is completely accurate and returns a
rational number mathematically equal to the precise value of the floating-point number.
rationalize assumes that the floating-point number is accurate only to the precision of the
floating-point representation and may return any rational number for which the
floating-point number is the best available approximation of its format; in doing this it
attempts to keep both numerator and denominator small.
It is always the case that
(float (rational x) x) == x
and
(float (rationalize x) x) == x
That is, rationalizing a floating-point number by either method and then converting it back
to a floating-point number of the same format produces the original number. What
distinguishes the two functions is that rational typically has a simple, inexpensive
implementation, whereas rationalize goes to more trouble to produce a result that is more
pleasant to view and simpler to compute with for some purposes.