[#35835] '_' の解説はどこに? — Shusaku <tsyk@...>
Shusakuです。
10 messages
2002/09/01
[#35837] Re: '_' の解説はどこに?
— Shugo Maeda <shugo@...>
2002/09/02
前田です。
[#35857] 日本語混じりの文字列を改行したい — FUJIOKA Takeyuki <fuji@...>
藤岡です。
7 messages
2002/09/05
[#35881] CGI vs mod_ruby vs FastCGI — MoonWolf <moonwolf@...>
MoonWolfです。
12 messages
2002/09/07
[#35890] Re: CGI vs mod_ruby vs FastCGI
— MoonWolf <moonwolf@...>
2002/09/09
MoonWolfです。
[#35893] Re: CGI vs mod_ruby vs FastCGI
— Shugo Maeda <shugo@...>
2002/09/10
前田です。
[#35896] Tofu の有効期限について — Takeshi Honda <moecho21@...>
Tofuを使って、サーブレットを作っているのですが、
6 messages
2002/09/10
[#35902] CGI & DBI — 金光雅夫 (KANEMITSU Masao) <masao-k@...>
金光です。cgi.rbについて教えてください。
8 messages
2002/09/12
[#35922] exit させた Thread の GC について — "USUI Makoto" <usui@...>
はじめまして、碓井といいます。
10 messages
2002/09/14
[#35923] Re: exit させた Thread の GC について
— matz@... (Yukihiro Matsumoto)
2002/09/14
まつもと ゆきひろです
[#35924] Re: exit させた Thread の GC について
— "USUI Makoto" <usui@...>
2002/09/14
碓井です。
[#35925] Re: exit させた Thread の GC について
— nobu.nakada@...
2002/09/14
なかだです。
[#35937] WeRDS (the Weekly Ruby-Doc Summary) 2002-09-13 — maili31s@... (SugHimsi == SUGIHARA Hiroshi)
すぎむし。
14 messages
2002/09/16
[#36004] WeRDS (the Weekly Ruby-Doc Summary) 2002-09-22
— maili31s@... (SugHimsi == SUGIHARA Hiroshi)
2002/09/25
すぎむし%くどいようですが、うるさければ謹慎しますので。
[#36052] WeRDS (the Weekly Ruby-Doc Summary) 2002-09-28
— maili31s@... (SugHimsi == SUGIHARA Hiroshi)
2002/09/30
すぎむし。
[#36127] WeRDS (the Weekly Ruby-Doc Summary) 2002-10-06
— maili31s@... (SugHimsi == SUGIHARA Hiroshi)
2002/10/07
すぎむし。
[#36180] WeRDS, the Weekly Ruby-Doc Summary, for 2002-10-20
— maili31s@... (SugHimsi == SUGIHARA Hiroshi)
2002/10/21
先週分のWeRDSを訳しました。ちなみに先先週分はありません。元記事は
[#36224] WeRDS, the Weekly Ruby-Doc Summary, for 2002-10-27
— maili31s@... (SugHimsi == SUGIHARA Hiroshi)
2002/10/28
先週分のWeRDSを訳しました。最近は ri の改良を軸に話が進んでいます。元記事は
[#35940] 9.2 の数値が 9.199999999999999 — "Inoue" <rubyist@...1.117.ne.jp>
井上です。
16 messages
2002/09/17
[#35941] Re: 9.2 の数値が 9.199999999999999
— matz@... (Yukihiro Matsumoto)
2002/09/17
まつもと ゆきひろです
[#35942] Re: 9.2 の数値が 9.199999999999999
— Fujimaru Hiroyasu <f-hiro@...>
2002/09/17
藤丸です。
[#35943] Ruby でメイルを出すには?
— 金光雅夫 (KANEMITSU Masao) <masao-k@...>
2002/09/17
金光です。どもっ。
[#35975] [ANN] xmlscan-0.1.0-20020920 — UENO Katsuhiro <unnie@...>
うえのです。
7 messages
2002/09/19
[#35977] [ANN] Exerb 2.1.0 — Yuya Kato <yuya-ml@4th.to>
Yuyaです。
18 messages
2002/09/20
[#35978] Cookie
— 金光雅夫 (KANEMITSU Masao) <masao-k@...>
2002/09/20
金光です。どもっ (_ _)
[#35979] Re: Cookie
— rio-t@...
2002/09/20
こんにちは、高石です。
[#35980] Re: Cookie
— 金光雅夫 (KANEMITSU Masao) <masao-k@...>
2002/09/20
金光です。どもっ。
[#35981] Re: Cookie
— Shinji Miura <snj@...>
2002/09/20
三浦@大阪電通大です。
[#35982] Re: Cookie
— 金光雅夫 (KANEMITSU Masao) <masao-k@...>
2002/09/20
金光です。どもっ。
[#35983] Re: Cookie
— rio-t@...
2002/09/21
こんにちは、高石です。
[#35986] Re: Cookie
— 金光雅夫 (KANEMITSU Masao) <masao-k@...>
2002/09/21
金光です。どもっ。
[#35987] Re: Cookie
— Shinji Miura <snj@...>
2002/09/22
三浦@大阪電通大です。おはようございます。
[#36015] [ann] BD released — keita yamaguchi <keita@...>
こんにちは、keita と申します。
12 messages
2002/09/26
[#36016] CGI
— 金光雅夫 (KANEMITSU Masao) <masao-k@...>
2002/09/26
金光です。どもっ。
[#36031] [ANN] xmlscan-0.1.0rc1 released. — UENO Katsuhiro <unnie@...>
うえのです。
9 messages
2002/09/28
[#36037] Re: [ANN] xmlscan-0.1.0rc1 released.
— "NAKAMURA, Hiroshi" <nakahiro@...>
2002/09/30
なひです。
[#36036] [ANN] ruby-sumo — "Shirai,Kaoru" <shirai@...1jp.com>
白井です。
15 messages
2002/09/30
[#36041] Re: [ANN] ruby-sumo
— "Shirai,Kaoru" <shirai@...1jp.com>
2002/09/30
白井です。
[ruby-list:35955] Re: 9.2 の数値が 9.199999999999999
From:
KIYONO Koichi <kiyono-k@...>
Date:
2002-09-17 15:59:47 UTC
List:
ruby-list #35955
はじめてメールいたします。きよの と申します。
On Tue, 17 Sep 2002 19:13:48 +0900
nobu.nakada@nifty.ne.jp wrote:
> なかだです。
>
> > 浮動小数点数を使う限り、多倍長になっても誤差が出るのは避けられないですよ
> > ね?(誤差を少なくはできるとして)
>
> BigDecimalってのもありますね。あれ、BigFloatだっけ。
>
> http://www.tinyforest.gr.jp/ruby/ruby.html#BIGFLOAT
(簡易)BigDecimal クラスを作ってみました。
正規化(?)を行っていませんし、なにより割り算がかなりいいかげんです...
が、それなりに動作します。
class BigDecimal
def initialize(init)
if init.is_a? BigDecimal
@exponent = init.exponent
@val = init.val
else
integer, fraction, = init.to_s.split('.')
int_int = integer.to_i
frac_int = fraction.to_i
frac_int = -frac_int if int_int < 0
@exponent = if fraction.nil? then 0 else fraction.length end
@val = int_int * (10 ** @exponent) + frac_int
end
end
def to_i; @val / (10 ** @exponent) end
def to_f; @val.to_f / (10 ** @exponent) end
def to_s
str = @val.to_s
if @exponent != 0
str[0..-(@exponent+1)] + '.' + @val.to_s[-@exponent..-1]
else
str
end
end
attr_accessor :val, :exponent
def +(other)
other = BigDecimal.new(other) unless other.is_a? BigDecimal
if @exponent < other.exponent
result = BigDecimal.new(self)
result.val = @val * (10 ** (other.exponent - @exponent)) + other.val
result.exponent = other.exponent
else
result = BigDecimal.new(other)
result.val = other.val * (10 ** (@exponent - other.exponent)) + @val
result.exponent = @exponent
end
result
end
def -(other)
negative = BigDecimal.new(other)
negative.val = -negative.val
self + negative
end
def *(other)
other = BigDecimal.new(other) unless other.is_a? BigDecimal
result = BigDecimal.new(self)
result.val *= other.val
result.exponent += other.exponent
result
end
def /(other)
other = BigDecimal.new(other) unless other.is_a? BigDecimal
result = BigDecimal.new(self * 10000000000) # must be improved...
result.val /= other.val
result.exponent -= (other.exponent - 10)
result
end
end
a = BigDecimal.new(5000000000)
b = BigDecimal.new("123456789.123456789")
p a, b
p a.to_i, b.to_i
p a.to_f, b.to_f
p a.to_s, b.to_s
print "** add\n"; result = a + b; p result, result.to_s
print "** sub\n"; result = a - b; p result, result.to_s
print "** mul\n"; result = a * b; p result, result.to_s
print "** div\n"; result = a / b; p result, result.to_s
---
KIYONO Koichi
E-Mail: kiyono-k@nifty.com
Web Site: http://homepage2.nifty.com/cat-chy/