GNU Emacs Lisp Reference Manual 3.6 Arithmetic Operations
Emacs Lisp ã¯, ä¼çµ±çãª4ã¤ã®ååæ¼ç®:å ç®, æ¸ç®, ä¹ç®, é¤ç®ãä¾çµ¦ãã¾ã.
remainder 㨠modulus é¢æ°ã¯, é¤ç®é¢æ°ã®è£å®ã§ã.
1ãå ç®, ã¾ãã¯, æ¸ç®ããé¢æ°ã¯, Lisp ã«ãããä¼çµ±ã§, ãã¤, ãã使ãããã®ã§, ä¾çµ¦ããã¾ã.
`%' ãé¤ããããã®é¢æ°ã®å ¨ã¦ã¯, ä½ããã®å¼æ°ãæµ®åå°æ°ã§ãããªãã°, æµ®åå°æ°ç¹ãè¿ãã¾ã.
Emacs Lisp ã§ã¯, ç®è¡é¢æ°ã¯, ãªã¼ãããã¼ããã§ãã¯ããªããã¨ã«æ³¨æãããã¨ãéè¦ã§ã.
å¾ã£ã¦, `(1+ 268435455)' ã¯, ããªãã®ãã¼ãã¦ã§ã¢ã«ä¾åãã¦, -268435456 ã«è©ä¾¡ãããã§ããã.
- -- é¢æ°: 1+ number-or-marker
-
ãã®é¢æ°ã¯, NUMBER-OR-MARKER 足ã 1 ãè¿ãã¾ã. ä¾ãã°,
(setq foo 4) => 4 (1+ foo) => 5
ãã®é¢æ°ã¯, C æ¼ç®å `++' ã¨ä¼¼ã¦ãã¾ãã. å¤æ°ãã¤ã³ã¯ãªã¡ã³ãããªãããã§ã.
ãã , åãè¨ç®ãã¾ã. å¾ã£ã¦, ããç¶ãããªã,foo => 4
ããå¤æ°ãã¤ã³ã¯ãªã¡ã³ãããããªãã°, ãã®ããã«, `setq' ã使ããªããã°ãªãã¾ãã.(setq foo (1+ foo)) => 5
- -- é¢æ°: 1- number-or-marker
ãã®é¢æ°ã¯, NUMBER-OR-MARKER å¼ã 1 ãè¿ãã¾ã.- -- é¢æ°: + &rest numbers-or-markers
ãã®é¢æ°ã¯, ãã®å¼æ°ããã£ããã«å ãã¾ã. å¼æ°ãä¸ããããªãã¨ã, `+' ã¯, 0 ãè¿ãã¾ã.(+) => 0 (+ 1) => 1 (+ 1 2 3 4) => 10
- -- é¢æ°: - &optional number-or-marker &rest more-numbers-or-markers
`-' é¢æ°ã¯, 2ã¤ã®ç®çãæããã¾ã. å¦å®ã¨æ¸ç®ã§ã.
`-' ã1ã¤ã®å¼æ°ãæã¤ã¨ã, ãã®å¤ã¯, å¼æ°ã®è² æ°ã§ã.
è¤æ°ã®å¼æ°ãããã¨ã, `-' ã¯, NUMBER-OR-MARKER ããç´¯ç©çã« MORE-NUMBERS-OR-MARKERS ã®ãããããå¼ãã¾ã.
å¼æ°ããªããªã, çµæã¯, 0ã§ã.(- 10 1 2 3 4) => 0 (- 10) => -10 (-) => 0
- -- é¢æ°: * &rest numbers-or-markers
ãã®é¢æ°ã¯, ãã®å¼æ°ããã£ããã«æã, ç©ãè¿ãã¾ã. å¼æ°ãä¸ããã¦ãªãã¨ã, `*' ã¯, 1 ãè¿ãã¾ã.(*) => 1 (* 1) => 1 (* 1 2 3 4) => 24
- -- é¢æ°: / dividend divisor &rest divisors
ãã®é¢æ°ã¯, DIVISORS ã«ãã, DIVIDEND ãå²ã, ãã®åãè¿ãã¾ã.
追å ã®å¼æ° DIVISORS ããããªãã°, ãã®æ, é çªã«ããããã®é¤æ°ã§ DIVIDEND ãå²ãã¾ã. ããããã®å¼æ°ã¯, æ°å¤ãããã¯, ãã¼ã«ã«ãªãã§ããã.
å ¨ã¦ã®å¼æ°ã, æ´æ°ãªãã°, ãã®æçµæãã¾ã, æ´æ°ã«ãªã. ããã¯, çµæã丸ãããããã¨ãæå³ãã.
ã»ã¨ãã©ã®è¨ç®æ©ã§ã¯, çµæã¯, åã ã®é¤ç®ã®å¾ã«ã¼ãã«åãã£ã¦ä¸¸ããããã, ããããã®è¨ç®æ©ã§ã¯, è² ã®å¼æ°ãç°ã£ã¦ä¸¸ãããããããªã.
ããã¯, Lisp é¢æ° `/' ã C é¤ç®æ¼ç®åã使ã£ã¦å®è£ ããã¦ãã, ããã¯ã¾ã, è¨ç®æ©ä¾åã®ä¸¸ãã許å¯ãã¦ããããã§ã.
å®ç¨ä¸, å ¨ã¦ã®ç¥ããã¦ããè¨ç®æ©ã¯, æ¨æºçãªæ¹æ³ã§ä¸¸ãã.
0 ã§æ´æ°ãå²ããªãã°, `arith-error' ãéç¥ããã¾ã. ( Erros:: ãåç §ãã¦ä¸ãã. )
ã¼ãã«ããæµ®åå°æ°ç¹é¤ç®ã¯, ããããªãã®è¨ç®æ©ã IEEE æµ®åå°æ°ç¹ããµãã¼ããããªãã°, ç¡é, ãããã¯, NaN ãè¿ãã¾ã.
ããã§ãªããã°, `arith-error' ã¨ã©ã¼ãéç¥ãã¾ã.(/ 6 2) => 3 (/ 5 2) => 2 (/ 5.0 2) => 2.5 (/ 5 2.0) => 2.5 (/ 5.0 2.0) => 2.5 (/ 25 3 2) => 4 (/ -17 6) => -2 (could in theory be -3 on some machines)
- -- é¢æ°: % dividend divisor
ãã®é¢æ°ã¯, DIVISOR 㧠DIVIDEND ãå²ã£ãå¾ã®æ´æ°ã®ä½ããè¿ãã¾ã.
ãã®å¼æ°ã¯, æ´æ°, ãããã¯, ãã¼ã«ã«ãªããªããã°ãªããªã.
è² ã®å¼æ°ã§ã¯, ä½ãã¯, åããããªã®ã§, åççã«è¨ç®æ©ä¾åã¨ãªã. ããã, å®ç¨çã«ã¯, å ¨ã¦ã®ç¥ãã¦ããè¨ç®æ©ã¯, åãããã«æ¯ãèã.
`arith-error' ã¯, ãã DIVISOR ã 0 ãªãã°, çµæã¨ãªã.
(% 9 4) => 1 (% -9 4) => -1 (% 9 -4) => 1 (% -9 -4) => -1
ä½ããã®2ã¤ã®æ´æ° DIVIDEND 㨠DIVISOR ã§ã¯,(+ (% DIVIDEND DIVISOR) (* (/ DIVIDEND DIVISOR) DIVISOR))
常㫠DIVIDEND ã¨åãã«ãªã.
- -- é¢æ°: mod dividend divisor
ãã®é¢æ°ã¯, DIVIDEND å²ã DIVISOR ã®ä½ãã®å¤ãè¿ã. è¨ããããã°, DIVISOR ã«ãã DIVIDEND ã®é¤ç®ã®å¾ã®ä½ãã§ããã, DIVISOR ã¨åã符å·ã§ãã.
å¼æ°ã¯, æ°å¤, ãããã¯, ãã¼ã«ã§ãªããã°ãªããªã.`%' ã¨éã, `mod' ã¯, è² ã®å¼æ°ã«å¯¾ãã¦, ããå®ç¾©ãããçµæãè¿ã. ã¾ã, æµ®åå°æ°ç¹å¼æ°ã許ã.
åãæ´æ°ã«( ãã¤ãã¹ã®ç¡éã«åãã£ã¦ )ä¸åãã«ä¸¸ã, ä½ããè¨ç®ããããã«ãã®åã使ã.
`arith-error' ã¯, DIVISOR ã0 ã®ã¨ãçµæã¨ãªã.
(mod 9 4) => 1 (mod -9 4) => 3 (mod 9 -4) => -3 (mod -9 -4) => -1 (mod 5.5 2.5) => .5
ä½ããã®2ã¤ã®æ°å¤ DIVIDEND 㨠DIVISOR ã«ããã¦(+ (mod DIVIDEND DIVISOR) (* (floor DIVIDEND DIVISOR) DIVISOR))
常㫠DIVIDEND ã¨åãã«ãªã, å¼æ°ã®ã©ã¡ãããæµ®åå°æ°ç¹ãªãã°, 丸ã誤差ãåæã¨ãã.
`floor' ã«ã¤ãã¦ã¯, Numeric Conversions:: ãåç §ãã¦ä¸ãã.
注æ
ãªãã¨ãªã翻訳ãã¦ã¿ãã ããªã®ã§, 誤訳ãããã¨æãã¾ã.
ãã®å ã®ããã¥ã¢ã«ã¯, GNU Emacs 23.0.50.2 ã«ä»å±ãã¦ãããã®ã§ã.
ã¾ã, ãã®å ç¶ããã©ããã¯, ä¸æã§ã.
ç¶ããã©ããã¯, æ°åãã ãã§ã.
誤訳, æ¥æ¬èªãå¤çã®ééãããã£ãã, ææãã¦é ããã¨å¬ããã§ã.
åèã«ãããã¼ã¸
æ´æ°æå»
2007å¹´, 10æ28æ¥, 22:10