Fractions of the form 123⁄456 are handled as if written 123:456. Note
in particular the difference in behavior from U+2215 DIVISION SLASH
and U+002F SOLIDUS, which result in division rather than a rational
fraction.
* lisp/calc/calc-aent.el (math-read-replacement-list): Substitute a
colon for any fraction slash. (Bug#66944)
* test/lisp/calc/calc-tests.el (calc-frac-input): Test various
fraction types.
* etc/NEWS:
* doc/misc/calc.texi (Fractions): Mention fraction slash, precomposed
fractions.
Copyright-paperwork-exempt: yes
(cherry picked from commit
77d9d05df87965409c537f49d59cb5ea632abda1)
@samp{@var{radix}#@var{num}:@var{denom}} (or in the analogous three-part
form). The numerator and denominator always use the same radix.
+@ifnottex
+Fractions may also be entered with @kbd{@U{2044}} (U+2044 FRACTION
+SLASH) in place of any @kbd{:}. Precomposed fraction characters from
+@kbd{@U{00BD}} (U+00BD VULGAR FRACTION ONE HALF) through
+@kbd{@U{215E}} (U+215E VULGAR FRACTION SEVEN EIGHTHS) as supported as
+well. Thus @samp{2:3}, @samp{2@U{2044}3}, and @samp{@U{2154}} are all
+equivalent.
+@end ifnottex
+@iftex
+Fractions may also be entered with U+2044 FRACTION SLASH in place of
+any @kbd{:}. Precomposed fraction characters from U+00BD VULGAR
+FRACTION ONE HALF through U+215E VULGAR FRACTION SEVEN EIGHTHS as
+supported as well.
+@end iftex
+
+
@node Floats
@section Floats
+++
*** New command 'customize-dirlocals'.
This command pops up a buffer to edit the settings in ".dir-locals.el".
-
+** Calc
++++
+*** Calc parses fractions written using U+2044 FRACTION SLASH
+Fractions of the form 123⁄456 are handled as if written 123:456. Note
+in particular the difference in behavior from U+2215 DIVISION SLASH
+and U+002F SOLIDUS, which result in division rather than a rational
+fraction. You may also be interested to know that precomposed
+fraction characters, such as ½ (U+00BD VULGAR FRACTION ONE HALF), are
+also recognized as rational fractions. They have been since 2004, but
+it looks like it was never mentioned in the NEWS, or even the manual.
\f
* New Modes and Packages in Emacs 30.1
("⅝" "(5:8)") ; 5/8
("⅞" "(7:8)") ; 7/8
("⅟" "1:") ; 1/...
+ ("⁄" ":") ; arbitrary fractions of the form 123⁄456
;; superscripts
("⁰" "0") ; 0
("¹" "1") ; 1
(var c var-c))))))
(calc-set-language nil)))
+(ert-deftest calc-frac-input ()
+ ;; precomposed fraction
+ (should (equal (math-read-expr "½")
+ '(frac 1 2)))
+ ;; ascii solidus
+ (should (equal (math-read-expr "123/456")
+ '(/ 123 456)))
+ (should (equal (math-read-expr "a/b")
+ '(/ (var a var-a) (var b var-b))))
+ ;; fraction slash
+ (should (equal (math-read-expr "123⁄456")
+ '(frac 41 152)))
+ (should (equal (math-read-expr "a⁄b")
+ '(error 1 "Syntax error")))
+ ;; division slash
+ (should (equal (math-read-expr "123∕456")
+ '(/ 123 456)))
+ (should (equal (math-read-expr "a∕b")
+ '(/ (var a var-a) (var b var-b))))
+ ;; division sign
+ (should (equal (math-read-expr "123÷456")
+ '(frac 41 152)))
+ (should (equal (math-read-expr "a÷b") ; I think this one is wrong
+ '(error 1 "Syntax error"))))
+
(defvar var-g)
;; Test `let'.