From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/53722 Path: news.gmane.org!not-for-mail From: Otared Kavian Newsgroups: gmane.comp.tex.context Subject: Re: format float numbers in luatex Date: Mon, 26 Oct 2009 11:48:43 +0100 Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1076) Content-Type: text/plain; charset="us-ascii"; Format="flowed"; DelSp="yes" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1256554173 1399 80.91.229.12 (26 Oct 2009 10:49:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 26 Oct 2009 10:49:33 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Oct 26 11:49:26 2009 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.50) id 1N2N8B-0005r6-8w for gctc-ntg-context-518@m.gmane.org; Mon, 26 Oct 2009 11:48:55 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 1D789C9AC1; Mon, 26 Oct 2009 11:47:46 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id OrBWp86EW6Q5; Mon, 26 Oct 2009 11:47:43 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 561FDC9AAA; Mon, 26 Oct 2009 11:47:43 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 295A0C9AAA for ; Mon, 26 Oct 2009 11:47:41 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id uf7b7JesdWtY for ; Mon, 26 Oct 2009 11:47:38 +0100 (CET) Original-Received: from ey-out-1920.google.com (ey-out-1920.google.com [74.125.78.145]) by balder.ntg.nl (Postfix) with ESMTP id 5EBAAC9A8A for ; Mon, 26 Oct 2009 11:47:38 +0100 (CET) Original-Received: by ey-out-1920.google.com with SMTP id 26so687058eyw.6 for ; Mon, 26 Oct 2009 03:48:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:mime-version :subject:from:in-reply-to:date:content-transfer-encoding:message-id :references:to:x-mailer; bh=8dUzvtIaaGzqpfImU2jbibPvHTJxXq7UyQcMVdD1D9A=; b=KtMwLcrvnhbZ+qTP+LKrwhKf47y1fhSSqElQ3Ow4/Lu10fTYhRTr9jhCIEmCnarAS5 R7d0yv0ThPXQWZw4ZbSGMksbvNvSuGYa/m+drCXUcaoKyzAhgkvE+BIzAS+yiH8761PP CMlGviOKnORkcSGBUiCY3jUJiubPTqNiBaNQQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=ftlpdr9ZGxDZl009He/fgyZMU7XYcISWm/YInj7fjCNbDK+UqAnKJ6FJ3erEGEi9fe 6Z7SPWiTfEWNyjpcy5gSX4l0oCRnmBpFdrUuhN/viB0uoglD6vVI7ynsO6AQF1xfaina XhCJrXxKSqVHJZjbm+W++PbOSbF7MqIE/jCrg= Original-Received: by 10.210.96.23 with SMTP id t23mr4350770ebb.11.1256554125147; Mon, 26 Oct 2009 03:48:45 -0700 (PDT) Original-Received: from ?192.168.0.11? (mna75-3-82-66-231-76.fbx.proxad.net [82.66.231.76]) by mx.google.com with ESMTPS id 28sm4683231eyg.46.2009.10.26.03.48.44 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 26 Oct 2009 03:48:44 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.1076) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 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 Xref: news.gmane.org gmane.comp.tex.context:53722 Archived-At: Hi Jorge, Regarding your first question try this: \starttext The square root of 2 is \ctxlua{tex.print(math.sqrt(2))}\dots, but usually the default value \ctxlua{tex.print(math.floor(1000*math.sqrt(2))/1000)} is considered to be a good approximation. \stoptext (There is also math.ceil) Best regards: OK On 24 oct. 2009, at 18:59, batela wrote: > > Dear Sirs, > > I'm looking a way to format float numbers. For example \ctxlua > {text.print(sqrt(2))} give me 1.41421356237309504880 but i want 1.414. > > Is there a way to format real numbers. > > Note: I had tried \ctxlua{a = sqrt(a) ; aformat = string.format > ("0.3%f", a) ; text.print(aformat)} > > but that don't work because the % character > > thanks a lot > > Have a nice day > > jorge > > ___________________________________________________________________________________ > If your question is of interest to others as well, please add an > entry to the Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________