From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Roland Orre Newsgroups: gmane.lisp.guile.user Subject: Re: Suggested fix in numbers.c Date: 24 Jan 2003 23:13:29 +0100 Organization: Royal Institute of Technology Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <1043446408.8808.199.camel@localhost> References: <1041117957.2962.55.camel@localhost> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1043446915 29056 80.91.224.249 (24 Jan 2003 22:21:55 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 24 Jan 2003 22:21:55 +0000 (UTC) Cc: guile-user@gnu.org Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18cCCp-0007Y6-00 for ; Fri, 24 Jan 2003 23:21:47 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18cC7H-0002E4-03 for guile-user@m.gmane.org; Fri, 24 Jan 2003 17:16:03 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18cC69-0001Dy-00 for guile-user@gnu.org; Fri, 24 Jan 2003 17:14:53 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18cC63-00016C-00 for guile-user@gnu.org; Fri, 24 Jan 2003 17:14:48 -0500 Original-Received: from smtp.nada.kth.se ([130.237.222.232]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18cC5A-0000Oz-00 for guile-user@gnu.org; Fri, 24 Jan 2003 17:13:52 -0500 X-Authentication-Info: Sender authentication was Original-Received: from [10.2.0.2] (h122n2fls33o875.telia.com [217.208.54.122]) (authenticated bits=0) by smtp.nada.kth.se (8.12.1/8.12.1) with ESMTP id h0OMDVNd015155; Fri, 24 Jan 2003 23:13:47 +0100 (MET) Original-To: ttn@glug.org In-Reply-To: X-Mailer: Ximian Evolution 1.2.1 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: General Guile related discussions List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:1573 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:1573 On tor, 2003-01-16 at 02:43, Thien-Thi Nguyen wrote: > From: Roland Orre > Date: 29 Dec 2002 00:25:58 +0100 > > Below is my standard fix to numbers.c [...] > > thanks for this; i've installed it in 1.4.1.x cvs. the changes were > small enough that no papers are required. i would like to mention this > feature in the documentation; could you provide a suitable example? I include here example code using a C format string for float values. This is useful when for instance dealing with float vectors. Assume that we make the following input: > (define foo #s(1.1 1.3 1.7)) The foo vector will be by default be displayed as: > foo #s(1.10000002384186 1.29999995231628 1.70000004768372) Now e.g. define float format to be the C-string "%g" > (float-format "%g") > foo #s(1.1 1.3 1.7) The user code below is an example of an implementation of USER_FLOAT_FORMAT. In your setup do #define USER_FLOAT_FORMAT 1 then the following code will allow you to set float format to a C format string: size_t scm_idbl2str(double f, char *a); extern size_t (*scm_user_idbl2str)(double f,char *a); static char float_format_string[40]; static size_t user_idbl2str(double f,char *a) { return (size_t)sprintf(a,float_format_string,f); } /* user_idbl2str */ SCM_PROC(s_float_format,"float-format",0,1,0,float_format); /* returns #f if default format is used otherwise returns format string. Optional format may be #f or format string. */ SCM float_format(SCM format) { SCM res; if SCM_UNBNDP(format) { if (scm_user_idbl2str==scm_idbl2str) /* default float conversion */ return SCM_BOOL_F; else { res=scm_makstr(strlen(float_format_string),0); strcpy(SCM_CHARS(res),float_format_string); return res; } } if (SCM_FALSEP(format)) { scm_user_idbl2str=scm_idbl2str; /* default float conversion */ return SCM_BOOL_F; } SCM_ASSERT(SCM_NIMP(format)&&SCM_STRINGP(format),format,SCM_ARG1,s_float_format); strcpy(float_format_string,SCM_CHARS(format)); scm_user_idbl2str=user_idbl2str; /* user float conversion */ return SCM_BOOL_T; } /* float_format */ On tor, 2003-01-16 at 02:43, Thien-Thi Nguyen wrote: > From: Roland Orre > Date: 29 Dec 2002 00:25:58 +0100 > > Below is my standard fix to numbers.c [...] > > thanks for this; i've installed it in 1.4.1.x cvs. the changes were > small enough that no papers are required. i would like to mention this > feature in the documentation; could you provide a suitable example? > > thi _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user