* Bug: Babel calc sqrt float var
@ 2013-12-10 10:43 Miguel Ruiz
2013-12-10 12:38 ` Rüdiger Sonderfeld
2013-12-10 13:13 ` Eric S Fraga
0 siblings, 2 replies; 3+ messages in thread
From: Miguel Ruiz @ 2013-12-10 10:43 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 2785 bytes --]
Hi,
Please, I am communicating the following problematic behaviour:
#------------------- problematic code ------------------------
#+begin_src calc
sqrt(0.8)
#+end_src
#+RESULTS:
: 0.894427191 # OK
#+begin_src calc :var x=0.8
sqrt(x)
#+end_src
#+RESULTS:
=Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p 0.80000000000000004)
math-idivmod(0.80000000000000004 0.80000000000000004)
math-div(0.80000000000000004 0.80000000000000004)
math-cancel-common-factor(0.80000000000000004 0.80000000000000004)
math-simplify-sqrt()
#[(math-simplify-expr) "\300 \207" [math-simplify-sqrt] 1]((calcFunc-sqrt 0.80000000000000004))
math-simplify-step((calcFunc-sqrt 0.80000000000000004))
math-simplify((calcFunc-sqrt 0.80000000000000004))
calc-normalize-fancy((calcFunc-sqrt 0.80000000000000004))
calc-normalize((calcFunc-sqrt 0.80000000000000004))
math-evaluate-expr((calcFunc-sqrt 0.80000000000000004))
#[(line) "
not copy-yank-able string
"
[line var-names calc-mode-map res x 0 calc-recall intern 1 "'" lookup-key nil calc-push-list calc-eval math-read-number error "Calc error \"%s\" on input \"%s\"" replace-regexp-in-string "" math-evaluate-expr mapcar org-babel-calc-maybe-resolve-var math-read-exprs] 11] ("sqrt(x)"))
org-babel-execute:calc("sqrt(x)" ((:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace") (:var x . 0.80000000000000004) (:session . "none") (:hlines . "no") (:result-type . value) (:result-params "replace") (:rowname-names) (:colname-names)))
org-babel-execute-src-block(nil)
org-babel-execute-src-block-maybe()
org-babel-execute-maybe()
org-babel-execute-safely-maybe()
run-hook-with-args-until-success(org-babel-execute-safely-maybe)
org-ctrl-c-ctrl-c(nil)
call-interactively(org-ctrl-c-ctrl-c nil nil)
#---------------------- end of problematic code --------------------------------
Command line: emacs -Q -l minimal-org.el
;;; minimal-org.el:
;;; Minimal setup to load latest `org-mode'
;; activate debugging
(setq debug-on-error t
debug-on-signal nil
debug-on-quit nil)
;; add latest org-mode to load path
(add-to-list 'load-path (expand-file-name "~/org-mode/maint/lisp"))
(add-to-list 'load-path (expand-file-name "~/org-mode/maint/contrib/lisp" t))
;; active Babel languages
(org-babel-do-load-languages
'org-babel-load-languages
'((calc . t)))
;;; end of minimal-org.el
GNU Emacs 24.3.1 (i686-pc-cygwin) of 2013-08-14 on moufang
Org-mode version 8.2.4 (release_8.2.4-3-g7fe99a @ /home/usuario/org-mode/maint/lisp/)
TIA.
Miguel Ruiz.
[-- Attachment #2: Type: text/html, Size: 7591 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bug: Babel calc sqrt float var
2013-12-10 10:43 Bug: Babel calc sqrt float var Miguel Ruiz
@ 2013-12-10 12:38 ` Rüdiger Sonderfeld
2013-12-10 13:13 ` Eric S Fraga
1 sibling, 0 replies; 3+ messages in thread
From: Rüdiger Sonderfeld @ 2013-12-10 12:38 UTC (permalink / raw)
To: emacs-orgmode, Miguel Ruiz
Hi,
the problem is that calc does not operate on regular elisp types but instead
uses a different format: (float NUM EXP) for decimal floats. But ob-calc.el
seems to simply push any value it gets on the stack and assigns it to a
variable. And since calc treats anything which isn't in such a lisp form as
an integer it tries to call idiv.
To fix this the value should be converted to calc format before `calc-push-
list' is called. But after a quick look into calc.el I couldn't find any
generic function to convert elisp values to calc values. The function `math-
read-number' seems to be the only way and it requires a string. However my
knowledge of calc internals is rather limited.
Regards,
Rüdiger
On Tuesday 10 December 2013 10:43:02 Miguel Ruiz wrote:
> Hi,
>
> Please, I am communicating the following problematic behaviour:
>
> #------------------- problematic code ------------------------
> #+begin_src calc
>
> sqrt(0.8)
> #+end_src
>
> #+RESULTS:
> : 0.894427191 # OK
>
> #+begin_src calc :var x=0.8
> sqrt(x)
> #+end_src
>
> #+RESULTS:
> =Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p
> 0.80000000000000004) math-idivmod(0.80000000000000004 0.80000000000000004)
> math-div(0.80000000000000004 0.80000000000000004)
> math-cancel-common-factor(0.80000000000000004 0.80000000000000004)
> math-simplify-sqrt()
> #[(math-simplify-expr) "\300 \207" [math-simplify-sqrt] 1]((calcFunc-sqrt
> 0.80000000000000004)) math-simplify-step((calcFunc-sqrt
> 0.80000000000000004))
> math-simplify((calcFunc-sqrt 0.80000000000000004))
> calc-normalize-fancy((calcFunc-sqrt 0.80000000000000004))
> calc-normalize((calcFunc-sqrt 0.80000000000000004))
> math-evaluate-expr((calcFunc-sqrt 0.80000000000000004))
> #[(line) "
> not copy-yank-able string
> "
> [line var-names calc-mode-map res x 0 calc-recall intern 1 "'" lookup-key
> nil calc-push-list calc-eval math-read-number error "Calc error \"%s\" on
> input \"%s\"" replace-regexp-in-string "" math-evaluate-expr mapcar
> org-babel-calc-maybe-resolve-var math-read-exprs] 11] ("sqrt(x)"))
> org-babel-execute:calc("sqrt(x)" ((:comments . "") (:shebang . "") (:cache
> . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports .
> "code") (:results . "replace") (:var x . 0.80000000000000004) (:session .
> "none") (:hlines . "no") (:result-type . value) (:result-params "replace")
> (:rowname-names) (:colname-names))) org-babel-execute-src-block(nil)
> org-babel-execute-src-block-maybe()
> org-babel-execute-maybe()
> org-babel-execute-safely-maybe()
> run-hook-with-args-until-success(org-babel-execute-safely-maybe)
> org-ctrl-c-ctrl-c(nil)
> call-interactively(org-ctrl-c-ctrl-c nil nil)
>
>
> #---------------------- end of problematic code
> --------------------------------
>
> Command line: emacs -Q -l minimal-org.el
>
> ;;; minimal-org.el:
> ;;; Minimal setup to load latest `org-mode'
>
> ;; activate debugging
> (setq debug-on-error t
> debug-on-signal nil
> debug-on-quit nil)
>
> ;; add latest org-mode to load path
> (add-to-list 'load-path (expand-file-name "~/org-mode/maint/lisp"))
> (add-to-list 'load-path (expand-file-name "~/org-mode/maint/contrib/lisp"
> t))
>
> ;; active Babel languages
> (org-babel-do-load-languages
> 'org-babel-load-languages
> '((calc . t)))
>
> ;;; end of minimal-org.el
>
> GNU Emacs 24.3.1 (i686-pc-cygwin) of 2013-08-14 on moufang
>
> Org-mode version 8.2.4 (release_8.2.4-3-g7fe99a @
> /home/usuario/org-mode/maint/lisp/)
>
>
> TIA.
> Miguel Ruiz.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bug: Babel calc sqrt float var
2013-12-10 10:43 Bug: Babel calc sqrt float var Miguel Ruiz
2013-12-10 12:38 ` Rüdiger Sonderfeld
@ 2013-12-10 13:13 ` Eric S Fraga
1 sibling, 0 replies; 3+ messages in thread
From: Eric S Fraga @ 2013-12-10 13:13 UTC (permalink / raw)
To: Miguel Ruiz; +Cc: emacs-orgmode@gnu.org
Miguel Ruiz <rbenit68@yahoo.es> writes:
[...]
> #+begin_src calc :var x=0.8
> sqrt(x)
> #+end_src
I confirm that this doesn't work. However, putting 0.8 in quotes, as in
var="0.8", works for me.
--
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.1, Org release_8.2.4-322-gece429
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-12-10 13:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-10 10:43 Bug: Babel calc sqrt float var Miguel Ruiz
2013-12-10 12:38 ` Rüdiger Sonderfeld
2013-12-10 13:13 ` Eric S Fraga
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.