
(require (quote calc-ext))

(defun calc-Need-calc-frac nil (byte-code "" [nil] 1))

(defun calc-fdiv (arg) (interactive "P") (byte-code "\"" [nil calc-do (lambda nil (byte-code "$" [arg calc-binary-op ":" calcFunc-fdiv 1] 5)) 116] 3))

(defun calc-fraction (arg) (interactive "P") (byte-code "\"" [nil calc-do (lambda nil (byte-code " 	 Â
 	=  !!E#0 !	- !E#)" [func arg calc-is-hyperbolic calcFunc-frac calcFunc-pfrac 0 calc-enter-result 2 "frac" calc-top-n 1 prefix-numeric-value] 12)) 280] 3))

(defun calc-over-notation (fmt) (interactive "sFraction separator (:, ::, /, //, :/): ") (byte-code "!" [nil calc-do (lambda nil (byte-code "\"9 !!\"# !O!\"	=- !	D#)< !" [fmt n nil t string-match "\\`\\([^ 0-9][^ 0-9]?\\)[0-9]*\\'" /= match-end 0 1 string-to-int math-match-substring error "Bad denominator" calc-change-mode calc-frac-format "Bad fraction separator format."] 12))] 2))

(defun calc-slash-notation (n) (interactive "P") (byte-code "!" [nil calc-do (lambda nil (byte-code "
 Ă #" [n t calc-change-mode calc-frac-format ("//" nil) ("/" nil)] 4))] 2))

(defun calc-frac-mode (n) (interactive "P") (byte-code "!" [nil calc-do (lambda nil (byte-code "$ Ƃ !" [n nil t calc-prefer-frac calc-change-mode message "Integer division will now generate fractions." "Integer division will now generate floating-point results."] 5))] 2))

(defun math-make-frac (num den) (byte-code ": @= W 	!!	\"
=8 =1 	5 	EP 
\"F 	
\"P 	
\"
\"E)" [den num gcd bigneg 0 math-neg math-gcd 1 frac equal math-quotient] 11))

(defun calc-add-fractions (a b) (byte-code "!=B 	!=/ 8	8\"8	8\"\"8	8\"\"? 88	\"\"8\"R 	8\"	8\"	8\"" [a b car-safe frac math-make-frac math-add math-mul 1 2] 16))

(defun calc-mul-fractions (a b) (byte-code "!=3 	!=% 8	8\"8	8\"\"0 8	\"8\"> 	8\"	8\"" [a b car-safe frac math-make-frac math-mul 1 2] 12))

(defun calc-div-fractions (a b) (byte-code "!=3 	!=% 8	8\"8	8\"\"0 88	\"\"> 	8\"	8\"" [a b car-safe frac math-make-frac math-mul 1 2] 12))

(defun calcFunc-frac (a &optional tol) (byte-code " Ɖ	:? 	@> 		@>+ 	@	A\"B	:< 	@=< 	8YE 	!	:~ 	@={ 	@=?{ 	@>x 	8:p 	8@=u 	8W{ 	! 	W 	!\"!	@=? 	! 	 	! 	 	\"! X 
\\		8!	8\\TZE\"@=? :? @> 	!\" \":7@=4@=?4@>18:)8@=.8W4!:WF	!\":h@>?e@=b8=e!k=u	\"\"?	!	:	@>?	@=	8=	!	=Ƃ	\"!*" [tol a calc-internal-prec t cfrac calc-prefer-frac 0 (bigpos bigneg frac) (cplx polar vec hms date sdev intv mod) mapcar (lambda (x) (byte-code "	\"" [x tol calcFunc-frac] 3)) float 2 math-trunc bigneg bigpos (frac float) 1 math-negp math-neg calcFunc-frac math-infinitep math-provably-integerp math-reject-arg numberp integerp 5 math-numdigs (bigpos bigneg frac float) math-float realp (frac float) (bigpos bigneg) math-zerop math-lessp-float (float 1 0) (bigpos bigneg) math-continued-fraction math-eval-continued-fraction] 26))

(defun math-continued-fraction (a tol) (byte-code "\\	?Z :4 @>?1 @=. 8=1 !7 =?Z 	!=P \")\"!	\"? !\"	B: @>? @= 8= ! = \" 	,)" [calc-internal-prec cfrac nil aa a calc-prefer-frac int f calc-display-working-message tol 2 (bigpos bigneg) float 1 0 math-zerop math-lessp-float math-abs math-sub math-eval-continued-fraction lots math-do-working "Fractionalize" math-trunc (bigpos bigneg) math-div] 13))

(defun math-eval-continued-fraction (cf) (byte-code "	@	A  	@\"
\" 
\"+" [n cf d temp 1 nil math-add math-mul math-div] 5))

(defun calcFunc-fdiv (a b) (byte-code ":? @> @= 8Yy 	:?5 	@>5 	@=5 	8Yr 	:Z 	@>?W 	@=T 	8=W 	!] 	=g \"o !	!\"v 	\"} \"" [a b (bigpos bigneg) float 2 0 (bigpos bigneg) (bigpos bigneg) 1 math-zerop math-reject-arg "*Division by zero" math-make-frac math-trunc integerp] 9))
