@@ -5946,33 +5946,65 @@ However, only the tests using @code{check} and @code{check-ec} are counted.
59465946
59475947@deftp {Module} srfi.94
59485948@mdindex srfi.94
5949- This module provides arithmetic functions specialized for exact integers
5950- and reals. Similar to @code{scheme.fixnum} (@pxref{R7RS fixnum})
5949+ @c EN
5950+ This module provides arithmetic functions specialized for reals
5951+ and exact integers. Similar to @code{scheme.fixnum} (@pxref{R7RS fixnum})
59515952and @code{scheme.flonum} (@pxref{R7RS flonum}) in a sense of restricting
59525953types of range and domains, but this srfi procedures cover wider range
59535954(e.g. @code{real-*} procedures can accept all real numbers include
59545955exact integers, and @code{integer-*} procedures can accept both fixnums
59555956and bignums).
5957+ @c JP
5958+ このモジュールは実数および正確な整数に特化した数値演算関数を提供します。
5959+ 定義域や値域の型を制約するという意味では
5960+ @code{scheme.fixnum} (@ref{R7RS fixnum}参照) や
5961+ @code{scheme.flonum} ((@ref{R7RS flonum})参照) と似ていますが、
5962+ このSRFIの関数はそれらのモジュールよりは広い範囲をカバーします
5963+ (例えば@code{real-*}手続きは正確な整数を含めた全ての実数を
5964+ 対象としますし、@code{integer-*}手続きはfixnumだけでなくbignumも
5965+ 扱えます)。
5966+ @c COMMON
59565967
5968+ @c EN
59575969This module is provided mostly for the completeness. Generally useful
59585970procedures are already built-in, so you don't need to use this
59595971module to use them. Furthermore, some SRFI-94 procedures have the
59605972same name of Gauche's built-in but behave slightly differently, so
59615973just importing everything from @code{srfi.94} may cause unexpected effect.
59625974If you need certain srfi-94 specific procedures, we recommend you to import
59635975them selectively.
5976+ @c JP
5977+ このモジュール自体は完全性のために用意してあります。
5978+ 一般的に有用と思われる関数については組み込みになっているので、
5979+ わざわざこのモジュールをuseする必要はありません。
5980+ さらに、SRFI-94の手続きのいくつかはGaucheの組み込み手続きと同じ名前を
5981+ 持ちながら振る舞いが他所う異なったりするので、
5982+ @code{srfi.94}をまるごとインポートすると思いがけない副作用があるかもしれません。
5983+ 特定の、SRFI-94特有の手続きを使いたい場合は、それに絞ってインポートすることを
5984+ お勧めします。
5985+ @c COMMON
59645986
5987+ @c EN
59655988The following procedures are built-in. @xref{Arithmetics} for the details.
5989+ @c JP
5990+ 以下の手続きは組み込みになっています。詳しくは@ref{Arithmetics}を参照してください。
5991+ @c COMMON
59665992@example
59675993real-exp real-tan atan make-rectangular
59685994real-ln real-asin real-sqrt make-polar
59695995real-sin real-acos integer-expt
59705996real-cos real-atan real-expt
59715997@end example
59725998
5999+ @c EN
59736000The following procedures are redefined in this module, shadowing
59746001Gauche's built-in procedures. See the description
59756002of each entry for the difference.
6003+ @c JP
6004+ 以下の手続きはこのモジュールで定義され、インポートすると
6005+ 組み込み手続きをシャドウします。違いについてはそれぞれの
6006+ エントリの記述を参照してください。
6007+ @c COMMON
59766008@example
59776009quotient modulo remainder mod abs
59786010@end example
@@ -5981,29 +6013,54 @@ quotient modulo remainder mod abs
59816013@defun real-log base x
59826014[SRFI-94]
59836015@c MOD srfi.94
6016+ @c EN
59846017The arguments must be nonnegative reals. Returns logarithm of @var{x}
59856018with base @var{base}, computed as
59866019@code{(/ (real-ln x) (real-ln base))}.
59876020
59886021Note that R7RS's @code{log} takes @var{x} first, then optional @var{base}.
59896022Gauche doesn't provide this procedure as built-in to avoid confusion.
6023+ @c JP
6024+ 引数は非負の実数でなければなりません。
6025+ @var{base}を底とする@var{x}の対数を@code{(/ (real-ln x) (real-ln base))}
6026+ で計算して返します。
6027+
6028+ R7RSの@code{log}は@var{x}を最初に取り、
6029+ 省略可能な@var{base}で底を指定することに注意してください。
6030+ Gaucheがこの手続きを組み込みとして提供していないのは、
6031+ 引数順の混乱を避けるためです。
6032+ @c COMMON
59906033@end defun
59916034
59926035@defun integer-sqrt n
59936036[SRFI-94]
59946037@c MOD srfi.94
6038+ @c EN
59956039This is the same as @code{exact-integer-sqrt} (@pxref{Arithmetics}).
6040+ @c JP
6041+ これは@code{exact-integer-sqrt}と同じです
6042+ (@ref{Arithmetics}参照)。
6043+ @c COMMON
59966044@end defun
59976045
59986046@defun integer-log base k
59996047[SRFI-94]
60006048@c MOD srfi.94
6049+ @c EN
60016050Both arguments must be exact integers, and @var{base} must be
60026051positive, while @var{x} must be nonnegative.
60036052
60046053Returns a maximum exact integer @var{n} such that @code{(<= (expt base n) k)}.
60056054
60066055The order of arguments is the same as @code{real-log}---not @code{log}.
6056+ @c JP
6057+ 引数は正確な整数でなければならず、@var{base}は正数、
6058+ @var{x}は非負でなければなりません。
6059+
6060+ @code{(<= (expt base n) k)}となるような最大の正確な整数@var{n}を返します。
6061+
6062+ 引数の順序は@code{real-log}と同じ、すなわち@code{log}とは異なります。
6063+ @c COMMON
60076064
60086065@example
60096066(integer-log 2 1500) @result{} 10
@@ -6013,41 +6070,122 @@ The order of arguments is the same as @code{real-log}---not @code{log}.
60136070@defun abs x
60146071[SRFI-94]
60156072@c MOD srfi.94
6073+ @c EN
60166074While Gauche's built-in @code{abs} can take a non-real number
60176075(in which case, it acts like @code{magnitude}), this version
60186076throws an error.
6077+ @c JP
6078+ Gauche組み込みの@code{abs}は実数でない複素数を取ることができて、
6079+ その場合は@code{magnitude}のように振る舞いますが、
6080+ この手続きはエラーを投げます。
6081+ @c COMMON
60196082@end defun
60206083
60216084@defun quo n d
60226085@defunx mod n d
60236086@defunx rem n d
60246087[SRFI-94]
60256088@c MOD srfi.94
6089+ @c EN
60266090Real version of @code{quotient}, @code{modulo}, and @code{remainder}
60276091(@pxref{Arithmetics}).
60286092
60296093Returns quotient, modulo, and remainder of @var{n} divided by @var{d}.
60306094Arguments doesn't need to be integers. If both are exact, the result
60316095is exact.
6096+ @c JP
6097+ @code{quotient}、@code{modulo}、@code{remainder}の実数への拡張版です。
6098+
6099+ @var{n}を@var{d}で割った時の商および余りを返します。
6100+ 引数は整数である必要はありません。両方とも正確数であれば結果も正確数となります。
6101+ @c COMMON
60326102
6103+ @c EN
60336104@code{quo} returns @code{(truncate (/ n d))}.
60346105@code{rem} returns @code{(- n (* d (quo n d)))}.
60356106@code{mod} returns @code{(- n (* d (floor (/ n d))))}.
6107+ @c JP
6108+ @code{quo}は@code{(truncate (/ n d))}を、
6109+ @code{rem}は@code{(- n (* d (quo n d)))}を、
6110+ そして@code{mod}は@code{(- n (* d (floor (/ n d))))}を返します。
6111+ @c COMMON
60366112
6037- Note: R6RS introduced different divison operators, @code{div} and @code{mod}
6113+ @c EN
6114+ Note: R6RS defined different divison operators, @code{div}, @code{mod},
6115+ @code{div0}, and @code{mod0}
60386116(@pxref{Arithmetics}).
60396117They can take non-integer arguments, but unfortunately, they behave
6040- differently from SRFI-94.
6118+ differently from SRFI-94. SRFI-94's @code{quo} behaves the same as
6119+ R6RS's @code{div0}, and SRFI-94's @code{rem} behaves the same as
6120+ R6RS's @code{mod0}.
6121+ @c JP
6122+ 註: R6RSは異なる除算オペレータ、@code{div}、@code{mod}、
6123+ @code{div0}、および@code{mod0}を定義しました(@ref{Arithmetics}参照)。
6124+ これらも非整数を取ることができますが、残念なことに
6125+ SRFI-94とは振る舞いが異なります。SRFI-94の@code{quo}は
6126+ R6RSの@code{div0}と、SRFI-94の@code{rem}は
6127+ R6RSの@code{mod0}と、それぞれ同じふるまいです。
6128+ @c COMMON
6129+
6130+ @example
6131+ (quo 2/3 1/5) @result{} 3
6132+ (mod 2/3 1/5) @result{} 1/15
6133+ (rem 2/3 1/5) @result{} 1/15
6134+
6135+ (quo 2/3 -1/5) @result{} -3
6136+ (mod 2/3 -1/5) @result{} -2/15
6137+ (rem 2/3 -1/5) @result{} 1/15
6138+
6139+ (quo -2/3 1/5) @result{} -3
6140+ (mod -2/3 1/5) @result{} 2/15
6141+ (rem -2/3 1/5) @result{} -1/15
6142+
6143+ (quo -2/3 -1/5) @result{} 3
6144+ (mod -2/3 -1/5) @result{} -1/15
6145+ (rem -2/3 -1/5) @result{} -1/15
6146+
6147+ @c EN
6148+ ;; For comparison- R6RS procedures
6149+ @c JP
6150+ ;; 比較のため: R6RS手続き
6151+ @c COMMON
6152+ (use gauche.base)
6153+ (div 2/3 1/5) @result{} 3
6154+ (mod 2/3 1/5) @result{} 1/15
6155+ (div0 2/3 1/5) @result{} 3
6156+ (mod0 2/3 1/5) @result{} 1/15
6157+
6158+ (div 2/3 -1/5) @result{} -3
6159+ (mod 2/3 -1/5) @result{} 1/15
6160+ (div0 2/3 -1/5) @result{} -3
6161+ (mod0 2/3 -1/5) @result{} 1/15
6162+
6163+ (div -2/3 1/5) @result{} -4
6164+ (mod -2/3 1/5) @result{} 2/15
6165+ (div0 -2/3 1/5) @result{} -3
6166+ (mod0 -2/3 1/5) @result{} -1/15
6167+
6168+ (div -2/3 -1/5) @result{} 4
6169+ (mod -2/3 -1/5) @result{} 2/15
6170+ (div0 -2/3 -1/5) @result{} 3
6171+ (mod0 -2/3 -1/5) @result{} -1/15
6172+ @end example
60416173@end defun
60426174
60436175@defun quotient n d
60446176@defunx modulo n d
60456177@defunx remainder n d
60466178[SRFI-94]
60476179@c MOD srfi.94
6180+ @c EN
60486181SRFI-94 version of these procedures throws an error if the arguments
60496182are not exact integers. Otherwise they behave the same
60506183as built-in (@pxref{Arithmetics}).
6184+ @c JP
6185+ SRFI-94のバージョンは、引数が正確な整数でなければエラーを投げます。
6186+ それ以外は組み込みと同じように振る舞います
6187+ (@ref{Arithmetics}参照)。
6188+ @c COMMON
60516189@end defun
60526190
60536191
0 commit comments