From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/24968 Path: news.gmane.org!not-for-mail From: David Arnold Newsgroups: gmane.comp.tex.context Subject: Arithmetic Overflow Date: Thu, 5 Jan 2006 18:15:22 -0800 Message-ID: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1136513823 28836 80.91.229.2 (6 Jan 2006 02:17:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 6 Jan 2006 02:17:03 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Fri Jan 06 03:17:01 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1Euh9n-0004s6-Az for gctc-ntg-context-518@m.gmane.org; Fri, 06 Jan 2006 03:16:43 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 66CE9127C2; Fri, 6 Jan 2006 03:16:41 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 30828-03; Fri, 6 Jan 2006 03:16:39 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id EB31F127B4; Fri, 6 Jan 2006 03:16:38 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 49483127B4 for ; Fri, 6 Jan 2006 03:16:37 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 30749-03 for ; Fri, 6 Jan 2006 03:16:36 +0100 (CET) Original-Received: from fed1rmmtao03.cox.net (fed1rmmtao03.cox.net [68.230.241.36]) by ronja.ntg.nl (Postfix) with SMTP id 752AD127B2 for ; Fri, 6 Jan 2006 03:16:34 +0100 (CET) Original-Received: from [10.0.1.2] (really [70.191.56.23]) by fed1rmmtao03.cox.net (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id <20060106021535.ERB20875.fed1rmmtao03.cox.net@[10.0.1.2]> for ; Thu, 5 Jan 2006 21:15:35 -0500 Original-To: Context Mailing List List X-Mailer: Apple Mail (2.746.2) X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.5 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:24968 Archived-At: All, Is there a switch I can set to get rid of the arithmetic overflow in the following example? %output=pdf \setupcolors[state=start] \definecolor[gridlines][s=0.7] \startMPinclusions color gridlines; gridlines:=\MPcolor{gridlines}; vardef create_grid (expr l,r,h,b,t,v,wid,ht)= save ux, uy; numeric ux, uy; (r-l)*ux=wid; (t-b)*uy=ht; for k=b step v until t: draw (l*ux,k*uy)--(r*ux,k*uy) withcolor \MPcolor{gridlines}; endfor; for k=l step h until r: draw (k*ux,b*uy)--(k*ux,t*uy) withcolor \MPcolor{gridlines}; endfor; enddef; vardef create_axes (expr l,r,b,t,wid,ht,blbl) (text xlbl,ylbl) = save ux, uy; numeric ux, uy; (r-l)*ux=wid; (t-b)*uy=ht; textextoffset:=3pt; drawdblarrow (1.05*l*ux,0)--(1.05*r*ux,0); draw textext.rt(xlbl) shifted (1.05*r*ux,0); if blbl:draw textext.bot(decimal r) shifted (r*ux,0); fi; drawdblarrow (0,1.05*b*uy)--(0,1.05*t*uy); draw textext.top(ylbl) shifted (0,1.05*t*uy); if blbl: draw textext.lft(decimal t) shifted (0,t*uy); fi; enddef; vardef drawfcn (expr ind,dep,l,r,b,t,wid,ht,n) text txt = save x, dx, ux, uy; numeric x, dx, ux, uy; dx:=(r-l)/n; (r-l)*ux=wid; (t-b)*uy=ht; save cpath; path cpath; cpath:=(l,b)--(r,b)--(r,t)--(l,t)--cycle; save p; path p; hide (x:=l;) p:=(scantokens(ind),scantokens(dep)); for xx:=l step dx until r: hide (x:=xx;) p:=p--(scantokens(ind),scantokens(dep)); endfor; hide(x:=r;) p:=p--(scantokens(ind),scantokens(dep)); p:=p cutbefore cpath; p:=reverse p; p:=p cutbefore cpath; p:=p xyscaled (ux,uy); drawdblarrow p txt; enddef; \stopMPinclusions \starttext \startMPpage %figure library name: x2 %initialize window parameters numeric xmin, xmax, xscl, ymin, ymax, yscl; xmin:=-10; xmax:=10; xscl:=1; ymin:=-10; ymax:=10; yscl:=1; %initialize number of points numeric num_points; num_points:=100; %initialize dimensions of image numeric width, height; width=1.5in; height=1.5in; %create the grid create_grid(xmin,xmax,xscl,ymin,ymax,yscl,width,height); boolean lbl_scl; lbl_scl:=true; %create the axes create_axes(xmin,xmax,ymin,ymax,width,height,lbl_scl)("$x$")("$y$"); %draw the function drawfcn("x","x*x",xmin,xmax,ymin,ymax,width,height,100) withcolor blue ; \stopMPpage \startMPpage %figure library name: x4 %initialize window parameters numeric xmin, xmax, xscl, ymin, ymax, yscl; xmin:=-10; xmax:=10; xscl:=1; ymin:=-10; ymax:=10; yscl:=1; %initialize number of points numeric num_points; num_points:=100; %initialize dimensions of image numeric width, height; width=1.5in; height=1.5in; %create the grid create_grid(xmin,xmax,xscl,ymin,ymax,yscl,width,height); boolean lbl_scl; lbl_scl:=true; %create the axes create_axes(xmin,xmax,ymin,ymax,width,height,lbl_scl)("$x$")("$y$"); %draw the function drawfcn("x","x**4",xmin,xmax,ymin,ymax,width,height,100) withcolor blue ; \stopMPpage \startMPpage %figure library name: x6 %initialize window parameters numeric xmin, xmax, xscl, ymin, ymax, yscl; xmin:=-10; xmax:=10; xscl:=1; ymin:=-10; ymax:=10; yscl:=1; %initialize number of points numeric num_points; num_points:=100; %initialize dimensions of image numeric width, height; width=1.5in; height=1.5in; %create the grid create_grid(xmin,xmax,xscl,ymin,ymax,yscl,width,height); boolean lbl_scl; lbl_scl:=true; %create the axes create_axes(xmin,xmax,ymin,ymax,width,height,lbl_scl)("$x$")("$y$"); %draw the function drawfcn("x","x**6",xmin,xmax,ymin,ymax,width,height,100) withcolor blue ; \stopMPpage \stoptext %%% Local Variables: %%% mode: conTeXt-en %%% End: